#
# Rules for the first pass recognition of portuguese relations inside chunks
# This file uses the Modex rules syntax
#
# Created on Thu nov 21 2003
# by Gael de Chalendar <Gael.de-Chalendar@cea.fr>
# initial rules by Hubert Naets
#

# NOTE: for these rules, the recognizer is called with the parameters:
# test all vertices: true
# stop at first success: false
# only one success per type: false
# return at first success: false


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


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

@Substantif:@PronPoss (@Adjectif|@Substantif){0-n}:@AfterNominalChunk:SYNTACTIC_RELATION:
+SecondUngovernedBy(left.1,trigger.1,"DETSUB")
+CreateRelationBetween(left.1,trigger.1,"DETSUB")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# 1. Relation entre adjectif prenominal et substantif : AdjPrenSub
#   @Adjectif*  (@Adjectif|@Substantif) @Substantif
# "a green car"
# ADJPRENSUB :    green[12|12]{27/70}     -> car[11|11]{23/37}
#   @Substantif*  (@Adjectif|@Substantif) @Substantif
# "a police car"
# ADJPRENSUB :    police[12|12]{27/70}     -> car[11|11]{23/37}
#----------------------------------------------------------------------

$NC::$NP $NP:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ADJPRENSUB")
+!GovernorOf(right.1,"SUBSUBJUX")
+SecondUngovernedBy(trigger.1,right.2,"ANY")
+SecondUngovernedBy(right.1,right.2,"ANY")
+CreateRelationBetween(trigger.1,right.2,"ADJPRENSUB")
+CreateRelationBetween(right.1,right.2,"SUBSUBJUX")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Substantif::@Substantif:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ADJPRENSUB")
+!GovernorOf(right.1,"SUBSUBJUX")
+SecondUngovernedBy(trigger.1,right.1,"ANY")
+CreateRelationBetween(trigger.1,right.1,"ADJPRENSUB")
=>AddRelationInGraph()
=<ClearStoredRelations()


@Substantif::(@Substantif|@Adjectif){1-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ADJPRENSUB")
+SecondUngovernedBy(trigger.1,right.2,"ANY")
+CreateRelationBetween(trigger.1,right.2,"ADJPRENSUB")
=>AddRelationInGraph()
=<ClearStoredRelations()

@Substantif::(@Substantif|@Adjectif){0-n} @Substantif:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"ADJPRENSUB")
+SecondUngovernedBy(trigger.1,right.2,"ANY")
+CreateRelationBetween(trigger.1,right.2,"ADJPRENSUB")
=>AddRelationInGraph()
=<ClearStoredRelations()

#--------------
# Relation entre les elements d'un nom propre
# John F. Kennedy
#

@NomPropre::(((@NomPropre){1-n})?) @NomPropre:SYNTACTIC_RELATION:
+!GovernorOf(trigger.1,"SUBSUBJUX")
+SecondUngovernedBy(trigger.1,right.2,"ANY")
+CreateRelationBetween(trigger.1,right.2,"SUBSUBJUX")
=>AddRelationInGraph()
=<ClearStoredRelations()

#----------------------------------------------------------------------
# 4. Relation de complement du nom : CompDuNom
# Deux noms juxtaposes. En dernier pour essayer de creer les autre relations
# avant et donc generer moins de bruit
#----------------------------------------------------------------------
#-@Substantif::(@Adjectif){0-n} @Substantif:SYNTACTIC_RELATION:
#-+SecondUngovernedBy(trigger.1,right.2,"ANY")
#-+CreateRelationBetween(trigger.1,right.2,"COMPDUNOM")


#----------------------------------------------------------------------
# Relation entre deux substantifs juxtaposés : SubSubJux
# A revoir et completer  (voir l2r 24/1/05 GG)
#----------------------------------------------------------------------
#-@NomPropre::@Substantif:SYNTACTIC_RELATION:
#-+SecondUngovernedBy(trigger.1,right.1,"ANY")
#-+CreateRelationBetween(trigger.1,right.1)

#-@NomPropre:@Substantif::SYNTACTIC_RELATION:
#-+SecondUngovernedBy(trigger.1,left.1,"ANY")
#-+CreateRelationBetween(trigger.1,left.1)

@Prep:@Sent:@Substantif $V-V @Comma:SYNTACTIC_RELATION:
+SecondUngovernedBy(right.2,right.1,"ANY")
+CreateRelationBetween(right.2,right.1,"SUBADJPOST")
=>AddRelationInGraph()
=<ClearStoredRelations()
