;
; relex-tagging-algs.txt
;
; Perform part-of-speech, tense, noun-number, gender and entity tagging.
; This tagging must be performed before relationship extraction is done.
;
;/////////////////////////////////////////////////////////////////////////////
;
; General remaks about the structure of the files:
;
;  Empty or blank node is shown by "%"
;
;  Regular expression is introduced by "\"
;  In regular expressions, "\." is converted to "[a-z\*]" 
;     (meaning any lower case or the * character)
;     (also meaning that there is no way to represent a "." in a regular expression)
;
;/////////////////////////////////////////////////////////////////////////////
; 
;  Part-of-speech Tagging:
;  categories for Morphy are "noun" "verb" "adj" "adv"
;
;  POS tagging done in two steps:
;  1) coarse/crude tagging, based on word subscripts obtained from
;     link-grammar.
;  2) refined tagging, based on actual links. This typically over-rides
;     the coarse tagging given above.
;
;/////////////////////////////////////////////////////////////////////////////
;
; Step one: coarse/crude POS tagging, based on word subscripts.
;
; adjectives
#TemplateActionAlg
SUBSCR_POS_A
<inflection> = .a
=
<POS> = adj

; Comparative adjectives
#TemplateActionAlg
SUBSCR_POS_A-C
<inflection> = .a-c
=
<POS> = adj
<degree> = comparative

; Superlative adjectives
#TemplateActionAlg
SUBSCR_POS_A-S
<inflection> = .a-s
=
<POS> = adj
<degree> = superlative

; b == both -- male or female given name.
#TemplateActionAlg
SUBSCR_POS_B
<inflection> = .b
=
<POS> = noun
<PERSON-FLAG> = T

; c == currency
#TemplateActionAlg
SUBSCR_POS_C
<inflection> = .c
=
<POS> = noun
<MONEY-FLAG> = T

; e -- adverb
#TemplateActionAlg
SUBSCR_POS_E
<inflection> = .e
=
<POS> = adv
;
; f -- female given name.
; n-f -- common noun, feminine -- e.g. duchess, grandmother, milkmaid, sister, etc
#TemplateActionAlg
SUBSCR_POS_F
<inflection> = .f|.n-f
=
<POS> = noun
<PERSON-FLAG> = T
<GENDER> = feminine
;
; g -- gerund -- tag as noun, for now; if verb, then override later.
#TemplateActionAlg
SUBSCR_POS_G
<inflection> = .g
=
<POS> = noun

; l -- location
#TemplateActionAlg
SUBSCR_POS_L
<inflection> = .l
=
<POS> = noun
<ref location-FLAG> = T

; m -- male given name.
; n-m -- common noun, masculine: e.g. uncle, grandfather, duke, brother.
#TemplateActionAlg
SUBSCR_POS_M
<inflection> = .m|.n-m
=
<POS> = noun
<PERSON-FLAG> = T
<GENDER> = masculine

; n -- plain old common noun
#TemplateActionAlg
SUBSCR_POS_N
<inflection> = .n
=
<POS> = noun

; n-u uncountable (mass) noun
#TemplateActionAlg
SUBSCR_POS_N-U
<inflection> = .n-u
=
<POS> = noun
<num> = uncountable

; o -- organization
#TemplateActionAlg
SUBSCR_POS_O
<inflection> = .o
=
<POS> = noun
<ORGANIZATION-FLAG> = T

; p -- plural count nouns
#TemplateActionAlg
SUBSCR_POS_P
<inflection> = .p
=
<POS> = noun

; q -- ordinary verb (in paraphrasing & question type sentences)
#TemplateActionAlg
SUBSCR_POS_Q
<inflection> = .q
=
<POS> = verb

; q-d -- ordinary verb, past tense
#TemplateActionAlg
SUBSCR_POS_Q-D
<inflection> = .q-d
=
<POS> = verb
<tense val> = past

; s -- singular count nouns
#TemplateActionAlg
SUBSCR_POS_S
<inflection> = .s
=
<POS> = noun

; t -- title or role
; XXX fixme -- to the left or right of title/role is a persons name -- 
#TemplateActionAlg
SUBSCR_POS_T
<inflection> = .t
=
<ROLE-FLAG> = T

; u -- unit of measurement
#TemplateActionAlg
SUBSCR_POS_U
<inflection> = .u
=
<POS> = noun
<MEASURE-FLAG> = T

; v -- ordinary verb
#TemplateActionAlg
SUBSCR_POS_V
<inflection> = .v
=
<POS> = verb

; v-d -- ordinary verb, past tense
#TemplateActionAlg
SUBSCR_POS_V-D
<inflection> = .v-d
=
<POS> = verb
<tense val> = past

; w -- ordinary verb (special cases)
#TemplateActionAlg
SUBSCR_POS_W
<inflection> = .w
=
<POS> = verb

; w-d -- ordinary verb, past tense
#TemplateActionAlg
SUBSCR_POS_W-D
<inflection> = .w-d
=
<POS> = verb
<tense val> = past

; x -- prefix abbreviation e.g. Mr.
#TemplateActionAlg
SUBSCR_POS_X
<inflection> = .x
=
<POS> = abbr

; y -- postfix abbreviation e.g. Ave.
#TemplateActionAlg
SUBSCR_POS_Y
<inflection> = .y
=
<POS> = abbr

