🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Opinion Mining: Targets, Holders, and Fine-Grained Polarity

Natural Language ProcessingOpinion Mining: Targets, Holders, and Fine-Grained PolarityđŸŸĸ Free Lesson

Opinion Mining: Targets, Holders, and Fine-Grained Polarity

Module: Natural Language Processing | Difficulty: Advanced

What You'll Learn

  • 1Decompose an opinion into entity, aspect, sentiment, holder, and time
  • 2Extract aspect terms and their opinion words as ordered pairs
  • 3Report macro-F1 alongside accuracy on imbalanced polarity classes
  • 4Explain why contradictory aspects break document-level sentiment

Opinion mining asks who feels what about which part of which thing and when, which is a strictly harder question than labelling a review positive or negative. The canonical representation is the opinion quintuple (entity, aspect, sentiment, holder, time), and most modern work collapses it to aspect-level sentiment: "the food was excellent but the service was slow" carries both signs in one sentence, so a single document label destroys the useful signal. This lesson builds the quintuple, the pair extractor, and the metrics that must be reported for an imbalanced five-class problem.

Opinion Quintuples

Hu and Liu (2004) formalized opinions as a set of tuples over entities and their properties, and every subsequent aspect-based sentiment analysis benchmark inherits that structure. The extraction pipeline runs three subtasks: find aspect terms, find the opinion words that modify them, and classify polarity for each pair.

Benchmarks

CorpusSizeAnnotationTask
SemEval-2014 T4 restaurant3,841 sentencesaspect and polarity5-class ABSA
SemEval-2014 T4 laptop3,041 sentencesaspect and polarity5-class ABSA
MAMS4,000 sentencesaspect and polarityconflicting aspects
MPQA 3.0535 documentsholder and expressionholder identification
Amazon multi-domain3,600,000 reviewsstar ratingdocument polarity

Why document polarity fails

MAMS (Xu et al., 2020) was built specifically because sentences contain two aspects with opposite sentiments, so a document-level model must pick one and be wrong about the other. MPQA 3.0 contributes the holder dimension over 535 news documents, where the person who holds the opinion is rarely the author of the sentence.

Worked Code

python
POS_LEX = {"excellent": 2, "great": 2, "good": 1, "fine": 1, "quick": 1,
           "friendly": 2, "slow": -1, "cold": -1, "terrible": -2,
           "awful": -2, "bad": -1, "pricey": -1, "cheap": -1, "fresh": 1}

PATTERNS = [
    "the {a} was {o}", "{a} was {o}", "{o} {a}",
    "the {a} is {o}", "{a} are {o}", "{a} seemed {o}",
]

ASPECTS = ["food", "service", "price", "room", "staff", "battery", "screen", "delivery"]


def extract_pairs(sentence):
    text = sentence.lower().strip(".! ")
    pairs = []
    for pat in PATTERNS:
        for aspect in ASPECTS:
            for opinion in POS_LEX:
                candidate = pat.format(a=aspect, o=opinion)
                if candidate in text:
                    pairs.append((aspect, opinion, POS_LEX[opinion]))
    seen, out = set(), []
    for a, o, s in pairs:
        if (a, o) not in seen:
            seen.add((a, o))
            out.append((a, o, s))
    return out


def polarize(score):
    return "positive" if score > 0 else ("negative" if score < 0 else "neutral")


TEST = [
    ("the food was excellent but the service was slow", {("food", "positive"), ("service", "negative")}),
    ("the room is great and the price is good", {("room", "positive"), ("price", "positive")}),
    ("the screen is terrible", {("screen", "negative")}),
    ("delivery was friendly and quick", {("delivery", "positive")}),
]

correct = total = 0
for sentence, gold in TEST:
    got = {(a, polarize(s)) for a, _, s in extract_pairs(sentence)}
    hits = got & gold
    correct += len(hits)
    total += len(gold)
    print(repr(sentence), "->", sorted(got))
print("aspect recall:", round(correct / total, 3))
python
from collections import defaultdict

LABELS = ["positive", "neutral", "negative"]


def prf(pred, gold, label):
    tp = sum(1 for p, g in zip(pred, gold) if p == label and g == label)
    fp = sum(1 for p, g in zip(pred, gold) if p == label and g != label)
    fn = sum(1 for p, g in zip(pred, gold) if p != label and g == label)
    p = tp / max(1, tp + fp)
    r = tp / max(1, tp + fn)
    return p, r, (0.0 if p + r == 0 else 2 * p * r / (p + r))


