简体   繁体   中英

Important name entity recognition in spacy

I am trying to find important name entities for a sentence as below:

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))

I am expecting to get the result "Machine learning","algorithms","decision-making" but i am getting an empty set as result. What am i doing wrong here.

spacy en model gives you only Natural entity like Name, Place, Date, ORG, etc. If you want some custom entity tags then you have create your own custom model with training. For more information about custom model creation please follow My another post.

There are no entities in those sentences.

Try

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))

when I ran the code this is the output I received

我运行你的代码的输出

For output like "machine learning","algorithm" ,you need to customize spacy NER and train accordingly .You can use regex for it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM