API Reading a concordance - czcorpus/kontext GitHub Wiki

HTTP API / Reading a concordance

To view a concordance, one must have a concordance ID (see conc_persistence_op_id argument in the previous section).

Request

  • URL: /view
  • HTTP Method: GET

URL query arguments

name required / default description
q :eight_spoked_asterisk: concordance persistence ID; the value must have a ~ prefix to distinct fully stored queries from legacy/NoSkE ones
format :eight_spoked_asterisk: json|xml
viewmode kwic kwic|sen|align (align applies only for parallel corpora)
pagesize 40 a positive number specifying size of the resulting page
attrs undefined multi-value attribute
attr_vmode visible-kwic visible-all|visible-kwic|visible-multiline|mouseover - this is useful mostly for GUI clients
base_viewattr word the main attribute the flow of text will be based on
refs undefined A multi-value argument specifying additional metadata attached to each row. Please note that for historical reasons, the values must have the = prefix, which is encoded in URLs as %3D. So e.g. adding doc.author requires you to write %3Ddoc.author. Multiple values can be obtained by repeating the refs key in url with different values (....&refs=%3Ddoc.author&refs=%3Ddoc.title&...)
structs undefined a list (possibly empty) of structural attributes to be shown

Response

(only a subset of the most important entries is shown below)

{
  "kwiclen": 2,
  "Lines": [
    {
      "Left": [],  // see the following section for the description
      "Kwic": [],  // ditto
      "Right": []  // ditto
    },
    {
      "Left": ["..."],
      "Kwic": ["..."],
      "Right": ["..."]
    }
  ],
  "conc_persistence_op_id": "RSiw4GIgW08s",
  "concsize": 115,
  "result_arf": 51.31,
  "result_relative_freq": 0.94
}

The format of Left, Kwic, Right entries is as follows:

[
  {
    "str": "setměním", 
    "class": "", 
    "tail_posattrs": ["setmění", "NNNS7-----A----"]
  }
  // other items/positions
]
attribute description
str value of the token (or structure - e.g. <p>)
class type of the value - empty string (normal token), col0 coll (for KWIC), strc (structure)
tail_posattrs additional positional attributes for the position (e.g. tag, lemma,...) - based on attrs, structattrs and attr_vmode