Tutorial >Concordance and Key-Word-In-Context

In publishing, a concordance is an alphabetical list of the words used in a book or body of work, listing each instance of each word with its immediate surrounding context1. In the precomputing era, when search was unavailable, a concordance offered the reader an easy way to search for words they might want to look up.

In programming, when we mention a concordance, we usually refer to an object that stores the words, and corresponding counts, for a given text. For example, if my text is

Summer is hot. It is hot today.

the corresponding concordance would be:

. 2
hot 2
is 2
it 1
summer 1
today 1

In RiTa, we can generate the above concordance with the RiTa.concordance() function.

  var args = {
    ignoreCase: true
  var c = RiTa.concordance("Summer is hot. It is hot today.", args);

Here is an example for you to test how a concordance would look like with your own text.

Key Word In Context

A common format for a concordance is Key-Word-In-Context or KWIC model. It sorts and aligns the words in a way that allows each to be searchable in the index. The search result for the word 'window' in an example KWIC model looks like this:


In RiTa, we can achieve this with the RiTa.kwic() function, as follows:

  var args = {
    ignoreCase: false,
    ignorePunctuation: true,
    wordCount: 6
  var lines = RiTa.kwic(text, keyword, args);

Here is an interactive example of a KWIC model in RiTa.