Skip to content

Collocations

collocations(text="", path=null, window=5, measure="logdice", min_freq=2, node=null, side=null, lemmatize=true, top_n=20)

Collocations - pairs of words that occur together more often than by chance: set phrases, terms, the company of a word (node). A pair is ordered: the right word stands at most window words after the left one. With lemmatize lemmas of esMorph in the context of the sentence are compared: «estado de ánimo» and «estados de ánimo» are one pair, and the word node takes that of its lemmas which occurs in the text («vino» is the wine in a text about wine and venir in a text where someone «vino a casa»). The definitions and formulas of the measures are on the esTS page Collocations.

The pair frequency freq_pair is the number of position pairs where the right word stands within the window after the left one. A word repeated within the window gives several pairs, so freq_pair can exceed the frequency of a word, and such a pair is a repetition rather than a set phrase. The texts of a query link follow one another, and at the junction of two texts pairs are made of the words of both: the company of a word within one text is more exact by a link to it.

Errors - those common to the tools, a text without words, a node that is not one word and side without node.

In Góngora's sonnet «Mientras por competir con tu cabello» most of the pairs gather around «cuello», the word that closes the quatrains and opens the enumeration «goza cuello, cabello, labio y frente»:

{
  "name": "collocations",
  "arguments": {
    "text": "Mientras por competir con tu cabello,\noro bruñido al sol relumbra en vano;\nmientras con menosprecio en medio el llano\nmira tu blanca frente el lilio bello;\n\nmientras a cada labio, por cogello,\nsiguen más ojos que al clavel temprano,\ny mientras triunfa con desdén lozano\nde el luciente cristal tu gentil cuello,\n\ngoza cuello, cabello, labio y frente,\nantes que lo que fue en tu edad dorada\noro, lilio, clavel, cristal luciente,\n\nno sólo en plata o vïola troncada\nse vuelva, mas tú y ello juntamente\nen tierra, en humo, en polvo, en sombra, en nada.",
    "top_n": 5
  }
}
{
  "n_words": 97,
  "measure": "logdice: logDice (Rychlý 2008): the higher, the stronger the pair, independent of the size of the text; a pair that always stands side by side gets 11.7, the maximum 14 goes to a pair found at every distance in the window, below zero is a weak link",
  "collocations": [
    {
      "left": "gentil",
      "right": "cuello",
      "freq_left": 1,
      "freq_right": 2,
      "freq_pair": 2,
      "score": 12.09
    },
    {
      "left": "antes",
      "right": "que",
      "freq_left": 1,
      "freq_right": 3,
      "freq_pair": 2,
      "score": 11.68
    },
    {
      "left": "cristal",
      "right": "cuello",
      "freq_left": 2,
      "freq_right": 2,
      "freq_pair": 2,
      "score": 11.68
    },
    {
      "left": "cuello",
      "right": "cabello",
      "freq_left": 2,
      "freq_right": 2,
      "freq_pair": 2,
      "score": 11.68
    },
    {
      "left": "cuello",
      "right": "labio",
      "freq_left": 2,
      "freq_right": 2,
      "freq_pair": 2,
      "score": 11.68
    }
  ],
  "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
window integer 5 Greatest distance between the words of a pair, from 1 to 10; 1 - adjacent words
measure string "logdice" Association measure: logdice, mi, mi3, t_score, dice, log_likelihood, npmi, min_sensitivity; logdice does not depend on the text size, mi overrates rare pairs, mi3 and t_score favor frequent ones
min_freq integer 2 Least pair frequency freq_pair
node string null Word whose company is needed; not given - all pairs
side string null Side of the company of node: left - words before it, right - after it; not given - both sides
lemmatize boolean true Compare lemmas
top_n integer 20 Number of pairs in the response, up to 200

Result

Field Type Description
n_words integer Number of words in the text
measure string The measure and how to read its values
collocations array[object] Pairs by descending measure: the left word left, the right one right, their frequencies freq_left and freq_right, the pair frequency freq_pair and the value of the measure score
warnings array[string] The text is not in Spanish, the node word is not in the text, there are no pairs with such a frequency