| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!DOCTYPE chapter SYSTEM "docbook-dtd-45/docbookx.dtd"> |
| 3 |
|
| 4 |
<chapter id="dependencies"> |
| 5 |
<title>Making use of Dependencies</title> |
| 6 |
|
| 7 |
<para> |
| 8 |
CG-3 can work with dependency trees in various ways. The input cohorts can have existing |
| 9 |
dependencies; the grammar can create new attachments; or a combination of the two. |
| 10 |
</para> |
| 11 |
|
| 12 |
<section id="dep-setparent"> |
| 13 |
<title>SETPARENT</title> |
| 14 |
<indexterm> |
| 15 |
<primary>SETPARENT</primary> |
| 16 |
</indexterm> |
| 17 |
<screen> |
| 18 |
[wordform] SETPARENT <target> [contextual_tests] |
| 19 |
TO|FROM <contextual_target> [contextual_tests] ; |
| 20 |
</screen> |
| 21 |
<para> |
| 22 |
Attaches the matching reading to the contextually targetted cohort as a child. |
| 23 |
The last link of the contextual test is used as target. |
| 24 |
</para> |
| 25 |
<para> |
| 26 |
If the contextual target is a scanning test and the first found candidate cannot be attached |
| 27 |
due to loop prevention, SETPARENT will look onwards for the next candidate. |
| 28 |
This can be controlled with rule option <link linkend="rule-options-nearest">NEAREST</link> |
| 29 |
and <link linkend="rule-options-allowloop">ALLOWLOOP</link>. |
| 30 |
</para> |
| 31 |
<screen> |
| 32 |
SETPARENT targetset (-1* ("someword")) |
| 33 |
TO (1* (step) LINK 1* (candidate)) (2 SomeSet) ; |
| 34 |
</screen> |
| 35 |
</section> |
| 36 |
|
| 37 |
<section id="dep-setchild"> |
| 38 |
<title>SETCHILD</title> |
| 39 |
<indexterm> |
| 40 |
<primary>SETCHILD</primary> |
| 41 |
</indexterm> |
| 42 |
<screen> |
| 43 |
[wordform] SETCHILD <target> [contextual_tests] |
| 44 |
TO|FROM <contextual_target> [contextual_tests] ; |
| 45 |
</screen> |
| 46 |
<para> |
| 47 |
Attaches the matching reading to the contextually targetted cohort as the parent. |
| 48 |
The last link of the contextual test is used as target. |
| 49 |
</para> |
| 50 |
<para> |
| 51 |
If the contextual target is a scanning test and the first found candidate cannot be attached |
| 52 |
due to loop prevention, SETCHILD will look onwards for the next candidate. |
| 53 |
This can be controlled with rule option <link linkend="rule-options-nearest">NEAREST</link> |
| 54 |
and <link linkend="rule-options-allowloop">ALLOWLOOP</link>. |
| 55 |
</para> |
| 56 |
<screen> |
| 57 |
SETCHILD targetset (-1* ("someword")) |
| 58 |
TO (1* (step) LINK 1* (candidate)) (2 SomeSet) ; |
| 59 |
</screen> |
| 60 |
</section> |
| 61 |
|
| 62 |
<section id="dep-remparent"> |
| 63 |
<title>REMPARENT</title> |
| 64 |
<indexterm> |
| 65 |
<primary>REMPARENT</primary> |
| 66 |
</indexterm> |
| 67 |
<screen> |
| 68 |
[wordform] REMPARENT <target> [contextual_tests] ; |
| 69 |
</screen> |
| 70 |
<para> |
| 71 |
Sets the target as having no parent. |
| 72 |
</para> |
| 73 |
<screen> |
| 74 |
REMPARENT targetset IF (p (cop)) ; |
| 75 |
</screen> |
| 76 |
</section> |
| 77 |
|
| 78 |
<section id="dep-switchparent"> |
| 79 |
<title>SWITCHPARENT</title> |
| 80 |
<indexterm> |
| 81 |
<primary>SWITCHPARENT</primary> |
| 82 |
</indexterm> |
| 83 |
<screen> |
| 84 |
[wordform] SWITCHPARENT [WITHCHILD <child_set>] <target> [contextual_tests] ; |
| 85 |
</screen> |
| 86 |
<para> |
| 87 |
Sets the grandparent of the target as its parent and sets the target as the parent of the previous parent. If <link linkend="rule-options-withchild">WTIHCHILD</link> is present, any siblings of the target which match the set will also become children of the target. |
| 88 |
</para> |
| 89 |
<screen> |
| 90 |
"<and>" |
| 91 |
"and" CCONJ #1->2 |
| 92 |
"<in>" |
| 93 |
"in" ADP #2->0 |
| 94 |
"<the>" |
| 95 |
"the" DET #3->4 |
| 96 |
"<house>" |
| 97 |
"house" NOUN #4->2 |
| 98 |
"<.>" |
| 99 |
"." PUNCT #5->2 |
| 100 |
|
| 101 |
SWITCHPARENT WITHCHILD (*) - (PUNCT) (NOUN) IF (p (ADP)) ; |
| 102 |
|
| 103 |
"<and>" |
| 104 |
"and" CCONJ #1->4 |
| 105 |
"<in>" |
| 106 |
"in" ADP #2->4 |
| 107 |
"<the>" |
| 108 |
"the" DET #3->4 |
| 109 |
"<house>" |
| 110 |
"house" NOUN #4->0 |
| 111 |
"<.>" |
| 112 |
"." PUNCT #5->2 |
| 113 |
</screen> |
| 114 |
</section> |
| 115 |
|
| 116 |
<section id="dep-input"> |
| 117 |
<title>Existing Trees in Input</title> |
| 118 |
<para> |
| 119 |
Dependency attachments in input comes in the form of #X->Y or #X→Y tags where X is the number of the current |
| 120 |
node and Y is the number of the parent node. The X must be unique positive integers and should |
| 121 |
be sequentially enumerated. '0' is reserved and means the root of the tree, so no node may claim |
| 122 |
to be '0', but nodes may attach to '0'. |
| 123 |
</para> |
| 124 |
<para> |
| 125 |
<emphasis>If the Y of a reading cannot be located, it will be reattached to itself.</emphasis> |
| 126 |
<emphasis>If a reading contains more than one attachment, only the last will be honored.</emphasis> |
| 127 |
<emphasis>If a cohort has conflicting attachments in its readings, the result is undefined.</emphasis> |
| 128 |
</para> |
| 129 |
<para> |
| 130 |
For example: |
| 131 |
<screen> |
| 132 |
"<There>" |
| 133 |
"there" <*> ADV @F-SUBJ #1->0 |
| 134 |
"<once>" |
| 135 |
"once" ADV @ADVL #2->0 |
| 136 |
"<was>" |
| 137 |
"be" <SVC/N> <SVC/A> V PAST SG1/3 VFIN IMP @FMV #3->2 |
| 138 |
"<a>" |
| 139 |
"a" <Indef> ART DET CENTRAL SG @>N #4->5 |
| 140 |
"<man>" |
| 141 |
"man" N NOM SG @SC #5->0 |
| 142 |
"<$.>" |
| 143 |
</screen> |
| 144 |
</para> |
| 145 |
</section> |
| 146 |
|
| 147 |
<section id="dep-delimit"> |
| 148 |
<title>Using Dependency as Delimiters</title> |
| 149 |
<para> |
| 150 |
Cmdline flag -D or --dep-delimit will enable the use of dependency information to delimit windows. |
| 151 |
Enabling this will disable <link linkend="keyword-delimiters">DELIMITERS</link> entirely, |
| 152 |
but will not affect the behavior of <link linkend="keyword-soft-delimiters">SOFT-DELIMITERS</link> |
| 153 |
nor the hard/soft cohort limits. |
| 154 |
</para> |
| 155 |
<para> |
| 156 |
Windows are delimited if a cohort has a node number less than or equal to |
| 157 |
the highest previously seen node number, and also if a cohort has a node number that seems like a discontinuous |
| 158 |
jump up in numbers. |
| 159 |
The discontinuous limit is by default 10 but you can pass a number to -D/--dep-delimit to set it yourself. |
| 160 |
Some systems do not output dependency numbers for punctuation, so setting it too low may break those; |
| 161 |
the default 10 was chosen since it is unlikely any real text would have 10 sequential cohorts not part of the tree. |
| 162 |
</para> |
| 163 |
<para> |
| 164 |
For example: |
| 165 |
<emphasis>#4→5 followed by #3→4 will delimit.</emphasis> |
| 166 |
<emphasis>#4→5 followed by #4→4 will delimit.</emphasis> |
| 167 |
<emphasis>#4→5 followed by #15→4 will delimit.</emphasis> |
| 168 |
<emphasis>#4→5 followed by #5→3 will not delimit.</emphasis> |
| 169 |
</para> |
| 170 |
</section> |
| 171 |
|
| 172 |
<section id="dep-grammar"> |
| 173 |
<title>Creating Trees from Grammar</title> |
| 174 |
<para> |
| 175 |
It is also possible to create or modify the tree on-the-fly with rules. |
| 176 |
See <link linkend="keyword-setparent">SETPARENT</link> |
| 177 |
and <link linkend="keyword-setchild">SETCHILD</link>. |
| 178 |
Dependencies created in this fashion will be output in the same format as above. |
| 179 |
</para> |
| 180 |
<para> |
| 181 |
For example: |
| 182 |
<screen> |
| 183 |
SETPARENT (@>N) (0 (ART DET)) |
| 184 |
TO (1* (N)) ; |
| 185 |
|
| 186 |
SETPARENT (@<P) |
| 187 |
TO (-1* (PRP)) (NEGATE 1* (V)) ; |
| 188 |
</screen> |
| 189 |
</para> |
| 190 |
</section> |
| 191 |
|
| 192 |
<section id="dep-contextual-tests"> |
| 193 |
<title>Contextual Tests</title> |
| 194 |
<para> |
| 195 |
Either case, once you have a dependency tree to work with, |
| 196 |
you can use that in subsequent contextual tests as seen below. |
| 197 |
These positions can be combined with the window spanning options. |
| 198 |
</para> |
| 199 |
|
| 200 |
<section id="dep-ct-parent"> |
| 201 |
<title>Parent</title> |
| 202 |
<indexterm> |
| 203 |
<primary>p</primary> |
| 204 |
</indexterm> |
| 205 |
<para> |
| 206 |
The 'p' position asks for the parent of the current position. |
| 207 |
</para> |
| 208 |
<screen> |
| 209 |
(-1* (ADJ) LINK p (N)) |
| 210 |
</screen> |
| 211 |
</section> |
| 212 |
|
| 213 |
<section id="dep-ct-ancestors"> |
| 214 |
<title>Ancestors</title> |
| 215 |
<indexterm> |
| 216 |
<primary>pp</primary> |
| 217 |
</indexterm> |
| 218 |
<para> |
| 219 |
The 'pp' position asks for an ancestor of the current position, |
| 220 |
where ancestor is defined as any parent, grand-parent, great-grand-parent, etc... |
| 221 |
</para> |
| 222 |
<screen> |
| 223 |
(-1* (N) LINK pp (ADJ)) |
| 224 |
</screen> |
| 225 |
<para> |
| 226 |
<emphasis>The analogue of <link linkend="gotcha-cc-vs-cstar">difference between cc and c*</link> applies to pp vs. p*</emphasis> |
| 227 |
</para> |
| 228 |
</section> |
| 229 |
|
| 230 |
<section id="dep-ct-children"> |
| 231 |
<title>Children</title> |
| 232 |
<indexterm> |
| 233 |
<primary>c</primary> |
| 234 |
</indexterm> |
| 235 |
<para> |
| 236 |
The 'c' position asks for a child of the current position. |
| 237 |
</para> |
| 238 |
<screen> |
| 239 |
(-1* (N) LINK c (ADJ)) |
| 240 |
</screen> |
| 241 |
</section> |
| 242 |
|
| 243 |
<section id="dep-ct-descendents"> |
| 244 |
<title>Descendents</title> |
| 245 |
<indexterm> |
| 246 |
<primary>cc</primary> |
| 247 |
</indexterm> |
| 248 |
<para> |
| 249 |
The 'cc' position asks for a descendent of the current position, |
| 250 |
where descendent is defined as any child, grand-child, great-grand-child, etc... |
| 251 |
</para> |
| 252 |
<screen> |
| 253 |
(-1* (N) LINK cc (ADJ)) |
| 254 |
</screen> |
| 255 |
<para> |
| 256 |
<emphasis><link linkend="gotcha-cc-vs-cstar">Difference between cc and c*</link></emphasis> |
| 257 |
</para> |
| 258 |
</section> |
| 259 |
|
| 260 |
<section id="dep-ct-siblings"> |
| 261 |
<title>Siblings</title> |
| 262 |
<indexterm> |
| 263 |
<primary>s</primary> |
| 264 |
</indexterm> |
| 265 |
<para> |
| 266 |
The 's' position asks for a sibling of the current position. |
| 267 |
</para> |
| 268 |
<screen> |
| 269 |
(-1* (ADJ) LINK s (ADJ)) |
| 270 |
</screen> |
| 271 |
</section> |
| 272 |
|
| 273 |
<section id="dep-ct-self"> |
| 274 |
<title>Self</title> |
| 275 |
<indexterm> |
| 276 |
<primary>S</primary> |
| 277 |
</indexterm> |
| 278 |
<para> |
| 279 |
The 'S' option allows the test to look at the current target as well. |
| 280 |
Used in conjunction with p, c, cc, s, or r to test self and the relations. |
| 281 |
</para> |
| 282 |
<para> |
| 283 |
Be aware that BARRIER and CBARRIER will check and thus possibly stop at the current target when 'S' is in effect. |
| 284 |
This can be toggled on a per context basis with modifier <link linkend="dep-ct-no-barrier">N</link>. |
| 285 |
</para> |
| 286 |
<screen> |
| 287 |
(cS (ADJ)) |
| 288 |
</screen> |
| 289 |
</section> |
| 290 |
|
| 291 |
<section id="dep-ct-no-barrier"> |
| 292 |
<title>No Barrier</title> |
| 293 |
<indexterm> |
| 294 |
<primary>N</primary> |
| 295 |
</indexterm> |
| 296 |
<para> |
| 297 |
The 'N' option causes barriers to ignore the self cohort. |
| 298 |
If <link linkend="grammar-options-self-no-barrier">self-no-barrier</link> is enabled, |
| 299 |
then instead it forces barriers to respect the self cohort. |
| 300 |
</para> |
| 301 |
</section> |
| 302 |
|
| 303 |
<section id="dep-ct-deep"> |
| 304 |
<title>Deep Scan</title> |
| 305 |
<indexterm> |
| 306 |
<primary>*</primary> |
| 307 |
</indexterm> |
| 308 |
<para> |
| 309 |
The '*' option behaves differently when dealing with dependencies. |
| 310 |
Here, the '*' option allows the test to perform a deep scan. |
| 311 |
Used in conjunction with p, c, or s to continue until there are no deeper relations. |
| 312 |
For example, position 'c*' tests the children, grand-children, great-grand-children, and so forth. |
| 313 |
</para> |
| 314 |
<screen> |
| 315 |
(c* (ADJ)) |
| 316 |
</screen> |
| 317 |
<para> |
| 318 |
<emphasis><link linkend="gotcha-cc-vs-cstar">Difference between cc and c*</link></emphasis> |
| 319 |
</para> |
| 320 |
</section> |
| 321 |
|
| 322 |
<section id="dep-ct-leftof"> |
| 323 |
<title>Left of</title> |
| 324 |
<indexterm> |
| 325 |
<primary>l</primary> |
| 326 |
</indexterm> |
| 327 |
<para> |
| 328 |
The 'l' option limits the search to cohorts that are to the left of the current target. |
| 329 |
</para> |
| 330 |
<screen> |
| 331 |
(lc (ADJ)) |
| 332 |
</screen> |
| 333 |
</section> |
| 334 |
|
| 335 |
<section id="dep-ct-rightof"> |
| 336 |
<title>Right of</title> |
| 337 |
<indexterm> |
| 338 |
<primary>r</primary> |
| 339 |
</indexterm> |
| 340 |
<para> |
| 341 |
The 'r' option limits the search to cohorts that are to the right of the current target. |
| 342 |
</para> |
| 343 |
<screen> |
| 344 |
(rc (ADJ)) |
| 345 |
</screen> |
| 346 |
</section> |
| 347 |
|
| 348 |
<section id="dep-ct-leftmost"> |
| 349 |
<title>Leftmost</title> |
| 350 |
<indexterm> |
| 351 |
<primary>ll</primary> |
| 352 |
</indexterm> |
| 353 |
<indexterm> |
| 354 |
<primary>lll</primary> |
| 355 |
</indexterm> |
| 356 |
<indexterm> |
| 357 |
<primary>llr</primary> |
| 358 |
</indexterm> |
| 359 |
<para> |
| 360 |
The 'll' option limits the search to the leftmost cohort of the possible matches. |
| 361 |
Note that this cohort may be to the right of the current target; |
| 362 |
use 'lll' if you want the leftmost of the cohorts to the left of the current target, |
| 363 |
or 'llr' if you want the leftmost of the cohorts to the right of the current target. |
| 364 |
</para> |
| 365 |
<screen> |
| 366 |
(llc (ADJ)) |
| 367 |
</screen> |
| 368 |
</section> |
| 369 |
|
| 370 |
<section id="dep-ct-rightmost"> |
| 371 |
<title>Rightmost</title> |
| 372 |
<indexterm> |
| 373 |
<primary>rr</primary> |
| 374 |
</indexterm> |
| 375 |
<indexterm> |
| 376 |
<primary>rrr</primary> |
| 377 |
</indexterm> |
| 378 |
<indexterm> |
| 379 |
<primary>rrl</primary> |
| 380 |
</indexterm> |
| 381 |
<para> |
| 382 |
The 'rr' option limits the search to the rightmost cohort of the possible matches. |
| 383 |
Note that this cohort may be to the left of the current target; |
| 384 |
use 'rrr' if you want the rightmost of the cohorts to the right of the current target, |
| 385 |
or 'rrl' if you want the rightmost of the cohorts to the left of the current target. |
| 386 |
</para> |
| 387 |
<screen> |
| 388 |
(rrc (ADJ)) |
| 389 |
</screen> |
| 390 |
</section> |
| 391 |
|
| 392 |
<section id="dep-ct-all"> |
| 393 |
<title>All Scan</title> |
| 394 |
<indexterm> |
| 395 |
<primary>ALL</primary> |
| 396 |
</indexterm> |
| 397 |
<para> |
| 398 |
The 'ALL' option will require that all of the relations match the set. |
| 399 |
For example, position 'ALL s' requires that all of the siblings match the set. |
| 400 |
</para> |
| 401 |
<screen> |
| 402 |
(ALL s (ADJ)) |
| 403 |
</screen> |
| 404 |
</section> |
| 405 |
|
| 406 |
<section id="dep-ct-not"> |
| 407 |
<title>None Scan</title> |
| 408 |
<indexterm> |
| 409 |
<primary>NONE</primary> |
| 410 |
</indexterm> |
| 411 |
<para> |
| 412 |
The 'NONE' option will require that none of the relations match the set. |
| 413 |
For example, position 'NONE c' requires that none of the children match the set. |
| 414 |
</para> |
| 415 |
<screen> |
| 416 |
(NONE c (ADJ)) |
| 417 |
</screen> |
| 418 |
</section> |
| 419 |
</section> |
| 420 |
|
| 421 |
</chapter> |