Corpus Search

Concordance - shows the search word or phrase in context.

Changed on

The concordance allows complex criteria for searching the corpus. The queries can combine any data, metadata and annotations found in the corpus.

To make basic concordance its enough to use just corpname and q parameters.

get/search/concordance

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.

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.

concordance_query[queryselector]'iquery' | 'cqlrow' | 'lemmarow' | 'charrow' | 'wordrow' | 'phraserow'

The query type. You can send it directly or via the json parameter, the results are the same.

concordance_query[iquery]string

Only works when queryselector is set to iqueryrow. Type a word or phrase.

These special wildcards are supported .

Use the asterisk (*) for any number of unspecified characters. Use a question mark (?) for exactly one unspecified character. Use the pipe (|) to include more than one word or phrase. Use two hyphens (--) to find a word which is hyphenated, non-hyphenated or spelt as two separate words.

concordance_query[cql]string

Only works when queryselector is set to cqlrow. Type the query using the cql query language.

concordance_query[lemma]string

Only works when queryselector is set to lemmarow. Type the lemma. Regex is supported.

concordance_query[char]string

Only works when queryselector is set to charrow. Type the characters that the tokens should contain. Regex is supported.

concordance_query[word]string

Only works when queryselector is set to wordrow. Type the word form. Regex is supported.

concordance_query[phrase]string

Only works when queryselector is set to phraserow. Type the phrase. Regex is supported.

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.

lpos'-n' | '-v' | '-j' | '-a' | '-d' | '-i'

The part of speech of the lemma. The concrete values depend on the corpus. If the corpus contains the lempos attribute and lpos is empty, the result defaults to the most frequent part of speech of the lemma.

default_attrstring

The attribute applied to tokens in the query which do not have an attribute specified explicitly as part of the query.

attrsstring

A list of comma-delimited attributes that are returned together with each token. Other examples are:word, lc, lemma, tag etc..

refsstring
Example:=bncdoc.alltyp

The text type (metadata) for which statistics should be calculated from the concordance. The default is bncdoc.alltyp (all available text types are included). Text types (attributes and there values) differ between corpora). You can find them in the response of corpus_info method in freqttattrs or subcorpattrs keys. Not all of them have attributes to show.

attr_allpos'kw' | 'all'

Determines which tokens will be returned with additional attributes defined in attrs. kw will add the attributes to the KWIC only. all will return them with all tokens.

viewmode'sen' | 'kwic'

Switches between sentence view and the KWIC view. sen returns complete sentences without trimming them. kwic returns the KWIC view with the query in the centre and some context left and right.

cup_hl'q' | 'e' | 'c' | 'b'

Only used with error-annotated corpora. It determines what should be highlighted. It is set to 'q' for corpora without error annotation. Meaning of individual options:

  • q -> to higlight query result.

  • e -> to higlight errors.

  • c -> to highlight corrections.

  • b -> to highlight both erros and corrections.

Example of such a corpus can be preloaded/enwiki_error_sample_sentences.

structsstring
Example:s,g

A list of comma-delimited structures (=structure tags) that should be included in the result.

frompinteger
Example:1

The number of the page that should be returned.

pagesizeinteger
Example:20

The number of lines in the concordance.

kwicleftctxstring
Example:100#

The size of the left context in KWIC view. Number of tokens.

kwicrightctxstring
Example:100#

The size of the right context in KWIC view. Number of tokens.

errcorr_switch'corr' | 'err'

(Only for error-annotated corpora.) Determines what should be highlighted. Corr means correction and err means error. An example of such a corpus is preloaded/enwiki_error_sample_sentences.

cup_err_code'.*' | 'lexicosemantic' | 'punct' | 'spelling' | 'style' | 'typographical' | 'unclassified'

(Only for error-annotated corpora). Determines which error type to higlight. An example of such a corpus is preloaded/enwiki_error_sample_sentences.

cup_errstring

(Only for error-annotated corpora.) An error token to search.

cup_corrstring

(Only for error-annotated corpora.) A correction token to search.

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"
    }
  ]
}
asyn0 | 1

Switches the asynchronous processing on/off. ON = partial results are returned as soon as the first page is filled with results. OFF = results are returned only after the search is completed. Normally, ON is used in the web interface and OFF when using the API.

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

frompinteger
concsizeinteger
concordance_size_limitinteger
Sort_idxstring[]
righttoleftboolean
Aligned_rtlstring[]
numofcollsinteger
finishedinteger
fullsizeinteger
relsizenumber
qstring[]
portinteger
gdex_scoresstring[]
api_versionstring
manatee_versionstring

Example response

{
  "Lines": [
    {
      "toknum": 10336,
      "hitlen": 1,
      "Refs": [
        "Written books and periodicals"
      ],
      "Tbl_refs": [
        "Written books and periodicals"
      ],
      "Left": [
        {
          "strc": "<s>"
        }
      ],
      "Kwic": [
        {
          "str": "dogs",
          "coll": 1
        }
      ],
      "Right": [
        {
          "str": "</s>"
        }
      ],
      "linegroup": "_"
    }
  ],
  "fromp": 1,
  "concsize": 12087,
  "concordance_size_limit": 10000,
  "finished": 1,
  "fullsize": 12087,
  "relsize": 107.59,
  "q": [
    "q[lc=\\\"dog\\\" | lemma_lc=\\\"dog\\\"]"
  ],
  "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"
  },
  "sc_strcts": [
    [
      "bncdoc"
    ]
  ],
  "api_version": "5.63.1",
  "manatee_version": "2.36.7-SkE-2.221",
  "request": {
    "concordance_query": [
      {
        "queryselector": "iqueryrow",
        "iquery": "dog"
      }
    ],
    "corpname": "preloaded/bnc2_tt21",
    "kwicleftctx": "100#",
    "structs": "s,g",
    "viewmode": "sen",
    "attr_allpos": "all",
    "fromp": "1",
    "json": "{\\\"concordance_query\\\":[{\\\"queryselector\\\":\\\"iqueryrow\\\",\\\"iquery\\\":\\\"dog\\\"}]}",
    "kwicrightctx": "100#",
    "refs": "=bncdoc.alltyp",
    "cup_hl": "q",
    "attrs": "word",
    "pagesize": "20"
  }
}

Changes

    • breaking

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

    • breaking

      for the query request parameter attr_allpos, default value all was added

    • info

      added the new enum value all to the query request parameter attr_allpos

    • info

      added the new enum value kw to the query request parameter attr_allpos