小编BAL*_*ALA的帖子

为什么 spacy ner 结果高度不可预测?

我尝试了 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_)
Run Code Online (Sandbox Code Playgroud)

输出:在这种情况下没有输出。

案例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_)
Run Code Online (Sandbox Code Playgroud)

输出:

<spacy.lang.en.English object at 0x7f2213bde080>
china   GPE
East Asia   LOC
more than 14,000km   QUANTITY
Run Code Online (Sandbox Code Playgroud)

python nlp named-entity-recognition spacy

3
推荐指数
1
解决办法
1040
查看次数

标签 统计

named-entity-recognition ×1

nlp ×1

python ×1

spacy ×1