###########################################################
#
# rules for the recognition of french subsentences
# this file uses the syntax for the declarations of automatons by Romaric
# Besancon (Cf. his 2003/03/11 document)
#
# Created on Tue Mar 15 2005
# by Gael de Chalendar (Gael.de-Chalendar@cea.fr)
#
# $Id$
#
###########################################################

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

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


#----------------------------------------------------------------------
# Supprime "D'une part," qui aurait du être une expr idiom adverbe
# "[D'une part, ] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @PrepComp:@PonctuForte:@PrepComp @Substantif ,:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.3,"Appos")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime un adverbe situé seul entre deux virgules
# "[, d'autre part, ] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# ,::@Adverbe ,:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.2,"AdvSeul")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime un adverbe en début de phrase
# ". [Ainsi ,] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @Adverbe:@PonctuForte:,:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.1,"AdvInit")
# =>Simplify()
# =<ClearStoredSubsentences()



#----------------------------------------------------------------------
# Relation entre adverbe et substantif: CompAdv
# (A6.6 - 4.2.1.6)
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# $ADV::@PrepComp @Determinant (@AdvPos|@AdjPren){0-n} @Substantif:SYNTACTIC_RELATION:
# +!SecondUngovernedBy(right.4,trigger.1,"COMPADV")
# +SubsentenceBounds(trigger.1,right.4,"CompAdv")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime tous les adverbes restant
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# $ADV:::SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,"Adverbe")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime un adverbe juste après un verbe
# "... je vois [vraiment] comment il joue ..."
#----------------------------------------------------------------------
@Adverbe:@Verbe::SYNTACTIC_RELATION:
+CreateRelationBetween(trigger.1,left.1,"MOD_V")
+SubsentenceBounds(trigger.1,"AdvSeul")
=>Simplify()
=<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime subordonnee simple dans "Le chat [qui regarde la souris] est très beau."
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @PronRelS::@Verbe (@ParticipePasse)? (@NonVerbe){0-n} @Verbe:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.3.last,"SubordRel")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime subordonnee en fin de phrase
# "... un X [qui est passé de ...]."
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @PronRelS::@Verbe (@ParticipePasse)? (@NonVerbe){0-n} @PonctuForte:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.3.last,"SubordRel")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime un groupe non recursif entre parentheses :
# " Le chien [(oui, oui, le chien)] de la voisine "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# \(::(^$PONCTU-PONCT){0-n} \):SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.2,"Parent")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime la seconde partie d'une conjonction infinitive :
# "cherchent à soutenir X [et à encourager Y]"
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# et::@PrepGVInf @VerbeInf (@NonVerbe){1-n}:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.3.last,"ConjInfSecond")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime un CC initial
# ". [A travers le repli,] les pouvoirs publics visaient"
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @PrepComp:@PonctuForte:(travers)? ($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){1-n} , ($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){1-n} (,|et|@NonVerbe){0-n} @Verbe:SYNTACTIC_RELATION:
# +GovernorOf(trigger.1,"PREPSUB")
# +GovernorOf(right.2,"DETSUB")
# +GovernorOf(right.5,"SUBADJPOST")
# +SubsentenceBounds(trigger.1,right.6,"CCInit")
# =>Simplify()
# =<ClearStoredSubsentences()

# @PrepComp:@PonctuForte:(travers)? ($DET)? (@AdjPren){0-n} @Substantif , ($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){1-n} (,|et|@NonVerbe){0-n}  @Verbe:SYNTACTIC_RELATION:
# +GovernorOf(trigger.1,"PREPSUB")
# +GovernorOf(right.2,"DETSUB")
# +SubsentenceBounds(trigger.1,right.5,"CCInit")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime une infinitive asociée à un participe passé
# " les politiques [ menées pour assainir ...] "
# plusieurs cas a traiter : dans un complement du nom, directement
# derriere un nom,...
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------

# Cas 1: dans un complement du nom
# @PrepComp::($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){0-n} @AdjPost @PrepGVInf @VerbeInf ($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){1-n} ,:SYNTACTIC_RELATION:
# +GovernorOf(trigger.1,"PREPSUB")
# +GovernorOf(right.1,"DETSUB")
# +GovernorOf(right.3,"COMPDUNOM")
# +GovernorOf(right.4,"SUBADJPOST")
# +SubsentenceBounds(right.5,right.11.last,"Infinitive")
# =>Simplify()
# =<ClearStoredSubsentences()

# @PrepComp::($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){0-n} @AdjPost @PrepGVInf @VerbeInf ($DET)? (@AdjPren){0-n} @Substantif ,:SYNTACTIC_RELATION:
# +GovernorOf(trigger.1,"PREPSUB")
# +GovernorOf(right.1,"DETSUB")
# +GovernorOf(right.3,"COMPDUNOM")
# +GovernorOf(right.4,"SUBADJPOST")
# +SubsentenceBounds(right.5,right.10,"Infinitive")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime un nom propre  juxtaposé
# " général [Pierre Jean de la Fayette] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @Prenom::((@Prenom){0-n} (de (la)?)?) @NpGen:SYNTACTIC_RELATION:
# +GovernorOf(right.2,"SUBSUBJUX")
# +SubsentenceBounds(trigger.1,right.2,"SUBSUBJUX")
# =>Simplify()
# =<ClearStoredSubsentences()

