Skip to content

Keywords

keyness(text="", path=null, reference=null, reference_path=null, measure="log_likelihood", positive=true, min_freq=2, n=1, lemmatize=true, top_n=20)

Keywords - words that are significantly more (or, with positive=false, less) frequent in the text than in a reference. The default reference is the frequency dictionary of Google Books Ngram (Spanish books of 1980-2019, 63 billion words; downloaded by ests-mcp download), and then the response shows how the vocabulary of the text differs from the language of today: for the first paragraphs of Don Quijote these are «leer», «caballero», the old form «mesmo», «rocín» and «requiebro». The reference can also be another text: reference or reference_path. With n from 2 phrases of n adjacent words are compared, only with a reference text; a phrase does not run across the end of a sentence or the border of the texts of a query link. With lemmatize these are phrases of lemmas («el casa»): kwic finds them with by_lemma=true. The definitions and formulas of the measures are on the esTS page Keywords.

Against the dictionary the words of the text are read in the context of their sentences and compared by the lemmas of the dictionary: a verb takes the first of its verb analyses («fue» is ser, also in «fue a casa»), and a proper noun the lemma of its form taken alone, so a name that is also a form of another word comes as that word («Tomás» - tomar). Numbers and words with a hyphen, a period or letters outside Spanish are left out, and a word outside the dictionary gets its least frequency: names, terms and typos become keywords. Against a text the words are compared in lower case. If the reference lacks a word, Log Ratio is an estimate with the 0.5 correction and can be below zero although the word is more frequent in the text. The p-value is not corrected for the number of words tested: p < 0.0001 (g2 from 15.13) is more reliable.

Errors - those common to the tools and:

  • no reference is given, and the frequency dictionary is not downloaded;
  • no reference is given, and the text has no words of Spanish letters;
  • the text or the reference has no words;
  • n is above 1 with no reference: the frequency dictionary stores words, not phrases;
  • the text or the reference has fewer than n words.

The second paragraph of Don Quijote, about the books of chivalry, against the first one, about the life of the hidalgo:

{
  "name": "keyness",
  "arguments": {
    "text": "Es, pues, de saber que este sobredicho hidalgo, los ratos que estaba ocioso, que eran los más del año, se daba a leer libros de caballerías, con tanta afición y gusto, que olvidó casi de todo punto el ejercicio de la caza, y aun la administración de su hacienda. Y llegó a tanto su curiosidad y desatino en esto, que vendió muchas hanegas de tierra de sembradura para comprar libros de caballerías en que leer, y así, llevó a su casa todos cuantos pudo haber dellos; y de todos, ningunos le parecían tan bien como los que compuso el famoso Feliciano de Silva, porque la claridad de su prosa y aquellas entricadas razones suyas le parecían de perlas, y más cuando llegaba a leer aquellos requiebros y cartas de desafíos, donde en muchas partes hallaba escrito: La razón de la sinrazón que a mi razón se hace, de tal manera mi razón enflaquece, que con razón me quejo de la vuestra fermosura. Y también cuando leía: ...los altos cielos que de vuestra divinidad divinamente con las estrellas os fortifican, y os hacen merecedora del merecimiento que merece la vuestra grandeza.",
    "reference": "En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que vivía un hidalgo de los de lanza en astillero, adarga antigua, rocín flaco y galgo corredor. Una olla de algo más vaca que carnero, salpicón las más noches, duelos y quebrantos los sábados, lantejas los viernes, algún palomino de añadidura los domingos, consumían las tres partes de su hacienda. El resto della concluían sayo de velarte, calzas de velludo para las fiestas, con sus pantuflos de lo mesmo, y los días de entresemana se honraba con su vellorí de lo más fino. Tenía en su casa una ama que pasaba de los cuarenta, y una sobrina que no llegaba a los veinte, y un mozo de campo y plaza, que así ensillaba el rocín como tomaba la podadera. Frisaba la edad de nuestro hidalgo con los cincuenta años; era de complexión recia, seco de carnes, enjuto de rostro, gran madrugador y amigo de la caza. Quieren decir que tenía el sobrenombre de Quijada, o Quesada, que en esto hay alguna diferencia en los autores que deste caso escriben; aunque, por conjeturas verosímiles, se deja entender que se llamaba Quejana. Pero esto importa poco a nuestro cuento; basta que en la narración dél no se salga un punto de la verdad.",
    "top_n": 3
  }
}
{
  "n_words": 190,
  "reference": "Reference text, 217 words",
  "measure": "log_likelihood: log-likelihood G² (Rayson and Garside 2000): the significance of the difference, negative - the word is more frequent in the reference; critical values: 3.84 - p < 0.05, 6.63 - p < 0.01, 10.83 - p < 0.001, 15.13 - p < 0.0001",
  "keywords": [
    {
      "word": "razón",
      "freq_target": 5,
      "freq_reference": 0.0,
      "ipm_target": 26320.0,
      "ipm_reference": 0.0,
      "g2": 7.618,
      "p_value": 0.005779,
      "log_ratio": 3.514,
      "score": 7.618
    },
    {
      "word": "leer",
      "freq_target": 4,
      "freq_reference": 0.0,
      "ipm_target": 21050.0,
      "ipm_reference": 0.0,
      "g2": 6.094,
      "p_value": 0.01356,
      "log_ratio": 3.192,
      "score": 6.094
    },
    {
      "word": "tanto",
      "freq_target": 3,
      "freq_reference": 0.0,
      "ipm_target": 15790.0,
      "ipm_reference": 0.0,
      "g2": 4.571,
      "p_value": 0.03252,
      "log_ratio": 2.777,
      "score": 4.571
    }
  ],
  "warnings": []
}

Parameters

Parameter Type Default Description
text string "" Text
path string null Absolute path to a file with the text or a link ests://datasets/... instead of text
reference string null Reference text; not given - the frequency dictionary
reference_path string null Absolute path to a file with the reference text or a link ests://datasets/... instead of reference; a query link makes all its texts one reference
measure string "log_likelihood" Sorting measure: log_likelihood, log_ratio, chi2, diff, bic, ell, odds_ratio; log_likelihood - significance of the difference, log_ratio - how many times more frequent the word is
positive boolean true Words more frequent in the text; false - more frequent in the reference
min_freq integer 2 Least frequency of a word where it is more frequent
n integer 1 Length of N-grams: 1 - words, 2-3 - phrases of adjacent words within a sentence; above 1 - only with a reference text
lemmatize boolean true Compare lemmas; against the dictionary lemmas are always compared
top_n integer 20 Number of words in the response, up to 200

Result

Field Type Description
n_words integer Number of words of the text compared with the reference
reference string The reference
measure string The sorting measure and how to read its values
keywords array[object] Words by descending measure with the fields below
warnings array[string] The text or the reference is not in Spanish, there are no keywords, keywords with p_value of 0.05 or more: their difference from the reference can be chance
Word field Description
word Word or lemma, with n above 1 a phrase of n words separated by spaces
freq_target, freq_reference Frequency in the text and in the reference
ipm_target, ipm_reference The same per million words
g2 Log-likelihood G²: significance of the difference, with a minus sign - the word is more frequent in the reference
p_value p-value of G²
log_ratio Log Ratio: binary logarithm of the frequency ratio, the effect size; 1 - the word is twice as frequent in the text
score Value of the sorting measure