0
0
NLPml~10 mins

Dependency parsing 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 import the spaCy library for dependency parsing.

NLP
import [1]
Drag options to blanks, or click blank then click option'
Aspacy
Btensorflow
Cnltk
Dsklearn
Attempts:
3 left
💡 Hint
Common Mistakes
Importing nltk instead of spaCy
Using sklearn which is for machine learning, not NLP
2fill in blank
medium

Complete the code to load the English language model in spaCy.

NLP
nlp = spacy.load('[1]')
Drag options to blanks, or click blank then click option'
Aes_core_news_sm
Ben_core_web_sm
Cde_core_news_sm
Dfr_core_news_sm
Attempts:
3 left
💡 Hint
Common Mistakes
Using a French or German model for English text
Misspelling the model name
3fill in blank
hard

Fix the error in the code to get the dependency label of the first token.

NLP
doc = nlp('I love AI')
label = doc[0].[1]
Drag options to blanks, or click blank then click option'
Alemma_
Bpos_
Cdep_
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using pos_ instead of dep_
Using text which gives the token string, not the dependency label
4fill in blank
hard

Fill both blanks to create a dictionary of tokens and their dependency labels.

NLP
dep_dict = {token.[1]: token.[2] for token in doc}
Drag options to blanks, or click blank then click option'
Atext
Bdep_
Cpos_
Dlemma_
Attempts:
3 left
💡 Hint
Common Mistakes
Using pos_ instead of dep_ for dependency labels
Using lemma_ instead of text for token keys
5fill in blank
hard

Fill all three blanks to print each token, its head token, and the dependency relation.

NLP
for token in doc:
    print(f"Token: {token.[1], Head: {token.[2].[3]")
Drag options to blanks, or click blank then click option'
Atext
Bhead
Ddep_
Attempts:
3 left
💡 Hint
Common Mistakes
Using dep_ instead of text for printing token strings
Trying to print head without accessing its text attribute