0
0
NLPml~10 mins

Challenges in language processing 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 tokenize the sentence into words.

NLP
tokens = sentence.[1]()
Drag options to blanks, or click blank then click option'
Asplit
Bjoin
Creplace
Dstrip
Attempts:
3 left
💡 Hint
Common Mistakes
Using join() instead of split()
Using replace() which changes characters
2fill in blank
medium

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

NLP
tokens = [word.[1]() for word in tokens]
Drag options to blanks, or click blank then click option'
Alower
Bcapitalize
Cupper
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Using upper() which makes all letters uppercase
Using capitalize() which only changes first letter
3fill in blank
hard

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

NLP
import string
clean_tokens = [word.strip(string.[1]) for word in tokens]
Drag options to blanks, or click blank then click option'
Aascii_letters
Bwhitespace
Cpunctuation
Ddigits
Attempts:
3 left
💡 Hint
Common Mistakes
Using whitespace which removes spaces, not punctuation
Using digits which removes numbers
4fill in blank
hard

Fill both blanks to create a dictionary counting word frequencies.

NLP
word_freq = {word: tokens.[1](word) for word in tokens if word [2] ''}
Drag options to blanks, or click blank then click option'
Acount
B!=
C==
Dappend
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of != in condition
Using append which is for lists, not counting
5fill in blank
hard

Fill all three blanks to filter out stopwords and create a list of important words.

NLP
stopwords = {'and', 'the', 'is', 'in'}
important_words = [word for word in tokens if word [1] stopwords and len(word) [2] [3]]
Drag options to blanks, or click blank then click option'
Anot in
B>
C2
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'in' instead of 'not in' to exclude stopwords
Using '<' instead of '>' for length condition