Keyword in Context (KWIC): What a Concordance Is and How to Use One
A keyword-in-context (KWIC) concordance lists every occurrence of a word or phrase in a text, each one lined up in a centre column with a fixed number of words to its left and right. A frequency count tells you how often a word appears; the concordance shows how it is used. Read it before you count or code: it shows what a frequent word actually means, supplies examples for a codebook, and exposes negation and other senses that a word count hides.
Last updated · by the simstat.com editorial team · How we write
Why a count is not enough
A word frequency list is usually the first thing you compute on a text. It tells you that a word is common, but not what the word is doing. Support can be a noun or a verb; not happy contains happy; great can be praise or sarcasm. If you build a coding scheme or a dictionary category on the bare count, you are assuming you know what every occurrence means.
A concordance tests that assumption. It pulls out every occurrence of the word, shows each one with the words around it, and stacks the results so you can read them all at a glance. Patterns that are invisible in running text, such as the same word always following not, jump out when the lines are aligned.
What a KWIC concordance is
In a keyword-in-context (KWIC) display, each occurrence of the search term, the keyword (the “center word” in Anthony’s (2022) help), sits in a centre column. Its left context (the words before it) is right-aligned, and its right context (the words after it) is left-aligned. Each row is a concordance line, and each occurrence is a hit. Baker and Levon (2015) describe concordances as “tables which show all of the occurrences of a word, phrase or related pair of words in the immediate context that they occur in”.
The term goes back at least to early machine indexing. Luhn (1960), in a paper on a “key word-in-context index” for technical literature, proposed indexes “giving keywords in their context” for new literature, built entirely by machine so that they could be kept up to date. The name survives in concordance software: Anthony (2022) describes the KWIC view of his free concordancer as a way “to see how words and phrases are commonly used in a corpus of texts”.
The formula
Write the text as a sequence of N words , and a search term as m word patterns (one pattern for a single word, two for a two-word phrase). There is a hit at position i when, for each j, word i + j − 1 of the text matches pattern j of the term. The set of hit positions is
For each hit i in H(q), with a left width L and a right width R, the concordance line is
where L and R are counted in words, and words that would fall before the first word or after the last are simply left out, so lines near the start or end of a text are shorter. The number of lines is the number of hits, . For a single word without a wildcard, that is exactly the word’s frequency in a word count, which is why the two views belong together: the count tells you how many lines there are, and the concordance shows them.
In our tools, matching ignores case, a word is a run of letters or digits with internal apostrophes and hyphens allowed, and the context keeps the original punctuation.
Sorting, wildcards and phrases
Sorting is what turns a list of lines into a pattern finder. Sorting by left context orders the lines by the word just before the keyword, then the word before that, so all the not lines and all the very lines end up together. Sorting by right context does the same for what follows. Anthony (2022) labels these positions 1L, 2L, … to the left and 1R, 2R, … to the right, and recommends ordering by the frequency of the resulting patterns to “identify the most commonly occurring patterns”. Our tool sorts alphabetically, which also brings identical neighbours together but does not rank the patterns by how often they occur.
Wildcards gather the forms of a word. In our tool * stands for any run of letters or digits, including none
(hyphens and apostrophes inside a word count too), so satisf* finds satisfied, satisfying and satisfaction,
but not unsatisfied, because the pattern still has to match from the start of the word; *satisf* finds all
four. Check what a wildcard catches: cat* also finds category.
Phrases search for words in sequence. A * on its own matches any one word, so * data lists every word
that comes before data. The concordance matches a phrase across commas and full stops, while the phrase counts
in our word frequency counter stop at punctuation, so a phrase search can return more lines than the phrase count.
A worked example
The passage is Abraham Lincoln’s Gettysburg Address (1863) in the Bliss copy, the version engraved in the Lincoln Memorial, as transcribed by the National Park Service; the speech and the transcription are in the public domain. The transcription marks Lincoln’s dashes with a tilde, which we print as dashes, and we leave out the quotation marks around the speech; no word changes. A word frequency count gives the starting point: the address has 271 words (138 different ones) by our counter’s rules, which treat can not as two words and a hyphenated form as one. Published counts of the address differ slightly with the transcription and with how such forms are counted. Joining every can not into cannot would give 268. The House Divided project at Dickinson College gives 272 words for its Bliss copy, which spells battle-field and resting-place with hyphens and reads upon and they here gave in two places where our text has on and they gave; our counter gives that copy 271 words, or 273 if each part of a hyphenated word is counted. With our word frequency counter’s defaults, which remove stop words (function words such as the and of) but keep negations, the most frequent words are nation and not (5 times each), and dedicated is ranked 3 with 4 occurrences, 1.48% of all words. Dedicate adds 2 more.
Worked example: what does dedicated mean in the Gettysburg Address?
A search for dedicated returns 4 lines and a search for dedicate returns 2,
the same as the word counts. The wildcard dedicat* returns both forms at once: 6 hits.
Here they are with 6 words on each side, sorted by left context (nearest word first). The last column is
our own reading of each line, not something the software computes.
| Word no. | Left context | Match | Right context | Our reading |
|---|---|---|---|---|
| 21 | new nation conceived in liberty, and | dedicated | to the proposition that all men | devoted to a principle |
| 173 | us the living rather to be | dedicated | here to the unfinished work which | committing oneself to a task |
| 198 | rather for us to be here | dedicated | to the great task remaining before | committing oneself to a task |
| 111 | a larger sense, we can not | dedicate | — we can not consecrate — we can | setting ground apart |
| 51 | any nation so conceived and so | dedicated | , can long endure. We are met | devoted to a principle |
| 69 | that war. We have come to | dedicate | a portion of that field as | setting ground apart |
Reading the lines gives 3 distinct senses, each with 2 lines:
- devoted to a principle: the nation “dedicated to the proposition that all men are created equal”;
- setting ground apart: “We have come to dedicate a portion of that field as a final resting place”;
- committing oneself to a task: the living should be “dedicated here to the unfinished work”.
The left sort also isolates the one negated line, we can not dedicate: Lincoln says that those present cannot dedicate the ground, because the men who struggled there have already consecrated it. A count of dedicat- words would score that line exactly like the others.
Finally, a phrase. The search can not finds 3 lines, matching the 3 counted two-word phrases. The search cannot finds 0: this transcription writes the word as two, and other transcriptions, such as Project Gutenberg’s e-text, print cannot, so a search for one spelling misses the other.
These lines come from the code behind our tool, so they match it exactly; the word numbers are in its CSV export.
Paste the address (from the National Park Service page in the references) into the tool, search for
dedicat*, keep the default 6 words of context on each side and choose “Left context” as the sort
order. Our word frequency counter gives the counts: its default settings (stop
words removed, negations kept) give the ranking above; untick “Remove stop words” to see the count for can not, which starts with
a stop word, and count single words only to see the 138 distinct words.
Concordances in content analysis and coding
Onwuegbuzie, Leech and Collins (2012) list keywords-in-context among the qualitative data analysis techniques that can be used to analyse the sources of a literature review, describing it as “identifying keywords and utilizing the surrounding words to understand the underlying meaning of the keyword”. Four practical uses follow:
- Checking a frequent word. Before you report that a word is common, read its lines to see which sense, or senses, you are counting.
- Building a codebook. Concordance lines are ready-made examples. Copy clear cases into the definition of a code, and borderline cases into its “do not code” notes.
- Catching negation and irony. Sort by left context and look at the words right before the keyword: not, never, hardly, so-called.
- Validating a dictionary category. If a category counts every match of
support*, read a sample of each word’s lines and note how many fit the category. Words that mostly misfit should be dropped or narrowed to a phrase.
Once the codebook is written and several people apply it, check that they agree; see our guides to Cohen’s kappa and Krippendorff’s alpha.
How to report it
A reader should be able to rerun your search and get the same lines. For the example above:
In the Gettysburg Address (Bliss copy, National Park Service transcription; 271 words), a case-insensitive search for
dedicat*returned 6 hits (dedicated 4, dedicate 2). With 6 words of context on each side, we read all 6 lines and coded each into one of 3 senses.
Include:
- the corpus: which texts, which edition or transcription, and its size in words;
- the exact search term, including wildcards, and whether case mattered;
- the context window, and whether you expanded lines to read more;
- the number of hits (Anthony’s (2022) concordancer, for example, reports it as “Total Hits”);
- how lines were selected: all of them, or a random sample of how many, drawn how;
- how you went from lines to claims, for example a coding scheme and who applied it.
Common mistakes
Cherry-picking lines. Quoting the three most striking lines out of three hundred tells the reader about your taste, not the text. Baker and Levon (2015) note that proponents of corpus methods present them as a guard against the accusation that critical discourse analysts “cherry-pick” atypical data to prove a point. They also report that, in an earlier study comparing analysts who worked independently, one particularly productive strategy was to apply a single technique very thoroughly, for example by reading every concordance line of a relevant term carefully rather than a sample. If there are too many lines to read, take a random sample and say so.
Ignoring case and tokenisation rules. Whether US matches us, whether well-being is one word, and whether can’t is split all change the hits. The worked example shows the simplest version: can not and cannot are different searches. Find out what your tool treats as a word before comparing counts across tools.
Too narrow a window. A few words either side are enough to sort and scan, but not always enough to interpret. Baker and Levon (2015) report that in many cases their concordance lines “needed to be expanded in order to access more context, which sometimes involved reading an entire article”. Widen the window, or go back to the source, before deciding what a line means.
Treating a concordance as a measurement. A concordance is a way of looking. The hit count is a frequency, with all a frequency’s limits, and your reading of the lines is an interpretation. If you turn readings into numbers, such as the share of lines in each sense, that is coding, and it needs a codebook and a reliability check like any other coding.
Assuming the meaning instead of checking it. Anthony (2022) defines collocates as words that “appear frequently within a certain distance of the search term”. Baker and Levon (2015) warn that when there are too many collocates to read expanded lines for every case, an analyst may end up “incorrectly assuming a collocate has a particular function when in fact it might be used in an unexpected way”. The fix is to read the lines, or a random sample of them, before interpreting the pattern.
Where to go next
The text analysis hub collects our tools and guides for counting and reading words. If your concordance is the first step towards coding interviews or open-ended answers, continue with the qualitative research hub.
References
- Luhn, H. P. (1960). Key word-in-context index for technical literature (KWIC index). American Documentation, 11(4), 288–295.
- Anthony, L. (2022). AntConc (Windows, MacOS, Linux) Build 4.1.1: Help. Waseda University.
- Baker, P. & Levon, E. (2015). Picking the right cherries? A comparison of corpus-based and qualitative analyses of news articles about masculinity. Discourse & Communication, 9(2), 221–236.
- Onwuegbuzie, A. J., Leech, N. L. & Collins, K. M. T. (2012). Qualitative Analysis Techniques for the Review of the Literature. The Qualitative Report, 17, Article 56, 1–28.
- Lincoln, A. (1863). Gettysburg Address (Bliss copy), transcription. National Park Service, Lincoln Memorial.
- Lincoln, A. (1863). Address at Soldiers' National Cemetery, Gettysburg, PA (Bliss copy), with word count. House Divided Project, Dickinson College.
- Lincoln, A. (1973). Lincoln's Gettysburg Address (eBook #4). Project Gutenberg.
Try it
- Keyword in context (KWIC): See every occurrence of a word or phrase with its surrounding text, sortable and exportable as CSV.
- Word frequency counter: count words and phrases: Count the frequency of words and 2–3-word phrases in any text, with a stop-word filter and CSV export.