Python 从NLTK WordNet中单独提取名词

Python 从NLTK WordNet中单独提取名词,python,nltk,wordnet,Python,Nltk,Wordnet,有什么方法可以检测一个给定的单词是名词还是不使用nltk wordnet?我还想单独提取特定单词的意思。如何做?要检测一个单词是名词还是不使用nltk wordnet,请尝试此方法 from nltk.corpus import wordnet as wn from nltk.corpus.reader import NOUN #this gives a synsets list of empty length, since there is no noun corresponding to

有什么方法可以检测一个给定的单词是名词还是不使用nltk wordnet?我还想单独提取特定单词的意思。如何做?

要检测一个单词是名词还是不使用nltk wordnet,请尝试此方法

from nltk.corpus import wordnet as wn
from nltk.corpus.reader import NOUN

#this gives a synsets list of empty length, since there is no noun corresponding to 'propose'
synsets = wn.synsets('propose', NOUN)

if synsets.length == 0 :
    print ' We found a pure NOUN'

 #this will give you a non empty synset list since 'iron' can be a NOUN too.
synsets = wn.synsets('iron',NOUN)

if synsets.length > 0 :
   print 'Iron is also a noun other than verb'
为了解决第二部分——一个词可能有许多含义,你需要清楚地定义你的意思是什么——词之间有各种各样的关系,如上下义、全义、下义、同义词等


此外,要找到与给定单词意义最接近的意义,您可能需要找到单词与其每个语法集之间的相似性,并选择值最高的一个。请参阅Wordnet中的LCH相似性和JCN相似性模块,了解更多信息

我将尝试使用此功能。谢谢!!你的意思是:打印“我们发现了一个纯非名词”