;/////////////////////////////////////////////////////////////////////////////
; 
; Step 2: Refined POS tagging based on linkage used.
;
#TemplateActionAlg
POS_VERB
<F_R POS> = WORD
<LAB> = \S\.*|\SF\.*|\SX\.*|\I\.*|\B\.*|\BW\.*|\P\.*|\PP\.*|\Mv\.*|\Mg\.*
=
<F_R POS> = verb
;
#TemplateActionAlg
POS_VERB_INVERTED
<F_L POS> = WORD
<LAB> = \SI\.*|\O\.*|\U\.*|\PP\.*|\SXI\.*|\SFI\.*
=
<F_L POS> = verb
;
;
#TemplateActionAlg
POS_NOUN
<F_L POS> = WORD
<LAB> = \S\.*|\SX\.*|\SF\.*|\AN\.*|\GN\.*|\YS\.* |\YP\.*|Mp|MF
=
<F_L POS> = noun
;
; BI: "That is what the man said" -- tag "what" as noun; it'll get tagged 
; with a pronoun flag later.
;
#TemplateActionAlg
POS_NOUN_INVERTED
<F_R POS> = WORD
<LAB> = \SI\.*|\O\.*|\U\.*|\J\.*|\ON\.*|\IN\.*|\SXI\.*|\JG\.*|\NS\.*|ND|\NM\.*|\BI\.*
=
<F_R POS> = noun
;---------------------------------------------------------------
;
; Closed-list determiners.
; These can be classified as:
; -- Article 
;    ++ definite article "the"
;    ++ indefinite article "a", "an"
; -- Possessive Adjective "my book" "their friends"
; -- Demonstrative Adjective "this book" "those rocks"
; -- Numeric determiner: "two dogs" "the first hour"
; -- Quantifier "some things", "few authors"
;
; See also: list of posessives, gernder, reflexive and anaphora below.
;
; One could argue that the following should be handled:
;    another some any 
;    my our thier her his its
;    no each every certain 
; Currently, most of the above get marked as "adjective", and that is
; arguably more correct. To make up for this, we could add a 
; "determiner-FLAG" to the output, for example, as shown below 
; (in the section that is commented out).
;
#TemplateActionAlg
DETERMINER_POS
<LAB> = \D\.*|\DD\.*|\NS\.*
<F_L str> = a|A|an|An|the|The|This|this|These|these|Those|those|That|that
=
<DETERMINER_LINK_FLAG> = T
<F_L DETERMINER_FLAG> = T
<F_L POS> = det
;
; Tag determiners that are inverested subjects: e.g.
; "Are those the the one we want?"
;
#TemplateActionAlg
DETERMINER_POS_SUBJ
<LAB> = \SI\.*
<F_R str> = this|these|those|that
=
<F_R POS> = det
;
; "The Widget Company" has a DG link to "the", which is missed by rule above.
#TemplateActionAlg
DETERMINER_POS2
<LAB> = \DG\.*
<F_L str> = the|The
=
<DETERMINER_LINK_FLAG> = T
<F_L DETERMINER_FLAG> = T
<F_L POS> = det
;
; The determiner flag gets output as a word-feature.
;
; #TemplateActionAlg
; DETERMINER_FLAG
; <LAB> = \D\.*|\DD\.*|\NS\.*
; =
; <F_L ref determiner-FLAG> = T
;
; ---------------------------------------------------------
;
; Determiners can point at nouns or adjectives:
; "This is the largest".  "largest" should have been tagged as adj by parser.
#TemplateActionAlg
POS_NOUN_DET
<DETERMINER_LINK_FLAG> = T
<F_R POS> = WORD
=
<F_R POS> = noun
;
#TemplateActionAlg
POS_PREP
<LAB> = \J\.*|\ON\.*|\IN\.*|\JG\.*
<F_L POS> = WORD
=
<F_L POS> = prep
;
#TemplateActionAlg
POS_PREP_INVERTED
<LAB> = \Mp\.*|\MVp\.*|\Pp\.*
<F_R POS> = WORD
=
<F_R POS> = prep
;
#TemplateActionAlg
PREP_OBJ_FLAG1
<LAB> = \J\.*|\ON\.*|\IN\.*|\JG\.*
=
<PREP-OBJ-LINK-FLAG> = T
;
#TemplateActionAlg
PREP_OBJ_FLAG2
<PREP-OBJ-LINK-FLAG> = T
=
<F_L PREP-OBJ> = T
;
#TemplateActionAlg
PREP_OBJ_FLAG_INVERSE
<LAB> = \B\.*|\BW\.*
<F_R POS> = prep
=
<F_R PREP-OBJ> = T
;
#TemplateActionAlg
PREP_CLAUSE_OBJ
; States that the prep takes an object when that object is actually a clause
; "I see the building where Joe lives"
<LAB> = \Cs\.*|\WR\.*
<F_L POS> = prep
=
<F_L PREP-OBJ> = T
;
; D == determiner
; DP == possesive determiner
; DT == time-related dterminer (e.g. next, every)
#TemplateActionAlg
POS_ADJ
<LAB> = \A\.*|\AF\.*|\DP\.*|\DT\.*|\D\.*
<F_L PREP-OBJ> = %
<F_L str> != a|A|an|An|the|The|
<F_L DETERMINER_FLAG> != T
=
<F_L POS> = %
<F_L POS> = adj
;
; Treat Pp like an adjective if it takes no object ("I am here.")
; Treat Mp like it identifies adjective to left if "prep" takes 
; no object (in_line: "The man in line is happy.")
; Treat Ma like an adjective, e.g. "appropriate", in
; "It was done in a manner appropriate for the occasion."
; EC: "How much more should we work on this?"
;
#TemplateActionAlg
POS_ADJ_INVERTED
<LAB> = \Pa\.*|\L\.*|\Pp\.*|\Mp\.*|\Ma\.*
<F_R PREP-OBJ> = %
=
<F_R POS> = %
<F_R POS> = adj
;
#TemplateActionAlg
POS_ADJ_INVERTED2
<LAB> = \EC\.*|Ya
<F_R POS> = WORD
=
<F_R POS> = adj
;
; Adverbs: 
; "He plays better" uses MVb link.
; "He hears more" uses the MVm link.
; Question words (WH-words) are typically adverbs
; QI: "I am wondering who to go to the party with."
#TemplateActionAlg
POS_ADV
<LAB> = \MVa\.*|\MVb\.*|\MVm\.*|\EB\.*|\EE\.*|Yt|\QI\.*|H
<F_R POS> = WORD
=
<F_R POS> = adv
;
#TemplateActionAlg
POS_ADV_INVERTED
<LAB> = \E\.*|\EA\.*|\EE\.*|EN|PF|WR
<F_L POS> = WORD
=
<F_L POS> = adv
;
;--------------------------------------------------------
; Oddball cases
;
;
#TemplateActionAlg
POS_WHO_NOUN
<F_R str> = who
=
<F_R POS> = noun
<F_R ref pronoun-FLAG> = T
;
;--------------------------------------------------------
; Identify a conjuction:
;   The word "after" in "He spoke after he ate." (subordinating 
;        conjunction, C link)
;   The word "yet" in "He crossed his heart, yet he lied."  
;        (coordinating conjunction, W link)
;   The word "than" in "He earns more than I expected."
;        (Z link)
#TemplateActionAlg
POS_CONJUNCTION_INVERTED
<LAB> = \C\.*|\W\.*|\Z\.*
<F_L POS> = WORD
=
<F_L POS> = conjunction
;
; Override prep
;   The second "as" in "He earns as much as I expected."
;        (Z link), override prep identification from MV.
; 
#TemplateActionAlg
POS_CONJUNCTION_INVERTED2
<LAB> = \Z\.*
<F_L POS> = prep
=
<F_L POS> = conjunction
;
; Closed-list "fanboys" coordinating conjunctions
#TemplateActionAlg
POS_CONJUNCTION_CLOSED
<str> = for|and|nor|but|or|yet|so|than|either|neither
<POS> = WORD
=
<POS> = conjunction
;
;--------------------------------------------------------
; Identify a particle: 
;   The word "that" in "I heard that you fell."
#TemplateActionAlg
POS_TH_PARTICLE
<LAB> = TH
<F_R POS> = WORD
=
<F_R POS> = particle
;
; Identify a particle: 
;   The word "to" in "I like to read."
; Well, but most people call ths a prep ... 
#TemplateActionAlg
POS_I_PARTICLE
<LAB> = I
<F_L POS> = WORD
=
<F_L POS> = prep
;
; particles to the right of verbs "Jules called out to Jim"
; or nouns: "His job is picking up the trash."
#TemplateActionAlg
POS_K_PARTICLE
<LAB> = K
<F_L POS> = verb|noun
<F_R POS> = WORD
=
<F_R POS> = particle
;
;--------------------------------------------------------
;
; "Is John Barleycorn alive?"  marks the ? as "punctuation"
; "Bling, also know as jewelry, is da bomb." has Xc and Xd.
#TemplateActionAlg
POS_PUNCTUATION
<LAB> = Xc|Xp|Xi|Xe|Xx
<F_R POS> = WORD
=
<F_R POS> = punctuation
;
#TemplateActionAlg
POS_PUNCTUATION2
<LAB> = Xd
<F_L POS> = WORD
=
<F_L POS> = punctuation
;
#TemplateActionAlg
POS_PUNCTUATION3
<str> = .|,|?|;|:|-
<POS> = WORD
=
<POS> = punctuation
;--------------------------------------------------------
; Misc pos tagging
;
; "except" We're in agreement, except for John.
; which might also be identified as a conjunction
#TemplateActionAlg
POS_EXCEPT
<str> = except
<POS> = WORD
=
<POS> = prep
;
; 'to' is almost always a prep.
#TemplateActionAlg
POS_TO
<LAB> = \TO\.*
<F_R POS> = WORD
=
<F_R POS> = prep
;
; 'not' on the right side of an N link
#TemplateActionAlg
POS_NOT
<LAB> = N
<F_R POS> = WORD
=
<F_R POS> = adv
;
; 'how' -- adverb
#TemplateActionAlg
POS_HOW
<LAB> = H|Q
<F_L POS> = WORD
=
<F_L POS> = adv
;
; numerical determiners
#TemplateActionAlg
POS_NUMBER
<LAB> = ND|NN|NIfn
<F_L POS> = WORD
=
<F_L POS> = det
;
#TemplateActionAlg
POS_DATE
<LAB> = TM|TY|NItn
<F_R POS> = WORD
=
<F_R POS> = det
;
; Subordinating conjunctions that the above rules missed
; some phrases that are not tagged ...
; in_case in_case_that in_order_that while only_if now_that even_though even_if whether_or_not
; not_only
#TemplateActionAlg
POS_CONJUNCTION_SUB
<str> = after|because|although|if|before|since|though|unless|when|while|as|whereas|since|until
<POS> = WORD
=
<POS> = conjunction
;
; well, lets tag some of the words in conjunction phrases... 
#TemplateActionAlg
POS_CONJUNCTION_SUB_PHRASE
<str> = not|only
<POS> = WORD
=
<POS> = conjunction
;
#TemplateActionAlg
POS_ONLY
<LAB> = \R\.*
<F_L str> = only|even
<F_L POS> = WORD
=
<F_L POS> = adj
;
#TemplateActionAlg
POS_IT
<str> = it
<POS> = WORD
=
<POS> = noun
;
;/////////////////////////////////////////////////////////////////////////////
;
; PAST-TENSE TENSE
; As of Dec 2008, this is no longer used, as tense tagging is now done
; at graph creation time.
;
; VTAlg flag only set for verbs which are possible past-tense forms
; #TemplateActionAlg
; VTALG1
; ;<F_R POS> = verb
; <lab_R> = S|RS|SFsi|SF
; =
; <F_R VTAlg_flag> = T
; ;
; #TemplateActionAlg
; VTALG2
; ;<F_L POS> = verb
; <lab_L> = SI|SFI|SI*j|SXI
; =
; <F_L VTAlg_flag> = T
; ;
; #TemplateActionAlg
; VTALG3
; <POS> = verb
; <str> = did|didn't|had|hadn't|was|wasn't|were|weren't
; =
; <VTAlg_flag> = T
; ;
; #TemplateActionAlg
; VTALG4
; <LAB> = PP|PPf
; <F_R str> = had|hadn't
; =
; <F_R VTAlg_flag> = F
;
;#VerbTenseAlg
;VERB_TENSE
;<VTAlg_flag> = T
;=
;
;/////////////////////////////////////////////////////////////////////////////
;
; MORPHOLOGY 
; Apply word lemmas before working on tense, so that tense can 
; make use of the root forms.
;
#MorphyAlg
;
; And now, for some lemma corrections...
; "He'd have to go" -> He would have to go"
; 'd ->would -> will-> indicates that "have" is conditional mood
;
; "He'd decided to stay" -> He had decided to stay"
; 'd ->had -> have
;
#TemplateActionAlg
MORPHY_FIX_WOULD
<F_L str> = 'd
<F_L POS> = verb
<LAB> = \I\.*
=
<F_L str> = will
<F_L morph root> = will
<F_L morph type> = verb
;
#TemplateActionAlg
MORPHY_FIX_HAD
<F_L str> = 'd
<F_L POS> = verb
<LAB> = \PP\.*
=
<F_L str> = have
<F_L morph root> = have
<F_L morph type> = verb
;
#TemplateActionAlg
MORPHY_FIX_WILL
<F_L str> = 'll
<F_L POS> = verb
<LAB> = \I\.*
=
<F_L str> = will
<F_L morph root> = will
<F_L morph type> = verb
;
;/////////////////////////////////////////////////////////////////////////////
;
; MODAL TENSE
;
; Done after morphology so that algorithms can match to word root forms
;
;
; PP links identify past participles, in perfect aspect
; Pv links identify past participles, in passive voice
#TemplateActionAlg
TENSE_PERFECT
<LAB>=\PP\.*
=
<TENSE-LINK-FLAG> = T
<F_R tense val> = perfect
<F_R tense prev> = <F_L tense>
;
#TemplateActionAlg
TENSE_PARTICIPLE
<LAB>=\Pv\.*
=
<TENSE-LINK-FLAG> = T
<F_R tense val> = passive
<F_R tense prev> = <F_L tense>
;
#TemplateActionAlg
TENSE_DO
<LAB>=\I\.d\.*
=
<TENSE-LINK-FLAG> = T
<F_R tense val> = none
<F_R tense prev> = <F_L tense>
;
#TemplateActionAlg
TENSE_COPULA
; Pp is not used if it takes a complement, so that copula is still explicit 
; in "John is in the park."
; But "John is here." treats "here" like a predicative adjective
<LAB> = \Pa\.*|\Pv\.*|\Pg\.*|\Pp\.*
<F_L PREP-OBJ> = %
<F_L str> = be
=
<TENSE-LINK-FLAG> = T
<F_R tense prev> = <F_L tense>
;
#TemplateActionAlg
TENSE_COPULA_INV
<LAB> = \AF\.*
<F_R str> = be
=
<INV-TENSE-LINK-FLAG> = T
<F_L tense prev> = <F_R tense>
;
; The place holder prevents "will" from having empty tense.
; Without that, the next verb might be affected by TENSE-LIST-CONNECT1, 
; which would incorrectly set the following verb's prev feature to itself.
#TemplateActionAlg
TENSE_FUTURE
<LAB>=\I\.*
<F_L str> = will|Will|won't|Won't|shall|Shall|shan't|Shan't|'ll|should|Should|shouldn't|Shouldn't|can|Can|can't|Can't|cannot|Cannot|may|May|mayn't|Mayn't|must|Must|mustn't|Mustn't
=
<TENSE-LINK-FLAG> = T
<F_R tense prev> = <F_L tense>
<F_R tense val> = future
<F_L tense PLACE-HOLDER> = T
;
#TemplateActionAlg
TENSE_INFINITIVE
<LAB>=\I\.*
<F_L str> != will|Will|won't|Won't|shall|Shall|shan't|Shan't|'ll|should|Should|shouldn't|Shouldn't|can|Can|can't|Can't|cannot|Cannot|may|May|mayn't|Mayn't|must|Must|mustn't|Mustn't
=
<F_R tense val> = infinitive
;
#TemplateActionAlg
TENSE_PROGRESSIVE
<LAB>=\Pg\.*
<F_L str> = be
=
<F_R tense val> = progressive
;
#TemplateActionAlg
TENSE_PASSIVE_PARTICIPLE
; This prevents tense from being set to present; the correct tense 
; should be "past" in most(?) all(?) cases.
<LAB>=\Mv\.*
<F_L str> != be
=
<F_R tense val> = passive
;
;
#TemplateActionAlg
INV-TENSE_NOTENSE
; This prevents tense from being set to present.
<LAB>=\AF\.*
<F_R str> != be
=
<F_L tense val> = none
;
#TemplateActionAlg
TENSE_PROGRESSIVE2
; This prevents tense from being set to present.
<LAB>=\Pg\.*|\Mg\.*
<F_L str> != be
=
<F_R tense val> = progressive
;
#TemplateActionAlg
BLANK_TENSE
<LAB>=\Pv\.*|\Pp\.*
=
<F_R BLANK-TENSE-FLAG> = T
;
#TemplateActionAlg
TENSE_PRESENT
; For verbs that are not identified with future or passive, set tense to present.
<POS> = verb
<str> != will|Will|won't|Won't|shall|Shall|shan't|Shan't|'ll
<BLANK-TENSE-FLAG> = %
<tense val> = %
=
<tense val> = present
;
#TemplateActionAlg
TENSE_IMPERATIVE
; Can overrule TENSE_PRESENT
<LAB> = \Wi\.*
=
<F_R tense val> = imperative
<F_R POS> = verb
;
; post-tense morphology cleanup: If the orig verb string is "saw" 
; and the tense is "past", then we are seeing with eyes, not 
; sawing with a saw.
#TemplateActionAlg
SEE_SAW
<tense val> = past
<orig_str> = saw
=
<str> = see
;
;/////////////////////////////////////////////////////////////////////////////
;
; BASIC REFERENCE
;
;
#TemplateActionAlg
BASIC_REF
<str> = $string
=
<ref name> = <str>
<ref nameSource> = <this>
;
;
;/////////////////////////////////////////////////////////////////////////////
;
; ENTITY PROCESSING
;
; If there was no pre-parse entity processor, then use the link-grammar
; output for identifying entities. These will have G links to the left.
;
#WordSequenceCombineAlg
PROPER_NAME_AND_ENTITIES_AND_IDIOMS
<LAB> = \G\.*|\ID[A-Z]*[a-z]*
<F_R> = $right
=
;
; Fix up entities and idioms -- 
; Necessary because the WordSequenceCombineAlg changes replaces <str> 
; with a new node
;
#TemplateActionAlg
PROPER_NAME_AND_ENTITIES_AND_IDIOMS_CORRECTION
<LAB> = \G\.*|\ID[A-Z]*[a-z]*
=
<F_R ref name> = %
<F_R ref name> = <F_R str>
;
; The above entity mangling sometimes leaves behind empty, non-null strings.
; Kill these here, explicitly -- replace them with nulls.
#TemplateActionAlg
MERGED_EMPTY_STRING_ELIMINATION
<LAB> = \G\.*|\ID[A-Z]*[a-z]*
<F_L str> = %
=
<F_L str> = %
;
; ---------------
; The LOCATION-FLAG, etc. are set by the entity detection code.
; the following rules copy them to the ref, where they will 
; appear in the relex output.
;
; Make sure that str is not null, as the G-link merging above will
; wipe some of these out. We want to promote to ref only those that
; have a completly merged entity name.
;
#TemplateActionAlg
ENTITY-LOCATION
<LOCATION-FLAG> = T
<str> != %
=
<ref location-FLAG> = T
;
#TemplateActionAlg
ENTITY-MEASURE
<MEASURE-FLAG> = T
<str> != %
=
<ref measure-FLAG> = T
;
#TemplateActionAlg
ENTITY-ORGANIZATION
<ORGANIZATION-FLAG> = T
<str> != %
=
<ref organization-FLAG> = T
;
#TemplateActionAlg
ENTITY-PERSON
<PERSON-FLAG> = T
<str> != %
=
<ref person-FLAG> = T
;
#TemplateActionAlg
ENTITY-DATE
<DATE-FLAG> = T
<str> != %
=
<ref date-FLAG> = T
;
#TemplateActionAlg
ENTITY-MONEY
<MONEY-FLAG> = T
<str> != %
=
<ref money-FLAG> = T
;
#TemplateActionAlg
ENTITY-EMOTICON
<EMOTICON-FLAG> = T
<str> != %
=
<ref emoticon-FLAG> = T
;
#TemplateActionAlg
INFLECTION_TAG
<inflection> != %
=
<ref inflection-TAG> = <inflection>
;
#TemplateActionAlg
LABEL_IDIOMS
<LAB> = \ID[A-Z]*[a-z]*
=
<F_R ref idiom-FLAG> = T
;
; Entities need to be identified as nouns, so that later
; relex rules, which look for nouns, treat them appropriately.
;
; As of Dec 2008, the ENTITY-FLAG is set at the graph creation time.
;
#TemplateActionAlg
ENTITY_IS_NOUN
<ENTITY-FLAG> = T
=
<POS> = %
<POS> = noun
;
#TemplateActionAlg
PROPER_NAME_POS_CORRECTION
<LAB> = \G\.*
=
<F_R POS> = %
<F_R POS> = noun
;
; G link are entities identified by link-grammar, that the 
; entity detector may have missed. Tag these as entities, of some
; unspecified type.
;
#TemplateActionAlg
LG_ENTITES
<LAB> = \G\.*
=
<F_R ref entity-FLAG> = T
;
#TemplateActionAlg
DEFINITE_NAMES
<LAB> = \G\.*
=
<F_R ref definite-FLAG> = T
;
; Entities are definite.
;
#TemplateActionAlg
DEFINITE_ENTITIES
<ENTITY-FLAG> = T
=
<ref definite-FLAG> = T
;
; Dates, appearing in IN links, e.g. "in the 1940's"
#TemplateActionAlg
IN_DATES
<LAB> = IN
=
<F_R ref date-FLAG> = T
;
#TemplateActionAlg
DATE_HEAD
<LAB> = TM|TY
=
<F_L ref date-FLAG> = T

