Practical Exercises
Exercise 1: Stop Word Removal
Task: Use the nltk library to remove stop words from the following text: "NLP enables computers to understand human language, which is a crucial aspect of artificial intelligence."
Solution:
from nltk.corpus import stopwords
nltk.download('stopwords')
text = "NLP enables computers to understand human language, which is a crucial aspect of artificial intelligence."
stop_words = set(stopwords.words('english'))
filtered_tokens = [word for word in tokens if word.lower() not in stop_words]
print("Original Tokens:")
print("\\\\nFiltered Tokens:")