The TGrep language by Richard Pito
formulates queries as patterns that consist of expressions
to match tree nodes and relationships defining links or negated links to other tree nodes.
Nodes of searched trees are matched either with
simple character strings or regular expressions (see sections 1).
A complex expression consists of a node expression followed by relationships,
as presented in section 2.
Possible relationships are illustrated in section 3.
When you compose a search expression in the box provided,
if the search expression uses TGrep-lite syntax,
the interface will recognize that and interpret the expression accordingly.
If the expression is well-formed but there are no matches in the corpus,
the screen shows no change after the “Submit” button is pressed.
If the expression is not well-formed, the warning
“Not a valid TGrep-lite expression.”
appears.
In the result page, if you check the “reveal” box and resubmit,
a translation of the TGrep-lite expression into XPath syntax is displayed.
This allows you to check whether the expression you have composed reflects the search that is intended.
The TGrep functionality available here is referred to as “TGrep-lite”.
This is less expressive than the full TGrep language implemented in the original TGrep program.
In particular,
the expression of relationships between nodes is limited to the relations detailed in section 3.
TGrep-lite is especially weak when compared to enhanced TGrep languages
available with TGrep2
and Tregex implementations,
notably,
missing the ability to express disjunctions of relations.
TGrep-lite will also exhibit behaviour distinct from what is expected from TGrep
with regards to how nodes are specified
(described in section 1).
Despite these mentioned limitations,
TGrep-lite is the easiest and most accessible way to search the corpus using this on-line interface,
and it is a powerful search language.
TGrep-lite works by rewriting expressions of a modified TGrep language into XPath queries over a database of XML encoded trees.
The formatting of the XML
requires
that the rewrite to XPath distinguishes
three different “node” kinds expressed with TGrep-lite node patterns:
word nodes,
pre-terminal nodes (that provide information about the word, e.g., the word is a zero element), and
part-of-speech/phrase-level nodes.
The wild card (“__”) is exceptional in not needing to distinguish its node kind,
since it will match all nodes.
A simple constant string,
such as “abc”, etc.,
will match word nodes that are the unique string abc.
The expression of all other node patterns
occurs as the statement of a regular expression
with deliminators to
determine the kind of the node searched.
Specifically:
a regular expression indicated by surrounding slashes (“/”), such as “/ab/”, will search for word nodes,
a regular expression indicated by surrounding curly brackets (“{”, “}”), such as “{AB}”, will search for pre-terminal nodes, and
a regular expression indicated by surrounding square brackets (“[”, “]”), such as “[AB]”, will search for part-of-speech/phrase-level nodes.
If a simple constant string or deliminated regular expression begins with “!”,
the matching process will be complemented. That is, matches will turn into non-matches,
and vice-versa.
For example, “!abc” will match all words that are not abc,
and “![^NP] will match any part-of-speech or phrase-level node that does not start with NP.
Specified as a string,
a regular expression matches a node if there is a part of the node that is matched.
For example, “[IP]” matches IP-MAT, IP-ADV, etc.
The caret (“^”) anchors the regular expression to the beginning of a matched node,
while a dollar sign (“$”) as the last character will anchor the regular expression
to the end of a matched node.
Use of both the caret and dollar-sign in “[^NP$]” constrains the match to only NP.
A word boundary can be stated with “\b”.
Thus,
while “[^NP]” will match both NP-SBJ and NPR,
“[^NP\b]” will match only NP-SBJ.
Disjunction can be expressed with the pipe (“|”),
and regular expression elements can be grouped with round brackets,
such that “[^NP-(SBJ|OB1)]” will find nodes that start with either NP-SBJ or NP-OB1.
Note that the on-line interface is case insensitive
when the node is identified as being either a pre-terminal or part-of-speech/phrase-level node,
while being case sensitive for word (terminal) nodes.
TGrep-lite expressions are composed of a node pattern followed by the relationships the node pattern participates in.
Because word information
serves as content of the same node under the XML encoding
as pre-terminal node information,
it becomes necessary if you wish to match the combination of a particular word with a particular pre-terminal node
that the “==” (equals) relation serves to connect this information about the same underlying node.
For example,
the following will find instances of words that contain “tuti” with the “PHON” pre-terminal tag.
The following example,
will match an IP node which immediately dominates a PP node and which dominates an IP node.
Note the parenthesis to ensure that the second relationship “<< [IP]” refers to the first IP and not to the PP.
As another example,
will match an IP which immediately dominates a PP which in turn dominates some IP.
The first node in a pattern or the first node following a left parenthesis is a “master” node which is related to the relationships to its right. Thus, a TGrep-lite pattern consists of a master node for the entire query followed by a series of relationships to other nodes that can themselves with parenthesis form master nodes with relationships to yet other nodes. In the first example above only the first [IP] is a master node, while in the second example both the first [IP] and the [PP] are master nodes.
Relationships define connections between the master node (being defined) and other nodes. There is a complete pairing of forward and backward links, allowing for flexibility in choosing what is the master node. Notable relationships are:
A << B A dominates (is an ancestor of) B
A >> B A is dominated by (is a descendant of) B
A < B A immediately dominates (is the parent of) B
A > B A is immediately dominated by (is the child of) B
A .. B A precedes B
A ,, B A follows B
A . B A immediately precedes B
A , B A immediately follows B
A $ B A is a sister of and not equal to 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 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 immediately follows B
A == B A and B are the same node
A <<, B B is a leftmost descendant of A
A <<- B B is a rightmost descendant of A
A >>, B A is a leftmost descendant of B
A >>- B A is a rightmost descendant of B
A <1 B B is the 1st child of A
A >1 B A is the 1st child of B
A <-1 B B is the last child of A
A >-1 B A is the last child of B
A <, B B is the first child of A (synonymous with A <1 B)
A >, B A is the first 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 via an unbroken chain (length > 0) of unary branches
A >>: B A is dominated by B via an unbroken chain (length > 0) of unary branches
The following presents pictures grouping some of the above relationships as forward and backward links:
C << __ (dominates, is an ancestor of)
__ >> C (is dominated by, is a descendant of)
E >> __ (is dominated by, is a descendant of)
__ << E (dominates, is an ancestor of)
C > __ (immediately dominates, is the parent of)
__ < C (is immediately dominated by, is the child of)
TGrep-lite returns the match for the left-most element in the search pattern. The following pattern matches PPs that are immediately dominated by an IP that dominates an IP:
TGrep-lite search results
Search results are listed in groups of up to twenty five entries,
each with highlighted portions corresponding to the focus of the query.
Immediately following each entry is a link to the tree for that entry in the form of the ID number of that entry.
Following the link
opens a tree view for the result,
with highlighted nodes corresponding to the focus of the search.
When appropriate,
there is a down arrow to click for moving to the next twenty five results,
and an up arrow for moving back.
In addition,
there is an open text area that contains the pattern for the search.
This gives the opportunity to see and also edit the search query.
Clicking the “Submit” button re-submits the possibly edited search.
At the page end,
there is the option to
download results for searches with results of 2000 items or less.
There are three possible forms in which search results can be downloaded:
basic text format, bracket format, and Alpino XML format.
All formats include the text and ID number of each entry.
Bracket format and Alpino XML format include all the syntactic information encoded for each entry.
Each line of text with the “basic text format” is a tab separated numbered entry,
and the number of the last entry is equal to the number of results for the search.
* mi tami ware * ik yeru sirusi ari * ame tuti no * sakayuru toki ni * ap ye raku omopeba MYS.6.996
* takudunwo no * sirakwi no kuni yu * pito goto wo * yo si to kika site * twopi saku ru * ugara parakara * na ki kuni ni * watari ki masite * opo kimi no * siki masu kuni ni * utipi sasu * miyakwo simimi ni * satwo ipye pa * sapa ni aredomo * ika sama ni * omopi kye me kamo * ture mo na ki * sapo no yama pye ni * naku kwo nasu * sitapi ki masite * siki tape no * ipye wo mo tukuri * ara tama no * tosi no wo naga ku * sumapitutu * imasi si mono wo * ik yeru mono * sinu to ipu koto ni * manukare nu * mono ni si areba * tanom yeri si * pito no kotogoto * kusa makura * tabi n aru potwo ni * sapo gapa wo * asa kapa watari * kasuga nwo wo * sogapi ni mitutu * asi pikwi no * yama pye wo sasite * kurekure to * kakuri masi nu re * ipa mu subye * se mu subye sira ni * ta motopori * tada pito ri site * sirwo tape no * koromo de posa zu * nagekitutu * wa ga naku namita * arima yama * kumo wi tanabiki * ame ni puri ki ya MYS.3.460
* tori ga naku * aduma no kuni ni * inisipye ni * ari kyeru koto to * ima madeni * taye zu ipi kuru * katusika no * mama no tegwona ga * asa ginu ni * awo kubi tuke * pita sa wo wo * mo ni pa ori kite * kami dani mo * kaki pa kedura zu * kutu wo dani * paka zu yukedomo * nisiki aya no * naka ni tutum yeru * ituki gwo mo * imo ni sika me ya * moti dukwi no * tar eru omowa ni * pana no goto * wemite tat ereba * natu musi no * pwi ni iru ga goto * minatwo iri ni * pune kogu goto ku * yuki kagure * pito no ipu toki * ikubaku mo * ik yerazi mono wo * nani su to ka * mwi wo tana sirite * nami no oto no * sawaku minatwo no * oku tu kwi ni * imo ga koyas eru * topo ki yo ni * ari kyeru koto wo * kinopu si mo * mi kye mu ga goto mo * omopoyuru kamo MYS.9.1807
* nani se mu ni * inoti wo motona * naga ku pori se mu * ik yeri tomo * wa ga omopu imo ni * yasu ku apa naku ni MYS.11.2358
* nemokoro ni * kata mopi sure ka * ko no koro no * wa ga kokorodwo no * ik yeru to mo na ki MYS.11.2525
* kusa makura * tabi no ke ni site * tuma sakari * ipye di omopu ni * ik yeru subye na si MYS.13.3347b
* maswo kagami * mi aka nu imo ni * apa zusite * tukwi no pe nure ba * ik yeri to mo na si MYS.12.2980
* sipo miteba * min awa ni ukabu * managwo ni mo * ware pa ik yeru ka * kwopwi pa sina zute MYS.11.2734
* yosi we ya si * sina mu yo wa g imo * ik yeri tomo * kaku nomwi koso a ga * kwopwi watari na me MYS.13.3298
* ama zakaru * pina no ara nwo ni * kimi wo okite * omopitutu areba * ik yeru two mo na si MYS.2.227
* pusuma di wo * * pikide no yama ni * imo wo okite * yama di omopu ni * ik yeru two mo na si MYS.2.215
* itu made ni * ika mu inoti so * oboroka ni * kwopwitutu ara zupa * sina mu masar eri MYS.12.2913
* notise yama * noti mo apa mu to * omope koso * sinu be ki mono wo * kyepu made mo ik yere MYS.4.739
* kwopwi sina mu * toki pa nani se mu * ik yeru pi no * tame koso imo wo * mi maku pori sure MYS.4.560
* tama ta suki * kake nu toki na ku * wa ga omopu * imo ni si apa ne ba * akane sasu * piru pa simira ni * nubatama no * yworu pa sugara ni * i mo ne zu ni * imo ni kwopuru ni * ik ye ru subye na si MYS.13.3297
* momo yo si mo * ti yo si mo ikite * ara me ya mo * wa ga omopu imo wo * okite nageka mu MYS.11.2600
* utusemi no * pito me wo sige mi * apa zusite * tosi no pe nureba * ik yeri to mo na si MYS.12.3107
* mi ke mukapu * apadi no sima ni * tada mukapu * minumye no ura no * oki pye ni pa * puka miru tori * ura mwi ni pa * nanoriso karu * pukamiru no * mi maku posi kye do * nanoriso no * ono ga na wosi mi * ma tukapi mo * yara zute ware pa * ik yeri to mo na si MYS.6.946
* sira tama no * mi gaposi * kimi wo * mi zu pisa ni * pina ni si woreba * ik yeru to mo na si MYS.19.4170
* pusuma di wo * * pikide no yama ni * imo wo okite * yama di wo yukeba * ik yeri to mo na si MYS.2.212
* wasure kusa * wa ga pimo ni tuku * toki to na ku * omopi watareba * ik yeri to mo na si MYS.12.3060
* ikite araba * mi maku mo sira zu * nani si kamo * sina mu yo imo to * ime ni mi ye turu MYS.4.581
* yasu yasu mo * ik yeraba ara mu wo * pata ya pata * munagi wo toru to * kapa ni nagaru na MYS.16.3854
* kwopwi kwopwite * noti mo apa mu to * nagusamoru * kokoro si na kupa * ikite ara me ya mo MYS.12.2904
* ik yeru yo ni * kwopwi to ipu mono wo * api mi neba * kwopwi no uti ni mo * ware so kurusi ki MYS.12.2930