Logical operations
PaCQL has no single place for and, or and not. Each is expressed by
the shape of the query: lines that stand together must all hold, sections offer
alternatives or rule structures out, a ! negates what it stands before, and a
| inside a pattern gives alternatives for a label, a word or a value. Only logic
variables and filters, which work on the values of coding variables after the search, have the
words and, or and not. With them, PaCQL writes and, or and not
nested to any depth, the logic CorpusSearch writes with parentheses and advises against, and
every condition stays visible (nested logic). This page defines each of these exactly
and shows how they combine. The Relations page defines the
relations themselves, and the reference sums up the syntax.
The table below is an overview. Its rows are the four places in a query where logic is
expressed: the lines and sections of the query, the patterns inside a line, the
where: section, and logic variables. Its columns say how and, or and
not are written in each place. The sections below explain each of them, and the
links in the table lead to them.
| and | or | not | |
|---|---|---|---|
| lines of a query | the lines of a section (all must hold) | either:/or: sections;
coding values (the first that holds) |
! on a relation, an exists line or a word lookup;
none: blocks |
| patterns (labels, words, lemmas, values) | — | | and […]:
IP-(MAT|SUB), NP-OB[12], hann|hún |
! before the pattern:
!PRO.*, !hann |
where: |
its lines | | in a value: text genre nar|rel |
! before a value: text genre !rel |
| logic variables | and; the lines of a value |
or; the values, tried in order |
not, !=, == !value; a
?!: filter removes the results for which its lines hold |
Reading this page
The definitions use the terms of the Relations page (names and results). A name stands for a node. A binding gives every name of a section a node of one tree, different nodes for different names. A line holds under a binding when its relation holds between (or for) the nodes the binding gives its names. The query has one result for each node that is the anchor of at least one binding under which every line it needs holds. The formulas use this notation (as on the Relations page, trees and notation, where label and word are defined):
| M | the first section of the query; A, B: lines (or parts) of a query |
| a, b, x | nodes; a is usually the anchor's node, b the node of a second name, x any node |
| result(a) | the query has a result whose anchor is the node a |
| β(N) | the node a binding β gives the name N; β(anchor) is the node of the anchor's name |
| label(x), word(x) | the label of x, and the word right under it, if it has one |
| a ⊳ x | a immediately dominates x (x is a child of a) |
| R(a, b) | the two-node relation R (idoms,
precedes, …) holds between a and b |
| rel(a, v) | the one-node relation rel (idomstotal,
idomsleaf, …) holds for a with the value v written after it |
| L(P) | the set of labels a label pattern P matches |
| W(w) | the set of words (or lemmas) a word pattern w matches |
| V(p) | the set of values (of coding and logic variables and of text attributes) a pattern p matches in a logic line |
And these symbols: ∧ and, ∨ or, ¬ not, ⇔ if and only if, ∃ there is, ∄ there is no, ∈ is in (a set), ∉ is not in, − the set difference (what is in the first set and not in the second), → if … then (A → B: whenever A, also B), ⊕ exactly one of the two.
And: the lines of a section
The lines of a section are joined by and: a result needs one binding under which all of them hold. For the first section M:
result(a) ⇔ ∃ binding β: β(anchor) = a ∧ every line of M holds under β
Because one binding serves every line, a name written in two lines is one node: the
lines are about the same node, not two nodes that happen to match the same pattern. Dative
subjects of subordinate clauses (260 in IcePaHC 2024.03): the NP-SBJ that the clause
dominates is the one that dominates the dative noun.
IP-SUB idoms NP-SBJ NP-SBJ idoms N-D
Different names get different nodes, so the conjunction also says that they are distinct:
IP-SUB idoms [1]NP.* and IP-SUB idoms [2]NP.* together mean two NP
children, not one found twice. The other names of a binding only have to exist (∃); the
anchor alone decides what is counted.
The order of the lines does not matter, with two exceptions that concern the anchor: the
first name of the first line is the anchor (unless another is marked with @), and a
word lookup as the first line finds the anchor, while
later it only tests the tree. Every other line can be moved without changing the results.
A first section of one-node relations only, such as N.* idomslemma maður and
ADJ.* idomslemma góður on two lines, finds each node anywhere in the tree: both
must occur in the same tree. The same and holds within every other section: the lines
of one either:/or: alternative, of one coding value, of a
none: block, of a logic value, and of where: must all hold.
Or: either:/or:
A group of alternatives starts with a section headed either:, followed by one or
more sections headed or:. A result must match the first section together with at
least one alternative of the group:
result(a) ⇔ ∃ alternative g of the group, ∃ binding β: β(anchor) = a ∧ every line of M and of g holds under β
A name of the first section is the same node in every alternative; a name used only in one
alternative is a node of that alternative, different from the first section's nodes. The lines
within an alternative are joined by and, so an alternative of several lines is a
conjunction: either: A, B / or: C means (A ∧ B) ∨ C. Several groups
must each hold: two groups mean (A ∨ B) ∧ (C ∨ D).
Subordinate clauses with a negation or a modal verb, or both (IcePaHC 2024.03: 2,603 with
NEG, 4,450 with a modal, 570 with both, so 2,603 + 4,450 − 570 = 6,483):
IP-SUB labelexists either: IP-SUB idoms NEG or: IP-SUB idoms MD.*
The output does not say which alternative matched, and a result that matches several is
still one result. To see which, write the alternatives as values of a coding variable
(below), which gives the same results with a column. For alternatives of a
single label or word, no section is needed: IP-SUB idoms NEG|MD.* gives the same
6,483 clauses (alternatives inside a pattern).
Alternatives and coding values are checked together: for each result, the first section,
one alternative of each group and one value of each coding variable are read as one query,
and a name that two of them share is one node (ordered choice). A
none: block applies to the first section only and cannot use a name that only an
alternative has.
Not: !
A ! negates what it stands right before. Where it stands decides what is
negated:
! before | means | example |
|---|---|---|
| a two-node relation | the relation does not hold (with a new node: there is no such node) | NP-SBJ !idoms PRO.*: no pronoun child |
| a one-node relation | the relation does not hold for the node | NP-OB1 !idomstotal 1: not exactly one child |
| an exists line or word lookup | the tree has no such node or words | NEG !labelexists |
| a label pattern | a node whose label does not match | NP-SBJ idoms !PRO.*: a child that is not a pronoun |
| a word, lemma or empty-category pattern | one that is there and does not match | PRO-N idomsleaf !hann |
a where: value | texts whose value does not match | text genre !rel |
| a value in a logic line | a value that does not match | np == !pro |
A negated two-node relation
In A !R B, where R is any two-node relation, A must be named by a line that is
not negated; a is A's node. What the line says depends on B:
- If a line that is not negated names B, B is that node, b, and the line says that the relation does not hold between the two: ¬R(a, b).
- Otherwise B is a pattern for a new node, and the line says that there is no such node: ∄ x: label(x) ∈ L(B) ∧ R(a, x), where x is none of the nodes the query names (different names, different nodes) and is looked for in the whole tree.
The second case is a none: block of one line: IP-MAT !idoms NP.*
after IP-MAT idoms NP-SBJ gives the main clauses whose only NP child is the subject
(33,792 in IcePaHC 2024.03), and so does a none: block with the line
IP-MAT idoms NP.* (below).
Since the new node is looked for in the whole tree, a relation that reaches beyond the clause
reaches beyond it in the negation too. VBPI !precedes NP-OB1 after
IP-MAT idoms VBPI means that no object follows the verb anywhere in the tree (5,582);
for "no object of this clause after the verb" (7,714), name the clause in a none:
block (Relations, "Negation").
A negated one-node relation, exists line or word lookup
A !rel v, where rel is any one-node relation and v its value, keeps A's node
a only if the relation does not hold for it:
¬rel(a, v). The node is found as it is without the !, by
another line, or by the line itself when the section has no two-node relation. So a line and
its negation split the nodes their name finds in two. In IcePaHC 2024.03 there are 47,168
direct objects (NP-OB1 exists). Of these, 23,146 have exactly one child:
NP-OB1 idomstotal 1
and the other 24,022 do not:
NP-OB1 !idomstotal 1
Every one-node relation can be negated except domsstringlowest and
domslemmastringlowest.
A negated exists line or word lookup names no node: it says that no node of the tree passes
its test. NEG !labelexists keeps the trees without a negation.
A negated label
!P as a name is a node whose label does not match P:
L(!P) = L(.*) − L(P). The negation is inside the
name, so the line itself is positive: it needs a node, one that is not a P. The
difference from a negated relation is the difference between ∄ and ∃¬:
| NP-SBJ !idoms PRO.* | ∄ x: a ⊳ x ∧ label(x) ∈ L(PRO.*):
the subject has no pronoun child (37,759 subjects of main clauses) |
| NP-SBJ idoms !PRO.* | ∃ x: a ⊳ x ∧ label(x) ∉ L(PRO.*):
the subject has a child that is not a pronoun (25,823) |
Here a is the subject's node; both queries come after
IP-MAT idoms NP-SBJ. A subject with a pronoun and another child is
found only by the second; an empty subject such as (NP-SBJ *con*), which has no
child node, only by the first. A ! on a label works wherever a label pattern does,
also in haslabel, labelexists and the labels allowed in between for
idomsmod. With a number prefix it may stand on either side:
![1]PRO.* = [1]!PRO.*.
A negated word
!w as a word pattern is a word that is there and does not match: for a node
x, x has a word ∧ word(x) ∉ W(w). A node with no word of its
own (a phrase) does not match !w any more than it matches w. It works for words,
lemmas, each word of a string, each side of near, and kinds of empty category.
PRO-N idomsleaf !hann: 39,396 pronouns other than hann. In quotes the
! goes inside, before the word it negates: '!hann', 'í !gær'
(í followed by any word but gær: 17,499).
Small rules
- One
!negates;!!PRO.*,!!hannand!!idomsare errors. - A lone
!is the exclamation mark as a word;\!is a word that starts with one. @comes before the other prefixes:@!PRO.*,@[1]!PRO.*.- A pattern that matches nothing (a typo, or a label of another corpus) makes a negated line hold every time, which the results do not show the way a positive line that never holds does. A notice under the query box says so.
Not: none:
A section headed none: rules out a structure of several lines. A result stands
only if the block cannot be matched together with the first section:
result(a) ⇔ ∃ binding β of M with β(anchor) = a ∧ ∄ extension β′ of β under which every line of the block holds
An extension β′ of β gives the first section's names the same nodes as β does, and also gives nodes to the names that only the block uses.
A name of the first section is the same node in the block; a name used only in the block is a new node, "some node", different from the first section's nodes and from the block's other names. The block's lines are joined by and, so the block is ¬(A ∧ B ∧ …). Subordinate clauses without a pronominal subject (30,316 of 46,383 in IcePaHC 2024.03):
IP-SUB labelexists none: IP-SUB idoms NP-SBJ NP-SBJ idoms PRO.*
Several blocks are each ruled out: two blocks are ¬A ∧ ¬B. A block can use every kind of
line, negated lines too, so a block with A and ¬B rules out "A without B" (
below). Blocks come right after the first section. They see only the first section, not
coding values or alternatives, and meta: cannot list their nodes, since they are
nodes that do not exist in a result.
A negated relation whose second name is new is the same as a block with that one line. A block is needed when what is ruled out takes more than one line, or when a new node must be tied to a named one, as for "no object of this clause after the verb":
IP-MAT idoms VBPI none: IP-MAT idoms NP-OB1 VBPI precedes NP-OB1
Combining and, or, not
With these pieces every Boolean combination of relations can be written. The table uses two
properties of subordinate clauses, A = IP-SUB idoms NEG (a negation) and
B = IP-SUB idoms MD.* (a modal verb), on the 46,383 subordinate clauses
of IcePaHC 2024.03, found with IP-SUB labelexists as the first line. ¬A is the negated
line IP-SUB !idoms NEG, and ¬B is IP-SUB !idoms MD.*. A alone gives
2,603 clauses and B alone 4,450. Each count is a link that runs its query, and the
counts add up as the logic says they must.
| A ∧ B | both lines in the first section: 570 |
| A ∨ B | either: A / or: B:
6,483 (= 2,603 + 4,450 − 570) |
| ¬A | the negated line: 43,780 (= 46,383 − 2,603) |
| ¬(A ∧ B) | one none: block with A and B:
45,813 (= 46,383 − 570) |
| ¬A ∧ ¬B = ¬(A ∨ B) | both lines negated, 39,900, or two
none: blocks, 39,900 (= 46,383 − 6,483) |
| A → B = ¬A ∨ B | a none: block with A and ¬B ("not A without B"),
44,350, or either: ¬A / or: B,
44,350 (= 46,383 − (2,603 − 570)) |
| A ⊕ B (exactly one) | either: A / or: B, and a
none: block with both: 5,913
(= 6,483 − 570) |
The last one, written out. The block's names get number prefixes because a block may not use a name that an alternative uses (either:/or:); as the block's own names they are its own nodes anyway:
IP-SUB labelexists none: IP-SUB idoms [1]NEG IP-SUB idoms [1]MD.* either: IP-SUB idoms NEG or: IP-SUB idoms MD.*
When the parts are classifications rather than filters, the same can be done after the search with a logic variable, which keeps every result and gives each a value.
Ordered choice: coding values
A coding variable is a choice between values, tried in the order written, like if … else if … else. Each value's lines are joined by and. A result gets the first value whose lines hold together with the first section; a value with no lines (the "otherwise" value) holds for every result, so it catches the rest. A result for which no value holds is left out. For a variable with values v1, …, vn, in the order written,
the value code(a) that the result with anchor a gets is
code(a) = the first vi such that ∃ binding β: β(anchor) = a ∧ every line of M and of vi holds under β
The order matters when values overlap. Subjects of main clauses coded for a pronoun child first, then a noun child (IcePaHC 2024.03):
IP-MAT idoms NP-SBJ np:pro NP-SBJ idoms PRO.* np:noun NP-SBJ idoms N.* np:other
This gives pro 19,276, noun 20,983 and other 16,776. With
np:noun before np:pro it gives noun 21,932 and
pro 18,327: the 949 subjects with both a pronoun and a noun child go to whichever
value comes first. Without np:other, the 16,776 subjects with neither are left
out (40,259 results). A value header written twice adds the lines of the second to the
first.
With several coding variables (and either:/or: groups, which work as
coding variables without a column), one value of each is read together with the first section
as one query, and a name that two of them share is one node. The combinations are tried in
order: the first variable's values in the order written, for each of them the second
variable's, and so on, with the either:/or: groups last. A result gets
the first combination that holds. So each variable gets the first of its values that holds,
given the values chosen for the variables before it; when the variables share no new names,
that is simply its own first value that holds.
Logic variables
A logic variable works on values, not on trees. After the search, it gives each result a
value worked out from the values the coding variables gave that result, from the logic
variables above it, and from text attributes. Its sections are headed
?variable:value; the values are tried in order and the first whose lines all hold
is the result's value, as for coding. Unlike a coding variable, a logic variable never leaves a
result out: if no value holds, its value is empty.
Syntax. Each line of a value is an expression, defined here step by step. In the
right column, { … } means that what is inside may be repeated any number of times
(also none), and a plain | separates choices; or, and, not,
the comparison signs and the parentheses are written as shown.
| expression | or-expr |
| or-expr | and-expr { or and-expr } |
| and-expr | not-expr { and not-expr } |
| not-expr | not not-expr | comparison |
| comparison | operand (== | !=) pattern
| operand (< | <= | > | >=) number
| variable (for a variable with the values 0 and 1)
| ( expression ) |
| operand | a coding or logic variable, or text.attribute |
So the order of operations is the usual one (as in Python and CorpusSearch):
comparisons first, then not, then and, then or.
not ov == 1 and np == pro is (not ov == 1) and np == pro, and
ov == 1 or np == pro and n > 2 is ov == 1 or (np == pro and n > 2).
Parentheses make it explicit.
Meaning. For a result, let c(var) be its value for the variable var (a coding or logic variable; empty if a logic variable got no value), and t(attr) the value of its text's attribute attr (for a tree with an attribute of its own, the tree's value). V(p) is the set of values that the pattern p matches, whole, as everywhere in PaCQL. Below, var stands for any variable, attr for any text attribute, p for any pattern, n for any number, and E and F for any expressions.
| var == p | c(var) ∈ V(p) (np == pro|quant;
in single quotes case is ignored: np == 'Pro') |
| var != p | c(var) ∉ V(p) |
| var == !p | c(var) ∉ V(p), the same as var != p and
not var == p; unlike ! on a word, this is also true when var has
no value |
| var < n | c(var) is a number and c(var) < n
(likewise <=, >, >=); false if c(var)
is not a number, so not var < n is then true |
| var | c(var) = 1, for a variable whose values are 0 and 1 |
| text.attr == p text.attr < n | the same with t(attr):
t(attr) ∈ V(p); t(attr) is a number and t(attr) <
n (text.year < 1700) |
| E and F E or F not E | E ∧ F, E ∨ F, ¬E |
ov == 0 means that the result got the value 0 for ov, not that the tree
lacks what ov:1 describes: the value may come from an otherwise value that caught the
rest. A logic variable answers questions about the classification, which is what makes it
useful for combining several codings into one, as one would in a spreadsheet or in R. The
exclusive or of the table above, as a value (5,913 of the 46,383 clauses get 1):
IP-SUB labelexists neg:1 IP-SUB idoms NEG neg:0 md:1 IP-SUB idoms MD.* md:0 ?one:1 (neg or md) and not (neg and md) ?one:0
Writing it. Each line is a condition of its own, and all must hold. An expression can
go on over several lines inside parentheses; outside them, 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. The
operators are written in lower case, and a value spelled like one goes in quotes
(neg == 'not'). ! stands only before a value and in !=; before
a variable, write not. Names and values are checked before the search: a value that no
coding value has is an error, and a logic value that no combination of coding values can
reach gets a notice. How it is read shows which coding values give which value.
Removing results: ?!:
A filter is a logic section with no name and no value, headed ?!:. Its
lines are logic lines, as in a logic variable, and a result for which all of them hold is
removed. It has no column, since every result that is left would have the same value in it.
Subordinate clauses with a non-empty subject (IcePaHC 2024.03), coded for a pronoun in the subject
(p) and in the object (n), without the clauses that have a pronominal
object but no pronominal subject:
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
This leaves 28,816 of the 29,382 clauses: those for which p ∨ ¬n holds. The filter works on the values, after the search, in the same way as a logic variable: removing a result is a decision about its classification, not another condition on the tree.
For a query whose results without filters are given by result₀, and filters F1, …, Fk, where Ej1, Ej2, … are the lines of Fj read with the values of the result with anchor a (as above),
result(a) ⇔ result₀(a) ∧ ¬(E11 ∧ E12 ∧ …) ∧ … ∧ ¬(Ek1 ∧ Ek2 ∧ …)
So the lines of one filter are joined by and, as in a none: block, and each
?!: section is a filter of its own, as each none: block is. Written as
two lines under one header, n and not p remove the same
566 clauses as the one line
above (the link runs the query that keeps just those, with the filter not (n and not p));
written as two filters, each removes what it matches, and only the
15,079
clauses with p 1 and n 0 are left. To keep only the results for which an
expression holds, put not ( … ) around it.
The values a result has. A filter sees each result's values: those of the first combination of coding values it matches. A result that a filter removes is removed; it does not move on to a later value that it also matches. With the values tried in this order,
IP-SUB idoms NP-SBJ NP-SBJ domswords> 0 pron:subject NP-SBJ idoms PRO.* pron:object IP-SUB idoms NP-OB1 NP-OB1 idoms PRO.* pron:none ?!: pron == subject
the 987
clauses with a pronoun both in the subject and in the object get subject, and the
filter removes them with the rest of the subject clauses. What is left is
13,316 clauses, with the values
object and none; none of the 987 comes back as object. The query
gives what one would get by running it without the filter and deleting the rows with
subject, and each value means the same with or without a filter. For the clauses with a
pronominal object whatever the subject is, code the two properties as two variables, as in the
first example.
How filters combine with coding variables into logic of any depth is the subject of the next section.
A filter can use the coding variables, the logic variables above it and text attributes
(text.year < 1500). Without text attributes, the filter is decided for each
combination of coding values before the search, so it costs nothing: the search leaves those
combinations' results out. A filter that removes nothing, or every result, gets a notice, and
How it is read lists the combinations of coding values it removes.
Nested logic: conditions as codes
CorpusSearch lets a query nest AND, OR and NOT inside
parentheses to any depth, and its manual advises against using OR and NOT,
since the results can be hard to predict. PaCQL expresses the same nested logic, to any depth, in
a way whose meaning is never in doubt: each condition becomes a coding variable, and the logic is
written over their values. The search then answers one simple question per condition, and the
and, or and not work on the answers.
- One coding variable per condition, with the value 1 when the condition holds and an otherwise value 0. Each condition is an ordinary set of lines, as complex as it needs to be.
- Names of their own for the nodes each variable adds (
[1]PRO.*,[2]PRO.*), so that the conditions are independent: a name that two variables share is one node, and a notice says so. Nodes the conditions should share go in the first section. - The logic in a filter (to keep or remove results) or in a
logic variable (to classify them), with
and,or,notand parentheses as deep as needed.
Subordinate clauses with a non-empty subject in which (the subject is a pronoun or the clause is negated) and not (the clause has a modal and a pronominal object):
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 neg:1 IP-SUB idoms NEG neg:0 md:1 IP-SUB idoms MD.* md:0 ?!: not ((p or neg) and not (md and n))
This keeps 16,578 of the 29,382 clauses, and the numbers add
up: 16,816 clauses have p or neg, and 238 of them also have md
and n. Each of these numbers can be read from the columns of the
unfiltered query, and so can every other part of the formula.
This is more than a way around a missing feature:
- No question of which node a name means. In a nested query, a name under an
ORor aNOTraises the question of whether it is the same node as elsewhere in the query, and the answer decides the results. Here each condition is matched on its own, by the rules of the sections above, and the logic sees only its answer. - Every part can be checked. Each condition is a column in the results, the summary and the download, so the clauses behind any part of the formula can be counted and read. A condition that matches too much or too little shows up before it is buried in a formula.
- The formula is separate from the conditions. The logic is decided for each combination of coding values before the search, so trying another formula over the same conditions changes only which combinations are kept, never what each condition matches.
The recipe covers conditions on the result, that is, on the anchor and on the nodes of the first section. That is what a nested CorpusSearch query says about its boundary node.
Alternatives inside a pattern
Every pattern in PaCQL is a regular expression in Python's syntax, matched against the whole label, word, lemma or value. Two of its devices give alternatives without any section, and they work wherever a pattern stands. This is not a guide to regular expressions (see Python's documentation for the full syntax), just the parts that express or and not. The counts are for IcePaHC 2024.03, and each one is a link that runs the query that gives it.
|separates alternatives:NP-OB1|NP-OB2. Since the whole pattern must match,|divides the whole pattern unless parentheses limit it:IP-(MAT|SUB) idoms NP-SBJfinds main and subordinate clauses with anNP-SBJchild (98,005), butIP-MAT|SUB idoms NP-SBJfinds IP-MAT or a label that is exactlySUB, so only the main clauses (57,035).[…]is one character from a set:NP-OB[12]is the same asNP-OB1|NP-OB2(main clauses with such a child: 16,605 withNP-OB[12], 16,605 withNP-OB1|NP-OB2),[NQD]-DisN-D,Q-DorD-D, andMD[PD][IS]the finite modal forms.?makes the part before it optional:IP-MAT(=.*)?is a main clause with or without a gapping index.(?!…)excludes what follows:(?!PRO).*is the same as!PRO.*(above).
| IP-SUB idoms NEG|MD.* | labels: 6,483, the same as
either:/or: above |
| PRO-N idomsleaf hann|hún | words: 16,749; in single
quotes, 'hann|hún', case is ignored: 19,651 |
| N.* idomslemma maður|kona | lemmas: 7,260 |
| 'í gær|dag' stringexists | each word of a string is a pattern of its own: í gær or í dag, 135 = 24 + 111 |
| NP-SBJ idomsempty T|ICH | kinds of empty category: 9,765 = 9,265 + 500 |
| NP-SBJ idomsmod NP.*|CONJP.* PRO.* | the labels allowed in between: subjects with a
pronoun, also inside a conjoined subject, 57,942
(with idoms, 53,719) |
| text genre nar|rel | a value in where:: dative subjects of main clauses in
narrative or religious texts, 1,871
= 1,541 +
330 |
| np == pro|quant | a value in a logic line |
Some characters have a meaning of their own in a pattern: . is any character
(\. the period), * repeats what comes before it (CorpusSearch's
NP* is NP.* here), and ( ) [ ] | ? as above. A
! at the start of a pattern is PaCQL's negation, not part of the regular
expression.
Compared with CorpusSearch
| CorpusSearch | PaCQL | |
|---|---|---|
| and | AND between search functions, with parentheses |
the lines of a section |
| or | OR (its manual advises against it) |
either:/or:, coding values, | in a pattern |
| not | NOT before a search function or parentheses (deprecated in its
manual), and ! before an argument |
! before a relation, none: blocks, and ! before a pattern |
| order of operations | NOT, then AND, then OR |
the same in logic lines; elsewhere the layout of the query decides |
| alternatives in an argument | | between wildcard patterns
(NP-SBJ*|NP-OB*), where * is any characters |
regular expressions: |, […], .* and the rest |
| coding | each column's conditions tried in order (ELSE for the rest); every
boundary node is coded, with _ when no condition holds |
each variable's values tried in order (a value with no lines for the rest); a result for which no value holds is left out |
| logic over codes | a second search on the coded output (the column
function) | logic variables in the same query |
| nested and, or, not | parentheses, to any depth, over search functions; its manual
advises against OR and NOT |
to any depth: one coding variable per condition, and the logic over
their values in a ?!: filter or a logic variable; each condition is a column that
can be counted and checked |
! before an argument. In CorpusSearch, (NP-SBJ iDoms !PRO*) means
that the subject has no pronoun child: the ! negates the relation for that argument.
In PaCQL that is NP-SBJ !idoms PRO.*. A ! before a pattern in PaCQL means a
node whose label does not match, which CorpusSearch has no way to say. A CorpusSearch user who
writes NP-SBJ idoms !PRO.* in PaCQL gets the other meaning (a
negated label).
Different names. In CorpusSearch, different names joined by AND may still be
the same node, unless number prefixes keep them apart; in PaCQL different names are always
different nodes. A conjunction in PaCQL therefore says more: IP-.* idoms NP-SBJ and
IP-MAT idoms NP-OB1 are two clauses.
How far NOT reaches. CorpusSearch's NOT rules a structure out for
the whole boundary node (node:), so with node: $ROOT one clause with a subject
removes every clause of the sentence from a search for clauses without one. A
none: block rules a structure out for the nodes of the first section.