0
0
NLPml~10 mins

Text preprocessing pipelines 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 convert all text to lowercase.

NLP
text = "Hello World!"
processed_text = text.[1]()
Drag options to blanks, or click blank then click option'
Alower
Bupper
Ccapitalize
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Using upper() instead of lower()
Using capitalize() which only changes the first letter
2fill in blank
medium

Complete the code to split the text into words.

NLP
text = "Machine learning is fun"
words = text.[1]()
Drag options to blanks, or click blank then click option'
Astrip
Bjoin
Creplace
Dsplit
Attempts:
3 left
💡 Hint
Common Mistakes
Using join() which combines words
Using replace() which changes characters
3fill in blank
hard

Fix the error in the code to remove punctuation from the text.

NLP
import string
text = "Hello, world!"
clean_text = text.translate(str.maketrans('', '', [1]))
Drag options to blanks, or click blank then click option'
Astring.punctuation
Bstring.whitespace
Cstring.ascii_letters
Dstring.digits
Attempts:
3 left
💡 Hint
Common Mistakes
Using whitespace which removes spaces
Using ascii_letters which removes letters
4fill in blank
hard

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

NLP
stopwords = {'is', 'the', 'and'}
words = ['this', 'is', 'fun']
filtered = [word for word in words if word [1] stopwords]
Drag options to blanks, or click blank then click option'
A==
Bin
Cnot in
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'in' which keeps stopwords
Using '==' which compares equality
5fill in blank
hard

Fill all three blanks to create a dictionary of word counts from a list.

NLP
words = ['apple', 'banana', 'apple']
word_counts = [1]((word, [2]) for word in words if words.count(word) [3] 1)
Drag options to blanks, or click blank then click option'
Adict
Bwords.count(word)
C>
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using list instead of dict
Using '<' instead of '>' in condition