【发布时间】:2019-11-03 04:38:23
【问题描述】:
我为 ner 尝试了 spacy,但结果非常不可预测。有时 spacy 无法识别特定国家/地区。谁能解释一下为什么会这样? 我尝试了一些随机的句子。
案例 1:
nlp = spacy.load("en_core_web_sm")
print(nlp)
sent = "hello china hello japan"
doc = nlp(sent)
for i in doc.ents:
print(i.text," ",i.label_)
输出:在这种情况下没有输出。
案例 2:
nlp = spacy.load("en_core_web_sm")
print(nlp)
sent = "china is a populous nation in East Asia whose vast landscape encompasses grassland, desert, mountains, lakes, rivers and more than 14,000km of coastline."
doc = nlp(sent)
for i in doc.ents:
print(i.text," ",i.label_)
输出:
<spacy.lang.en.English object at 0x7f2213bde080>
china GPE
East Asia LOC
more than 14,000km QUANTITY
【问题讨论】:
-
你用的是什么语言模型?你能给我们举个例子来说明它是如何不可预测的吗?你能提供你使用的代码吗?
-
我编辑了问题,请再次检查。
标签: python nlp spacy named-entity-recognition