0
0
NLPml~10 mins

Why NER extracts structured information in 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 import the library used for Named Entity Recognition (NER).

NLP
import [1]
Drag options to blanks, or click blank then click option'
Aspacy
Bnumpy
Cmatplotlib
Dtensorflow
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like numpy or matplotlib.
Trying to import tensorflow which is for deep learning but not specific to NER.
2fill in blank
medium

Complete the code to load the English language model needed for NER.

NLP
nlp = spacy.load('[1]')
Drag options to blanks, or click blank then click option'
Aen_core_web_sm
Bfr_core_news_sm
Ces_core_news_sm
Dde_core_news_sm
Attempts:
3 left
💡 Hint
Common Mistakes
Using models for other languages like French or German.
Forgetting to load a model before processing text.
3fill in blank
hard

Fix the error in the code to extract entities from the text.

NLP
doc = nlp(text)
for ent in doc.[1]:
    print(ent.text, ent.label_)
Drag options to blanks, or click blank then click option'
Aentities
Bents
Ctokens
Dwords
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'entities' which is not a valid attribute in spacy.
Using 'tokens' or 'words' which refer to individual words, not entities.
4fill in blank
hard

Fill both blanks to create a dictionary of entity text and their labels.

NLP
entities = {ent.[1]: ent.[2] for ent in doc.ents}
Drag options to blanks, or click blank then click option'
Atext
Blabel_
Cstart_char
Dend_char
Attempts:
3 left
💡 Hint
Common Mistakes
Using character positions instead of text or label.
Mixing up label_ with other attributes.
5fill in blank
hard

Fill all three blanks to filter entities of type 'PERSON' and print their text.

NLP
for ent in doc.ents:
    if ent.[1] == '[2]':
        print(ent.[3])
Drag options to blanks, or click blank then click option'
Alabel_
BPERSON
Ctext
Dstart_char
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'label' instead of 'label_' which is the correct attribute.
Printing the wrong attribute like start_char instead of text.