AplikaceAplikace
Nastavení

This is an old revision of the document!


Query language

Query languages are used to query database systems in information technologies; every system uses a query language with precisely defined syntax.

For work with language corpora, the query language is used for inputting queries into corpus managers, concordance programs etc. Even here the individual languages usually differ, despite the fact that they are all based on regular expressions, which they then expand on and adapt to fit their individual needs.

Query language used in ČNK

The query language used in the ČNK corpora operating on the corpus manager Manatee is called CQL (corpus query language) and is in fact a modified version of the original CQL created for the corpus manager CWB. Its cornerstone is a query for a single position (word) in the corpus:

[attribute="value"]

where the attribute is positional (word, lemma, tag etc.), the value is the search term itself, or a pattern specified with the help of regular expressions. The query can also include limitations on structural attributes (sentence, doc, opus), where it is also possible to specify other values (e.g. for opuses it is the publication year, genre, author etc.). Limitations for structural attributes are, unlike those for positional attributes, written in in pointed brackets (e.g. <s id="10"/>); see a more detailed and complete description of the CQL . CQL is a formal language which has a precise (and finite) definition. CQL supports some elements of traditional regular languages 1), but it also supports expanded, specifically corpus-related commands such as within, meet, union or containing, which work with the structure of the corpus.

A simultaneous query for more than one position (i.e. word sequence or wider context) is formed simply by the concatenation of the individual queries for each successive position. E.g. the query [lemma="have"][][lemma="heart"] searches for all occurrences of the lemmas have and heart, in between which there is one position (i.e. word or punctuation).

The following example of the Manatee corpus manager's query language will find all instances of the construction type „neither woman nor man“, „neither man nor beast“ etc. occurring in the corpus within one sentence (structure<s/>, see structural attributes):

[lemma="neither"] [tag="N.*"] []{0,1} [lemma="nor"] [tag="N.*"] within <s/>

Každou pozici v sekvenci zde zastupuje jedna hranatá závorka, případně doplněná kvantifikátorem ve složených závorkách. První pozici vyhovují všechna slova lemmatizovaná jako “bez”, druhé pozici vyhovují všechna substantiva (tedy slovní tvary opatřené morfologikých tagem začínajícím písmenem “N” za nímž následuje libovolná sekvence libovolných znaků), třetí pozici vyhovuje libovolné jedno (či žádné) slovo, čtvrtá pozice je opět omezena lemmatem “bez”, pátá opět pouze morfologickou značkou substantiva. Direktiva “within” omezuje celý dotaz na rámec jednoho strukturního atributu typu “<s/>” (tedy jedné věty). Pro tento účel lze využít též direktivu containing.

Při práci s korpusovým manažerem je vhodné znát použitý dotazovací jazyk a jeho možnosti. Ačkoli některá uživatelská rozhraní umožňují zadávat dotaz i bez znalosti konkrétního dotazovacího jazyka, bývají v tomto případě možnosti práce s korpusem omezeny, což je dáno snahou o uživatelský komfort a srozumitelnost rozhraní, která je vždy na úkor plného využití bohatých kombinací možností vyhledávání.

1)
E.g. quantificators, round brackets and logical operators.