Entity recognition means extracting or detecting entities in the given text. It is also known as Named Entity Recognition (NER). An entity can be defined as an object, such as a location, people, an organization, or a date. Entity recognition is one of the advanced topics of NLP. It is used to extract important information from text.
Let's see how to get entities from text using spaCy:
# Import spacy
import spacy
# Load English model for tokenizer, tagger, parser, and NER
nlp = spacy.load('en')
# Sample paragraph
paragraph = """Taj Mahal is one of the beautiful monuments. It is one of the wonders of the world. It was built by Shah Jahan in 1631 in memory of his third beloved wife Mumtaj Mahal."""
# Create nlp Object to handle linguistic annotations in documents.
docs=nlp(paragraph)
entities=[(i.text, i.label_) for i in docs.ents]
print(entities)
This results in the following output:
[('Taj Mahal', 'PERSON'),...