Chapter 23. FAQ & Tips & Tricks

Table of Contents

FAQ
How far will a (*-1C A) test scan?
How can I match the tag * from my input?
Tricks
Determining whether a cohort has (un)ambiguous base forms
Attach all cohorts without a parent to the root
Use multiple cohorts as a barrier
Add a delimiting cohort

FAQ

How far will a (*-1C A) test scan?

The CG-2 spec dictates that for a test (*-1C A): "There is a cohort to the left containing a reading which has a tag belonging to the set A. The first such cohort must have a tag belonging to the set A in all its readings." ...meaning scanning stops at the first A regardless of whether it is carefully A. To scan further than the first A you must use **.

VISLCG2 was not compliant with that and would scan until it found a "careful A". This caused the need for ugly hacks such as (*1C A BARRIER A) to emulate the correct behavior.

See this reference thread.

How can I match the tag * from my input?

You can't. The single * symbol is reserved for many special meanings in CG-3. I suggest replacing it with ** or <*> or anything that isn't a single * if you need to work with it in CG.

Tricks

Determining whether a cohort has (un)ambiguous base forms

If you for whatever reason need to determine whether a cohort has readings with (un)ambiguous base forms, the following is how:

        LIST bform = ".*"r ;
        
        # Determines ambiguous base forms
        ADD (@baseform-diff) $$bform (0 (*) - $$bform) ;
        
        # ...so NEGATE to determine unambigious base forms
        ADD (@baseform-same) $$bform (NEGATE 0 (*) - $$bform) ;
      

Attach all cohorts without a parent to the root

A final cleanup step of many dependency grammars is to attach anything that was not assigned a parent to the root of the window. This can be done easily with:

        # For all cohorts that has no parent, attach to 0th cohort
        SETPARENT (*) (NEGATE p (*)) TO (@0 (*)) ;
      

Use multiple cohorts as a barrier

The BARRIER and CBARRIER behavior may only refer to a single cohort, but often you want to stop because of a condition expressed in multiple cohorts. This can be solved in a flat manner via MAP, ADD, or SUBSTITUTE.

        ADD (¤list) Noun (1 Comma) ;
        SELECT Noun (-1* Adj BARRIER (¤list)) ;
      

Add a delimiting cohort

ADDCOHORT can be used to add any type of cohort, including delimiter ones. But it will not automatically delimit the window at such a cohort, so you need to add a DELIMIT rule after if that is your intended outcome. Just be mindful that DELIMIT will restart the grammar, so ADDCOHORT may fire again causing an endless loop; break it by conditioning ADDCOHORT, such as

        ADDCOHORT ("§") AFTER (@title-end) IF (NOT 1 (<<<)) ;
        DELIMIT _S_DELIMITERS_ ; # Use the magic set that contains what DELIMITERS defined