## Search the database with queries

Queries use the TGrep2 language or regular expressions (show the list of operators).

Rohde, D. L. (2005).

TGrep2 user manual version 1.15. Massachusetts Institute of Technology.

For more information, check
the

manual
or
the

tutorial.

**Tgrep2 operators**

A < B A is the parent of (immediately dominates) B.
A > B A is the child of B.
A <N B B is the Nth child of A (the first child is <1).
A >N B A is the Nth child of B (the first child is >1).
A <, B Synonymous with A <1 B.
A >, B Synonymous with A >1 B.
A <-N B B is the Nth-to-last child of A (the last child is <-1).
A >-N B A is the Nth-to-last child of B (the last child is >-1).
A <- B B is the last child of A (synonymous with A <-1 B).
A >- B A is the last child of B (synonymous with A >-1 B).
A <` B B is the last child of A (also synonymous with A <-1 B).
A >` B A is the last child of B (also synonymous with A >-1 B).
A <: B B is the only child of A.
A >: B A is the only child of B.
A << B A dominates B (A is an ancestor of B).
A >> B A is dominated by B (A is a descendant of B).
A <<, B B is a left-most descendant of A.
A >>, B A is a left-most descendant of B.
A <<` B B is a right-most descendant of A.
A >>` B A is a right-most descendant of B.
A <<: B There is a single path of descent from A and B is on it.
A >>: B There is a single path of descent from B and A is on it.
A . B A immediately precedes B.
A , B A immediately follows B.
A .. B A precedes B.
A ,, B A follows B.
A $ B A is a sister of B (and A != B).
A $. B A is a sister of and immediately precedes B.
A $, B A is a sister of and immediately follows B.
A $.. B A is a sister of and precedes B.
A $,, B A is a sister of and follows B.
A = B A is also matched by B.

**Regular expression operators**

"." Matches any character except a newline.
"^" Matches the start of the string.
"$" Matches the end of the string or just before the newline at
the end of the string.
"*" Matches 0 or more (greedy) repetitions of the preceding RE.
Greedy means that it will match as many repetitions as possible.
"+" Matches 1 or more (greedy) repetitions of the preceding RE.
"?" Matches 0 or 1 (greedy) of the preceding RE.
*?,+?,?? Non-greedy versions of the previous three special characters.
{m,n} Matches from m to n repetitions of the preceding RE.
{m,n}? Non-greedy version of the above.
"\\" Either escapes special characters or signals a special sequence.
[] Indicates a set of characters.
A "^" as the first character indicates a complementing set.
"|" A|B, creates an RE that will match either A or B.
(...) Matches the RE inside the parentheses.
The contents can be retrieved or matched later in the string.
(?:...) Non-grouping version of regular parentheses.
(?i) Perform case-insensitive matching.

For example, one can search for sentences containing:

- a clausal co-subordination:
**CLAUSE < ( CLAUSE $.. CLAUSE )**
- a core coordination:
**( CORE $.. CORE ) !> CORE**

Regular expressions can be used, for example to look for specific words, tags or traces. Regular expressions start and end with **/**, and contain symbols such as **$** to denote the end of the string. The symbol **=** can be used to refer to the beginning of a word.

- sentences containing "started":
**/=started$/**
- sentences where the word "Winston" follows the word "said":
**/=said$/ . /=Winston$/**
- trees containing a node with a "NUCID=1" trace:
**/NUCID=1/** (with the Func-Tags box ticked)

Multiple operators are assumed to be related by an AND relation. To nest operators, you must group them with parentheses:

- A CORE that immediately dominates an NP and immediately dominates a CLAUSE:
**CORE < NP < CLAUSE**
- A CORE that immediately dominates an NP which dominates a CLAUSE:
**CORE < (NP < CLAUSE)**