# @NomPropre:::SYNTACTIC_RELATION:
# +GovernorOf(trigger.1,"SUBSUBJUX")
# +SubsentenceBounds(trigger.1,"SUBSUBJUX")
# =>Simplify()
# =<ClearStoredSubsentences()


#----------------------------------------------------------------------
# Supprime le deuxième membre d'une conjonction de coordination
# " de croissance [et d'assainissement] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @PrepComp::($DET)? (@AdjPren){0-n} (@Substantif){0-n} (@Substantif|$ADJ-ADJ) @PrepComp ($DET)? (@AdjPren){0-n} @Substantif @ConjCoord @PrepComp ($DET)? (@AdjPren){0-n} @Substantif:SYNTACTIC_RELATION:
# +SubsentenceBounds(right.9,right.13,"ConjNominale")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime un complement du nom
# " le repli [de l'état] "
#----------------------------------------------------------------------
@PrepCompDuNom:^$V-V:$DET (@AdjPren){0-n} (@Substantif|$ADJ-ADJ){1-n} (@AdjPost){1-n} ^@PrepGVInf:SYNTACTIC_RELATION:
+GovernorOf(trigger.1,"PREPSUB")
+GovernorOf(right.1,"DETSUB")
+GovernorOf(right.3,"COMPDUNOM")
+GovernorOf(right.4,"SUBADJPOST")
+SubsentenceBounds(trigger.1,right.4.last,"CompDuNom1")
=>Simplify()
=<ClearStoredSubsentences()

@PrepCompDuNom:^$V-V:$DET (@AdjPren){0-n} (@Substantif|$ADJ-ADJ){1-n} (@AdjPost){1-n} ^@PrepGVInf:SYNTACTIC_RELATION:
+GovernorOf(trigger.1,"PREPSUB")
+GovernorOf(right.1,"DETSUB")
+GovernorOf(right.3,"COMPADJ")
+GovernorOf(right.4,"SUBADJPOST")
+SubsentenceBounds(trigger.1,right.4.last,"CompDuNom1")
=>Simplify()
=<ClearStoredSubsentences()

@PrepCompDuNom:^$V-V:(@AdjPren){0-n} (@Substantif|$ADJ-ADJ) (@Substantif){0-n} (@AdjPost){1-n} ^@PrepGVInf:SYNTACTIC_RELATION:
+GovernorOf(trigger.1,"PREPSUB")
+GovernorOf(right.2,"COMPDUNOM")
+GovernorOf(right.4,"SUBADJPOST")
+SubsentenceBounds(trigger.1,right.4.last,"CompDuNom1")
=>Simplify()
=<ClearStoredSubsentences()

@PrepCompDuNom:^$V-V:($DET)? (@AdjPren){0-n} (@Substantif){0-n} (@Substantif|$ADJ-ADJ) ^$ADJ-ADJ:SYNTACTIC_RELATION:
+GovernorOf(trigger.1,"PREPSUB")
+SubsentenceBounds(trigger.1,right.4,"CompDuNom2")
=>Simplify()
=<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime le deuxième membre d'une conjonction de coordination
# " de croissance [et d'assainissement] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @ConjCoord:@PrepComp ($DET)? (@AdjPren){0-n} @Substantif:@PrepComp ($DET)? (@AdjPren){0-n} @Substantif:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.4,"ConjNominale")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime un complement d'adjectif
# " dépendante [des flux] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @PrepComp:$ADJ:($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){1-n} ^@PrepGVInf:SYNTACTIC_RELATION:
# +GovernorOf(right.1,"DETSUB")
# +GovernorOf(right.3,"COMPADJ")
# +GovernorOf(right.4,"SUBADJPOST")
# +SubsentenceBounds(trigger.1,right.4.last,"CompAdj1")
# =>Simplify()
# =<ClearStoredSubsentences()

# @PrepComp:$ADJ:($DET)? (@AdjPren){0-n} @Substantif ^$ADJ-ADJ:SYNTACTIC_RELATION:
# +GovernorOf(right.1,"DETSUB")
# +GovernorOf(right.3,"COMPADJ")
# +SubsentenceBounds(trigger.1,right.3,"CompAdj2")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime une participiale avec participe présent juxtaposée
# " ces prescriptions améliorant son état, le médecin poursuivit le traitement "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @ParticipePresent:$DET @Substantif (^V){0-n}:($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){1-n} @PonctuFaible:SYNTACTIC_RELATION:
# +SubsentenceBounds(left.1,right.5,"SubordParticipiale")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime une participiale avec participe présent
# " des flux [provenant du reste] ... "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @ParticipePresent::@PrepComp ($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){1-n}  ($PONCTU|$V):SYNTACTIC_RELATION:
# +GovernorOf(right.1,"DETSUB")
# +SubsentenceBounds(trigger.1,right.5.last,"SubordParticipiale")
# =>Simplify()
# =<ClearStoredSubsentences()

