1. detection of a string or a word that forms the queried entity
  2. categorising the entity based on common categories like names, dates, locations and organizations
  3. 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 Model

where:

  • displacy is a built-in visualizer in SpaCy
  • en_core_web_sm is a pretrained English pipeline that includes an NER tagger and many other nlp functionalities like tokenizer, tagger, parser
  • _sm refers to the small model version, _lg refers 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 ents property
  • .ents is a property of the object doc which 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.ents is 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.