【问题标题】:How to get the close words in WordNet in python如何在python中获取WordNet中的关闭词
【发布时间】:2020-01-13 04:00:00
【问题描述】:

我正在使用 WordNet 如下使用 python 获取同义词。

import nltk 
from nltk.corpus import wordnet
synonyms = []
for syn in wordnet.synsets("alzheimer"): 
    for l in syn.lemmas(): 
        synonyms.append(l.name())
print(set(synonyms))

但是,alzheimer 这个词似乎不在 WordNet 中,因为我得到了一个空的同义词集列表。然后,我尝试了不同的其他变体,例如alzheimer diseasealzheimer's diseasealzheimersalzheimer'salzhemimers disease

我的问题是;是否可以让 WordNet 中的单词接近单词 alzheimer,这样我就不需要手动验证 WordNet 中的术语是什么来获取同义词集。

如果需要,我很乐意提供更多详细信息。

【问题讨论】:

    标签: python nlp nltk text-mining wordnet


    【解决方案1】:

    您可以从 wordnet 词汇表中的给定单词中找到相似的单词。

    from nltk.corpus import wordnet as wn
    wordnet_vocab = list(wn.all_lemma_names())
    
    similar_string = 'alzheimer'
    [word for word in wordnet_vocab if similar_string in word]
    #op if exact word is not present,  you can get similar word which are present in wordnet vocab
    ["alzheimer's", "alzheimer's_disease", 'alzheimers']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-16
      • 2013-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多