| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!DOCTYPE chapter SYSTEM "docbook-dtd-45/docbookx.dtd"> |
| 3 |
|
| 4 |
<chapter id="parentheses"> |
| 5 |
<title>Parenthesis Enclosures</title> |
| 6 |
|
| 7 |
<para> |
| 8 |
A new feature in CG-3 is handling of enclosures by defining pairs of parentheses. |
| 9 |
Any enclosure found will be omitted from the window on first run, then put back in the window and all rules |
| 10 |
are re-run on the new larger window. This continues until all enclosures have been put back one-by-one. |
| 11 |
</para> |
| 12 |
<para> |
| 13 |
The idea is that by omitting the enclosures their noise cannot disrupt disambiguation, thus providing |
| 14 |
an easy way to write clean grammars that do not have to have special tests for parentheses all over the place. |
| 15 |
</para> |
| 16 |
|
| 17 |
<section id="parentheses-example"> |
| 18 |
<title>Example</title> |
| 19 |
<para> |
| 20 |
Example is adapted from the ./test/T_Parentheses/ regression test. |
| 21 |
</para> |
| 22 |
|
| 23 |
<para> |
| 24 |
Given the following sentence: |
| 25 |
</para> |
| 26 |
<screen> |
| 27 |
There once were (two [three] long red (more like maroon (dark earthy red]), actually) cars {trucks}. |
| 28 |
</screen> |
| 29 |
<para> |
| 30 |
...and given the following parenthesis wordform pairs: |
| 31 |
</para> |
| 32 |
<screen> |
| 33 |
PARENTHESES = ("<(>" "<)>") ("<[>" "<]>") ("<{>" "<}>") ; |
| 34 |
</screen> |
| 35 |
<para> |
| 36 |
...results in the sentence being run in the order of: |
| 37 |
</para> |
| 38 |
<screen> |
| 39 |
1: There once were (two long red cars. |
| 40 |
2: There once were (two [three] long red cars. |
| 41 |
3: There once were (two [three] long red (more like maroon, actually) cars. |
| 42 |
4: There once were (two [three] long red (more like maroon (dark earthy red]), actually) cars. |
| 43 |
5: There once were (two [three] long red (more like maroon (dark earthy red]), actually) cars {trucks}. |
| 44 |
</screen> |
| 45 |
<para> |
| 46 |
The example has 2 unmatched parenthesis in the words (two and red] which are left in untouched as they |
| 47 |
are not really enclosing anything. |
| 48 |
</para> |
| 49 |
|
| 50 |
<para> |
| 51 |
Note that enclosures are put back in the window left-to-right and only one at the time. |
| 52 |
The depth of enclosure has no effect on the order of resurrection. |
| 53 |
This may seem unintuitive, but it was the most efficient way of handling it. |
| 54 |
</para> |
| 55 |
<para> |
| 56 |
Also of note is that all rules in all sections will be re-run each time an enclosure is resurrected. |
| 57 |
This includes BEFORE-SECTIONS and AFTER-SECTIONS. So in the above example, all of those are run 5 times. |
| 58 |
</para> |
| 59 |
</section> |
| 60 |
|
| 61 |
<section id="parentheses-pos-left"> |
| 62 |
<title>Contextual Position L</title> |
| 63 |
<para> |
| 64 |
In a contextual test you can jump to the leftward parenthesis of the currently active enclosure |
| 65 |
with the L position. It is only valid from within the enclosure. |
| 66 |
</para> |
| 67 |
<screen> |
| 68 |
(L (*) LINK 1* (V) BARRIER _RIGHT_) |
| 69 |
</screen> |
| 70 |
</section> |
| 71 |
|
| 72 |
<section id="parentheses-pos-right"> |
| 73 |
<title>Contextual Position R</title> |
| 74 |
<para> |
| 75 |
In a contextual test you can jump to the rightward parenthesis of the currently active enclosure |
| 76 |
with the R position. It is only valid from within the enclosure. |
| 77 |
</para> |
| 78 |
<screen> |
| 79 |
(R (*) LINK -1* (V) BARRIER _LEFT_) |
| 80 |
</screen> |
| 81 |
</section> |
| 82 |
|
| 83 |
<section id="parentheses-tag-left"> |
| 84 |
<title>Magic Tag _LEFT_</title> |
| 85 |
<para> |
| 86 |
A magic tag that represents the active enclosure's leftward parenthesis wordform. |
| 87 |
This tag is only valid when an enclosure is active and only exactly on the leftward parenthesis cohort. |
| 88 |
Useful for preventing scanning tests from crossing it with a barrier. |
| 89 |
</para> |
| 90 |
</section> |
| 91 |
|
| 92 |
<section id="parentheses-tag-right"> |
| 93 |
<title>Magic Tag _RIGHT_</title> |
| 94 |
<para> |
| 95 |
A magic tag that represents the active enclosure's rightward parenthesis wordform. |
| 96 |
This tag is only valid when an enclosure is active and only exactly on the rightward parenthesis cohort. |
| 97 |
Useful for preventing scanning tests from crossing it with a barrier. |
| 98 |
</para> |
| 99 |
</section> |
| 100 |
|
| 101 |
<section id="parentheses-tag-encl"> |
| 102 |
<title>Magic Tag _ENCL_</title> |
| 103 |
<para> |
| 104 |
This tag is only valid when an enclosure is hidden away and only on cohorts that own hidden cohorts. |
| 105 |
Useful for preventing scanning tests from crossing hidden enclosures with a barrier. |
| 106 |
</para> |
| 107 |
</section> |
| 108 |
|
| 109 |
<section id="parentheses-set-left"> |
| 110 |
<title>Magic Set _LEFT_</title> |
| 111 |
<para> |
| 112 |
A magic set containing the single tag (_LEFT_). |
| 113 |
</para> |
| 114 |
</section> |
| 115 |
|
| 116 |
<section id="parentheses-set-right"> |
| 117 |
<title>Magic Set _RIGHT_</title> |
| 118 |
<para> |
| 119 |
A magic set containing the single tag (_RIGHT_). |
| 120 |
</para> |
| 121 |
</section> |
| 122 |
|
| 123 |
<section id="parentheses-set-encl"> |
| 124 |
<title>Magic Set _ENCL_</title> |
| 125 |
<para> |
| 126 |
A magic set containing the single tag (_ENCL_). |
| 127 |
</para> |
| 128 |
</section> |
| 129 |
|
| 130 |
<section id="parentheses-set-paren"> |
| 131 |
<title>Magic Set _PAREN_</title> |
| 132 |
<para> |
| 133 |
A magic set defined as _LEFT_ OR _RIGHT_. |
| 134 |
</para> |
| 135 |
</section> |
| 136 |
|
| 137 |
</chapter> |