Sentiment Analysis

NLP interview text classification lexicon aspect-based

What is sentiment analysis and how is it framed?

Sentiment analysis classifies the emotional polarity of text — positive, negative, or neutral. It's usually framed as a text classification problem, either binary, three-class, or fine-grained (1–5 stars).

Follow-ups
  • “Classification or regression?” — Polarity is classification; a continuous intensity score can be regression. Star ratings are often treated as ordinal.

Lexicon vs ML vs transformer approaches?

Three eras of methods, trading simplicity for accuracy and context-awareness.

Lexicon word lists

Sum positive/negative word scores (e.g. VADER). No training, but blind to context.

Classic ML TF-IDF + classifier

TF-IDF features into logistic regression / Naive Bayes / SVM.

Transformers fine-tuned BERT

Contextual embeddings capture meaning — current state of the art.

Follow-ups

Why are negation and sarcasm hard?

Surface words mislead. “Not good” contains a positive word but is negative; “Oh great, it broke again” is positive on the surface but sarcastic.

Why bag-of-words struggles

Count-based features ignore order and scope, so they can't see that “not” flips “good.” Sarcasm and irony often need world knowledge or tone that's absent from the text — still hard even for large models.

What is aspect-based sentiment analysis?

Instead of one label per document, aspect-based sentiment assigns polarity to specific aspects. “The food was great but the service was slow” → food: positive, service: negative.

Follow-ups
  • “Why is it useful?” — A single overall score hides actionable detail; businesses want to know what customers liked or disliked.

How do you evaluate it?

Standard classification metrics — accuracy, and precision/recall/F1 per class. Sentiment data is often imbalanced (lots of positives), so report macro-F1, not just accuracy. See classification metrics.

Follow-ups
  • “Watch-outs in labeling?” — Human annotators disagree on neutral/mixed cases; measure inter-annotator agreement and define guidelines.