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 empty lines (a header such as none: right under a line of another section is an error that says so). The first section lists relations that must hold; the node it names first is the anchor, and there is one result per anchor. Another node of the first section can be made the anchor by writing @ before its name (choosing the anchor). The names in a query are patterns: regular expressions matched against whole labels (an index such as -1 is ignored, so NP-SBJ also matches NP-SBJ-1). In a regular expression * repeats the character before it, so CorpusSearch's NP* is written NP.* here; NP* would be N followed by any number of P. A query with such a * gets a notice saying what it matched, or an error if it matches no label. The same name written twice means the same node (for two nodes with one pattern, see [1] and [2]). 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

Seeing how a query is read. While you type, the query box shows which names are nodes: put the cursor on a name and every place where the same node is named gets a light shade, and a name that is no node (the second name of a negated line that no other line names) is grey. Pointing at a name tells you which node it is (node 1 is the anchor) or that it is only a pattern. The button How it is read under the box shows the whole query in plain words, line by line, with the nodes numbered.

Each line is one of four kinds: a two-node relation (A idoms B), a one-node relation that tests one node (A domswords 2), an exists line that finds a node anywhere in the tree (X wordexists), or a word lookup that finds a node by the words of the text ('í gær' stringexists, góður near 2 maður).

Other sections are headed by a word and a colon: coding values (ov:1), logic variables (?x:1) and filters (?!:), either:/or:, none:, where:, meta: and define:. none: blocks must come right after the first section; the others may come in any order, but queries are easiest to read in this one:

  1. define: (shortcuts, used anywhere below)
  2. the first section (the main section)
  3. none:
  4. either:/or:
  5. coding values
  6. logic variables (?x:1) and filters (?!:)
  7. where:
  8. meta:

What each section can see of the others is summed up in how the sections fit together.

A first section can also consist of one-node relations alone. Each of them then finds its node anywhere in the tree, as an exists line would, and the first line's node is the anchor. All nouns with the lemma maður (6,557 in IcePaHC 2024.03):

N.* idomslemma maður

One-node relations on different names mean that both occur in the same tree. Nouns with maður in a tree that also has an adjective with the lemma góður (355 nouns in 310 trees):

N.* idomslemma maður
ADJ.* idomslemma góður

Once the first section has a two-node relation, every name in a one-node relation must also appear in a two-node relation, so that a mistyped name is reported rather than searched for elsewhere in the tree.

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

Two-node relations

Each relation name below links to its full definition on the Relations page, with notes on punctuation, traces and negation and a comparison with CorpusSearch.

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 domslowest BA dominates B, and no node between them matches A's pattern: only the lowest A above each B. See only the lowest node
A domslocal IP-SUB.* BA dominates B, and no node in between has one of the given labels: doms that does not look into subordinate clauses (or whatever the labels name). IP-MAT domslocal IP-SUB.* NP-OB1 is a main clause with an object of its own
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 isprec BA and B are sisters and B begins right after A ends: sprec and iprecedes together, the same as writing both lines. Punctuation and codes in between are skipped, as for iprecedes
A sameindex BA and B have the same index: on the label (WNP-1) or on a trace right under the node ((NP-SBJ *T*-1)); see traces
A idomsviatrace ICH BA immediately dominates a trace of this kind with an index ((CP-REL *ICH*-2)), and B is a child of the node with that index (the antecedent, CP-REL-2), as CorpusSearch's iDomsViaTrace. The kind of trace is written as for idomsempty: ICH, *ICH*, T|ICH. See traces
A ccommands BA c-commands B: neither dominates the other, and the first node above A that branches (has two or more children) dominates B, as defined for CorpusSearch's cCommands. Sisters c-command each other and everything inside each other. Punctuation, codes and traces count as children when deciding whether a node branches (as in CorpusSearch). More
A !idoms BNegation: there is no B that A immediately dominates. Any two-node relation can be negated, and so can the one-node relations below. A must also appear in a positive relation. If B is named nowhere else, it is a new node, looked for in the whole tree, and other than the nodes the query names (more). To rule out a structure of several lines, use none:; for "a B that is not X", !X
IP-MAT idoms VBPI
IP-MAT !idoms NP-SBJ

ccommands

