0
0
NLPml~10 mins

Entity linking concept 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 a pre-trained entity linking model from spaCy.

NLP
import spacy
nlp = spacy.load('[1]')
Drag options to blanks, or click blank then click option'
Aen_core_web_md
Ben_core_web_trf
Cen_core_web_sm
Den_core_entity_linker
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a general language model like 'en_core_web_sm' which does not include entity linking.
Using transformer models that don't have entity linking by default.
2fill in blank
medium

Complete the code to extract entities and their linked Wikipedia IDs from a processed document.

NLP
for ent in doc.ents:
    print(ent.text, ent.kb_id_[1])
Drag options to blanks, or click blank then click option'
A()
B_
C[]
D.
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to call kb_id_ as a method with parentheses.
Using dot or brackets incorrectly after kb_id.
3fill in blank
hard

Fix the error in the code to add the entity linker component to the spaCy pipeline.

NLP
nlp = spacy.load('en_core_web_sm')
nlp.add_pipe('[1]', last=True)
Drag options to blanks, or click blank then click option'
Atextcat
Bner
Centity_linker
Dparser
Attempts:
3 left
💡 Hint
Common Mistakes
Adding 'ner' instead of 'entity_linker'.
Using component names unrelated to entity linking.
4fill in blank
hard

Fill both blanks to create a dictionary of entity texts mapped to their Wikipedia URLs.

NLP
entity_links = {ent.text: 'https://en.wikipedia.org/wiki/' + ent.kb_id_[1] for ent in doc.ents if ent.kb_id_[2] != ''}
Drag options to blanks, or click blank then click option'
A_
B.
C()
D[]
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses or brackets which cause errors.
Using dot notation incorrectly after kb_id.
5fill in blank
hard

Fill all three blanks to filter entities with confidence score above 0.85 and create a dictionary of their texts and Wikipedia URLs.

NLP
entity_links = {ent.text: 'https://en.wikipedia.org/wiki/' + ent.kb_id_[1] for ent in doc.ents if ent.kb_id_[2] != '' and ent._.kb_[3] > 0.85}
Drag options to blanks, or click blank then click option'
A_
B.
Cscore
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot instead of underscore for kb_id_.
Using wrong attribute name for confidence score.