0
0
NLPml~10 mins

Limitations of classical methods 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 create a simple bag-of-words representation of text.

NLP
from sklearn.feature_extraction.text import CountVectorizer
texts = ['I love AI', 'AI loves me']
vectorizer = CountVectorizer()
X = vectorizer.[1](texts)
Drag options to blanks, or click blank then click option'
Afit_transform
Btransform
Cfit
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using only fit or transform separately causes errors or incomplete processing.
2fill in blank
medium

Complete the code to remove stop words from the text using CountVectorizer.

NLP
vectorizer = CountVectorizer(stop_words=[1])
X = vectorizer.fit_transform(texts)
Drag options to blanks, or click blank then click option'
A'english'
BNone
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using True or False does not remove stop words automatically.
3fill in blank
hard

Fix the error in the code that tries to vectorize text but uses an incorrect method.

NLP
vectorizer = CountVectorizer()
X = vectorizer.[1](['sample text'])
Drag options to blanks, or click blank then click option'
Apredict
Bfit_transform
Ctransform
Dfit_predict
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict or fit_predict causes attribute errors.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters words longer than 3 characters.

NLP
filtered_words = {word: len(word) for word in words if len(word) [1] 3 and word [2] 'the'}
Drag options to blanks, or click blank then click option'
A>
B<
C!=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '==' changes the filter logic incorrectly.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths, excluding short words.

NLP
result = [1]: [2] for w in words if len(w) [3] 4
Drag options to blanks, or click blank then click option'
Aw.upper()
Blen(w)
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' includes short words, changing the result.