#----------------------------------------------------------------------
#                                                                    #
# rules for the recognition of english heterosyntagmatic relations   #
# this file uses the syntax for the declarations of automatons by    #
# Romaric Besancon (Cf. his 2003/03/11 document)                     #
# Created on Mon oct 4 2004                                          #
# by Romaric Besancon                                                #
# modified by Claire Mouton, Gael de Chalendar, etc.                 #
#----------------------------------------------------------------------
# NOTE:for heterosyntagmatic relations, the recognizer with the
# following parameters :
# test all vertices: true
# stop at first success: false
# only one success per type: true
# return at first success: false

set encoding=utf8
using modex lima-analysis.xml
using groups LinguisticProcessing


#----------------------------------------------------------------------
# microcategories classes
#----------------------------------------------------------------------
use categoriesClassesDeclaration-eng.txt


#----------------------------------------------------------------------
# sub-automatons

# noun group size=3
# head is at position 3
define subautomaton NounGroup {
 pattern=$DET? (@Adverb{0-2} @Adj|@Substantif|@ConjCoord|@Ing|@DetNum|@PrepComp){0-n} @Substantif
}

# prep group size=2
# head is at position 2.3
define subautomaton PrepGroup {
 pattern=@PrepComp %NounGroup
}


#----------------------------------------------------------------------
# relation sujet/verbe
# SUJ_V

# !!! Attention à l'ordre des règles: les règles sont réordonnées en fonction
# !!! des triggers communs *ET* les triggers sont comparés en tenant compte
# !!! de leurs contraintes => triggers égaux si contraintes égales