# " des coteaux [environnant la ville] sont ..."
# @ParticipePresent::(@PrepComp)? ($DET)? (@AdjPren){0-n} @Substantif $V:SYNTACTIC_RELATION:
# +GovernorOf(right.1,"DETSUB")
# +SubsentenceBounds(trigger.1,right.4,"SubordParticipiale")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime une participiale avec participe passé en début de phrase
# " Leurs enfants élevés, "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# ,:$DET (@AdjPren){0-n} @Substantif @ParticipePasse::SYNTACTIC_RELATION:
# +SubsentenceBounds(left.1,trigger.1,"SubordParticipiale")
# =>Simplify()
# =<ClearStoredSubsentences()


#----------------------------------------------------------------------
# Supprime un element de liste
# " le repli [, la dérégulation] et "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# ,::($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){1-n} et:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.4.last,"ElemListe")
# =>Simplify()
# =<ClearStoredSubsentences()

# ,::($DET)? (@AdjPren){0-n} @Substantif (@ConjCoord|@Ponctu):SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.3,"ElemListe")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime la seconde partie d'une conjonction sujet :
# " Le chien [et le chat ] mangent"
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# et::($DET)? (@AdjPren){0-n} @Substantif (@AdjPost){1-n}  ($V|$PONCTU|@PronRefl):SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.4.last,"ConjSecond")
# =>Simplify()
# =<ClearStoredSubsentences()

# et::($DET)? (@AdjPren){0-n} @Substantif ($V|$PONCTU|@PronRefl):SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.3,"ConjSecond")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime une incise nominale
# " resultent[, dans une large mesure,] des..."
#----------------------------------------------------------------------
,::@PrepComp (@NonVerbe){0-n} $NC (@AdjPost){1-n} ,:SYNTACTIC_RELATION:
+SubsentenceBounds(trigger.1,right.5,"InciseNom")
=>Simplify()
=<ClearStoredSubsentences()

# Désactivé après tests Easy benchmarking
# ,::@PrepComp (@NonVerbe){0-n} $NC ,:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.4,"InciseNom")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime une "subordonnee participiale" (??)
# " l'ouverture [, doublée de la surévaluation ] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# ,::@AdjAvecSubCompDeAdj @PrepComp ($DET)? (@AdjPren){0-n} @Substantif:SYNTACTIC_RELATION:
# +GovernorOf(right.2,"PREPSUB")
# +GovernorOf(right.3,"DETSUB")
# +GovernorOf(right.5,"COMPADJ")
# +SubsentenceBounds(trigger.1,right.5,"SubordParticipiale")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime certains CC
# " [, à cette époque-là ] " ou "[A cette époque-là, ] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# ,::@PrepComp @DetDemons @Substantif $ADV:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.4,"CompCirc")
# =>Simplify()
# =<ClearStoredSubsentences()

# @PrepComp:@PonctuForte:@DetDemons @Substantif $ADV ,:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.4,"CompCirc")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime "De même," qui aurait du être une expr idiom adverbe
# "[De même, ] "
# Désactivé après tests Easy benchmarking
#----------------------------------------------------------------------
# @PrepComp:@PonctuForte:@PronIndef ,:SYNTACTIC_RELATION:
# +SubsentenceBounds(trigger.1,right.2,"Appos")
# =>Simplify()
# =<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime une subordonnee conjonctive plassée en tête
# ". [Alors_que ... ont ... ,] les ..."
#----------------------------------------------------------------------
@ConjSubord:@PonctuForte:@Tout{0-n} @VerbeInd @Tout{0-n} ,:SYNTACTIC_RELATION:
+SubsentenceBounds(trigger.1,right.4,"SubordInit")
=>Simplify()
=<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime une interjection, surtout utile dans les transcriptions orales (AdvSeul should be Interj)
# "... ça c'est la structure [euh] interprofessionnelle ..."
#----------------------------------------------------------------------
$INTERJ:::SYNTACTIC_RELATION:
+SubsentenceBounds(trigger.1,"Interjonction")
=>Simplify()
=<ClearStoredSubsentences()

#----------------------------------------------------------------------
# Supprime les adjectifs autours d'un nom
# "... le [jolie] voiture [bleue] ..."
#----------------------------------------------------------------------
@AdjPren::@Substantif:SYNTACTIC_RELATION:
+!SecondUngovernedBy(trigger.1,right.1,"ADJPRENSUB")
+SubsentenceBounds(trigger.1,"AdjNom")
=>AddRelationInGraph()
=<ClearStoredRelations()

@AdjPost:@Substantif::SYNTACTIC_RELATION:
+!SecondUngovernedBy(trigger.1,left.1,"ADJPRENSUB")
+SubsentenceBounds(trigger.1,"AdjNom")
=>AddRelationInGraph()
=<ClearStoredRelations()
