Introduction
Language processing helps computers understand human language, but it is hard because human language is full of meaning, rules, and exceptions.
Jump into concepts and practice - no test required
No specific code syntax applies because challenges are concepts, not code.Ambiguity example:
Input: "I saw her duck"
Possible meanings:
- She lowered her head quickly
- She owns a duck (the bird)Context example: Input: "Can you book a room?" Meaning depends on context: - 'book' as a noun (a thing to read) - 'book' as a verb (to reserve)
Idioms example: Input: "It's raining cats and dogs" Literal meaning is wrong; it means heavy rain.
from sklearn.feature_extraction.text import CountVectorizer from sklearn.naive_bayes import MultinomialNB from sklearn.pipeline import make_pipeline # Simple example showing ambiguity challenge texts = ["I saw her duck", "She owns a duck"] labels = [0, 1] # 0=action, 1=animal model = make_pipeline(CountVectorizer(), MultinomialNB()) model.fit(texts, labels) # Test ambiguous sentence test_text = ["I saw her duck"] prediction = model.predict(test_text) print(f"Prediction for '{test_text[0]}':", "Action" if prediction[0] == 0 else "Animal")
sentence = "I saw her duck." tokens = sentence.split() print(tokens)
stopwords = ['the', 'is', 'at'] tokens = ['the', 'cat', 'is', 'on', 'the', 'mat'] filtered = [word for word in tokens if word not in stopwords()] print(filtered)
"kick the bucket" are hard for AI to understand?