In this tree (the one in CorpusSearch's manual):

       A
      / \
     B   C
    / \   \
   D   E   F

B c-commands C and F; C and F c-command B, D and E; D and E c-command only each other; A, the root, c-commands nothing. F does not c-command its mother C (C dominates it, and C does not branch). In the same way, the noun in an NP with only a noun does not c-command its own NP:

   NP
   |
   N
   |
  man

CorpusSearch's program does find these non-branching nodes above a node, although its manual's definition excludes them; Treebank Studio follows the definition. For the same reason as everywhere else, the patterns match labels only (CorpusSearch's also match words), and an unlabeled outer bracket around several constituents counts as a branching node.

NP-SBJ ccommands NP-OB1
NEG ccommands Q.*
[1]NP.* ccommands [2]NP.*
[2]NP.* !ccommands [1]NP.*

The last query finds noun phrases that c-command another one that does not c-command them back.

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.

One-node relations

Here too, each relation name links to its full definition on the Relations page.

These test one node: its label, its word or lemma, its empty category, how many words or children it has. What follows the relation name is a value, not a second 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 domswordslocal IP-SUB.* 7A has exactly 7 words outside the nodes below it with the given labels (also domswordslocal> and domswordslocal<): the length of a clause without its subordinate clauses
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 hasindexA's label has an index (NP-SBJ-1, IP-MAT=4); nothing follows the relation. CP-REL !hasindex is a CP-REL without one, which is what CorpusSearch's CP-REL matches
A idomsleaf orðA's word matches (the whole word); in single quotes, 'orð', case is ignored (see upper and lower case)
A idomsempty *T*A's child is this empty category, written as in the corpus (no escaping): *T* also finds *T*-3; *T*-3 only that one; several with |: *T*|*ICH*. The stars may be left out: T, T-3, T|ICH. See traces
A idomslemma takaA's lemma matches (the whole lemma; taka.* also finds takast); only in corpora with lemmas (otherwise an error); single quotes as for idomsleaf
A domsstring "þvert á móti"A contains these words in this order; also spansstring (A's words are exactly these) and domslemmastring, spanslemmastring for lemmas. See strings of words
A !domswords 2Negation: the relation does not hold for A (here: A does not contain exactly 2 words). Every one-node relation can be negated except domsstringlowest and domslemmastringlowest

A phrase has no word of its own: idomsleaf, idomslemma and idomsempty test the node right above the word. So NP-SBJ !idomsleaf hann finds every subject. For subjects whose pronoun is not hann, name the pronoun (IcePaHC labels carry case, so PRO-N):

NP-SBJ idoms PRO-N
PRO-N !idomsleaf 'hann'

Strings of words

The string relations find a node by the words of the text under it, written in double quotes with a space between them. This is useful for multi-word expressions, and for finding how an expression has been analysed when one does not know which labels to search for. All PPs that contain þvert á móti (17 in IcePaHC 2024.03):

PP domsstring "þvert á móti"

The words must follow each other directly in the text. Punctuation, codes and empty categories between them do not count, so þvert, á móti matches too. Each word is a regular expression for one whole word. Words split by the annotation count as one, as in the text column: mál$ $inu is written málinu.

In double quotes, case matters. In single quotes, it does not, so a phrase is also found at the start of a sentence. PP spansstring "í gær" finds 21 PPs in IcePaHC 2024.03; with single quotes it finds 24, including Í gær:

PP spansstring 'í gær'

Only the first and the last character are the quotes, so words with an apostrophe can stand between single quotes: 'at o'clock'. Single quotes work the same way in all the string relations, including the lemma versions, and for single words in idomsleaf, idomslemma, wordexists and lemmaexists (see upper and lower case).

A domsstring "w1 w2"A contains the words, in this order
A spansstring "w1 w2"A's words are exactly these and no others
A domslemmastring "l1 l2"A contains words with these lemmas, in this order
A spanslemmastring "l1 l2"A's words have exactly these lemmas
A domsstringlowest "w1 w2"only the lowest such A around each occurrence (also domslemmastringlowest); see only the lowest node

With .* as A, domsstring finds every node that contains the words, up to the root (74 nodes for þvert á móti). To see which constituents have been made of an expression, use spansstring. For þvert á móti that is 5 PPs. The other 12 PPs have more words, mostly an object (þvert á móti hans boði), and in those the three words are not a constituent of their own.

.* spansstring "þvert á móti"

The lemma versions match the lemmas of the words, so góður maður also finds góðan mann and góðir menn. Alternatives work as in other patterns (215 NPs in IcePaHC 2024.03):

NP.* domslemmastring "(góður|vondur) maður"

A split word has a lemma for each of its parts. manninn, annotated manni$ $nn, has the lemmas maður and hinn, so spanslemmastring needs both: "góður maður hinn". One word may be written without quotes (N.* domsstring móti). A string relation is a one-node relation on A, like idomsleaf: on its own it is the whole query, and with two-node relations, A is the node they name. It can be negated (NP-SBJ !domsstring "hann": subjects without the word hann). The lemma versions need a corpus with lemmas.

Only the lowest node

A node that contains a string of words is usually inside larger nodes that contain it too. .* domsstring 'þvert á móti' finds 82 nodes in IcePaHC 2024.03, every node from the PP up to the root. To see how an expression is annotated, the lowest node is usually enough. domsstringlowest finds, for each occurrence of the words, the lowest node that matches A's pattern and contains them: here 17 nodes, all of them PPs.

.* domsstringlowest 'þvert á móti'
A domsstringlowest "w1 w2"A contains the words, and no smaller node inside A that matches A's pattern contains them too
A domslemmastringlowest "l1 l2"the same with lemmas
A domslowest BA dominates B, and no node between them matches A's pattern

Each occurrence is looked at on its own. If two PPs with í gær are both inside a larger PP, PP domsstringlowest 'í gær' finds the two small PPs and not the larger one. "Lowest" means lowest among the nodes that match A's pattern. PP finds the lowest PP around the words, whatever smaller nodes of other labels there are. With .* it is the lowest node of any label. If the words do not form a constituent of their own, that is the node where they meet, such as an IP, which shows how the words have been split up. For a single word, .* finds the word's own node (N, ADV), so use a phrase label instead.

domslowest does the same for two nodes. In IcePaHC 2024.03, 15,816 PPs contain a proper noun (PP doms NPR.*), and 13,589 are the lowest PP above one (PP domslowest NPR.*). The rest contain proper nouns only inside smaller PPs.

PP domslowest NPR.*

The pattern of A decides which nodes are in the way: with NP.*|PP, both NPs and PPs are; NP.* also matches NPR. With [1]NP.* domslowest [2]NP.*, an NP is found when another NP is inside it with no NP between them. With .* as A, domslowest is nearly the same as idoms.

One result for each A. As with every relation, a result is a node A (the first node of the query). If A is the lowest for two nodes B (an NP with two nouns), or contains the words twice, that is one result. A node that is the lowest for one B but not for another is found too. To get a result for each B, put B first with an exists line. Each proper noun with a PP above it, then:

NPR.* labelexists
PP domslowest NPR.*

domslowest can be negated like the other relations. PP !domslowest NPR.* finds PPs that are not the lowest PP above any proper noun, which includes PPs without one. domsstringlowest and domslemmastringlowest cannot be negated; use !domsstring for nodes without the words. CorpusSearch has no relations like these.

Exists lines: finding a node anywhere

An exists line, one pattern and exists, finds a node anywhere in the tree whose label or word matches the pattern, as CorpusSearch's exists. The specialized versions test only one thing. As everywhere, the pattern is a regular expression that must match the whole label, word or lemma.

X existsa node whose label or word matches X
X labelexistsa node whose label matches X (as the first line, it makes X the anchor, as @X does)
X wordexistsa node whose word matches X (the node above the word, e.g. N)
X lemmaexistsa node whose lemma matches X; only in corpora with lemmas (otherwise an error). In a corpus with lemmas in some texts only, such as the IPCHG, a query that matches lemmas gets a notice saying so, since the other texts can hardly match
'w1 w2' stringexistsa string of words anywhere in the tree (also lemmastringexists); a word lookup, not an exists line
X !existsNegation: no node in the tree matches X (also !labelexists, !wordexists, !lemmaexists)

Such a line can be a whole query, with one result per node found:

IP-INF labelexists
konungur lemmaexists

The line names a node, like a relation does, so the name can be used in other lines, and it means the node found that way everywhere in the query. Here, subjects whose child has the lemma konungur:

NP-SBJ idoms konungur
konungur lemmaexists

A node that is not related to the others only has to be in the same tree. Main clauses with a non-empty subject, in trees where the word konungur occurs (or, with !wordexists, does not occur anywhere):

IP-MAT idoms NP-SBJ
NP-SBJ domswords> 0
konungur wordexists

A negated line names no node, so it cannot be the first line, and its pattern can be anything. One name cannot have two kinds of line (X wordexists and X lemmaexists); use [1]X and [2]X for two nodes. Unlike CorpusSearch, which matches the whole terminal (in corpora with lemmas, the word and the lemma together, konungur-konungur), exists matches the word, and finds the node above it rather than the word itself.

Word lookups: stringexists

Sometimes one just wants to find a phrase in the text. A word lookup does that: a line with words in quotes and stringexists (or near, below). It finds each occurrence of the words anywhere in the tree, matched word by word as in the string relations. Single quotes ignore case, and lemmastringexists matches lemmas. til þess að occurs 366 times in IcePaHC 2024.03:

'til þess að' stringexists
'w1 w2' stringexiststhe words, in this order, anywhere in the tree
'l1 l2' lemmastringexistswords with these lemmas; only in corpora with lemmas
'w1 w2' !stringexistsNegation: the tree does not have the words (also !lemmastringexists)

Each result is the lowest node that holds the words, so one occurrence gives one result, and the result shows how the phrase has been analysed: a constituent if the words are one, otherwise the node where they meet. For a single word it is the node above the word, as with wordexists. The line finds the same nodes as .* domsstringlowest (see only the lowest node).

With other lines, a stringexists line says that the tree has the words, or with !stringexists that it does not. Main clauses with a non-empty subject in trees with í gær (7 in IcePaHC 2024.03):

IP-MAT idoms NP-SBJ
NP-SBJ domswords> 0
'í gær' stringexists

Unlike other exists lines, the phrase cannot be used as a name in other lines. For a node with the words, use the string relations: IP.* domsstring 'í gær' finds the clauses that contain í gær (42 at every level; with domsstringlowest, the 24 lowest), and spansstring the constituents that are exactly the phrase. One word may be written without quotes (gær stringexists); several need them.

Words near each other: near

A word lookup with two words, a number and near between them finds places where the words are at most that many words apart, in either order. Each side is one word, or several in quotes, written as in the string relations (single quotes ignore case), and lemmanear matches lemmas. góður and maður in any form, with at most two words between them (148 in IcePaHC 2024.03):

góður lemmanear 2 maður
w1 near 2 w2the words with at most 2 words between them, either order; near 0: next to each other
'w1 w2' near 3 w3a string and a word (or two strings)
l1 lemmanear 2 l2the same with lemmas; only in corpora with lemmas
w1 !near 2 w2Negation: the tree has no such pair (also !lemmanear)

Each result is the lowest node that holds both, as with stringexists: a phrase if the words are close, the clause or sentence if they are far apart. The distance counts words as the text column shows them: punctuation and empty categories are not counted, and a word split by the annotation is one word. With lemmas, the two lemmas of a split word are next to each other, so maður lemmanear 0 hinn finds manninn (manni$ $nn). With other lines, the line says that the tree has such a pair, and other lines cannot refer to it, as with stringexists. CorpusSearch's neighborhood is similar, but counts traces and the parts of split words, and takes labels.

Upper and lower case

Words and lemmas are matched as written, so guð wordexists does not find Guð. A word in single quotes is matched without regard to case. In IcePaHC 2024.03, guð wordexists finds 633 words and Guð wordexists 539; 'guð' wordexists finds both, 1,172:

'guð' wordexists

This is mostly useful for words at the start of a sentence: og wordexists finds 43,793 instances of og, and 'og' wordexists 46,841, with Og. Single quotes work in every place that takes a word or a lemma:

A idomsleaf 'orð'A's word, whatever its case
A idomslemma 'taka'A's lemma, whatever its case
'orð' wordexistsa node whose word matches, whatever its case (also lemmaexists)
A domsstring 'í gær'a string of words, whatever their case (all the string relations)
'í gær' stringexistsa phrase anywhere, whatever its case (also lemmastringexists)
A idomsempty 'pro'an empty category, whatever its case (also the kind of trace in idomsviatrace); see traces
text author 'jón.*'a text attribute under where:, whatever its case; see searching only some texts

Double quotes are the same as no quotes. Labels are never in quotes: quotes mark a word.

A word in double quotes is the same as one without quotes: "Guð" finds Guð only. A pattern in quotes is still a regular expression (N.* idomsleaf 'ísland.*' finds Ísland, Íslandi, …). Only the first and the last character are the quotes, and only when they are the same, so a single ' or " is still a word of its own. Quotes mark a word, so they cannot stand where a label is meant: NP idoms 'guð' is an error. To relate a node found by its word to other nodes, use its name, quotes and all:

NP-SBJ idoms 'guð'
'guð' wordexists

Ruling out a structure: none:

A negated line rules out one relation: NP-SBJ !idoms PRO.* is a subject with no pronoun child. To rule out a structure of several lines, put them in a section headed none:. Subordinate clauses that do not have a pronominal subject (30,316 of the 46,383 in IcePaHC 2024.03, including the 5,413 with no NP-SBJ at all):

IP-SUB labelexists

none:
IP-SUB idoms NP-SBJ
NP-SBJ idoms PRO.*

A result stands if there is no way to find the nodes of the block so that all its lines hold. A name that the main section uses means the same node in the block; a name used only in the block is a new node, "some node". The main section's nodes are found first, and then the block must fail for them. So with NP-SBJ in the main section (IP-SUB idoms NP-SBJ), the same block means a subject that has no pronoun, as NP-SBJ !idoms PRO.* does; above, where only the block names it, it means no such subject at all. A negated line is the same as a block with that one line in it.

As everywhere, different names are different nodes, so a block can say "no other". Main clauses with exactly two objects, not three (1,586):

IP-MAT idoms [1]NP-OB.*
IP-MAT idoms [2]NP-OB.*
[1]NP-OB.* sprec [2]NP-OB.*

none:
IP-MAT idoms [3]NP-OB.*

Nothing but adverbs between the finite verb and the negation (725 of 1,263 main clauses with both). The last line of the block leaves out traces and other nodes without words, which do not stand between words in the text:

IP-MAT idoms VB[PD]I
IP-MAT idoms NEG
VB[PD]I precedes NEG

none:
VB[PD]I precedes [3]!ADV.*
[3]!ADV.* precedes NEG
[3]!ADV.* domswords> 0

A block can also rule something out in the whole tree, when it names no node of the main section. A query can have several none: blocks; each is ruled out on its own. They come right after the main section, before any other section, since they apply to it alone. A block can use two-node and one-node relations, negated lines, exists lines and word lookups. It applies to the main section only: it cannot use a node that only a coding value or an either:/or: alternative names, and its own nodes are not results, so meta: cannot list them. CorpusSearch writes the same as NOT ((…) AND (…)). See also how the sections fit together.

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. How or combines with and and not is on the Logical operations page.

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 (in quotes, inside them: '!rel', as for words), and several lines must all hold. The summary then counts only the searched texts and trees. As with words, a value in single quotes is matched without regard to case, and a value with spaces goes in quotes (text title "Íslendinga saga").

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

where:
text century 15|16
text genre !rel

Traces and empty categories

Words and empty categories (*T*-1, *ICH*-2, *pro*, 0) are not nodes of their own in PaCQL: they are found on the node right above them, with idomsempty (or idomsleaf for words). A pattern for a trace where a label belongs, as one writes it in CorpusSearch (NP-SBJ iDoms \*T*), is an error that says how to write it.

With idomsempty an empty category is written as it stands in the corpus, not as a regular expression, so the stars need no backslashes (CorpusSearch's \*T* works too, the backslashes ignored). It may be in quotes, as a word can, and in single quotes case is ignored ('PRO' finds *pro*). The stars may also be left out: idomsempty T is the same as idomsempty *T*, and T|ICH as *T*|*ICH*. This goes for names made of letters only (with or without an index, T-3); 0 and * are written as they are. Either way, an empty category without an index also finds it with one (T finds *T*-3, and * finds *=1).

To connect a trace with its antecedent, name the node above the trace and use sameindex, which compares the index of a node's label and of a trace right under it. Relative clauses with a subject trace:

CP-REL idoms WNP.*
CP-REL doms NP-SBJ
NP-SBJ idomsempty *T*
WNP.* sameindex NP-SBJ

An extraposed relative clause and the place it belongs (*ICH*):

IP-MAT doms CP-REL
CP-REL idomsempty *ICH*
IP-MAT doms [2]CP-REL
[2]CP-REL sameindex CP-REL

With idomsviatrace, a trace leads straight to what its antecedent contains, without naming the antecedent. The kind of trace comes between the two nodes. Extraposed relative clauses whose clause has a non-empty subject:

CP-REL idomsviatrace ICH IP-SUB
IP-SUB idoms NP-SBJ
NP-SBJ domswords> 0

A is the node right above the trace (here the empty CP-REL in the noun phrase), and B is a child of the node with the trace's index, whatever that node's label is. In (ADVP *T*-5) with the antecedent NP-5, ADVP idomsviatrace T PRO finds a PRO in NP-5. This is what CorpusSearch's program does; its manual says the antecedent must have A's label, but the program does not check it, and neither does PaCQL. To require a label, name the antecedent and use sameindex as above. !idomsviatrace means that there is no such B.

Unlike CorpusSearch's sameIndex, which compares the index of the trace itself, sameindex here also holds between two phrases whose traces carry the index, or between a phrase and the node above a trace.

An index can follow - or = (gapping); see Indexes: - and = for how the two differ.

Indexes: - and =

Corpora mark two kinds of index on labels. -1 links a moved or extraposed phrase with its trace (WNP-1 … *T*-1) or marks co-reference. =1 marks gapping: a conjoined clause that lacks elements of the clause it is parallel to (IP-MAT=1) gets the index of that clause (IP-MAT-1).

-1=1 (gapping)
In a label patternignored: NP-SBJ also finds NP-SBJ-1 part of the label: IP-MAT does not find IP-MAT=1; write IP-MAT=.* for gapped clauses only, IP-MAT(=.*)? for both
For sameindex and idomsviatrace the same: the number after the last - or =, as in CorpusSearch. IP-MAT-1 and IP-MAT=1 have the same index
On an empty categorythe same: *T*-1, *=1 carry an index; other words (such as a numeral vii-7) do not

So a search for main or subordinate clauses leaves gapped clauses out, which is usually what one wants: a gapped clause lacks elements, e.g., it generally lacks a verb. In IcePaHC 2024.03, IP-MAT idoms NP-SBJ finds 57,035 main clauses with an NP-SBJ child; IP-MAT(=.*)? idoms NP-SBJ also finds the 1,297 gapped ones.

To find a clause together with the gapped clause that is parallel to it, name the gapped one with its = and connect the two with sameindex (2,355 in IcePaHC 2024.03):

IP-MAT sameindex IP-MAT=.*

Here IP-MAT finds IP-MAT-1 (the -1 is ignored in the label) and IP-MAT=.* finds IP-MAT=1; sameindex checks that the numbers are the same. IP-SUB sameindex IP-SUB=.* does the same for subordinate clauses.

Negation with !: relations, labels and words

A ! means "not" in three places, and where it stands decides what is negated:

! beforemeansexample
a relationthe relation does not holdNP-SBJ !idoms PRO.*: no pronoun child
a label patterna node whose label does not matchNP-SBJ idoms !PRO.*: some child that is not a pronoun
a word patterna word that is there and does not matchPRO-N idomsleaf !hann: a pronoun other than hann

On an exists line or a word lookup, ! before the relation name says that the tree has no such node or words (exists lines). In where: it negates a text attribute's value.

A !idoms X means that A has no child X. For "A has some child that is not X", put the ! on the label instead: !X is a node whose label does not match X. Subjects with a child that is not a pronoun (51,980 in IcePaHC 2024.03):

NP-SBJ idoms !PRO.*

Coming from CorpusSearch: there, a ! before an argument means that there is no such node: (NP-SBJ iDoms !PRO*) is a subject with no pronoun child, which PaCQL writes NP-SBJ !idoms PRO.* (37,759 with IP-MAT idoms NP-SBJ), not NP-SBJ idoms !PRO.*.

As everywhere, the pattern must match the whole label, so !X leaves out exactly the labels that X matches. Punctuation and codes are left out too, as with .*, unless X is about them. With a number prefix, the ! may come before it or after it: ![1]PRO.* and [1]!PRO.*.

!N-Nany label except exactly N-N (NS-N, NPR-N remain)
!(N-N|D-N)any label except 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
!(NP-SBJ|PP).*any label that does not start with NP-SBJ or PP

The same can be written with a regular expression, since (?!…) excludes what follows it: (?!PRO).* is !PRO.*. A ! on a label works wherever a label pattern does: in relations, in haslabel, in the labels allowed between for idomsmod, in the labels kept out for domslocal and domswordslocal, and in labelexists.

On a word pattern, !w is a word that does not match w: a word must be there, and it is not w. It works wherever a word pattern does: idomsleaf, idomslemma, wordexists, lemmaexists, the word part of exists, each word of a string relation or word lookup, each side of near, and the kind of empty category in idomsempty and idomsviatrace. Counts for IcePaHC 2024.03:

PRO-N idomsleaf !hannpronouns other than hann (39,396; with hann 13,659)
N.* idomslemma !maðurnouns with a lemma other than maður (194,399)
'í !gær' stringexistsí followed by any word but gær (17,499)
'!góður maður' stringexistsmaður after a word other than góður (1,431)
NP-SBJ idomsempty !conempty subjects other than conjunction reduction (17,139)
'!hann' wordexistsa node with a word other than hann, whatever its case

The difference from ! on the relation is the same as for labels. PRO-N idomsleaf !hann needs a word that is not hann; NP-SBJ !idomsleaf hann only needs no word hann, so it holds for every subject that is a phrase, since a phrase has no word of its own. In quotes, the ! goes inside, before the word it negates: '!hann', 'í !gær'. A lone ! is the exclamation mark, and \! a word starting with one. One ! negates: !!hann, !!PRO.* and !!idoms are errors.

A new node in a negated relation

In A !idoms B, if B is named in a line that is not negated, the line is about that node: A does not immediately dominate it. Otherwise B is a pattern for a new node, and the line says that there is no such node. Two things follow.

The new node is none of the nodes the query names, as everywhere (different names, different nodes). Main clauses whose only NP child is the subject (33,792 in IcePaHC 2024.03), the same as with the line in a none: block:

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

In a none: block, the new node is other than the main section's nodes and the block's own; with coding values or either:/or: sections, other than the nodes of the combination.

The new node is looked for in the whole tree, not only in A's clause. For idoms and doms that makes no difference, but it does for relations that reach outside a clause, such as precedes. Main clauses with a finite verb that no object follows anywhere in the tree, also in a later clause (5,582):

IP-MAT idoms VBPI
VBPI !precedes NP-OB1

For "no object of this clause after the verb" (7,714), name the clause in a none: block:

IP-MAT idoms VBPI

none:
IP-MAT idoms NP-OB1
VBPI precedes NP-OB1

A pattern that matches nothing, such as a typo or a label that another corpus has, makes a negated line hold every time, which does not show in the results the way a positive line that never holds does. When a pattern of the query matches no label or word in the corpus, a notice under the query box says so.

Names and nodes

A name is a label pattern as written in a query, with its prefixes: NP-SBJ, [2]NP.*, !PRO.*, @N-D. Most names stand for a node of the tree, and two rules connect them:

Not every word of a line is a name for a node. What a word is depends on where it stands:

WhereWhat it isExample
both sides of a two-node relationnodesIP-MAT idoms NP-SBJ
the second side of a negated two-node relation, when no other line names it a pattern, not a node: the line says there is no such node VBPI !precedes NP-OB1
the first word of an exists linea node, found anywhere in the tree (and, as a different name, a different node from the others)manni wordexists
the first word of a negated exists linea pattern: the tree has no such node NEG !labelexists
what follows a one-node relationa value: a word, lemma, number, kind of empty category or label patternPRO-N idomsleaf hann
the words of a word lookupwords; as the first line the lookup is a node (the anchor), later it only says that the tree has the words 'í gær' stringexists
a word from define:its replacement, where a label pattern stands; as written anywhere elseobject

Adding a line can turn a pattern into a node. The second side of a negated line is a node as soon as another line names it, and then the negated line is about that node. Main clauses with a finite verb:

IP-MAT idoms VBPI
VBPI !precedes NP-OB1
no object after the verb anywhere in the tree (5,582)
IP-MAT idoms VBPI
IP-MAT idoms NP-OB1
VBPI !precedes NP-OB1
the clause has an object that the verb does not precede (205)
IP-MAT idoms VBPI

none:
IP-MAT idoms NP-OB1
VBPI precedes NP-OB1
no object of this clause after the verb (7,714)

An exists line is a node of its own. For objects whose noun is manni, name the noun's node: NP-OB1 idoms N-D with N-D idomsleaf manni (33). With manni wordexists instead, manni is a second node, which must differ from the N-D: objects in a tree that has another manni (14). With 'manni' stringexists after the first line, it is no node, only a test of the tree: objects in a tree that has the word anywhere (47).

Names in none: blocks, alternatives and coding values follow the same rules within what each section can see (how the sections fit together). In the query box, putting the cursor on a name shades every place where the same node is named, a name that is no node is grey, and How it is read numbers the nodes and says what each line means.

Two nodes with the same pattern

To use two different nodes matched by the same pattern, 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. A prefix is a number: [x]NP.* is a regular expression (one character from the brackets, then NP), which matches no label.

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

The other way round: different names are always different nodes, also when their patterns 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. Here PaCQL differs from CorpusSearch, where two different names may be the same node and only [1] and [2] keep nodes apart.

Choosing the anchor: @

There is one result per anchor, and the anchor is the first name of the first section. To count another node of the same structure, write @ before its name; it is then the anchor, and the query still matches the same structures. The tutorial's dative subjects, counted per dative noun rather than per clause (263 in IcePaHC 2024.03; 260 clauses, since a few subjects have two dative nouns):

IP-SUB idoms NP-SBJ
NP-SBJ idoms @N-D

@ may stand on any occurrence of the name, and only one name can have it. It comes before the other prefixes: @[2]NP-OB.*, @!PRO.*, @[1]!PRO.*. The anchor must be a node the first section finds, through a relation (not only as the second side of a negated one) or an exists line; it cannot be in a coding value, an either:/or: section or a none: block, and a word lookup (stringexists, near) cannot be marked. Writing @X means the same as starting the query with the line X labelexists, which is what the search does with it.

Coding

A section headed variable:value adds lines that must hold; each result gets the first value whose lines all 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.

A variable's name is letters, digits and _, starting with a letter (ov, np_type, þolfall); it becomes a column name, also in R. A value is letters, digits, _ and - (1, pro, aux-V-O). The reserved words and, or, not, either, none, where, define, meta and text cannot be variable names, in any case: or:1 would be too close to an or: section, and and could not be used in a logic line. Node names are not affected: there the place in the line says what a word is, so IP-MAT idoms and looks for a node labelled and.

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. A definition stands for a label pattern and is used only where a label pattern stands: in node names (also after [1], ! and @), in haslabel, in the labels between for idomsmod, in the labels kept out for domslocal and domswordslocal, and in meta:. Words are never replaced, so with a definition of guð, N.* idomsleaf guð still looks for the word guð (a notice says that the defined word is read as written there). Nor are numbers, kinds of empty categories, where: values or relation names (a defined word in the place of a relation is an error). A defined word stands for its replacement, so two defined words with the same replacement are one node, as is a defined word and its replacement written out; a notice says so. If a word is defined twice with different replacements, the later definition is used, and a notice says so too.

Logic variables

A logic variable gets its value from the values of the coding variables, after the search. It combines classifications that the coding values have already made, the way one would in a spreadsheet or in R, and its column appears in the results, the summary and the download like any coding variable. Its sections are headed with a question mark, ?variable:value:

IP-(MAT|SUB) idoms MD[PD][IS]
IP-(MAT|SUB) idoms NP-OB[12]
NP-OB[12] domswords> 0

ov:1
MD[PD][IS] sprec NP-OB[12]
NP-OB[12] sprec VB

ov:0
MD[PD][IS] sprec VB
VB sprec NP-OB[12]

np:pro
NP-OB[12] idomsonly PRO-.*

np:other

?order:OV-full
ov == 1 and np == other

?order:OV-pronoun
ov == 1

?order:VO

In IcePaHC 2024.03 this gives 1,720 clauses with a modal and an overt object: 338 OV-full, 158 OV-pronoun and 1,224 VO. As with coding, the lines of a value must all hold, the values are tried in the order written, and each result gets the first that holds; a value with no lines catches the rest. Unlike a coding value, a logic variable never leaves a result out: if no value holds, its value is empty. It looks at the values the coding variables gave a result, not at the tree: ov == 0 means that the result got the value 0 for ov (the first value that held, or the one that catches the rest), not that the tree has no object before the verb.

ov == 1the result has the value 1 for ov; the value is a pattern, as everywhere: np == pro|quant, in quotes np == 'Pro' ignoring case, np == !pro for any other value
ov != 1any value but 1
ovshort for ov == 1, for a variable whose values are 0 and 1
n > 2also <, <=, >=: numbers (every value of the variable must be a number)
text.year < 1700a text attribute, written with a dot: in a logic line every operand is one word (in where: and meta: it is text year, with a space); a text whose value is not a number makes a comparison of numbers false
a and b, a or b, not aand, or, not; parentheses group

The order of operations is the usual one (as in Python): comparisons first, then not, then and, then or. So not ov == 1 and np == pro means (not ov == 1) and np == pro, and ov == 1 or np == pro and n > 2 means ov == 1 or (np == pro and n > 2). Parentheses make this explicit and are easier to read. A ! stands only before a value (np == !pro) and in !=; before a variable, write not.

Each line is a condition of its own, and all of them must hold. A long expression can go on over several lines inside parentheses: a line with a ( that is not yet closed goes on with the next lines until it is. There can be no empty line in between, since an empty line ends the section.

?order:OV-full
ov == 1
(np == other
   or np == quant)

These are two conditions: ov == 1, and the expression in parentheses. Without the parentheses, a line that starts with and or or, or ends with and, or or not, is an error, so a line break never silently means and where or was meant.

and, or and not are written in lower case. A value spelled like one of them goes in quotes: with neg:not and neg:never as coding values, neg == 'not' (a bare neg == not is an error). In the query box, the operators of a logic line have their own color, and a quoted one does not. Putting the cursor on a parenthesis marks its partner, and on a variable, every place where it is named.

A logic variable can use every coding variable, the logic variables above it, and text attributes; not the either:/or: sections, which have no names, and not the nodes or their words. Names and values are checked before the search: a value that no coding value has (np == prn) is an error that lists the values. A value that no combination of the coding values can reach gets a notice, and How it is read shows a table of which coding values give which value.

Removing results: ?!:

A section headed ?!:, with no name and no value, is a filter: a result for which all its lines hold is removed. The lines are logic lines, as above. Subordinate clauses with a non-empty subject, without those that have a pronominal object but no pronominal subject (28,816 of 29,382 in IcePaHC 2024.03):

IP-SUB idoms NP-SBJ
NP-SBJ domswords> 0

p:1
NP-SBJ idoms [1]PRO.*

p:0

n:1
IP-SUB idoms NP-OB1
NP-OB1 idoms [2]PRO.*

n:0

?!:
n and not p

The lines of one filter must all hold for a result to be removed; each ?!: section is a filter of its own, and a result that any of them matches is removed. To keep only the results for which an expression holds, write not ( … ) around it. A filter uses the values each result has, those of the first combination of coding values it matches, and a removed result does not move on to a later value it also matches. So the query gives what running it without the filter and deleting the matching rows would give. A filter can use the coding variables, the logic variables above it and text attributes, and it has no column. The Logical operations page has more on filters, and on nested logic: and, or and not to any depth over coding variables.

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.

Three node columns say where a node's words are in the sentence. Words are counted as in the text column: no punctuation, traces or other empty categories, and a word split in the annotation (mál$ $ið) is one word.

node firstwordposition Athe position of A's first word in the sentence, counting from 1; no value (-) for a node with no words, such as a trace
node lastwordposition Athe position of A's last word
node wordsbetween A Bthe number of words between A and B, whichever comes first; no value if one of them dominates the other. A trace or other empty node has no words but has its place in the sentence, so the words between it and the other node are counted. Two names per line; each line is a column (wordsbetween, wordsbetween2, …)

Added to the example "OV/VO with modals" as node wordsbetween modal VB, this gives in IcePaHC 2024.03 on average 2.7 words between the modal and the main verb in the 496 OV clauses and 0.9 in the 1,224 VO clauses (598 with none).

Column names. A column can be given a name of its own: the name first, a colon, and then what the column holds, as in a coding header (ov:1).

IP-MAT idoms NP-SBJ
IP-MAT idoms NP-OB1
IP-MAT idoms VBDI

meta:
node objectwords:nodewords NP-OB1
node subjectwords:nodewords NP-SBJ
node gap:wordsbetween VBDI NP-OB1
text written:year
tree length:treewords

This works for every node, text and tree treewords line. A named node line has one node (or two, for wordsbetween); put each node on a line of its own. A name is letters, digits and _, starting with a letter, and not a reserved word. Columns without a name are named as above, numbered among the unnamed ones of the same kind. A name changes only the column's name: in logic lines and where:, text.year and year still name the attribute, and the summary is grouped by century as always. treeid, text and the text id column (textid), which end every table, keep their names.

Every column needs a name of its own: two columns of the same name, such as a coding variable year and text year, give an error, and naming one of them solves it (text written:year).

How the sections fit together

A query is read in three steps, and each kind of section takes part in one of them. What a section can see follows from the step it belongs to.

  1. Matching the main section. The first section is matched in each tree, and each none: block is checked against that match. A result needs a match of the main section that no none: block can extend.
  2. Choosing alternatives and values. For each result, the either:/or: alternatives and the coding values are checked together with the main section, one combination at a time: the main section, one alternative of each either: group and one value of each coding variable, read as a single query. A result must have at least one alternative of each either: group that holds, and each coding variable gets the first of its values, in the order written, that holds (an empty value catches the rest).
  3. Output. Logic variables get their values from the coding values, filters (?!:) remove results, and meta: lists the nodes of the combination that was chosen.

where: works before all this: it decides which trees are searched, by the texts' attributes, and names no nodes. define: is a shortcut that is filled in before anything else, wherever it is written.

SectionCan use the names ofIts new names are
the main sectionitselfthe nodes of the query; the first one (or the one marked with @) is the anchor
none:the main sectionnew nodes, which must differ from the main section's nodes; no other section can use them
either:/or:, coding valuesthe main section, and the other alternatives and values of the same combinationnew nodes, which must differ from all other nodes of the combination
logic variables (?x:1)the values of the coding variables and of the logic variables above, and text attributes(names no nodes)
filters (?!:)the same as logic variables(names no nodes)
meta:the main section, alternatives and coding values (- where the value that names the node does not apply)(names no new nodes)

Same name, same node; different names, different nodes, within what a section can see, also for the new node of a negated relation. A coding value that uses NP-SBJ from the main section is about the same subject, and a new name in it is another node. With this query, the value n:1 is given to main clauses with an NP child other than the subject (23,243 in IcePaHC 2024.03), and n:0 to the 33,792 whose only NP child is the subject:

IP-MAT idoms NP-SBJ

n:1
IP-MAT idoms NP.*

n:0

The same lines in a none: block leave only those 33,792, since a block's new nodes also differ from the main section's nodes. A none: block sees nothing but the main section: a name that only a coding value or an alternative finds is an error there, and its new nodes may be the same nodes that an alternative or a value finds. Main clauses with a finite verb and a subject or an object (28,474), with a none: block that rules out any NP child: none are left, because the block's NP may be the very subject or object that the alternative found.

IP-MAT idoms VBDI

none:
IP-MAT idoms NP.*

either:
IP-MAT idoms NP-SBJ

or:
IP-MAT idoms NP-OB1

Alternatives and values see each other within a combination, so a new name used in two coding variables is the same node whenever both values apply, and a node of its own otherwise. To keep the values easy to read, introduce a new name in one value and use it only there, and use the main section's names for anything shared. A query with a new name in two variables (or in a variable and an either:/or: group) gets a notice saying so.

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, the string relations 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.

Aliases and CorpusSearch

This documentation and the examples write every relation in lower case (idoms, sprec). The names below are accepted too, exactly as written here (case matters: iDoms works, IDOMS does not), with or without !. For relations that CorpusSearch has, they are the spellings of its manual; the others follow the same pattern. A query means the same whichever spelling it uses.

idomsiDominates, idominates, iDoms
idomsfirstiDomsFirst
idomslastiDomsLast
idomsonlyiDomsOnly
idomsnumberiDomsNumber, iDomsNum, idomsnum
idomsmodiDomsMod
idomsviatraceiDomsViaTrace
domsDominates, dominates, Doms
precedesPrecedes, Pres, pres, Prec, prec
iprecedesiPrecedes, iPres, ipres, iPrec, iprec
sprecsPrecedes, sprecedes, sPrec
isprecisPrecedes, isprecedes, isPrec
hassisterHasSister, hasSister
sameindexSameIndex, sameIndex
ccommandsCCommands, cCommands
haslabelHasLabel, hasLabel
hasindexHasIndex, hasIndex
idomsemptyiDomsEmpty
idomsleafiDomsLeaf
idomslemmaiDomsLemma
domswordsDomsWords, domsWords
domswords<DomsWords<, domsWords<
domswords>DomsWords>, domsWords>
idomstotaliDomsTotal
idomstotal<iDomsTotal<
idomstotal>iDomsTotal>
existsExists
labelexistsLabelExists, labelExists
wordexistsWordExists, wordExists
lemmaexistsLemmaExists, lemmaExists
stringexistsStringExists, stringExists
lemmastringexistsLemmaStringExists, lemmaStringExists
domsstringDomsString, domsString
spansstringSpansString, spansString
domslemmastringDomsLemmaString, domsLemmaString
spanslemmastringSpansLemmaString, spansLemmaString
domslowestDomsLowest, domsLowest
domslocalDomsLocal, domsLocal
domswordslocalDomsWordsLocal, domsWordsLocal
domswordslocal<DomsWordsLocal<, domsWordsLocal<
domswordslocal>DomsWordsLocal>, domsWordsLocal>
domsstringlowestDomsStringLowest, domsStringLowest
domslemmastringlowestDomsLemmaStringLowest, domsLemmaStringLowest
nearNear
lemmanearLemmaNear, lemmaNear

Former names. Until 23 November 2026, domslowest, domsstringlowest and domslemmastringlowest were called domsclosest, domsstringclosest and domslemmastringclosest. The old names still work for now, with a notice under the query box, but will stop working later.

The names are CorpusSearch's, but the relations work as described on this page: label patterns are regular expressions and ignore an index (NP-SBJ also finds NP-SBJ-2), sameindex also reads a trace under a node, and ccommands follows CorpusSearch's definition (more). CorpusSearch's Column, DomsT, InID, IsRoot, iDomsT are not available; a query that uses them says so. A query in CorpusSearch's own form, such as (NP-SBJ* iDoms PRO*) AND ..., gets a message showing how to write it here: one relation per line, no parentheses, .* where CorpusSearch has *.

Changes since the 2015 version