【发布时间】:2020-02-03 20:30:48
【问题描述】:
我继续收到我的语料库中没有 NER 的消息。我期待猫、狗等将被识别为人。让我知道如何解决它。
import numpy as np
import pandas as pd
import spacy
from spacy import displacy
nlp = spacy.load("en_core_web_sm")
corpus=['cats are selfish', 'it is raining cats and dogs', 'dogs do not like birds','i do not like rabbits','i have eaten frogs snakes and alligators']
for sent in corpus:
sentence_nlp = nlp(sent)
# print named entities in sentences
print([(word, word.ent_type_) for word in sentence_nlp if word.ent_type_])
# visualize named entities
displacy.render(sentence_nlp, style='ent', jupyter=True)
我得到的错误是:
[]
./NER_Spacy.py:19: UserWarning: [W006] No entities to visualize found in Doc object. If this is surprising to you, make sure the
Doc was processed using a model that supports named entity recognition, and check the `doc.ents` property manually if necessary
.
displacy.render(sentence_nlp, style='ent', jupyter=False)
[]
./NER_Spacy.py:19: UserWarning: [W006] No entities to visualize found in Doc object. If this is surprising to you, make sure the
Doc was processed using a model that supports named entity recognition, and check the `doc.ents` property manually if necessary
.
displacy.render(sentence_nlp, style='ent', jupyter=False)
[]
./NER_Spacy.py:19: UserWarning: [W006] No entities to visualize found in Doc object. If this is surprising to you, make sure the
Doc was processed using a model that supports named entity recognition, and check the `doc.ents` property manually if necessary
.
displacy.render(sentence_nlp, style='ent', jupyter=False)
[]
./NER_Spacy.py:19: UserWarning: [W006] No entities to visualize found in Doc object. If this is surprising to you, make sure the
Doc was processed using a model that supports named entity recognition, and check the `doc.ents` property manually if necessary
.
displacy.render(sentence_nlp, style='ent', jupyter=False)
[]
./NER_Spacy.py:19: UserWarning: [W006] No entities to visualize found in Doc object. If this is surprising to you, make sure the
Doc was processed using a model that supports named entity recognition, and check the `doc.ents` property manually if necessary
.
displacy.render(sentence_nlp, style='ent', jupyter=False) ```
【问题讨论】:
标签: python spacy named-entity-recognition