0
0
NLPml~10 mins

What NLP actually does - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to tokenize the sentence into words.

NLP
words = sentence.[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 instead of splitting.
Using replace() which changes characters but does not split.
Using strip() which removes spaces only at ends.
2fill in blank
medium

Complete the code to convert all words to lowercase for uniformity.

NLP
lower_words = [word.[1]() for word in words]
Drag options to blanks, or click blank then click option'
Acapitalize
Blower
Cupper
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Using upper() which makes letters uppercase.
Using capitalize() which only changes the first letter.
Using title() which capitalizes first letters of words.
3fill in blank
hard

Fix the error in the code to remove punctuation from each word.

NLP
import string
clean_words = [word.strip(string.[1]) for word in lower_words]
Drag options to blanks, or click blank then click option'
Apunctuation
Bdigits
Cwhitespace
Dascii_letters
Attempts:
3 left
💡 Hint
Common Mistakes
Using digits which removes numbers, not punctuation.
Using whitespace which removes spaces, not punctuation.
Using ascii_letters which removes letters, not punctuation.
4fill in blank
hard

Fill both blanks to create a dictionary counting word frequencies.

NLP
word_counts = {word: words.[1](word) for word in [2]
Drag options to blanks, or click blank then click option'
Acount
Bindex
Cset
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using index which finds position, not count.
Using list which includes duplicates, causing repeated keys.
Using count with list keys causing repeated counting.
5fill in blank
hard

Fill all three blanks to filter words longer than 3 letters and create a frequency dictionary.

NLP
filtered_counts = {word: words.[1](word) for word in [2] if len(word) [3] 3}
Drag options to blanks, or click blank then click option'
Acount
Bset
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' which filters shorter words.
Using list instead of set causing duplicate keys.
Using index instead of count causing errors.