From f5846cf35f0d5ca5685d520ac4d424651d32bdc4 Mon Sep 17 00:00:00 2001 From: Brandon Lim Date: Sat, 19 Oct 2019 21:58:38 +1100 Subject: [PATCH] Default pos to ADJ, NOUN and VERB if empty, to avoid empty tagged_words --- minpair/minpair.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/minpair/minpair.py b/minpair/minpair.py index a13dc68..e7fd645 100644 --- a/minpair/minpair.py +++ b/minpair/minpair.py @@ -7,7 +7,7 @@ import re -def vowel_minpair(vowels: list, pos: list = ['ADJ', 'NOUN', 'VERB']): +def vowel_minpair(vowels: list, pos: list = []): """Find words that differ in only the vowel phonological element, for the given vowel arpabets. For example, ['bad', 'bed', 'bid'] are one of the vowel minimal pairs for ['AE', 'EH', 'IH'] vowels. @@ -38,6 +38,7 @@ def vowel_minpair(vowels: list, pos: list = ['ADJ', 'NOUN', 'VERB']): nltk_download('cmudict') nltk_download('universal_tagset') nltk_download('words') + pos = pos or ['ADJ', 'NOUN', 'VERB'] tagged_words = {word for word, tag in brown.tagged_words(tagset='universal') if tag in pos}