Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load the English model in spaCy.
NLP
import spacy nlp = spacy.[1]("en_core_web_sm")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'download' instead of 'load' to get the model.
Trying to 'install' the model inside the code instead of loading it.
✗ Incorrect
The correct function to load a spaCy model is 'load'.
2fill in blank
mediumComplete the code to process the text with the loaded spaCy model.
NLP
doc = nlp([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the model object 'nlp' instead of a text string.
Passing an unprocessed variable instead of a string.
✗ Incorrect
You need to pass a string of text to the model to process it.
3fill in blank
hardFix the error in the code to get the lemma of each token.
NLP
lemmas = [token.[1] for token in doc]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lemma' without underscore which returns a token attribute object.
Trying to call a method 'lemmatize' which does not exist.
✗ Incorrect
The correct attribute to get the lemma string is 'lemma_'.
4fill in blank
hardFill both blanks to create a dictionary of tokens and their lemmas.
NLP
lemma_dict = [1]([2]: token.[3] for token in doc)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'list' or 'set' instead of 'dict' to create the dictionary.
Using 'lemma' without underscore for the lemma attribute.
✗ Incorrect
Use 'dict' to create a dictionary, 'token.text' for keys, and 'lemma_' to get lemma strings.
5fill in blank
hardFill all three blanks to print each token and its lemma in a loop.
NLP
for token in doc: print(token.[1], token.[2], token.[3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lemma' or 'pos' without underscore which are not strings.
Mixing up 'tag_' and 'pos_' which represent different tag types.
✗ Incorrect
Print token text, lemma string, and part-of-speech tag string.