def macro_f1(pred, gold):
    per = {lab: prf(pred, gold, lab) for lab in LABELS}
    macro = sum(v[2] for v in per.values()) / len(LABELS)
    accuracy = sum(1 for p, g in zip(pred, gold) if p == g) / max(1, len(gold))
    return per, macro, accuracy


gold = ["positive"] * 62 + ["neutral"] * 23 + ["negative"] * 15
pred = (["positive"] * 57 + ["neutral"] * 3 + ["positive"] * 2
        + ["neutral"] * 21 + ["positive"] * 2
        + ["negative"] * 12 + ["neutral"] * 3)

per, macro, accuracy = macro_f1(pred, gold)
for lab, (p, r, f) in per.items():
    print(f"{lab:9s} P={p:.3f} R={r:.3f} F1={f:.3f}")
print(f"macro-F1 {macro:.3f}  accuracy {accuracy:.3f}")

Real-World Applications

  • SemEval-2014 Task 4 supplies 3,841 restaurant and 3,041 laptop sentences, still the reference split for five-class aspect polarity.
  • MAMS (Xu et al., 2020) contributes 4,000 sentences chosen because two aspects in the same sentence carry opposite polarity, the case document-level models cannot resolve.
  • Amazon's multi-domain release holds 3,600,000 reviews from 233,000 reviewers, the usual pre-training corpus for document-level rating prediction.
  • MPQA 3.0 annotates holder and expression over 535 news documents, which is what lets a system attribute "the minister denied the claim" to the minister rather than the journalist.

âš ī¸Accuracy hides the minority class

On a 62 / 23 / 15 class split a model can print 0.86 accuracy while scoring 0.77 macro-F1; publish macro-F1 or per-class F1, never accuracy alone.

Common Mistakes

Reporting accuracy as the headline number

Fix: Report macro-F1 with per-class precision and recall, since polarity sets are routinely 60 percent majority class

Extracting aspects without their opinion words

Fix: Evaluate (aspect, opinion) pairs, because an aspect with the wrong attached modifier flips the polarity label

Ignoring conflicting aspects in one sentence

Fix: Use a corpus like MAMS for evaluation; otherwise the model is rewarded for collapsing two opinions into one

Best Practices

  • Score each (aspect, polarity) pair and only aggregate to a document score at the end
  • Evaluate on both standard SemEval splits and a conflicting-aspect split such as MAMS
  • Report macro-F1 next to accuracy so majority-class shortcuts are visible

Key Takeaways

  • An opinion is the quintuple (entity, aspect, sentiment, holder, time)
  • Aspect-based sentiment evaluates pairs, not documents, and needs macro-F1 because classes are imbalanced
  • SemEval-2014 T4 holds 3,841 restaurant and 3,041 laptop sentences; MAMS adds 4,000 conflicting cases
  • On a 62/23/15 split, accuracy near 0.86 can coexist with macro-F1 of 0.835

Frequently Asked Questions

How is opinion mining different from sentiment analysis?

Sentiment analysis assigns a polarity to a span or document. Opinion mining additionally recovers the aspect being judged and the holder who judges it, so "Alice found the battery excellent" and "Bob found the battery poor" share a document label but not an opinion.

Why does the MAMS split exist?

Because 4,000 of its sentences contain two aspects with contradictory polarity, so any system that emits one label per sentence scores at most half right. It was built to expose exactly that shortcut.

What does MPQA contribute that review corpora do not?

Holder annotation. MPQA 3.0 marks who holds each opinion across 535 news documents, which review corpora cannot do because there the holder and the author are always the same person.

Interview Questions

Q1: Why macro-F1 rather than accuracy for aspect polarity?

Polarity is imbalanced, roughly 60 percent positive on restaurant data; macro-F1 averages the per-class F1 so neutral and negative performance cannot be hidden by the majority class

Q2: What is an opinion quintuple?

(entity, aspect, sentiment, holder, time), formalized by Hu and Liu in 2004; most ABSA work drops holder and time and predicts (aspect, sentiment) pairs

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-07

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Continue Learning

Suggested next tutorials based on this topic

Need Expert NLP Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement