I have a python dictionary of words where I want to attach a single synonym to each of the items in the dictionary using Wordnet's synsets function. My current code picks up several synonyms but I only want to be able to narrow it down to just one word (i.e. the first in the set). Additionally, if there isn't an available synonym, I would like for it to just use the word as is in the dictionary.
dic = {w : [] for w in words if not w in stop_words}
for k, v in dic.items():
for synset in wordnet.synsets(k):
for lemma in synset.lemmas():
v.append(lemma.name())
I'm fairly new at this so any help would be greatly appreciated. Thanks in advance.