Treebank StudioDocumentation

PaCQL reference

This page complements the tutorial and the case studies: it lists everything PaCQL can do, including what is new since the 2015 version of Treebank Studio.

Structure of a query

A query has sections separated by blank lines. The first section lists relations that must hold; its first label is the anchor, and there is one result per anchor. Labels are regular expressions matched against whole labels (an index such as -1 is ignored, so NP-SBJ also matches NP-SBJ-1). The same label written twice means the same node. In the IPCHG, part-of-speech labels carry morphology after ^ (N^A^SG, VBPI^3^SG); write such a label as it is, since a ^ after a character is taken literally. N.* matches N^A^SG, while N alone does not.

IP-(MAT|SUB) idoms NP-SBJ
NP-SBJ idoms .*-D

A line starting with # is a comment and is ignored by the search. It can stand anywhere, also between the lines of a section.

# subjects in the dative
IP-(MAT|SUB) idoms NP-SBJ
NP-SBJ idoms .*-D

Relations

A idoms BA immediately dominates B
A idomsfirst B… and B is the first child
A idomslast B… and B is the last child
A idomsonly B… and B is the only child
A idomsnumber 2 B… and B is the 2nd child (counting from 1; punctuation and codes are not counted, traces are), as CorpusSearch's iDomsNumber. IP-MAT idomsnumber 2 VBPI finds verb-second clauses
A doms BA dominates B at any depth
A idomsmod NP.*|CONJP.* BA dominates B, and every node in between has one of the given labels (or there is none in between), as CorpusSearch's iDomsMod. NP-SBJ idomsmod NP.*|CONJP.* PRO also finds a pronoun in a later conjunct of the subject
A sprec BA and B are sisters and A comes first
A hassister BA and B are sisters, in either order
A precedes BA ends before B begins
A iprecedes BB begins right after A ends (as CorpusSearch's iPrecedes); punctuation and codes in between are skipped. A and B need not be sisters: N iprecedes VBDI also finds a subject noun before the verb
A sameindex BA and B have the same index (e.g. a trace and its antecedent)
A !idoms BNegation: there is no B that A immediately dominates. Any relation between two nodes can be negated (not the conditions below). A must also appear in a positive relation.
IP-MAT idoms VBPI
IP-MAT !idoms NP-SBJ

Punctuation and codes

As in CorpusSearch, punctuation and CODE nodes are skipped by idomsfirst, idomslast and idomsonly: a subject followed only by the final period counts as last. Broad patterns such as .* do not match them either. To find them, name them: , or \. (a plain . is a regular expression for any one character, so it also matches labels such as C and P). Which labels count as punctuation is set per corpus.

Conditions on a node

A domswords 2A contains exactly 2 words (also domswords> and domswords<). A domswords 0 finds empty nodes such as traces ((NP-OB1 *T*-1)); A domswords> 0 keeps only nodes with overt words
A idomstotal 3A has exactly 3 children (also idomstotal> and idomstotal<), as CorpusSearch's iDomsTotal: punctuation and codes are not counted, traces and words are
A haslabel NP-OB1A's label matches
A idomsleaf orðA's word matches (the whole word)
A idomslemma takaA's lemma matches (the whole lemma; taka.* also finds takast)

Either/or

An either: section followed by one or more or: sections gives alternatives: a result must match the main section and at least one alternative. The lines within one alternative must all hold. A name used in the main section is the same node in every alternative; a name used only inside one alternative belongs to that alternative. Several groups (each starting with either:) must all hold. Which alternative matched is not shown in the output; to see it, use a coding variable instead (intro:that, intro:wh), which is the same search with a column.

clause idoms IP-SUB.*
IP-SUB.* idoms MD.*

either:
C domswords> 0

or:
clause idoms W.*

Alternatives of a single label do not need this: NP-OB1|NP-OB2 already means either label.

Searching only some texts

A where: section restricts the search to texts (or, in corpora with metadata for single trees, such as the letters of PCEEC, to trees) whose attribute matches a pattern. The pattern must match the whole value; ! in front negates it, and several lines must all hold. The summary then counts only the searched texts and trees.

IP-MAT idoms NP-SBJ
NP-SBJ idoms .*-D

where:
text century 15|16
text genre !rel

A child other than X

A !idoms X means that A has no child X. For "A has some child that is not X" (CorpusSearch's ! inside an argument), use a pattern that excludes X: label patterns are regular expressions, and (?!…) excludes what follows it.

IP-MAT idoms (?!NP-SBJ|PP).*

This finds main clauses with at least one child that is neither a subject nor a PP. A lookahead only checks how the label begins; the .* after it matches the rest. So (?!NP-SBJ) excludes every label starting with NP-SBJ (also NP-SBJ-1, NP-SBJ-RSP), and (?!N) excludes every label starting with N (N, NP, NPR, NEG, …). To exclude exactly one label, end the lookahead with $ (end of the label):

(?!N-N$).*any label except exactly N-N (NS-N, NPR-N remain)
(?!(N-N|D-N)$).*any label except exactly N-N and D-N
(?!N-.*).*any label except a singular common noun in any case (IcePaHC N-N, N-A, …)
(?!N(\^|$)).*any label except N, also with IPCHG morphology (N^A^SG); NPR remains

Two nodes with the same label

To use two different nodes with the same label, give them a number prefix, as in CorpusSearch. [1]NP.* and [2]NP.* are different nodes, both matched by NP.*; refer to them by these names elsewhere in the query.

[1]NP.* hassister [2]NP.*

The other way round: different names are always different nodes, also when their labels overlap. IP-.* idoms NP-SBJ together with IP-MAT idoms NP-OB1 asks for two clauses, an IP-.* and a separate IP-MAT; to talk about one clause, write its name the same way in every line. Likewise NP-SBJ idoms PRO-.* and NP-SBJ idomsfirst .* need two different children.

Coding

A section headed variable:value adds conditions; each result gets the first value whose conditions hold. A value with no lines under it is the "otherwise" case: it catches every result no earlier value matched. Without it, results that match no value are left out. The first variable with the values 0 and 1 is shown in the summary.

define:
object NP-OB[12]

IP-(MAT|SUB) idoms MD[PD][IS]

ov:1
MD[PD][IS] sprec object
object sprec VB

ov:0
MD[PD][IS] sprec VB
VB sprec object

np:pro
object idomsonly PRO-.*

np:other

Every define: section applies, and a definition replaces whole names only.

Output columns

IP-(MAT|SUB) idoms NP-SBJ

meta:
node label IP-(MAT|SUB)
node nodewords NP-SBJ
node nodestring NP-SBJ
tree treewords
text year
text genre

A node line can name several nodes (node label NP-SBJ VBDI), or the same kind can be given on several lines; the columns are label, label2, … in that order. text takes any attribute of the corpus (see below). Some corpora also have attributes of single trees, such as the fitt and line of the Heliand or the Bible chapter and verse in FarPaHC; text gives the tree's own value where it has one. Columns come out in the order written.

What counts as a word

Punctuation, CODE, empty categories (*T*-1, *pro*, 0) and markup are not words. A word split by the annotation (mál$ $inu) counts once. This applies to domswords, nodewords, treewords, the text column and all word counts and rates.

Attributes per corpus

Use these after text in the meta: section, e.g. text century. Attributes marked per sentence can differ from sentence to sentence within a text.

Loading…

Citing the corpora

Please cite the corpus in work that uses results from it. The search page shows the citation of the selected corpus (Cite this corpus) in APA and BibTeX format.

Loading…

Sharing and recent queries

Copy link (next to Run) copies a link that opens the current query on the current corpus, for sending to colleagues or putting in teaching materials. The Recent menu lists your last 20 queries that finished, with their corpus and number of results; it is kept in your own browser only.

Changes since the 2015 version