【发布时间】:2021-09-09 04:37:59
【问题描述】:
我正在像这样使用nltk.ne_chunk():
sent="Azhar is asking what is weather in Chicago today? "
chunks = nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(sent)), binary=True)
print(list(chunks))
然后像这样得到 oitput:
[Tree('NE', [('Azhar', 'NNP')]), ('is', 'VBZ'), ('asking', 'VBG'), ('what', 'WP'), ('is',
'VBZ'), ('weather', 'NN'), ('in', 'IN'), Tree('NE', [('Chicago', 'NNP')]), ('today', 'NN'),
('?', '.')]
但我期待这样的输出:
[Tree('PERSON', [('Azhar', 'NNP')]), ('is', 'VBZ'), ('asking', 'VBG'), ('what', 'WP'), ('is',
'VBZ'), ('weather', 'NN'), ('in', 'IN'), Tree('GPE', [('Chicago', 'NNP')]), ('today', 'NN'),
('?', '.')]
谁能告诉我我在这里做错了什么?
【问题讨论】:
-
我猜你在找NERs,对吗?
-
是的,我正在寻找命名实体
标签: python nlp nltk tagging chunking