Debian Codegraph @

manual/faq.xml

raw
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE chapter SYSTEM "docbook-dtd-45/docbookx.dtd">
3
4 <chapter id="faq">
5 <title>FAQ &amp; Tips &amp; Tricks</title>
6
7 <section id="faq-faq">
8 <title>FAQ</title>
9
10 <section id="faq-careful-scan">
11 <title>How far will a <code>(*-1C A)</code> test scan?</title>
12
13 <para>
14 The CG-2 spec dictates that for a test <code>(*-1C A)</code>:
15 "There is a cohort to the left containing a reading which has a tag belonging to the set A.
16 The <emphasis>first such cohort</emphasis> must have a tag belonging to the set A in all its readings."
17 ...meaning scanning stops at the first A regardless of whether it is carefully A.
18 To scan further than the first A you must use **.
19 </para>
20 <para>
21 VISLCG2 was not compliant with that and would scan until it found a "careful A".
22 This caused the need for ugly hacks such as <code>(*1C A BARRIER A)</code> to emulate the correct behavior.
23 </para>
24 <para>
25 See <ulink url="http://groups.google.com/group/constraint-grammar/browse_thread/thread/45a00e1ea99bc4ad">this reference thread</ulink>.
26 </para>
27 </section>
28
29 <section id="faq-matching-asterisk">
30 <title>How can I match the tag <code>*</code> from my input?</title>
31
32 <para>
33 You can't. The single <code>*</code> symbol is reserved for many special meanings in CG-3.
34 I suggest replacing it with <code>**</code> or <code>&lt;*&gt;</code> or anything that isn't
35 a single <code>*</code> if you need to work with it in CG.
36 </para>
37 </section>
38 </section>
39
40 <!-- section id="faq-tips">
41 <title>Tips</title>
42
43 <section id="faq-tips-TODO">
44 <title>Tips TODO</title>
45 </section>
46 </section -->
47
48 <section id="faq-tricks">
49 <title>Tricks</title>
50
51 <section id="faq-multi-base-forms">
52 <title>Determining whether a cohort has (un)ambiguous base forms</title>
53
54 <para>
55 If you for whatever reason need to determine whether a cohort has readings with (un)ambiguous base forms,
56 the following is how:
57 </para>
58 <screen>
59 LIST bform = ".*"r ;
60
61 # Determines ambiguous base forms
62 ADD (@baseform-diff) $$bform (0 (*) - $$bform) ;
63
64 # ...so NEGATE to determine unambigious base forms
65 ADD (@baseform-same) $$bform (NEGATE 0 (*) - $$bform) ;
66 </screen>
67 </section>
68
69 <section id="faq-default-parent-root">
70 <title>Attach all cohorts without a parent to the root</title>
71
72 <para>
73 A final cleanup step of many dependency grammars is to attach anything that was not assigned a parent to the
74 root of the window. This can be done easily with:
75 </para>
76 <screen>
77 # For all cohorts that has no parent, attach to 0th cohort
78 SETPARENT (*) (NEGATE p (*)) TO (@0 (*)) ;
79 </screen>
80 </section>
81
82 <section id="faq-barrier-multiple-cohorts">
83 <title>Use multiple cohorts as a barrier</title>
84
85 <para>
86 The BARRIER and CBARRIER behavior may only refer to a single cohort, but often you want to stop because of
87 a condition expressed in multiple cohorts. This can be solved in a flat manner via MAP, ADD, or SUBSTITUTE.
88 </para>
89 <screen>
90 ADD (¤list) Noun (1 Comma) ;
91 SELECT Noun (-1* Adj BARRIER (¤list)) ;
92 </screen>
93 </section>
94
95 <section id="faq-add-delimiter-cohort">
96 <title>Add a delimiting cohort</title>
97
98 <para>
99 ADDCOHORT can be used to add any type of cohort, including delimiter ones. But it will not automatically delimit
100 the window at such a cohort, so you need to add a DELIMIT rule after if that is your intended outcome.
101 Just be mindful that DELIMIT will restart the grammar, so ADDCOHORT may fire again causing an endless loop;
102 break it by conditioning ADDCOHORT, such as
103 </para>
104 <screen>
105 ADDCOHORT ("§") AFTER (@title-end) IF (NOT 1 (&lt;&lt;&lt;)) ;
106 DELIMIT _S_DELIMITERS_ ; # Use the magic set that contains what DELIMITERS defined
107 </screen>
108 </section>
109 </section>
110
111 </chapter>