词性标注 - NLTK 认为名词是形容词

wai*_*ani 5 python nltk

在下面的代码中,为什么 nltk 认为 'fish' 是形容词而不是名词?

>>> import nltk
>>> s = "a woman needs a man like a fish needs a bicycle"
>>> nltk.pos_tag(s.split())
[('a', 'DT'), ('woman', 'NN'), ('needs', 'VBZ'), ('a', 'DT'), ('man', 'NN'), ('like', 'IN'), ('a', 'DT'), ('fish', 'JJ'), ('needs', 'NNS'), ('a', 'DT'), ('bicycle', 'NN')]
Run Code Online (Sandbox Code Playgroud)

Cha*_*pta 4

我不确定解决方法是什么,但您可以在此处查看源代码https://nltk.googlecode.com/svn/trunk/nltk/nltk/tag/

与此同时,我用几乎不同的方法尝试了你的句子。

>>> s = "a woman needs a man. A fish needs a bicycle"
>>> nltk.pos_tag(s.split())
[('a', 'DT'), ('woman', 'NN'), ('needs', 'VBZ'), ('a', 'DT'), ('man.', NP'), ('A','NNP'),   ('fish', 'NN'), ('needs', 'VBZ'), ('a', 'DT'), ('bicycle', 'NN')]
Run Code Online (Sandbox Code Playgroud)

结果鱼是“NN”。