fails to find wordnet synset in python

Viewed 50

i have function

def find_n_similar():
    word = input("please enter a word: ")
    word_syntest = wordnet.synsets(word)[0]
    print(word_syntest)
    similarity_rate = {}
    with open("1-1000.txt", 'r') as file:
        file_words = file.read().split("\n")
    print(file_words)
    for file_word in file_words:
        file_word_syntest = wordnet.synsets(file_word)
        similarity_rate.update({f"{file_word}": word_syntest.path_similarity(file_word_syntest)})

if i type "the", "of" etc it throws exception: IndexError: list index out of range how can i find synset for such words?

1 Answers

WordNet doesn't really do articles. :( From their main page:

Nouns, verbs, adjectives and adverbs are grouped into sets of cognitive synonyms (synsets)

It's a bummer, but there aren't any synonyms for "the" or "a" anyway, right?

Related