Challenge - 5 Problems
Punctuation Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of punctuation removal code
What is the output of the following Python code that removes punctuation and special characters from a text string?
NLP
import re text = "Hello, world! Welcome to AI & ML." clean_text = re.sub(r'[^\w\s]', '', text) print(clean_text)
Attempts:
2 left
💡 Hint
Look at the regular expression pattern used in re.sub to remove characters.
✗ Incorrect
The pattern '[^\w\s]' matches any character that is NOT a word character or whitespace. So punctuation and special characters like ',' '!' '&' are removed.
❓ Model Choice
intermediate2:00remaining
Best model for text preprocessing with punctuation removal
Which model type is best suited for handling text data that requires punctuation and special character removal before training?
Attempts:
2 left
💡 Hint
Think about models designed to process sequences of words.
✗ Incorrect
RNNs are designed to handle sequences like text and benefit from preprocessing steps like punctuation removal to improve input quality.
❓ Hyperparameter
advanced2:00remaining
Choosing tokenizer settings for punctuation removal
When using a tokenizer in NLP, which setting helps ensure punctuation and special characters are removed during tokenization?
Attempts:
2 left
💡 Hint
Look for the parameter that controls which characters are removed during tokenization.
✗ Incorrect
The 'filters' parameter in tokenizers specifies characters to remove, including punctuation and special characters.
❓ Metrics
advanced2:00remaining
Effect of punctuation removal on text classification accuracy
If you train a text classification model on raw text and then on text with punctuation removed, what is the most likely effect on accuracy?
Attempts:
2 left
💡 Hint
Consider how punctuation might affect different types of text data.
✗ Incorrect
Punctuation can sometimes add useful information or noise, so its removal can help or hurt accuracy depending on context.
🔧 Debug
expert2:00remaining
Debugging punctuation removal code
What error does the following code raise when trying to remove punctuation from text?
import string
text = "Hello, world!"
clean_text = text.translate(str.maketrans('', '', string.punctuation))
print(clean_text)
NLP
import string text = "Hello, world!" clean_text = text.translate(str.maketrans('', '', string.punctuation)) print(clean_text)
Attempts:
2 left
💡 Hint
Check the usage of str.maketrans and translate methods.
✗ Incorrect
The code correctly uses str.maketrans to remove punctuation and prints 'Hello world' without errors.