Dictionary-Based Text Analysis

Machine Learning
Introduced by
Content-analysis tradition (formalized for political text by Grimmer & Stewart; sentiment dictionaries by Young & Soroka)
Year
2013
Type
Rule-based text scoring from validated word lists
Family
Text-as-data / content analysis

What does it do?

Dictionary-based text analysis scores documents by counting how often they use words from a predefined, validated list (a dictionary or lexicon) tied to a concept such as sentiment, emotion, or a policy area.

Each document's score is the rate at which dictionary terms appear, so large collections of speeches, news articles, or manifestos can be measured for tone or thematic emphasis without hand-coding every document. Young and Soroka (2012) introduced and validated the Lexicoder Sentiment Dictionary for political news, and Grimmer and Stewart (2013) stress that automated text methods of this kind require extensive, problem-specific validation.

The intuition behind the method

If you want to know whether a news article is positive or negative, you can read it, or you can count its positive and negative words. Dictionary methods formalize the second strategy: a human or prior research decides in advance which words signal a category, and the computer tallies them. The strength is transparency: the measurement rule is a word list that anyone can read and reproduce. The danger is that words mean different things in different contexts. 'Tax relief' and 'tax burden' both contain 'tax', and 'not good' contains 'good'. A dictionary built and validated for one domain can therefore fail in another, which is why these methods depend on validation rather than on the simplicity of the counting.

History

Word counting of this kind is a standard approach in automated content analysis. Young and Soroka (2012) described and validated the Lexicoder Sentiment Dictionary for automated coding of sentiment in political news. They tested it against human-coded news content and compared it with nine existing content-analytic dictionaries, finding that its results were more systematically related to human coding than those of the other dictionaries. Grimmer and Stewart (2013) placed dictionary methods within a wider set of automated text methods for political science and emphasized the need for validation.

When to use it

Use dictionary methods when you have a well-defined concept with a validated word list, a need for transparent and reproducible measurement, and documents whose language matches the dictionary's domain. They are ideal for large-scale sentiment or tone measurement, for tracking issue or emotion emphasis over time, and as a fast, interpretable baseline. They are inappropriate when the concept is context-dependent or sarcastic, when no validated dictionary exists for your domain and you cannot validate one, or when categories require understanding word order and meaning beyond presence — in those cases supervised classification or topic models are better. Always validate the dictionary on your own corpus before trusting its scores.

Limitations and considerations

  • Ignores word order, syntax, negation, and context, so meaning beyond the presence of category terms is lost.
  • Dictionaries validated in one domain or period may mismeasure another. Grimmer and Stewart stress that dictionaries need problem-specific validation, and off-the-shelf lexicons should not be assumed to transfer to a new domain without it.
  • Cannot capture sarcasm, irony, or sentiment expressed without category words.
  • Performance is limited by the coverage of the word list, which can miss key terms or include ambiguous ones.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Transparent and reproducible: the measurement rule is an inspectable word list, so scores can be audited and replicated.
  • Needs no labeled training data to apply the dictionary, but validation requires a hand-coded benchmark sample, so total cost is not negligible.
  • Computationally cheap: counting terms and dividing by document length is fast even for large corpora.
  • Interpretable scores: each score can be traced back to the specific terms that produced it.

Applications

  • Measuring the tone of news coverage of parties, candidates, or policies over time.
  • Scoring emotional content (anger, fear, anxiety) in political speeches, debates, or social media.
  • Tracking issue or policy-area emphasis across documents using domain lexicons.
  • Detecting populist, moralizing, or uncivil rhetoric with specialized word lists.
  • Providing a fast, interpretable baseline against which supervised classifiers and topic models are compared.

How it works

How it works

1

A dictionary is a set of terms grouped into one or more categories, such as positive and negative sentiment, an emotion, or a policy domain. Researchers either adopt a validated word list from prior work, such as a published sentiment lexicon, or build one for the task from expert knowledge, existing word lists, and inspection of the corpus. Because the dictionary determines the entire measurement, its construction and provenance should be documented.

2

