Corpus Search

Calculates frequencies of words, lemmas… in the concordance.

Changed on

The frequency of any [positional attribute] (https://www.sketchengine.eu/my_keywords/positional-attribute/) such as word forms, lemmas, tags can be counted with this method. Structure attributes (metadata/text types) can also be counted.

get/search/freqml

Request

  • The document declares no server URL.
  • Auth: HTTP basic

Query parameters

corpnamestring required

Corpus name. To query your own corpus (e.g. username john, corpus mycorpus), use value user/john/mycorpus.

ml1attrstring required
Example:word

Used to count the frequency of positional attributes attributes or structure attributes (metadata/text types) of any token in the concordance.\n\n A maximum of 6 attributes is allowed (e.g. ml2attr, ml3attr). At least one attribute is required.

ml1ctxstring required
Example:-1<0

Position of the selected attribute in the concordance. Minus means left context (-1<0). Plus means right context (6>0). At least one attribute is required, the others are optional. Every attribute (ml1attr, ml2attr. etc.) needs it's own context position (e.g. if 3 attributes are selected three context position needs to be set ml1ctx, ml2ctx, ml3ctx).

Positions can be referenced as follows:

integer number - where 0 is the first token in KWIC, -1 the rightmost token in the left context etc.

1:x - where x is one of the corpus structures (e.g. “doc” or “s” if the corpus has the particular markup). Its meaning is the first token in the structure, except when it is the right boundary of a range - then it is the last token in the structure. Also, other numbers can be used, e.g. -2:x, 3:x, etc. (-1 is the same as 1 with meaning “structure containing KWIC”)

a<0 - where a stands for a position reference as described in the first two points with meaning 'a positions before/after the firs KWIC position' (so this is equivalent to a)

a>0 - where a stands for the same position reference with meaning 'positions before/after the last KWIC position'

in the previous two points, if 0 is substituted with a natural number k, it means 'before/after k-th collocation' instead of 'before/after KWIC'. Collocations are special token groups in the context, that can be added using positive filters (see below).

Ranges can be referenced as a~b where a, b stand for token identifiers as above. Examples of positions and ranges:

-1<0 - rightmost token in the left context

3>0 - third token in right context

0>0 - last token in KWIC

0<0 - first token in KWIC

0<0~0>0 - range of KWIC

-1<0~1>0 - range of KWIC with one token from the left context and one from the right context

1:s - first token in the sentence containing KWIC (or its first token)

1:s>0 - first token in the sentence containing KWIC (or its last token)

0<1 - first token of the first-added collocation.

Examples:

sword/ 1>0~3>0

sword/ 1>0~3>0

slemma/ 0<0~0>0

sword/i -1

sword/ 0 word/ir -1<0 tag/r -2<0

ml2attrstring
Example:word

Used to count the frequency of positional attributes attributes. Just like ml1attr but optional.

ml2ctxstring
Example:-1<0

Position of the selected attribute in the concordance. Minus means left context (-1<0). Plus means right context (6>0). Just like ml1ctx but optional.

ml3attrstring
Example:word

Used to count the frequency of positional attributes attributes. Just like ml1attr but optional.

ml3ctxstring
Example:-1<0

Position of the selected attribute in the concordance. Minus means left context (-1<0). Plus means right context (6>0). Just like ml1ctx but optional.

ml4attrstring
Example:word

Used to count the frequency of positional attributes attributes. Just like ml1attr but optional.

ml4ctxstring
Example:-1<0

Position of the selected attribute in the concordance. Minus means left context (-1<0). Plus means right context (6>0). Just like ml1ctx but optional.

ml5attrstring
Example:word

Used to count the frequency of positional attributes attributes. Just like ml1attr but optional.

ml5ctxstring
Example:-1<0

Position of the selected attribute in the concordance. Minus means left context (-1<0). Plus means right context (6>0). Just like ml1ctx but optional.

ml6attrstring
Example:word

Used to count the frequency of positional attributes attributes. Just like ml1attr but optional.

ml6ctxstring
Example:-1<0

Position of the selected attribute in the concordance. Minus means left context (-1<0). Plus means right context (6>0). Just like ml1ctx but optional.

qstring

The CQL query. Regexes are supported for lemma, phrase and word types. The iquery supports simplified wildcards (see concordance_query[iquery]). If you decide to use the concordance_query in a json parameter, you do not have to use this parameter.

usesubcorpstring

The name of the subcorpus. The default value empty string refers to the entire corpus. An example for preloaded/bnc2_tt21 can be Written Academic or 1960-1974.

fmaxitemsinteger

The number of items in one response.

fpageinteger

The number of the response batch (page). The number of items in each batch is specified by fmaxitems.

group1 | 0

If there are more attributes (e.g. m1attr, m2attr), the results can be grouped by the first column/attribute.

showpoc1 | 0

Includes the percentage of the concordance in the result.

showreltt1 | 0

Includes relative in text types value in the result.

showrel1 | 0

Includes the relative frequency in the result.

freqlevel1 | 2 | 3 | 4 | 5 | 6

The number of attributes for which the frequencies should be counted.

jsonobject

An optinal way of wraping parameters. It is possible to send all parametres via this parameter only.

The most frequent uses are:

queryselector: To select the query type. Supported options are: cqlrow, iqueryrow, lemmarow, charrow, phraserow, wordrow. For more information see concordance_query parameters.

iquery: Use with iqueryrow.

cql: Use with cqlrow.

lemma: Use with lemmarow.

lpos: The part of speech of the lemma.

qmcase: Sets the attribute to its lowercased version, i.e. the data are extracted from a lowercased version of the corpus. It used for case insensitive analysis. 1 = case sensitive), 0 = lowercased corpus/case insensitive).

