- detection of a string or a word that forms the queried entity
- categorising the entity based on common categories like names, dates, locations and organizations
- NER often uses POS tags as helpful input data
During Inference
import spacy
from spacy import displacy
nlp = spacy.load("en_core_web_sm") # Load SpaCy's small English Modelwhere:
displacyis a built-in visualizer in SpaCyen_core_web_smis a pretrained English pipeline that includes an NER tagger and many other nlp functionalities like tokenizer, tagger, parser_smrefers to the small model version,_lgrefers to the larger model version
sentence = "This course is lectured by Dr. S. Supraja, and Simon Liu at NTU, Singapore."
doc = nlp(sentence) # Runs our sentence through spaCy's processing pipeline and returns a Doc object
for word in doc.ents:
print(word.text, word.label_)where:
- these tokens can be accessed via the
entsproperty .entsis a property of the objectdocwhich stands for entity- calling this property on an object retrieves all the Named Entities detected
S. Supraja[PERSON]
Simon Liu[PERSON]
NTU[ORG]
Singapore[GPE]
- here, the output of
doc.entsis called span - a span is a slice of one or more tokens treated as a unit
# Used to explore the definition of the given POS tag, dependency label or entity type in spacy
spacy.explain('ORG')'Companies, agencies, institutions, etc.'
displacy.render(doc, style="ent", jupyter=True)
Application of NER
- performing sentiment analysis towards a company or product
- we can use NER to identify relationships and sementic meaning between named entities
A named entity is 1 of the mention types collected by Coreference Resolution.