Guides
How to analyze text data
From word counts and topic models to LLM classification — matching the method to the question instead of reaching for the newest tool by default.
Text data resists the instinct to jump straight to the most sophisticated tool available. A simple word-frequency count answers some questions better than a large language model would, faster and more transparently. Text analytics is a ladder of methods, roughly ordered by complexity and by how much you can explain about why the method produced the answer it did — and the right rung depends on the question, not on what's newest.
Rung one: counting and concordance
Before any modeling, look at the words themselves. Word frequency, collocations (words that appear near each other more than chance would predict), and keyword-in-context concordance — seeing every occurrence of a term alongside its surrounding words — surface patterns a model might hide behind a single aggregate score, and they require no training data or model to trust. This is often the fastest way to understand a new corpus, and the right first step even before you decide whether a heavier method is needed at all.
Rung two: classic NLP tasks
Once you move beyond counting, the standard building blocks are:
- Tokenization — splitting text into words or subword units, the input every downstream step depends on. Getting this right for the language and domain you're working in (contractions, hyphenation, domain jargon) matters more than it looks like it should.
- Part-of-speech tagging and dependency parsing — identifying grammatical roles and sentence structure, useful when you need to know not just what words appear but how they relate.
- Named Entity Recognition — pulling out people, organizations, locations, and other named things from free text, the backbone of turning unstructured text into structured fields you can filter and count.
- classification — assigning each document or sentence to a predefined category, from spam detection to support-ticket routing, either through a trained model or, for well-defined categories with enough labeled examples, a simpler rule-based or statistical classifier.
- sentiment analysis — scoring text as positive, negative, or neutral, or on a finer scale. Useful as a rough aggregate signal across thousands of documents, unreliable at the level of any single ambiguous or sarcastic sentence — validate it against a human-coded sample before trusting the aggregate.
Rung three: discovering structure you didn't specify in advance
topic modeling algorithms such as LDA find clusters of words that tend to co-occur across a corpus, without you having to define the categories beforehand — useful for exploring an unfamiliar corpus or surfacing themes at a scale no person could read manually. The trade-off: topics are statistical patterns, not human-labeled categories, and someone still has to look at each topic's top words and decide what to call it and whether it's coherent. A topic model run on the wrong number of topics produces either an unhelpfully broad mush or a fragmented set of near-duplicates — plan to try a few settings, not just the default.
Word and document embeddings — word2vec, doc2vec, and similar — represent words or documents as vectors positioned so that similar meaning corresponds to proximity in the vector space, useful for similarity search, clustering, and as an input to downstream models.
Rung four: pretrained transformer models and LLMs
Modern pretrained language models handle most of the classic tasks above — classification, entity recognition, summarization — with far less labeled training data than earlier approaches required, and can do things classic NLP could not, such as answering open-ended questions about a document's content or generating a coherent summary. The trade-off is interpretability and cost: a transformer's classification decision is harder to explain than a rule-based classifier's, and running a large model over a big corpus costs meaningfully more in compute or API spend than a classic NLP pipeline. For a genuinely large corpus, run a cost and latency estimate before committing to an LLM-based pipeline over a lighter classical one — the accuracy gain isn't always worth the multiplier in cost.
Matching the method to the question
| Question | Reach for |
|---|---|
| What words and phrases actually appear, and how often? | Word frequency, concordance |
| What themes exist in this corpus, and I don't know them in advance? | Topic modeling |
| Which of these known categories does each document belong to? | Classification (classic or transformer-based) |
| What entities — people, places, organizations — are mentioned? | Named entity recognition |
| Is sentiment broadly positive or negative across many documents? | Sentiment analysis, validated against a human-coded sample |
| Does this document answer a specific open-ended question? | An LLM, with the answer checked against the source |
A shortlist by situation
- You're teaching, learning, or prototyping classic techniques: NLTK remains the standard teaching library, even though production pipelines have largely moved on to faster tools.
- You're putting NLP into a production service: spaCy is built for that specifically — fast tokenization, pretrained pipelines for 70-plus languages, and production-ready model packaging.
- You want topic modeling or to train custom word embeddings on a large corpus: Gensim specializes in exactly that unsupervised work, memory-efficient enough to stream corpora too large to fit in memory at once.
- You want pretrained transformer models for classification, summarization, or other modern NLP tasks without training from scratch: Hugging Face Transformers is the default entry point, with a unified API across thousands of hosted models.
- You're a humanities researcher or student who wants quick, no-code exploration of a corpus: Voyant Tools runs entirely in the browser, free, with linked word-frequency, concordance, and trend views.
- You need enterprise sentiment and entity extraction embedded into a product or CX pipeline, not a research library: Lexalytics packages that as a commercial platform with industry-specific models.
Common mistakes
- Reaching for the heaviest available model when a word count or a rule-based classifier would answer the question just as well, faster and more transparently.
- Trusting an aggregate sentiment score without ever reading a sample of the actual sentences behind it.
- Running topic modeling once, at one topic count, and treating the first output as final rather than iterating.
- Skipping tokenization quality for a specialized domain — medical, legal, or heavily abbreviated text — and getting garbage downstream from a generic pipeline built for general prose.
- Using an LLM to answer a factual question about a document set without checking its answer against the actual source text.
For survey open-ends specifically, see how to analyze survey data. For the wider set of NLP and text-analytics tools, including enterprise platforms and digital-humanities-specific tools, see every tool in this category and every tool in this category.