;
; Time: It lasted five years
#TemplateActionAlg
TIME_EXP
<LAB> = OT|TQ
=
<F_R ref time-FLAG> = T
;
#TemplateActionAlg
TIME_EXP2
<LAB> = BT
=
<F_L ref time-FLAG> = T
;
#TemplateActionAlg
DISTANCE_EXP
<LAB> = OD
=
<F_R ref distance-FLAG> = T
;
; -------------------------------------------
; Combine particles and other things.
; For example, "Please go away" creates the polyword "go_away".
; Note that part of speech is still identified as "verb", which 
; in this case should be taken to mean "phrasal verb".
;
#TwoWordCombineToLeftAlg
COMBINE_PARTICLES
<LAB> = K
=
;
#TemplateActionAlg
POLYWORD_PARTICLES
<LAB> = K
=
<F_L ref polyword-FLAG> = T
;
; "He ate as many as I did"  combines into "as_many"
;
#TwoWordCombineToRightAlg
COMBINE_AS_MANY
<LAB> = AM
=
;
#TemplateActionAlg
POLYWORD_AS_MANY
<LAB> = AM
=
<F_R ref polyword-FLAG> = T
;
; "How much does the book cost?" combines "how_much"
;
#TwoWordCombineToRightAlg
COMBINE_HOW_MUCH
<LAB> = H
=
;
#TemplateActionAlg
POLYWORD_HOW_MUCH
<LAB> = H
=
<F_R ref polyword-FLAG> = T
;
; -------------------------------------------
;
#TemplateActionAlg
DEFINITE_DETERMINED
<LAB> = \D\.*
<F_L orig_str> = the|The|This|this|These|these|Those|those|That|that|'s|his|His|her|Her|their|Their|my|My|our|Our|your|Your
=
<F_R ref definite-FLAG> = T
;
#TemplateActionAlg
DEFINITE_NUMBERED1
<LAB> = \DD\.*
=
<F_R DD-FLAG> = T
;
#TemplateActionAlg
DEFINITE_NUMBERED1
<LAB> = \D\.*
<F_L DD-FLAG> = T
=
<F_R ref definite-FLAG> = T
;
; -----------------------------------------------------------
;
#TemplateActionAlg
QUESTION1
<LAB> = \W[sq]\.*|\Jw\.*
<F_R str> = who|Who|whom|Whom
=
<F_R ref QUERY-TYPE> = who
<F_R ref name> = %
<F_R ref name> = _$qVar
<F_R ref nameSource> = %
<F_R ref nameSource> = <F_R>
;
#TemplateActionAlg
QUESTION1
<LAB> = \W[sq]\.*|\Jw\.*
<F_R str> = what|What
=
<F_R ref QUERY-TYPE> = what
<F_R ref name> = %
<F_R ref name> = _$qVar
<F_R ref nameSource> = %
<F_R ref nameSource> = <F_R>
;
#TemplateActionAlg
QUESTION1
<LAB> = \W[sq]\.*|\Jw\.*
<F_R str> = which|Which
=
<F_R ref QUERY-TYPE> = which
<F_R ref name> = %
<F_R ref name> = _$qVar
<F_R ref nameSource> = %
<F_R ref nameSource> = <F_R>
;
;
;//////////////////////////////////////////////////////////////////////
;
; RELATIVE REFERENCE (who, which, whom, that)
;
; The rules below mainly serve to drop the relative-reference pronouns
; from the output, since thier referents are immediately resolved. So,
; for example, "The dog, who barked,...", its clear that "who" refers 
; to "dog"; this is explicit in the parse, and so "who" plays no role
; in the relex output. 
;
#TemplateActionAlg
SET_RS_FLAG
; Puts a flag in a node to indicate that it has an RS link
<LAB> = \RS\.*
=
<F_R RS-FLAG> = T
;
#TemplateActionAlg
RELATIVE_REF1
<LAB> = \R\.*
<F_R RS-FLAG> = T
;The dog who barked, ... (no comma between 'dog' and 'barked')
=
<F_R ref> = %
;
#TemplateActionAlg
RELATIVE_REF2
<LAB> = \R\.*
<F_R RS-FLAG> = T
;The dog who barked, ... (no comma between 'dog' and 'barked')
=
<F_R ref> += <F_L ref>
;
#TemplateActionAlg
RELATIVE_REF1
<LAB> = \MX.r\.*
;The dog, who barked, ...
=
<F_R ref> = %
;
#TemplateActionAlg
RELATIVE_REF2
<LAB> = \MX.r\.*
;The dog, who barked, ...
=
<F_R ref> += <F_L ref>
;
#TemplateActionAlg
PREP_RELATIVE_REF1
<LAB> = \Jw\.*
;The man, of whom I know, ...
=
<F_L RELATIVE-REF-LOC> = <F_R>
;
#TemplateActionAlg
PREP_RELATIVE_REF2
<LAB> = \MX.j\.*|\Mj\.*
<F_R RELATIVE-REF-LOC> != %
;The man, of whom I know, ...
=
<F_R RELATIVE-REF-LOC ref> = %
;
#TemplateActionAlg
PREP_RELATIVE_REF3
<LAB> = \MX.j\.*|\Mj\.*
<F_R RELATIVE-REF-LOC> != %
;The man, of whom I know, ...
=
<F_R RELATIVE-REF-LOC ref> += <F_L ref>
;
;/////////////////////////////////////////////////////////////////////////////
;
; NOUN NUMBER
; Determiners (D links) get priority to identify noun number.
; Then S and O links can identify as singular or plural.  However,
; if an S or O link identifies the noun as singular, but it has no
; determiner, then it is "uncountable"  
;
; Test sentences
; Kim eats butter and those deer at Tuesdays.
; Deer eat mice.
;
;
#TemplateActionAlg
ENTITY_SINGULAR
<ENTITY-FLAG> = T
=
<num> = %
<num> = singular
;
; Hmmm. This rule assumes that the wordnet lemmatization is more
; accurate than the parse.. and this is probably not true. Maybe
; we should steer the lemmatization based on the parse!?
#TemplateActionAlg
LEMMA_NOUN_NUMBER
<POS> = noun
<str> != <orig_str>
<num> = %
=
<num> = plural
;
#TemplateActionAlg
SINGULAR_DET
<LAB>=\Ds\.*
<F_R num> = %
=
<F_R num> = singular
;
#TemplateActionAlg
PLURAL_DET
<LAB>=\Dmc\.*
<F_R num> = %
=
<F_R num> = plural
;
#TemplateActionAlg
UNCOUNTABLE_DET
<LAB>=\Dmu\.*
<F_R num> = %
=
<F_R num> = uncountable
;
#TemplateActionAlg
DET-FLAG
<LAB> = \D\.*|\DG\.*
=
<F_R DET-FLAG> = T
;
#TemplateActionAlg
SINGULAR_OBJ
<LAB> = \Os\.*|Us\.*
<F_R DET-FLAG> = T
<F_R num> = %
=
<F_R num> = singular
;
; XXX as of link-grammar 4.6.5, Os should never be used with
; uncountable objects; it should always be Ou.
#TemplateActionAlg
UNCOUNTABLE_OBJ
<LAB> = \Ou\.*|\Os\.*|\Us\.*
<F_R DET-FLAG> != T
<F_R num> = %
=
<F_R num> = uncountable
;
#TemplateActionAlg
PLURAL_OBJ
<LAB> = \Op\.*|\Up\.*
<F_R num> = %
=
<F_R num> = plural
;
#TemplateActionAlg
SINGULAR_SUBJ
<LAB> = \Ss\.*
<F_L DET-FLAG> = T
<F_L num> = %
=
<F_L num> = singular
;
#TemplateActionAlg
SINGULAR_SUBJ_INV
<LAB> = \SIs\.*
<F_R DET-FLAG> = T
<F_R num> = %
=
<F_R num> = singular
;
#TemplateActionAlg
UNCOUNTABLE_SUBJ
<LAB> = \Ss\.*
<F_L DET-FLAG> != T
<F_L num> = %
=
<F_L num> = uncountable
;
#TemplateActionAlg
UNCOUNTABLE_SUBJ_INV
<LAB> = \SIs\.*
<F_R DET-FLAG> != T
<F_R num> = %
=
<F_R num> = uncountable
;
#TemplateActionAlg
PLURAL_SUBJ
<LAB> = \Sp\.*
<F_L num> = %
<F_L str> != i|I|you|You
=
<F_L num> = plural
;
#TemplateActionAlg
PLURAL_SUBJ
<LAB> = \SIp\.*
<F_R num> = %
<F_R str> != i|I|you|You
=
<F_R num> = plural
;
#TemplateActionAlg
SINGULAR_PRONOUNS
<str> = I|i|Me|me|Myself|myself|He|he|She|she|Him|him|Her|her|Himself|himself|Herself|herself
=
<num> = singular
<ref definite-FLAG>=T
;
#TemplateActionAlg
PLURAL_PRONOUNS
<str> = We|we|Us|us|Them|them|Ourselves|ourselves|Themselves|themselves
=
<num> = plural
<ref definite-FLAG>=T
;
; "it" is definite, but can be singular or uncountable (but not plural).
; (It was hot coffee. It was a book.)
;
#TemplateActionAlg
IT_IS_DEFINITE
<str> = It|it
=
<num> = %
<ref definite-FLAG>=T
;
#TemplateActionAlg
NUM_TO_REF
<num> != %
<ref noun_number> = %
=
<ref noun_number> = <num>
;
;/////////////////////////////////////////////////////////////////////////////
;
; PRONOUN IDENTIFICATION
; Needed for Anaphora resolution
; Perhaps this info could be obtained from the link grammar parser,
; but it seems easier to just make an exhaustive list.
;
#TemplateActionAlg
IDENTIFY_POSSESSIVE
<orig_str> = his|His|her|Her|hers|Hers|their|Their|theirs|Theirs|my|My|mine|Mine|our|Our|ours|Ours|your|Your|yours|Yours|thy|Thy|thine|Thine
=
<POSSESSIVE-FLAG> = T
;
#TemplateActionAlg
TAG_PRONOUNS
<str> = I|i|Me|me|We|we|Us|us|You|you|He|he|Him|him|It|it|She|she|Them|them|They|they|who|Who|whoever|whom|whomever
=
<ref pronoun-FLAG> = T
; <ref ANAPHORA-FLAG> = T
;
; We don't (currently) put a possesive tag on these pronouns; instead,
; we use a later rule to determine what is being possesed; e.g "your
; singing is ugly", which generates _poss(singing, your)
;
#TemplateActionAlg
TAG_PRONOUNS_POSS
<str> = my|My|mine|Mine|our|Our|ours|Ours|your|Your|yours|Yours|Her|her|Hers|hers|His|his|Its|its|their|Their|thiers|Thiers|whose|Whose
=
<ref pronoun-FLAG> = T
; <ref ANAPHORA-FLAG> = T
;
#TemplateActionAlg
TAG_REFLEXIVE_PRONOUNS
<str> = Myself|myself|Ourselves|ourselves|yourself|Yourself|yourselves|ourselves|Himself|himself|Itself|itself|Herself|herself|Themselves|themselves
=
<ref pronoun-FLAG> = T
; <ref ANAPHORA-FLAG> = T
<ref REFLEXIVE-FLAG> = T
;
; Tag these as anaphora *only* if they are already tagged as nouns;
; as otherwise, many of these can be adjectives, interjections.
;
; XXX This is wrong, need to be more careful here, tagging only things
; appropriate per syntax: e.g. "Are those the ones?" -- tag "those"
; because its subject.
;
#TemplateActionAlg
TAG_PRONOUNS_WH
<str> = all|another|any|anybody|anyone|anything|both|each|eachother|either|everybody|everyone|everything|few|little|many|more|most|much|neither|no_one|nobody|none|nothing|one|one_another|other|others|several|some|somebody|someone|something|that|these|this|those|what|whatever|whenever|which|whichever
<POS> = noun
=
<ref pronoun-FLAG> = T
; <ref ANAPHORA-FLAG> = T
;
;
;/////////////////////////////////////////////////////////////////////////////
;
; GENDER IDENTIFICATION
; Needed for Anaphora resolution
;
#TemplateActionAlg
MALE_PRONOUNS
<str> = He|he|Him|him|Himself|himself|His|his
=
<gend> = masculine
;
#TemplateActionAlg
FEMALE_PRONOUNS
<str> = She|she|Her|her|Hers|hers|Herself|herself
=
<gend> = feminine
;
; Sex is unknown, but personal pronouns cannot refer to inanimate objects.
#TemplateActionAlg
PERSON_PRONOUNS
<str> = I|me|Me|We|we|Us|us|You|you|Them|them|They|they|Myself|myself|Ourselves|ourselves|Themselves|themselves|anybody|anyone|everybody|everyone|no_one|nobody|somebody|someone|whose|whomever|self|ownself|thee|thou|thyself
=
<gend> = person
;
#TemplateActionAlg
NEUTER_PRONOUNS
<str> = It|it|Its|its|Itself|itself
=
<gend> = neuter
;
; person == not neuter == masc or fem
; i.e. even if we don't know sex, at least we know its a human.
#TemplateActionAlg
PERSON_HAS_GENDER
<PERSON-FLAG> = T
<gend> = %
=
<gend> = person
;
#TemplateActionAlg
ENTITY_GENDER
<GENDER> != %
=
<gend> = %
<gend> = <GENDER>
;
#TemplateActionAlg
GENDER_TO_REF
<gend> != %
=
<ref gender> = %
<ref gender> = <gend>
;
;
;/////////////////////////////////////////////////////////////////////////////
; Misc promotion
;
#TemplateActionAlg
DEGREE_TO_REF
<degree> != %
=
<ref degree> = <degree>

;/////////////////////////////////////////////////////////////////////////////
;/////////////////////////////// END OF FILE /////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////
