def get_wordnet_syns(word):
synonyms = []<EOL>regex = r"<STR_LIT:_>"<EOL>pat = re.compile(regex)<EOL>synset = nltk.wordnet.wordnet.synsets(word)<EOL>for ss in synset:<EOL><INDENT>for swords in ss.lemma_names:<EOL><INDENT>synonyms.append(pat.sub("<STR_LIT:U+0020>", swords.lower()))<EOL><DEDENT><DEDENT>synonyms = f7(synonyms)<EOL>return synonyms<EOL>
Utilize wordnet (installed with nltk) to get synonyms for words
word is the input word
returns a list of unique synonyms