# Past perfect
@Aux:%NounGroup (@DetNum (@ConjCoord @DetNum)?)?:(@Adverb){0-2} @Verb:SYNTACTIC_RELATION:
+!GovernorOf(left.1.3,"ANY")
+SecondUngovernedBy(left.1.3,right.2,"ANY")
+CreateRelationBetween(left.1.3,right.2,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


# relatives
# si après conjonction ou virgule, le précédent ne doit pas être complément de nom
# (ou alors, on remonte les liens)
@Verb:($NC|$NP) ($ADV? $ADJ)? (,|,? $CONJ-CONJ) @Pron (@PronPers){0-2}::SYNTACTIC_RELATION:
+!GovernorOf(left.1,"COMPDUNOM")
+SecondUngovernedBy(left.4,trigger.1,"ANY")
+CreateRelationBetween(left.4,trigger.1,"SUJ_V")
+CreateRelationBetween(trigger.1,left.1,"MOD_N")
=>AddRelationInGraph()
=<ClearStoredRelations()

# a pronoun at the end of an enumeration
@Verb:($NC|$NP) %NounGroup ($NC|$NP) ($ADV? $ADJ)? (,|,? $CONJ-CONJ) @Pron (@PronPers){0-2}::SYNTACTIC_RELATION:
+!GovernorOf(left.1,"COMPDUNOM")
+SecondUngovernedBy(left.6,trigger.1,"ANY")
+CreateRelationBetween(left.6,trigger.1,"SUJ_V")
+CreateRelationBetween(trigger.1,left.1,"MOD_N")
=>AddRelationInGraph()
=<ClearStoredRelations()

# a pronoun at the end of an enumeration
@Verb:($NC|$NP) %NounGroup ($NC|$NP) %NounGroup ($NC|$NP) ($ADV? $ADJ)? (,|,? $CONJ-CONJ) @Pron  (@PronPers){0-2}::SYNTACTIC_RELATION:
+!GovernorOf(left.1,"COMPDUNOM")
+SecondUngovernedBy(left.8,trigger.1,"ANY")
+CreateRelationBetween(left.8,trigger.1,"SUJ_V")
+CreateRelationBetween(trigger.1,left.1,"MOD_N")
=>AddRelationInGraph()
=<ClearStoredRelations()

# a pronoun after a noun
@Verb:($NC|$NP) ($ADV? $ADJ)? @Pron  (@PronPers){0-2}::SYNTACTIC_RELATION:
+SecondUngovernedBy(left.3,trigger.1,"ANY")
+CreateRelationBetween(left.3,trigger.1,"SUJ_V")
+CreateRelationBetween(trigger.1,left.1,"MOD_N")
=>AddRelationInGraph()
=<ClearStoredRelations()


# subject is proper noun
@Verb:$NP [(@NotNoun){0-n}]::SYNTACTIC_RELATION:
+!GovernorOf(left.1,"COMPDUNOM")
+!GovernorOf(left.1,"COD_V")
+!GovernorOf(left.1,"CPL_V")
+SecondUngovernedBy(left.1,trigger.1,"ANY")
+CreateRelationBetween(left.1,trigger.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# compound tense with double quotes around the subject which is a noun group
@Copule:@OpenQuot %NounGroup (@Adj){0-n} @ClosQuot:(@Adverb){0-2} @Verb:SYNTACTIC_RELATION:
+!GovernorOf(left.1,"ANY")
+SecondUngovernedBy(left.2.3,right.2,"ANY")
+CreateRelationBetween(left.2.3,right.2,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# compound tense
@Copule:%NounGroup (@DetNum (@ConjCoord @DetNum)?)?:(@Adverb){0-2} @Verb:SYNTACTIC_RELATION:
+!GovernorOf(left.1.3,"ANY")
+SecondUngovernedBy(left.1.3,right.2,"ANY")
+CreateRelationBetween(left.1.3,right.2,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# ex: he/John/the cat will really be catched by/when …
@AuxModal:(@Substantif|@Pron) (@NotVerbPrincipal){0-n}:(@Adverb){0-2} @BaseFormVerb @Verb:SYNTACTIC_RELATION:
+!GovernorOf(left.1,"ANY")
+!GovernedBy(left.1,"PREPSUB")
+!GovernorOf(trigger.1,"CPL_V")
+SecondUngovernedBy(left.1,right.3,"ANY")
+CreateRelationBetween(left.1,right.3,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# present continuous
@Copule:%NounGroup (@DetNum (@ConjCoord @DetNum)?)?:(@Adverb){0-2} @Ing:SYNTACTIC_RELATION:
+!GovernorOf(left.1.3,"ANY")
+SecondUngovernedBy(left.1.3,right.2,"ANY")
+CreateRelationBetween(left.1.3,right.2,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


# infinitive with modal
# ex: he/John/the cat must really eat the mouse
@BaseFormVerb:(@Substantif|@Pron) (@SujVOther){0-n} @AuxModal (@Adverb){0-2}::SYNTACTIC_RELATION:
+!GovernorOf(left.1,"ANY")
+!GovernedBy(left.1,"PREPSUB")
+SecondUngovernedBy(left.1,trigger.1,"ANY")
+CreateRelationBetween(left.1,trigger.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


@Verb:(@Substantif|@Pron) (@SujVOther){0-n} $NC (@SujVOther){0-n} (@AuxModal @BaseFormVerb?)?::SYNTACTIC_RELATION:
+NumberAgreement(trigger.1,left.1)
+!GovernorOf(left.1,"ANY")
+!GovernedBy(left.1,"PREPSUB")
+!GovernorOf(left.5.1,"CPL_V")
+SecondUngovernedBy(left.1,trigger.1,"ANY")
+CreateRelationBetween(left.1,trigger.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Verb:(@Substantif|@Pron) ((@SujVOther){0-n} $NC){2-2} [(@SujVOther){0-n}] (@AuxModal @BaseFormVerb?)? ^@Verb::SYNTACTIC_RELATION:
+NumberAgreement(trigger.1,left.1)
+!GovernorOf(trigger.1,"auxpass")
+!GovernorOf(left.1,"ANY")
+!GovernedBy(left.1,"PREPSUB")
+!GovernorOf(left.4,"auxpass")
+SecondUngovernedBy(left.1,trigger.1,"ANY")
+SecondUngovernedBy(left.4.1,trigger.1,"ANY")
+CreateRelationBetween(left.1,trigger.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Verb:(@Substantif|@Pron) ((@SujVOther){0-n} $NC){2-2} [(@SujVOther){0-n}] @AuxModal @BaseFormVerb? ::SYNTACTIC_RELATION:
+NumberAgreement(trigger.1,left.1)
+!GovernorOf(trigger.1,"auxpass")
+!GovernorOf(left.1,"ANY")
+!GovernedBy(left.1,"PREPSUB")
+!GovernorOf(left.4,"auxpass")
+SecondUngovernedBy(left.1,trigger.1,"ANY")
+SecondUngovernedBy(left.4,trigger.1,"ANY")
+CreateRelationBetween(left.1,trigger.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# cas des relatives
# Paul, qui est gentil, parle

@Verb:@Pron (@PronPers){0-2} @Verb (@NotVerbPrincipal){0-n}::SYNTACTIC_RELATION:
+CreateRelationReverseWithRelated(trigger.1,left.3,"MOD_N,SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# cas ou le nom sujet est modifie par un participe 
# "the robot installed performs well."
# Warning: this rule should not match a preterit and its subject like
#   in "the robots installed the part ."
#----------------------------------------------------------------------

@PastParticiple:@Determinant @Substantif:@Verb:SYNTACTIC_RELATION:
+GovernorOf(trigger.1,"SUBADJPOST")
+SecondUngovernedBy(left.2,right.1,"ANY")
+CreateRelationBetween(left.2,right.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


#----------------------------------------------------------------------
# cas ou le superlatif est utilisé comme un nom
# "The oldest of my cousins is at home this week."
#----------------------------------------------------------------------
$ADJ:The (@Adverb){0-2}:of @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif @Verb:SYNTACTIC_RELATION:
+SecondUngovernedBy(trigger.1,right.5,"ANY")
+CreateRelationBetween(trigger.1,right.5,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# simplest case
# "He eats."
#----------------------------------------------------------------------
@Verb:@Pron (@Adverb){0-3}::SYNTACTIC_RELATION:
+!GovernorOf(left.1,"ANY")
+CreateRelationBetween(left.1,trigger.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# simplest case
# "The cat eats."
#----------------------------------------------------------------------
@Verb:@Substantif (@Adverb){0-3}::SYNTACTIC_RELATION:
+!GovernorOf(left.1,"ANY")
+CreateRelationBetween(left.1,trigger.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# simplest case
# "The cat of the neighbours eats."
#----------------------------------------------------------------------
@Verb:@Substantif (@NotVerbPrincipal){0-n} @Substantif ,?::SYNTACTIC_RELATION:
+!GovernorOf(left.1,"ANY")
+!SecondUngovernedBy(left.3,left.1,"COMPDUNOM")
+CreateRelationBetween(left.1,trigger.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Substantif::(@NotVerbPrincipal){0-n} @Substantif ,? @Verb:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ANY")
+CreateRelationBetween(trigger.1,right.4,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# Using the following of relations up to the head
@Verb:@Substantif (@Adverb){0-3}::SYNTACTIC_RELATION:
+GovernorOf(left.1,"COMPDUNOM")
+CreateRelationReverseWithRelated(trigger.1,left.1,"COMPDUNOM,SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


#----------------------------------------------------------------------
# relation attribut du sujet
# ATB_S

# @Adj:(@Copule|être$V) ($ADV){0-2}::SYNTACTIC_RELATION:
# +CreateRelationBetween(trigger.1,left.1,"ATB_S")
# =>AddRelationInGraph()

@Adj:@Copule ($ADV){0-2}::SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ATB_S")
+CreateRelationBetween(trigger.1,left.1,"ATB_S")
=>AddRelationInGraph()
=<ClearStoredRelations()

# on ajoute epithete detachee pour trouver la relation meme
# si le postagging est faux => mais seulement avec verbes copule

@AttributSujCandidates=($ADJ)

@AttributSujCandidates:@Copule ($ADV){0-2}::SYNTACTIC_RELATION:
+CreateRelationBetween(trigger.1,left.1,"ATB_S")
=>AddRelationInGraph()
=<ClearStoredRelations()

# verbes infinitifs comme attributs du sujet
# elle paraît avoir renoncé

@CopulePlusInfinitif::$ADV{0-2} $V @PastParticiple:SYNTACTIC_RELATION:
+CreateRelationBetween(right.3,trigger.1,"ATB_S")
+CreateRelationReverseWithRelated(right.2,trigger.1,"SUJ_V,SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


#  l'auxiliaire a été changé pour former un temps composé
@CopulePlusInfinitif::$ADV{0-2} @BaseFormVerb @PastParticiple:SYNTACTIC_RELATION:
+CreateRelationBetween(right.3,trigger.1,"ATB_S")
+CreateRelationReverseWithRelated(right.2,trigger.1,"SUJ_V,SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@CopulePlusInfinitif::$ADV{0-2} @BaseFormVerb:SYNTACTIC_RELATION:
+CreateRelationBetween(right.2,trigger.1,"ATB_S")
+CreateRelationReverseWithRelated(right.2,trigger.1,"SUJ_V,SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Copule:@OpenQuot (^$PONCTU-QUOT){0-n} ^$PONCTU-QUOT (^$PONCTU-QUOT){0-n} @ClosQuot:(@Adverb){0-n} @Verb:SYNTACTIC_RELATION:
+!GovernorOf(left.3,"ANY")
+CreateRelationBetween(left.3,right.2,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Verb:@OpenQuot (^$PONCTU-QUOT){0-n} ^$PONCTU-QUOT (^$PONCTU-QUOT){0-n} @ClosQuot::SYNTACTIC_RELATION:
+!GovernorOf(left.3,"ANY")
+CreateRelationBetween(left.3,trigger.1,"SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


#----------------------------------------------------------------------
# object verb relation
# double complements
#----------------------------------------------------------------------

# He gives him a book.

@Verb::$PRON @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.4,"ADJPRENSUB")
+CreateRelationBetween(right.1,trigger.1,"CPL_V")
+CreateRelationBetween(right.4,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


# He gives the boy a book.

@Verb::@Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.3,"ADJPRENSUB")
+!GovernorOf(right.6,"ADJPRENSUB")
+CreateRelationBetween(right.3,trigger.1,"CPL_V")
+CreateRelationBetween(right.6,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


# He gives a book to him.

@Verb::@Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif to $PRON:SYNTACTIC_RELATION:
+!GovernorOf(right.3,"ADJPRENSUB")
+CreateRelationBetween(right.3,trigger.1,"COD_V")
+CreateRelationBetween(right.5,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# He gives it to him.

@Verb::$PRON to $PRON:SYNTACTIC_RELATION:
+CreateRelationBetween(right.1,trigger.1,"COD_V")
+CreateRelationBetween(right.3,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# He gives a book to his friend.

@Verb::@Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif to @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.3,"ADJPRENSUB")
+!GovernorOf(right.7,"ADJPRENSUB")
+CreateRelationBetween(right.3,trigger.1,"COD_V")
+CreateRelationBetween(right.7,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# He gives it to his friend.

@Verb::$PRON to @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.5,"ADJPRENSUB")
+CreateRelationBetween(right.1,trigger.1,"COD_V")
+CreateRelationBetween(right.5,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()
#----------------------------------------------------------------------



#----------------------------------------------------------------------
# object verb relation
# COD_V

# il ne mange avec plaisir que des gateaux
# @Verb:ne:$ADV{0-2} $PREP $DET? ($ADV{0-2} $ADJ){0-2} $NC que $DET? ($ADV{0-2} $ADJ){0-2} $NC:SYNTACTIC_RELATION:
# +CreateRelationBetween(right.5,trigger.1,"CPL_V")
# +CreateRelationBetween(right.6,trigger.1,"MOD_V")
# +CreateRelationBetween(right.9,trigger.1,"COD_V")
# =>AddRelationInGraph()
# =<ClearStoredRelations()

# il ne mange que des gateaux
#@Verb:ne:$ADV{0-2} que $DET? ($ADV{0-2} $ADJ){0-2} $NC:SYNTACTIC_RELATION:
#+CreateRelationBetween(right.2,trigger.1,"MOD_V")
#+CreateRelationBetween(right.5,trigger.1,"COD_V")
#=>AddRelationInGraph()
#=<ClearStoredRelations()

# simple case 
@Verb::$ADV{0-2} @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.4,"ANY")
+!GovernedBy(trigger.1,"COD_V")
+CreateRelationBetween(right.4,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# simple case with a number as determiner 
@Verb::$ADV{0-2} @DetNum? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.4,"ANY")
+!GovernedBy(trigger.1,"COD_V")
+CreateRelationBetween(right.4,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Verb::$ADV{0-2} @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.4,"ANY")
+!GovernedBy(trigger.1,"COD_V")
+CreateRelationBetween(right.4,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# l'infinitif qui suit le verbe est COD si le verbe n'a pas
# déjà un COD et si l'infinitif n'est pas déjà attribut
#@AuxModal::$ADV{0-2} @BaseFormVerb:SYNTACTIC_RELATION:
#+!GovernedBy(trigger.1,"COD_V")
#+!GovernorOf(trigger.1,"aux")
#+SecondUngovernedBy(right.2,trigger.1,"ANY")
#+CreateRelationBetween(right.2,trigger.1,"COD_V")
#=>AddRelationInGraph()
#=<ClearStoredRelations()

@Verb::$ADV{0-2} (@BaseFormVerb|@PastParticiple):SYNTACTIC_RELATION:
+!GovernedBy(trigger.1,"COD_V")
+!GovernedBy(right.2,"auxpass")
+!GovernorOf(trigger.1,"aux")
+SecondUngovernedBy(right.2,trigger.1,"ATB_S")
+CreateRelationBetween(right.2,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# complement en incise (vraisemblablement circonstantiel) +
# COD
@Verb::, ($PREP)? @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} $NC , $DET? ($ADV{0-2} $ADJ){0-2} @Substantif:SYNTACTIC_RELATION:
+CreateRelationBetween(right.5,trigger.1,"CPL_V")
+CreateRelationBetween(right.9,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# adverbe en incise  +COD
#
@Verb::, $ADV{0-2} $ADV , @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.3,"ADVADV")
+CreateRelationBetween(right.3,trigger.1,"MOD_V")
+CreateRelationBetween(right.7,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# adverbe en incise  +COI
#
@Verb::, $ADV{0-2} $ADV , $PREP $DET? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.3,"ADVADV")
+CreateRelationBetween(right.3,trigger.1,"MOD_V")
+CreateRelationBetween(right.8,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


# complement en incise (vraisemblablement circonstantiel) +
# COD
@Verb::, ($PREP) @Determinant? ($ADV{0-2} $ADJ){0-2} $NC , $DET? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
+CreateRelationBetween(right.5,trigger.1,"CPL_V")
+CreateRelationBetween(right.9,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# subordinate clause
# in Universal Dependencies, it would be ccomp (with mark between that and the 
# second verb)
@Verb::@SubordConj %NounGroup (@Adverb){0-3} @Verb:SYNTACTIC_RELATION:
+CreateRelationBetween(right.4,trigger.1,"COD_V")
+CreateRelationBetween(right.1,right.4,"mark")
=>AddRelationInGraph()
=<ClearStoredRelations()

# subordinate clause without its own subject
# in Universal Dependencies, the first COD_V would be xcomp
# and the second one woud be ccomp
@Ing:@Verb:@SubordConj %NounGroup (@Adverb){0-3} @Verb:SYNTACTIC_RELATION:
+CreateRelationBetween(trigger.1,left.1,"COD_V")
+CreateRelationBetween(right.4,trigger.1,"COD_V")
+CreateRelationBetween(right.1,right.4,"mark")
=>AddRelationInGraph()
=<ClearStoredRelations()


# complement COI suivi d'un COD
# il donne a Pierre un livre

#@Verb::($PREP) @Determinant? #($ADV{0-2} (@Adj|@Substantif)){0-n} #($NC|$NP) $DET? ($ADV{0-2} #(@Adj|@Substantif)){0-n} #@Substantif:SYNTACTIC_RELATION:
#+CreateRelationBetween(right.4,trigger.1,"CPL_V")
#+CreateRelationBetween(right.7,trigger.1,"COD_V")
#=>AddRelationInGraph()
#=<ClearStoredRelations()


@Verb::($PREP) @Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} ($NC|$NP|$PRON) @Substantif:SYNTACTIC_RELATION:
+CreateRelationBetween(right.4,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@PastParticiple::%PrepGroup:SYNTACTIC_RELATION:
+!GovernorOf(right.1.2.3,"ANY")
+GovernorOf(trigger.1,"ATB_S")
+GovernedBy(trigger.1,"SUJ_V")
+CreateRelationBetween(right.1.2.3,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


# complement en enumeration:
# ex: X can handle spot welding, material handling and assembly
# with the head of each complement being a noun or a verb in ing, or a pronoun

@Ing:@Verb (@Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing|$PRON)){0-n} ,){0-n} @Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing|$PRON)){0-n}::SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ANY")
+CreateRelationBetween(trigger.1,left.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Ing:@Verb @Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing)){0-n} (, @Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing)){0-n}){0-n} ,? and @Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing)){0-n}::SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ANY")
+CreateRelationBetween(trigger.1,left.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Substantif:@Verb (@Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing)){0-n} ,){0-n} @Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing)){0-n}::SYNTACTIC_RELATION:
+!GovernedBy(left.1,"COD_V")
+!GovernorOf(trigger.1,"ANY")
+!GovernorOf(left.1,"SUBADJPOST")
+CreateRelationBetween(trigger.1,left.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Substantif:@Verb @Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing)){0-n} (, @Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing)){0-n}){0-n} ,? and @Determinant? ($ADV{0-2} (@Adj|@Substantif|@Ing)){0-n}::SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ANY")
+!GovernorOf(left.1,"SUBADJPOST")
+CreateRelationBetween(trigger.1,left.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# Quoted Imperative
# ex: "consider X"
@BaseFormVerb:@OpenQuot:%NounGroup @ClosQuot:SYNTACTIC_RELATION:
+!GovernorOf(right.1.3,"ANY")
+!GovernedBy(trigger.1,"COD_V")
+SecondUngovernedBy(right.1.3,trigger.1,"ANY")
+CreateRelationBetween(right.1.3,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@BaseFormVerb:$DIVERS-SYM:%NounGroup:SYNTACTIC_RELATION:
+!GovernorOf(right.3,"ANY")
+!GovernedBy(trigger.1,"COD_V")
+SecondUngovernedBy(right.3,trigger.1,"ANY")
+CreateRelationBetween(right.3,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


#----------------------------------------------------------------------
# Relation entre pronom personnel reflexif et verbe: "... likes himself ..."
#----------------------------------------------------------------------
@Pron:@Verb::SYNTACTIC_RELATION:
+SecondUngovernedBy(trigger.1,left.1,"ANY")
+CreateRelationBetween(trigger.1,left.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# Relation entre pronom personnel objet et verbe: "... likes me."
#----------------------------------------------------------------------
@PronPers:@Verb::SYNTACTIC_RELATION:
+SecondUngovernedBy(trigger.1,left.1,"ANY")
+CreateRelationBetween(trigger.1,left.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@BaseFormVerb::@Adverb{0-3} @Adj:SYNTACTIC_RELATION:
+!GovernorOf(right.2,"ANY")
+GovernedBy(trigger.1,"auxpass")
+CreateRelationBetween(right.2,trigger.1,"COD_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


#----------------------------------------------------------------------
# relation verbe/agent(voie passive) (complément d'agent)
# CAgent_V


#by:VERBE_GENERAPASSIF:@Determinant? ($ADV{0-2} (@Adj|@Substantif)){0-n} @Substantif:SYNTACTIC_RELATION:
#+SecondUngovernedBy(left.1,right.3,"ANY")
#+CreateRelationBetween(left.1,right.3,"CAgent_V")
#=>AddRelationInGraph()
#=<ClearStoredRelations()


#by:VERBE_GENERAPASSIF:@PronPers:SYNTACTIC_RELATION:
#+SecondUngovernedBy(left.1,right.1,"ANY")
#+CreateRelationBetween(left.1,right.1,"CAgent_V")
#=>AddRelationInGraph()
#=<ClearStoredRelations()

#----------------------------------------------------------------------
# relation verbe/complement (COI+circonstantielles)
# CPL_V, CPL_V

# groupe prépositionnel infinitif après le verbe
# (this permits to recover the flaps)
# => relation particuliere CPLV_V

@Verb::$ADV? to $ADV? @BaseFormVerb:SYNTACTIC_RELATION:
+CreateRelationBetween(right.4,trigger.1,"CPLV_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# groupe prépositionnel infinitif après le verbe suivi d'un COI
# ("elle permet a l'industrie de se developper")
# -> toujours avec à

# @Verb::$ADV{0-2} $DET? ($ADV{0-2} $ADJ){0-2} $NC ($ADV{0-2} $ADJ){0-2} $PREP $ADV? (@PronPers)? @BaseFormVerb:SYNTACTIC_RELATION:
# +CreateRelationBetween(right.4,trigger.1,"CPL_V")
# +CreateRelationBetween(right.9,trigger.1,"CPLV_V")
# +CreateRelationBetween(right.4,right.10,"SUJ_V")
# =>AddRelationInGraph()
# =<ClearStoredRelations()

# with a compound  tense
# ex: is only triggered, on the ECAM
@Verb:@Copule (@Adverb){0-n}:@Comma? @Adverb{0-2} @Comma? @Prep $DET? (@Adverb{0-2} ($ADJ|@Substantif)){0-2} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.7,"ANY")
+CreateRelationBetween(right.7,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Verb::@Comma? @Adverb{0-2} @Comma? @PrepComp $DET? (@Adverb{0-2} ($ADJ|@Substantif)){0-2} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(right.7,"ANY")
+CreateRelationBetween(right.7,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# simple COI
@Verb::$ADV{0-2} @PrepComp $DET? ($ADV{0-2} $ADJ){0-2} $NC:SYNTACTIC_RELATION:
+SecondUngovernedBy(right.5,trigger.1,"CPL_V")
+SecondUngovernedBy(right.5,trigger.1,"MOD_V")
+CreateRelationBetween(right.5,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# simple COI avec pronom
@Verb::$ADV{0-2} @PrepComp @PronPers:SYNTACTIC_RELATION:
+CreateRelationBetween(right.3,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# with compound tense
@Verb:@Copule (@Adverb){0-n}:@Adverb? @Comma? @Prep %NounGroup in\ case\ of %NounGroup:SYNTACTIC_RELATION:
+!GovernorOf(right.6.3,"ANY")
+SecondUngovernedBy(right.6.3,trigger.1,"ANY")
+CreateRelationBetween(right.6.3,trigger.1,"CPL_V")
+RemoveOutRelationFrom(right.6.3,"COMPDUNOM")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Verb::@Adverb? @Comma? @Prep %NounGroup in\ case\ of %NounGroup:SYNTACTIC_RELATION:
+!GovernorOf(right.6.3,"ANY")
+SecondUngovernedBy(right.6.3,trigger.1,"ANY")
+CreateRelationBetween(right.6.3,trigger.1,"CPL_V")
+RemoveOutRelationFrom(right.6.3,"COMPDUNOM")
=>AddRelationInGraph()
=<ClearStoredRelations()

# group prépositionnel non rattaché à un nom ou un verbe => rattaché
# au premier verbe qui suit

# cas temps composé
@PrepComp::($DET)? (($ADV){0-2} $ADJ){0-2} (@Substantif){0-n} @Substantif (@NotVerbPrincipal){0-n} @BaseFormVerb  ($ADV){0-2} @Verb:SYNTACTIC_RELATION:
+!GovernorOf(right.4,"ANY")
+CreateRelationBetween(right.4,right.8,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# cas temps simple
@Verb:@PrepComp ($DET)? ($ADV{0-2} $ADJ){0-2} (@Substantif){0-n} @Substantif (@NotVerbPrincipal){0-n}::SYNTACTIC_RELATION:
+!GovernorOf(left.5,"ANY")
+!GovernorOf(trigger.1,"auxpass")
+!GovernedBy(left.5,"SUBADJPOST")
+CreateRelationBetween(left.5,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# groupe introduit par une conjonction de subordination 
# non rattaché à un element precent => rattache
# le premier verbe qui suit au premier verbe suivant

@PrepComp::(@NotVerbPrincipal){0-n} @Verb  $ADV{0-2} @Verb (@NotVerbPrincipal){0-n} @Verb:SYNTACTIC_RELATION:
+!GovernorOf(right.4,"ANY")
+CreateRelationBetween(right.4,right.6,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# covers too much. For example: create relation CPL_V between "considers" and "remain" in:
# "in the table considers that all spoilers remain"
# with "in" being the trigger
# simple tense case
#@PrepComp::(@NotVerbPrincipal){0-n} @Verb (@NotVerbPrincipal){0-n} @Verb:SYNTACTIC_RELATION:
#+!GovernorOf(right.2,"ANY")
#+CreateRelationBetween(right.2,right.4,"CPL_V")
#=>AddRelationInGraph()
#=<ClearStoredRelations()

@Verb:$NC ($ADV? $ADJ)? ,? @PrepComp? @Pron (@PronPers){0-2}::SYNTACTIC_RELATION:
+CreateRelationBetween(left.5,trigger.1,"CPL_V")
+CreateRelationBetween(trigger.1,left.1,"MOD_N")
=>AddRelationInGraph()
=<ClearStoredRelations()

# Prepositional group at the beginning of the sentence, before a comma,
# with compound tense
@Copule:@Prep %NounGroup $V? @Comma %NounGroup:(@Adverb){0-n} @Verb:SYNTACTIC_RELATION:
+!GovernorOf(left.2.3,"ANY")
+CreateRelationBetween(left.2.3,right.2,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# Prepositional group at the beginning of the sentence, before a comma
@Verb:@Prep %NounGroup $V? @Comma %NounGroup @BaseFormVerb?::SYNTACTIC_RELATION:
+!GovernorOf(left.2.3,"ANY")
+CreateRelationBetween(left.2.3,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

# Prepositional clause at the beginning of the sentence, before a comma
@Verb:@Prep @BaseFormVerb %NounGroup @Comma %NounGroup @AuxModal?::SYNTACTIC_RELATION:
+!GovernorOf(left.2,"ANY")
+CreateRelationBetween(left.2,trigger.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


#----------------------------------------------------------------------
# relation modifieur nom : complément qui 
# est une chaine verbale ("envie de changer")
# les autre modifieurs de noms --adjectifs,compléments de nom-- sont 
# dans les chaines
# les relatives sont traitées avec les sujets
# MOD_N

$NC::to @BaseFormVerb:SYNTACTIC_RELATION:
+CreateRelationBetween(right.2,trigger.1,"MOD_N")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# relation modifieur adjectif (fière qu'il ait réussi)
# MOD_A -> traité avec les COMPL

#----------------------------------------------------------------------
# relation de coordination 
# COORD1 et COORD2 -> les deux éléments de la coordination,
# chacun en relation avec le coordinant

# coordination de noms
@ConjCoord:($NC|$PRON) ($ADV|$ADJ){0-2}:($DET|@DetNum)? ($ADV|$ADJ){0-2} ($NC|$PRON):SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"COORD1")
+!GovernorOf(trigger.1,"COORD2")
+!GovernorOf(left.1,"COMPDUNOM")
+CreateRelationBetween(trigger.1,left.1,"COORD1")
+CreateRelationBetween(trigger.1,right.3,"COORD2")
=>AddRelationInGraph()
=<ClearStoredRelations()

# coordination de noms un peu plus complexe
@ConjCoord:(@Substantif|$PRON) from ($ADV|$ADJ){0-2} @Substantif to ($ADV|$ADJ){0-2} @Substantif:($DET|@DetNum)? ($ADV|$ADJ){0-2} (@Substantif|$PRON):SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"COORD1")
+!GovernorOf(trigger.1,"COORD2")
+!GovernorOf(trigger.1,"COMPDUNOM")
+CreateRelationBetween(trigger.1,left.1,"COORD1")
+CreateRelationBetween(trigger.1,right.3,"COORD2")
=>AddRelationInGraph()
=<ClearStoredRelations()

# Special case of nouns coordination with idiom "in case of"
@ConjCoord:in\ case\ of %NounGroup @Comma?:in\ case\ of %NounGroup:SYNTACTIC_RELATION:
+!GovernorOf(right.2.3,"ANY")
+SecondUngovernedBy(trigger.1,left.2.3,"ANY")
+SecondUngovernedBy(trigger.1,right.2.3,"ANY")
+CreateRelationBetween(trigger.1,left.2.3,"COORD1")
+CreateRelationBetween(trigger.1,right.2.3,"COORD2")
+CopyRelationsOutOfTo(left.2.3,right.2.3,"")
=>AddRelationInGraph()
=<ClearStoredRelations()

# adjectives coordination
@ConjCoord:$ADJ:$ADV{0-2} $ADJ:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"COORD1")
+!GovernorOf(trigger.1,"COORD2")
+CreateRelationBetween(trigger.1,left.1,"COORD1")
+CreateRelationBetween(trigger.1,right.2,"COORD2")
+CopyRelationsOutOfTo(right.2,left.1,"")
=>AddRelationInGraph()
=<ClearStoredRelations()

# adverbs coordination
@ConjCoord:$ADV:$ADV? $ADV:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"COORD1")
+!GovernorOf(trigger.1,"COORD2")
+CreateRelationBetween(trigger.1,left.1,"COORD1")
+CreateRelationBetween(trigger.1,right.2,"COORD2")
=>AddRelationInGraph()
=<ClearStoredRelations()

# coordination de verbes => plus difficile

#verbe direct apres le et"COMP
@ConjCoord:@Verb (@NotVerbPrincipal){0-n}:@Verb:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"COORD1")
+!GovernorOf(trigger.1,"COORD2")
+CreateRelationBetween(trigger.1,left.1,"COORD1")
+CreateRelationBetween(trigger.1,right.1,"COORD2")
=>AddRelationInGraph()
=<ClearStoredRelations()

#verbes avec preposition
@ConjCoord:$PREP @Verb (@NotVerbPrincipal){0-n}:$PREP @Verb:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"COORD1")
+!GovernorOf(trigger.1,"COORD2")
+CreateRelationBetween(trigger.1,left.2,"COORD1")
+CreateRelationBetween(trigger.1,right.2,"COORD2")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# APP

$NC::, $DET ($ADV|$ADJ){0-2} $NC ,:SYNTACTIC_RELATION:
+CreateRelationBetween(trigger.1,right.4,"APPOS")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# acl

@PastParticiple:@Substantif %PrepGroup:@Prep?:SYNTACTIC_RELATION:
+!GovernorOf(left.1,"ANY")
+CreateRelationBetween(trigger.1,left.1,"acl")
+CreateRelationReverseWithRelated(trigger.1,right.1,"PREPSUB,CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

@PastParticiple:@Substantif:@Prep?:SYNTACTIC_RELATION:
+!GovernorOf(left.1,"ANY")
+CreateRelationBetween(trigger.1,left.1,"acl")
+CreateRelationReverseWithRelated(trigger.1,right.1,"PREPSUB,CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


@Verb:@PastParticiple %PrepGroup::SYNTACTIC_RELATION:
+CreateRelationReverseWithRelated(trigger.1,left.1,"acl,SUJ_V")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# Long distance conjunction
@Verb:@Verb @ConjCoord %NounGroup @AuxModal?::SYNTACTIC_RELATION:
+!GovernorOf(left.2,"ANY")
+GovernedBy(left.1,"SUJ_V")
+GovernedBy(trigger.1,"SUJ_V")
+CreateRelationBetween(left.2,left.1,"COORD1")
+CreateRelationBetween(left.2,trigger.1,"COORD2")
=>AddRelationInGraph()
=<ClearStoredRelations()


#----------------------------------------------------------------------
# Long distance adverbial clause modifier
@Verb:@Adverb @Comma (@NotVerbPrincipal|@BaseFormVerb|@Aux){0-n}::SYNTACTIC_RELATION:
+!GovernorOf(left.1,"ANY")
+CreateRelationBetween(left.1,trigger.1,"AdvVerbe")
=>AddRelationInGraph()
=<ClearStoredRelations()


#----------------------------------------------------------------------
@PastParticiple:@PastParticiple @PrepComp:@Substantif:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ANY")
+!GovernorOf(left.2,"ANY")
+!GovernorOf(right.1,"ANY")
+CreateRelationBetween(trigger.1,right.1,"ADJPRENSUB")
+CreateRelationBetween(left.2,right.1,"PREPSUB")
+CreateRelationBetween(right.1,left.1,"CPL_V")
=>AddRelationInGraph()
=<ClearStoredRelations()


