Named entity recognition (NER)

The goal of NER is to recognize tokens associated with people, organizations, and locations. Let's use an example to explain it further:

In: import nltk    text = "Elvis Aaron Presley was an American singer and actor. Born in \            Tupelo, Mississippi, when Presley was 13 years old he and his \             family relocated to Memphis, Tennessee."    chunks = nltk.ne_chunk(nltk.pos_tag(nltk.word_tokenize(text)))    print (chunks)Out:  (S      (PERSON Elvis/NNP)      (PERSON Aaron/NNP Presley/NNP)      was/VBD      an/DT      (GPE American/JJ)      singer/NN      and/CC      actor/NN      ./.      Born/NNP      in/IN      (GPE Tupelo/NNP)      ,/,      (GPE Mississippi/NNP)      ,/,      when/WRB      (PERSON Presley/NNP)      was/VBD      13/CD      years/NNS      old/JJ      he/PRP      and/CC      his/PRP$      family/NN     relocated/VBD ...

Get Python Data Science Essentials - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.