Complete the code to import the library used for Named Entity Recognition (NER).
import [1]
We use spacy for NER because it provides easy-to-use tools for extracting entities from text.
Complete the code to load the English language model needed for NER.
nlp = spacy.load('[1]')
The English model en_core_web_sm is used to process English text for NER.
Fix the error in the code to extract entities from the text.
doc = nlp(text) for ent in doc.[1]: print(ent.text, ent.label_)
The correct attribute to get named entities from a processed document is ents.
Fill both blanks to create a dictionary of entity text and their labels.
entities = {ent.[1]: ent.[2] for ent in doc.ents}We use ent.text for the entity string and ent.label_ for its type label.
Fill all three blanks to filter entities of type 'PERSON' and print their text.
for ent in doc.ents: if ent.[1] == '[2]': print(ent.[3])
We check if ent.label_ equals 'PERSON' and print ent.text to get the person's name.