Complete the code to import the NER model from spaCy.
import spacy nlp = spacy.load('[1]')
The correct spaCy model for basic English NER is en_core_web_sm.
Complete the code to extract named entities from the text.
doc = nlp(text) entities = [(ent.text, ent.[1]) for ent in doc.ents]
ent.type which does not exist.ent.tag which is for part-of-speech tags.In spaCy, the entity label is accessed with ent.label_.
Fix the error in the code to correctly print entity text and label.
for ent in doc.ents: print(ent.text, ent.[1])
ent.label which returns an integer code, not the string.ent.entity which does not exist.The correct attribute to get the entity label as a string is label_, not label.
Fill both blanks to create a dictionary of entity texts and their labels.
entity_dict = {ent.[1]: ent.[2] for ent in doc.ents}Use ent.text as the key and ent.label_ as the value to map entity text to its label.
Fill all three blanks to filter entities with label 'PERSON' and get their texts.
person_entities = [ent.[1] for ent in doc.ents if ent.[2] == '[3]']
ent.label instead of ent.label_.We want the text of entities where the label is 'PERSON'. So use ent.text, check ent.label_, and compare to 'PERSON'.
