我正在尝试为一个句子找到重要的命名实体,如下所示:
import spacy
nlp = spacy.load('en')
sentences = "The machine learning is a field within computer science,\
it differs from traditional computational approaches. In traditional computing,\
algorithms are sets of explicitly programmed instructions used by computers to \
calculate or problem solve. The Machine learning algorithms instead allow for computers \
to train on data inputs and use statistical analysis in order to output values that fall\
within a specific range. Because of this, machine learning facilitates computers in building\
models from sample data in order to automate decision-making processes based on data inputs."
doc = nlp(sentences)
print('Name Entity:{0}'.format(doc.ents))我期望得到“机器学习”,“算法”,“决策”的结果,但我得到的结果是一个空集。我到底做错了什么。
发布于 2019-12-09 14:54:51
spacy en model只给你提供像名字,地点,日期,ORG等自然实体。如果你想要一些自定义实体标签,那么你已经创建了你自己的带有训练的自定义模型。有关自定义模型创建的更多信息,请访问My another post.
发布于 2019-12-10 04:52:46
这些句子中没有实体。
试一试
import spacy
nlp = spacy.load('en_core_web_sm')
sentences = "The machine learning is a field within computer science,\
it differs from traditional computational approaches. In traditional computing,\
algorithms are sets of explicitly programmed instructions used by computers to \
calculate or problem solve. The achine learning algorithms instead allow for computers \
to train on data inputs and use statistical analysis in order to output values that fall\
within a specific range. Because of this, at Apple, machine learning facilitates computers in building\
models from sample data in order to automate decision-making processes based on data inputs."
doc = nlp(sentences)
print('Name Entity:{0}'.format(doc.ents))发布于 2019-12-10 15:22:25
当我运行代码时,这是我收到的输出

对于像“机器学习”,“算法”这样的输出,你需要定制spacy NER并进行相应的训练,.You可以为它使用正则表达式。
https://stackoverflow.com/questions/59243362
复制相似问题