0
0
NLPml~10 mins

Why spaCy is production-grade NLP - Test Your Understanding

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

Complete the code to load a spaCy model for English.

NLP
import spacy
nlp = spacy.load('[1]')
Drag options to blanks, or click blank then click option'
Aenglish_model
Bspacy_en
Cen_nlp
Den_core_web_sm
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or made-up model names.
Forgetting to install the model before loading.
2fill in blank
medium

Complete the code to process text and get tokens using spaCy.

NLP
doc = nlp('[1]')
tokens = [token.text for token in doc]
Drag options to blanks, or click blank then click option'
Atoken.text
Bnlp
CThis is a test.
Ddoc
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the nlp object itself instead of text.
Passing token attributes instead of raw text.
3fill in blank
hard

Fix the error in the code to get named entities from a spaCy doc.

NLP
for ent in doc.[1]:
    print(ent.text, ent.label_)
Drag options to blanks, or click blank then click option'
Aentities
Bents
Ctokens
Dnamed_entities
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'entities' or 'named_entities' which do not exist.
Trying to iterate over 'tokens' for entities.
4fill in blank
hard

Fill both blanks to create a dictionary of token texts and their parts of speech.

NLP
pos_dict = {token.[1]: token.[2] for token in doc}
Drag options to blanks, or click blank then click option'
Atext
Bpos_
Clemma_
Dtag_
Attempts:
3 left
💡 Hint
Common Mistakes
Using lemma_ instead of text for keys.
Using tag_ instead of pos_ for parts of speech.
5fill in blank
hard

Fill all three blanks to filter tokens that are alphabetic and lowercase their text.

NLP
filtered = [token.[1].lower() for token in doc if token.[2] and not token.[3]]
Drag options to blanks, or click blank then click option'
Atext
Bis_alpha
Cis_stop
Dis_punct
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_stop instead of is_punct to exclude tokens.
Not converting text to lowercase.