I am wondering if there is a simple way to get synonyms of nouns in wordnet. It seems that synonyms of adjectives are quite easy to get.
for ss in wn.synsets('beautiful'):
print(ss)
for sim in ss.similar_tos():
print(' {}'.format(sim))
I found the code above from another SO question and it works well for adjectives. But when my word is 'gasoline' or 'fire' the results are terrible. Ideally, I would get a list of words very similar to this site.
Something else I have tried that has worked with good results but extremely slow is this:
def syn(word, lch_threshold=2.26):
for net1 in wn.all_synsets():
try:
lch = net1.lch_similarity(wn.synset(word))
except:
continue
# The value to compare the LCH to was found empirically.
# (The value is very application dependent. Experiment!)
if lch >= lch_threshold:
yield (net1, lch)
for x in syn('gasoline.n.1'):
print x
Which was also found from another SO question. Is there an easier way to get synonyms of nouns like in the link provided above?