The corpus is tokenized and normalized (for example, lowercased, optionally stemmed or lemmatized) so that document tokens can be matched against dictionary entries. Negation and multi-word expressions also need a decision. Matching choices, such as whole-word versus wildcard stem matching and the treatment of negation, change the counts, so they should match the assumptions under which the dictionary was validated.

3

For each document, the method counts the tokens that belong to a dictionary category and divides this count by the document's total number of tokens. Writing c_dw for the number of occurrences of dictionary term w in document d, and N_d for the total token count of document d, the score is the sum of c_dw over the terms w in the dictionary D, divided by N_d. The result is the proportion of the document devoted to that category. Length normalization makes long and short documents comparable; a raw count alone confounds category emphasis with document length.

Formula
s_d = \frac{\sum_{w \in D} c_{dw}}{N_d}
4

When a dictionary has opposing categories, such as positive and negative terms, a single net tone score can be formed. A common convention sets P_d and N_d to the counts of positive and negative dictionary terms in document d and computes (P_d − N_d)/(P_d + N_d). This value lies between −1 and 1 whenever the document contains at least one dictionary term, so it summarizes net affect per document on a bounded scale. Other categories can be combined in the same way to produce emphasis or position scores.

Formula
\text{tone}_d = \frac{P_d - N_d}{P_d + N_d}
5

Scores should be checked against an external benchmark, such as human coding of a sample or expert ratings, because a dictionary that works in one domain may systematically mismeasure another. Grimmer and Stewart stress that automated methods require extensive, problem-specific validation. In practice, draw a sample of documents, hand-code it, and compare the dictionary scores with the codes, for example by correlation or by classification accuracy against the codes. Inspect the misclassified documents to see which terms or contexts drive the errors. Report the agreement and any revisions made, and revise the dictionary if validation fails.

Common pitfalls

  • Applying an off-the-shelf sentiment dictionary to a new domain without revalidating it, and so inheriting its gaps and biases.
  • Reporting raw term counts instead of length-normalized rates, which confounds category emphasis with document length.
  • Mishandling negation: 'not corrupt' contains the negative term 'corrupt', so naive counting scores it as negative even though the phrase is not negative about corruption.
  • Treating a high agreement with human codes on one sample as proof that the dictionary is valid for a heterogeneous corpus.

Frequently asked questions

How is a dictionary method different from supervised text classification?

A dictionary method applies a fixed, human-specified word list and needs no labeled examples: you decide in advance which words count. Supervised classification instead learns the mapping from text features to categories from hand-labeled training documents. It can pick up context-dependent cues but requires labeled data. Dictionaries are more transparent but can be brittle across domains, while classifiers are usually more accurate within the domain they were trained on and may not generalize. The two are often combined, with a dictionary serving as a baseline that a classifier aims to improve on. See supervised-text-classification.

Can I use an off-the-shelf sentiment dictionary on my corpus?

You can, but you should validate it on your own data first. Published lexicons such as the Lexicoder Sentiment Dictionary were built and tested on specific kinds of text, and their word lists may misfire in a different domain, register, or time period. Domain-specific vocabulary can carry meanings the dictionary did not anticipate. A responsible workflow is to hand-code a sample of the corpus, compare the dictionary scores with those codes, inspect the disagreements, and then revise or reject the dictionary.

How do dictionary methods handle negation and context?

By default they do not. Simple term counting treats 'good' and 'not good' identically, and it cannot distinguish 'tax relief' from 'tax burden'. Some implementations add negation-handling windows, multi-word expressions, or wildcard stems to reduce these errors, but these are partial fixes that also need validation. When context, negation, and word order are central to the concept, dictionary methods are the wrong tool, and supervised classification or other approaches that use richer features are preferable.

Related methods

Sources

  1. Grimmer, J., & Stewart, B. M. (2013). Text as Data: The Promise and Pitfalls of Automatic Content Analysis Methods for Political Texts. Political Analysis, 21(3), 267–297.

    Open DOI reference
  2. Young, L., & Soroka, S. (2012). Affective News: The Automated Coding of Sentiment in Political Texts. Political Communication, 29(2), 205–231.

    Open DOI reference