Complete the code to load a spaCy model for English.
import spacy nlp = spacy.load('[1]')
The correct model name to load the small English model in spaCy is en_core_web_sm.
Complete the code to process text and get tokens using spaCy.
doc = nlp('[1]') tokens = [token.text for token in doc]
You need to pass a string of text to the nlp object to process it and get tokens.
Fix the error in the code to get named entities from a spaCy doc.
for ent in doc.[1]: print(ent.text, ent.label_)
The correct attribute to access named entities in a spaCy doc is ents.
Fill both blanks to create a dictionary of token texts and their parts of speech.
pos_dict = {token.[1]: token.[2] for token in doc}Use text for token text and pos_ for part of speech tags.
Fill all three blanks to filter tokens that are alphabetic and lowercase their text.
filtered = [token.[1].lower() for token in doc if token.[2] and not token.[3]]
We use text to get token text, is_alpha to check if token is alphabetic, and exclude punctuation with is_punct.