char: Use with charrow.

phrase: Use with phraserow.

word: Use with wordrow

name:

pnfilter:

inclkwic:

filfpos:

filtpos:

desc:

q:

{
  "concordance_query": [
    {
      "queryselector": "iqueryrow",
      "iquery": "test"
    }
  ]
}
freq_sort'frq' | 'rel'

The identifier of the sorted column. Use frq (default) to sort by frequency.

format'json' | 'xml' | 'csv' | 'tsv' | 'txt' | 'xls'

The format of the output. Empty value is interpreted as JSON. Not every endpoint supports all formats.

Response

OK

fcritstring
paginginteger
concsizeinteger
fullsizeinteger
numofcollsinteger
hitleninteger
wllimitinteger
lastpageinteger
mlboolean
api_versionstring
manatee_versionstring

Example response

{
  "fcrit": "fcrit=word%2Fe+-1%3C0+lemma%2Fe+-1%3C0",
  "FCrit": [
    {
      "fcrit": "word/e -1<0 lemma/e -1<0"
    }
  ],
  "Blocks": [
    {
      "Head": [
        {
          "n": "word",
          "id": "word/e"
        }
      ],
      "total": 1700,
      "totalfrq": 12087,
      "Items": [
        {
          "Word": [
            {
              "n": "the"
            }
          ],
          "frq": 2621,
          "fbar": 301,
          "pfilter": ";q=p-1%3C0+-1%3C0+0+%5Bword%3D%22the%22%5D;q=p-1%3C0+-1%3C0+0+%5Blemma%3D%22the%22%5D",
          "pfilter_list": [
            [
              "p-1<0 -1<0 0 [word=\"the\"]"
            ]
          ],
          "poc": 21.684454372466284,
          "fpm": 23.329771292938062
        }
      ]
    }
  ],
  "paging": 1,
  "concsize": 12087,
  "fullsize": 14297,
  "Desc": [
    {
      "op": "Query",
      "arg": "[lc=\"dog\" | lemma_lc=\"dog\"]",
      "nicearg": "dog",
      "rel": 107.59,
      "size": 12087,
      "tourl": "q=q%5Blc%3D%22dog%22+%7C+lemma_lc%3D%22dog%22%5D"
    }
  ],
  "hitlen": 1,
  "wllimit": 1000,
  "ml": true,
  "api_version": "5.63.12",
  "manatee_version": "2.36.7-SkE-2.223.6",
  "request": {
    "concordance_query": [
      {
        "queryselector": "iqueryrow",
        "iquery": "dog"
      }
    ],
    "format": "json",
    "fpage": "1",
    "showpoc": "1",
    "freqlevel": "2",
    "group": "1",
    "freq_sort": "freq",
    "ml1ctx": "-1<0",
    "showreltt": "1",
    "ml2attr": "lemma",
    "ml1attr": "word",
    "ml2ctx": "-1<0",
    "fmaxitems": "5000",
    "corpname": "preloaded/bnc2_tt21",
    "showrel": "1"
  }
}

Changes

    • breaking

      the query request parameter freq_sort was restricted to a list of enum values

    • breaking

      for the query request parameter freq_sort, default value was changed from freq to frq

    • info

      added the new optional query request parameter ml2attr

    • info

      added the new optional query request parameter ml2ctx

    • info

      added the new optional query request parameter ml3attr

    • info

      added the new optional query request parameter ml3ctx

    • info

      added the new optional query request parameter ml4attr

    • info

      added the new optional query request parameter ml4ctx

    • info

      added the new optional query request parameter ml5attr

    • info

      added the new optional query request parameter ml5ctx

    • info

      added the new optional query request parameter ml6attr

    • info

      added the new optional query request parameter ml6ctx

    • info

      added the new enum value frq to the query request parameter freq_sort

    • info

      added the new enum value rel to the query request parameter freq_sort