【问题标题】:fails to find wordnet synset in python无法在 python 中找到 wordnet 同义词集
【发布时间】:2021-11-07 17:12:44
【问题描述】:

我有功能

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)})

如果我输入“the”、“of”等,它会抛出异常:IndexError: list index out of range 我怎样才能找到这些词的同义词?

【问题讨论】:

    标签: python nltk wordnet


    【解决方案1】:

    WordNet 并不真正做文章。 :( 来自他们的main page:

    名词、动词、形容词和副词被分成一组 认知同义词(synsets)

    这很糟糕,但无论如何“the”或“a”都没有同义词,对吧?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-20
      • 1970-01-01
      • 1970-01-01
      • 2015-09-22
      相关资源
      最近更新 更多