0
0
NLPml~10 mins

Stopword removal 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 remove stopwords from the list of words.

NLP
filtered_words = [word for word in words if word not in [1]]
Drag options to blanks, or click blank then click option'
Astopwords
Bpunctuation
Cvocabulary
Dtokens
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tokens' instead of 'stopwords' causes wrong filtering.
Using 'punctuation' removes symbols, not stopwords.
2fill in blank
medium

Complete the code to import the stopwords list from NLTK.

NLP
from nltk.corpus import [1]
Drag options to blanks, or click blank then click option'
Awords
Bstopwords
Ctokenize
Dcorpus
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'words' instead of 'stopwords' causes attribute errors.
Importing 'tokenize' is unrelated to stopword lists.
3fill in blank
hard

Fix the error in the code to get English stopwords from NLTK.

NLP
stop_words = set(stopwords.words([1]))
Drag options to blanks, or click blank then click option'
A'eng'
B'English'
C'en'
D'english'
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalized 'English' causes a KeyError.
Using abbreviations like 'eng' or 'en' are invalid.
4fill in blank
hard

Fill both blanks to create a list of words without stopwords from a sentence.

NLP
filtered = [[1] for [2] in sentence.split() if [1] not in stop_words]
Drag options to blanks, or click blank then click option'
Aword
Bsentence
Cstop_words
Dwords
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in the loop and condition causes errors.
Using 'sentence' or 'words' instead of 'word' is incorrect.
5fill in blank
hard

Fill all three blanks to create a dictionary of word counts excluding stopwords.

NLP
word_counts = [1](word for word in words if word not in [2])
filtered_counts = {word: count for word, count in word_counts.[3]()}
Drag options to blanks, or click blank then click option'
ACounter
Bstop_words
Citems
Ddict
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'dict' instead of 'Counter' loses counting functionality.
Using 'keys()' instead of 'items()' misses counts.