Nlp 查找单词的类别

Nlp 查找单词的类别,nlp,Nlp,我想找一个更大的词类。比如说 蓝色-->颜色 猫-->动物 幸福-->情感 最简单的方法是什么 我查看了Wordnet演示: 但我不知道Wordnet中的哪个字段可以帮助我做到这一点。有什么想法吗 明白了! 在页面上: 我只需要点击“S”,然后点击“定向超词” 除非你能更具体地定义它,否则我认为没有一个明确的方法来获得你需要的东西。例如: >>> from nltk.corpus import wordnet as wn >>> blue = wn.syns

我想找一个更大的词类。比如说

蓝色-->颜色

猫-->动物

幸福-->情感

最简单的方法是什么

我查看了Wordnet演示:

但我不知道Wordnet中的哪个字段可以帮助我做到这一点。有什么想法吗

明白了! 在页面上:


我只需要点击“S”,然后点击“定向超词”

除非你能更具体地定义它,否则我认为没有一个明确的方法来获得你需要的东西。例如:

>>> from nltk.corpus import wordnet as wn
>>> blue = wn.synsets('blue')[0]
>>> cat = wn.synsets('cat')[0]
>>> blue.definition()
u'blue color or pigment; resembling the color of the clear sky in the daytime'
>>> cat.definition()
u'feline mammal usually having thick soft fur and no ability to roar: domestic cats; wildcats'
有时,你们会幸运地升到一到两级的超词:

>>> blue.hypernyms()
[Synset('chromatic_color.n.01')]
>>> blue.hypernyms()[0].hypernyms()
[Synset('color.n.01')]
有时,你必须把缩略语提高很多层次才能得到你想要的

>>> cat.hypernyms()
[Synset('feline.n.01')]
>>> cat.hypernyms()[0].hypernyms()
[Synset('carnivore.n.01')]
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms()
[Synset('placental.n.01')]
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()
[Synset('mammal.n.01')]
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()
[Synset('vertebrate.n.01')]
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()
[Synset('chordate.n.01')]
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()
[Synset('animal.n.01')]
而要达到最顶级的超词级别也没有多大意义:

>>> blue.root_hypernyms()
[Synset('entity.n.01')]
>>> cat.root_hypernyms()
[Synset('entity.n.01')]
有时,您根本无法使用缩写:

>>> happy = wn.synsets('happy')[0]
>>> happy.definition()
u'enjoying or showing or marked by joy or pleasure'
>>> happy.hypernyms()
[]
>>> happy.root_hypernyms()
[Synset('happy.a.01')]