Imagine you have a very long article and want a short summary that captures the main points. Which NLP application would you use?
Think about which task reduces text length while keeping important info.
Text Summarization creates a shorter version of a long text, keeping key ideas. NER finds names, Sentiment Analysis finds feelings, and Machine Translation changes language.
Given the code below that uses a simple rule-based sentiment check, what will be the printed output?
text = "I love sunny days but hate the rain." positive_words = ['love', 'happy', 'joy'] negative_words = ['hate', 'sad', 'angry'] score = 0 for word in text.lower().split(): if word in positive_words: score += 1 elif word in negative_words: score -= 1 if score > 0: print('Positive') elif score < 0: print('Negative') else: print('Neutral')
Count how many positive and negative words appear exactly in the list.
The text contains 'love' (positive) and 'hate' (negative), so score is 0, resulting in 'Neutral'.
You want to convert spoken words into text instantly during a live conversation. Which model type is best suited?
Consider models that handle sequences and context well for language tasks.
Transformer-based seq2seq models are state-of-the-art for speech-to-text, handling long sequences efficiently. RNNs are older and slower, CNNs are for images, and K-Means is unsupervised clustering.
You built a system that translates English sentences to French. Which metric should you use to measure how good the translations are?
Think about metrics that compare generated text to reference translations.
BLEU score measures how close the machine translation is to human translations by comparing overlapping words and phrases. Accuracy and F1 are for classification, MSE is for regression.
Consider this Python code using a popular NLP library to extract named entities. What error will it raise?
from transformers import pipeline ner = pipeline('ner') text = "Apple is looking at buying U.K. startup for $1 billion" results = ner(text, aggregation_strategy='simple') print(results)
Check if the 'aggregation_strategy' argument is valid for the current transformers version.
In recent versions of transformers, 'aggregation_strategy' is a valid argument for the NER pipeline and will return aggregated entities without error.