0
0
NLPml~20 mins

NER with NLTK in NLP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
NER with NLTK Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this NER chunking code?
Given the following Python code using NLTK for Named Entity Recognition (NER), what is the output?
NLP
import nltk
from nltk import word_tokenize, pos_tag, ne_chunk
sentence = "Apple is looking at buying U.K. startup for $1 billion"
tokens = word_tokenize(sentence)
pos_tags = pos_tag(tokens)
chunks = ne_chunk(pos_tags)
print(list(chunks))
A[('Apple', 'NNP'), ('is', 'VBZ'), ('looking', 'VBG'), ('at', 'IN'), Tree('ORGANIZATION', [('buying', 'VBG')]), ('U.K.', 'NNP'), ('startup', 'NN'), ('for', 'IN'), ('$', '$'), ('1', 'CD'), ('billion', 'CD')]
B[Tree('GPE', [('Apple', 'NNP')]), ('is', 'VBZ'), ('looking', 'VBG'), ('at', 'IN'), ('buying', 'VBG'), Tree('GPE', [('U.K.', 'NNP')]), ('startup', 'NN'), ('for', 'IN'), ('$', '$'), ('1', 'CD'), ('billion', 'CD')]
C[('Apple', 'NNP'), ('is', 'VBZ'), ('looking', 'VBG'), ('at', 'IN'), ('buying', 'VBG'), ('U.K.', 'NNP'), ('startup', 'NN'), ('for', 'IN'), ('$', '$'), ('1', 'CD'), ('billion', 'CD')]
D[Tree('ORGANIZATION', [('Apple', 'NNP')]), ('is', 'VBZ'), ('looking', 'VBG'), ('at', 'IN'), ('buying', 'VBG'), Tree('GPE', [('U.K.', 'NNP')]), ('startup', 'NN'), ('for', 'IN'), ('$', '$'), ('1', 'CD'), ('billion', 'CD')]
Attempts:
2 left
💡 Hint
Look at how NLTK labels named entities like organizations and geopolitical entities.
🧠 Conceptual
intermediate
1:30remaining
Which NLTK function performs POS tagging before NER?
In the NLTK pipeline for Named Entity Recognition, which function is responsible for assigning part-of-speech tags to tokens before chunking?
Ane_chunk()
Bword_tokenize()
Cpos_tag()
Dsent_tokenize()
Attempts:
2 left
💡 Hint
POS tags describe the role of each word like noun or verb.
Hyperparameter
advanced
1:30remaining
What is the effect of using binary=True in ne_chunk()?
In NLTK's ne_chunk function, setting binary=True changes the output. What does this parameter do?
AIt merges all named entities into a single 'NE' label without specific types.
BIt disables named entity recognition and returns only POS tags.
CIt enables recognition of only person names, ignoring other entity types.
DIt outputs entities as plain strings instead of Tree objects.
Attempts:
2 left
💡 Hint
Think about simplifying entity categories.
🔧 Debug
advanced
2:00remaining
Why does this NER code raise a LookupError?
Consider this code snippet: import nltk sentence = "Google is a tech giant" tokens = nltk.word_tokenize(sentence) pos_tags = nltk.pos_tag(tokens) chunks = nltk.ne_chunk(pos_tags) When running, it raises a LookupError about missing 'maxent_ne_chunker'. What is the cause?
AThe sentence contains unknown words causing the error.
BThe 'maxent_ne_chunker' model is not downloaded in NLTK data.
Cpos_tag() was not called before ne_chunk().
Dword_tokenize() requires a language parameter that is missing.
Attempts:
2 left
💡 Hint
Check if all required NLTK models are installed.
Model Choice
expert
2:30remaining
Which NLTK model is used internally by ne_chunk for NER?
NLTK's ne_chunk function uses a pre-trained model internally. Which model does it use for Named Entity Recognition?
AA Maximum Entropy classifier trained on the ACE corpus
BA Hidden Markov Model trained on the CoNLL 2003 dataset
CA Maximum Entropy classifier trained on the CONLL 2000 corpus
DA Maximum Entropy classifier trained on the ACE corpus and Treebank data
Attempts:
2 left
💡 Hint
Consider the training data NLTK mentions for ne_chunk.