0
0
NLPml~10 mins

Lemmatization in spaCy in NLP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Aload
Bparse
Cinstall
Ddownload
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.
2fill in blank
medium

Complete 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'
Adoc
Bnlp
Cspacy
D"This is a test sentence."
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the model object 'nlp' instead of a text string.
Passing an unprocessed variable instead of a string.
3fill in blank
hard

Fix 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'
Alemmatize
Blemma_
Clemma
Dtext
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.
4fill in blank
hard

Fill 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'
Adict
Blist
Clemma_
Dset
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.
5fill in blank
hard

Fill 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'
Atext
Blemma_
Cpos_
Dtag_
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.