在下面的代码中,为什么 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')]
最佳答案
我不确定解决方法是什么,但您可以在此处查看源代码 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')]
这导致鱼为“NN”。
关于python - 词性标注——NLTK 认为名词是形容词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13529945/