1
0
forked from GitHub/gf-core

French working, but only in the old size.

This commit is contained in:
aarne
2003-11-14 11:40:48 +00:00
parent 309716563c
commit 13de08f794
8 changed files with 3174 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,205 @@
--# -path=.:../abstract:../../prelude
--1 The Top-Level French Resource Grammar
--
-- Aarne Ranta 2002 -- 2003
--
-- This is the French concrete syntax of the multilingual resource
-- grammar. Most of the work is done in the file
-- $syntax.Romance.gf$, some in $syntax.Fra.gf$.
-- However, for the purpose of documentation, we make here explicit the
-- linearization types of each category, so that their structures and
-- dependencies can be seen.
-- Another substantial part are the linearization rules of some
-- structural words.
--
-- The users of the resource grammar should not look at this file for the
-- linearization rules, which are in fact hidden in the document version.
-- They should use $resource.Abs.gf$ to access the syntactic rules.
-- This file can be consulted in those, hopefully rare, occasions in which
-- one has to know how the syntactic categories are
-- implemented. Most parameter types are defined in $types.Romance.gf$, some in
-- $types.Fra.gf$.
concrete ResFra of ResAbs = open Prelude, TypesFra, MorphoFra, SyntaxFra in {
flags
startcat=Phr ;
parser=chart ;
lincat
N = CommNoun ;
-- = {s : Number => Str ; g : Gender} ;
CN = CommNoun ;
NP = {s : NPForm => Str ; g : PronGen ;
n : Number ; p : Person ; c : ClitType} ;
PN = {s : Str ; g : Gender} ;
Det = {s : Gender => Str ; n : Number} ;
Adj1 = Adjective ;
-- = {s : Gender => Number => Str ; p : Bool} ;
Adj2 = Adjective ** {s2 : Preposition ; c : Case} ;
AdjDeg = {s : Degree => Gender => Number => Str ; p : Bool} ;
AP = Adjective ;
Fun = CommNoun ** {s2 : Preposition ; c : Case} ;
V = Verb ;
-- = {s : VF => Str} ;
VP = {s : Gender => VF => Str} ;
TV = Verb ** {s2 : Preposition ; c : Case} ;
VS = Verb ** {mp,mn : Mode} ;
AdV = {s : Str} ;
S = Sentence ;
-- = {s : Mode => Str} ;
Slash = Sentence ** {s2 : Preposition ; c : Case} ;
RP = {s : RelForm => Str ; g : RelGen} ;
RC = {s : Mode => Gender => Number => Str} ;
IP = {s : Case => Str ; g : Gender ; n : Number} ;
Qu = {s : QuestForm => Str} ;
Imp = {s : Gender => Number => Str} ;
Phr = {s : Str} ;
Conj = {s : Str ; n : Number} ;
ConjD = {s1,s2 : Str ; n : Number} ;
ListS = {s1,s2 : Mode => Str} ;
ListAP = {s1,s2 : Gender => Number => Str ; p : Bool} ;
ListNP = {s1,s2 : Case => Str ; g : PronGen ; n : Number ; p : Person} ;
--.
lin
UseN = noun2CommNounPhrase ;
ModAdj = modCommNounPhrase ;
ModGenOne = npGenDet singular ;
ModGenMany = npGenDet plural ;
UsePN = nameNounPhrase ;
UseFun = funAsCommNounPhrase ; -- [SyntaxFra.noun2CommNounPhrase]
AppFun = appFunComm ;
AdjP1 = adj2adjPhrase ;
ComplAdj = complAdj ;
PositAdjP = positAdjPhrase ;
ComparAdjP = comparAdjPhrase ;
SuperlNP = superlNounPhrase ;
DetNP = detNounPhrase ;
IndefOneNP = indefNounPhrase singular ;
IndefManyNP = indefNounPhrase plural ;
DefOneNP = defNounPhrase singular ;
DefManyNP = defNounPhrase plural ;
PredVP = predVerbPhrase ;
PosV = predVerb True ;
NegV = predVerb False ;
PosA = predAdjective True ;
NegA = predAdjective False ;
PosCN = predCommNoun True ;
NegCN = predCommNoun False ;
PosTV = complTransVerb True ;
NegTV = complTransVerb False ;
PosNP = predNounPhrase True ;
NegNP = predNounPhrase False ;
PosVS = complSentVerb True ;
NegVS = complSentVerb False ;
AdvVP = adVerbPhrase ;
LocNP = locativeNounPhrase ;
AdvCN = advCommNounPhrase ;
PosSlashTV = slashTransVerb True ;
NegSlashTV = slashTransVerb False ;
IdRP = identRelPron ;
FunRP = funRelPron ;
RelVP = relVerbPhrase ;
RelSlash = relSlash ;
ModRC = modRelClause ;
RelSuch = relSuch ;
WhoOne = intPronWho singular ;
WhoMany = intPronWho plural ;
WhatOne = intPronWhat singular ;
WhatMany = intPronWhat plural ;
FunIP = funIntPron ;
NounIPOne = nounIntPron singular ;
NounIPMany = nounIntPron plural ;
QuestVP = questVerbPhrase ;
IntVP = intVerbPhrase ;
IntSlash = intSlash ;
QuestAdv = questAdverbial ;
ImperVP = imperVerbPhrase ;
IndicPhrase = indicUtt ;
QuestPhrase = interrogUtt ;
ImperOne = imperUtterance singular ;
ImperMany = imperUtterance plural ;
lin
TwoS = twoSentence ;
ConsS = consSentence ;
ConjS = conjunctSentence ;
ConjDS = conjunctDistrSentence ; -- [Coordination.conjunctDistrTable]
TwoAP = twoAdjPhrase ;
ConsAP = consAdjPhrase ;
ConjAP = conjunctAdjPhrase ;
ConjDAP = conjunctDistrAdjPhrase ;
TwoNP = twoNounPhrase ;
ConsNP = consNounPhrase ;
ConjNP = conjunctNounPhrase ;
ConjDNP = conjunctDistrNounPhrase ;
SubjS = subjunctSentence ; -- stack
SubjImper = subjunctImperative ;
SubjQu = subjunctQuestion ;
PhrNP = useNounPhrase ;
PhrOneCN = useCommonNounPhrase singular ;
PhrManyCN = useCommonNounPhrase plural ;
PhrIP ip = ip ;
PhrIAdv ia = ia ;
INP = pronNounPhrase pronJe ;
ThouNP = pronNounPhrase pronTu ;
HeNP = pronNounPhrase pronIl ;
SheNP = pronNounPhrase pronElle ;
WeNP = pronNounPhrase pronNous ;
YeNP = pronNounPhrase pronVous ;
YouNP = pronNounPhrase pronVous ;
TheyNP = pronNounPhrase pronIls ;
-- Here is a point where the API is really inadequate for French,
-- which distinguishes between masculine and feminine "they".
-- The following solution is not attractive.
--- TheyNP = pronNounPhrase (variants {pronIls ; pronElles}) ;
EveryDet = chaqueDet ;
AllDet = tousDet ; --- expected constr head instead of [SyntaxFra.mkDeterminer]
WhichDet = quelDet ;
MostDet = plupartDet ;
HowIAdv = ss "comment" ;
WhenIAdv = ss "quand" ;
WhereIAdv = ss "où" ;
WhyIAdv = ss "pourquoi" ;
AndConj = ss "et" ** {n = Pl} ;
OrConj = ss "ou" ** {n = Sg} ;
BothAnd = sd2 "et" "et" ** {n = Pl} ;
EitherOr = sd2 "ou" "ou" ** {n = Sg} ;
NeitherNor = sd2 "ni" "ni" ** {n = Sg} ; --- requires ne !
IfSubj = ss siSubj ;
WhenSubj = ss "quand" ;
PhrYes = ss "Oui." ;
PhrNo = ss "Non." ; --- and also Si!
}

View File

@@ -0,0 +1,295 @@
--# -path=.:../romance:../../prelude
instance SyntaxFra of SyntaxRomance = TypesFra ** open Prelude, (CO=Coordination), MorphoFra in {
oper
nameNounPhrase = \jean ->
normalNounPhrase
(\\c => prepCase c ++ jean.s)
jean.g
Sg ;
chaqueDet = mkDeterminer1 Sg "chaque" ;
tousDet = mkDeterminer Pl ["tous les"] ["toutes les"] ;
plupartDet = mkDeterminer1 Pl ["la plupart des"] ;
unDet = mkDeterminer Sg "un" "une" ;
plDet = mkDeterminer1 Pl "des" ; ---
quelDet = mkDeterminer Sg "quel" "quelle" ;
quelsDet = mkDeterminer Pl "quels" "quelles" ;
npGenPoss = \n,ton,mec ->
\\c => prepCase c ++ ton.s ! Poss n mec.g ++ mec.s ! n ;
mkAdjReg : Str -> Bool -> Adjective = \adj,p ->
mkAdjective (adjGrand adj) p ;
comparConj = elisQue ;
mkAdjDegrReg : Str -> Bool -> AdjDegr = \adj,p ->
mkAdjDegrLong (adjGrand adj) p ;
-- The commonest case for functions is common noun + "de".
funDe : CommNounPhrase -> Function = \mere ->
mere ** complementCas genitive ;
-- Chains of "dont" - "dont" do not arise.
funRelPron : Function -> RelPron -> RelPron = \mere,lequel ->
{s = table {
RComplex g n c => variants {
case mere.c of { ---
Gen => lequel.s ! RSimple Gen ++
artDef mere.g n c ++ mere.s ! n ;
_ => nonExist} ;
artDef mere.g n c ++ mere.s ! n ++
mere.s2 ++ lequel.s ! RComplex g n mere.c
} ;
_ => nonExist
} ;
g = RG mere.g
} ;
-- Verbs
negVerb = \va -> elisNe ++ va ++ "pas" ;
copula = \b -> (etreNetre b).s ;
isTransVerbClit = \v -> case v.c of {
Acc => True ;
_ => False --- hmmm
} ;
-- The "ne - pas" negation.
posNeg = \b,v,c ->
if_then_else Str b
(v ++ c)
(elisNe ++ v ++ "pas" ++ c) ; --- exception: infinitive!
-- Exampe: 'to be or not to be'.
etreNetre : Bool -> VerbPres = \b ->
{s = \\w => posNeg b (verbEtre.s ! w) []} ; ---- v reveals a BUG in refresh
locativeNounPhrase = \jean ->
{s = "dans" ++ jean.s ! Ton Acc} ;
embedConj = elisQue ;
-- Relative pronouns
identRelPron = {
s = table {
RSimple c => relPronForms ! c ;
RComplex g n c => composRelPron g n c
} ;
g = RNoGen
} ;
suchPron = telPron ;
composRelPron = lequelPron ;
allRelForms = \lequel,g,n,c ->
variants {
lequel.s ! RSimple c ;
lequel.s ! RComplex g n c
} ;
-- Interrogative pronouns
nounIntPron = \n, mec ->
{s = \\c => prepCase c ++ quelPron mec.g n ++ mec.s ! n ;
g = mec.g ;
n = n
} ;
intPronWho = \num -> {
s = \\c => prepCase c ++ "qui" ;
g = Masc ; --- can we decide this?
n = num
} ;
intPronWhat = \num -> {
s = table {
Gen => ["de quoi"] ;
Acc => ["à quoi"] ;
c => elisQue
} ;
g = Masc ; --- can we decide this?
n = num
} ;
-- Questions
questVerbPhrase = \jean,dort ->
{s = table {
DirQ => optStr (estCeQue Acc) ++ (predVerbPhrase jean dort).s ! Ind ;
IndirQ => siSubj ++ (predVerbPhrase jean dort).s ! Ind
}
} ;
intVerbPhrase = \qui, dort ->
{s = table {
DirQ => qui.s ! Nom ++ optStr (estCeQue Nom) ++
dort.s ! qui.g ! VFin Ind qui.n P3 ;
IndirQ => "ce" ++ qui.s ! Nom ++ dort.s ! qui.g ! VFin Ind qui.n P3
}
} ;
intSlash = \Qui, Tuvois ->
let {qui = Tuvois.s2 ++ Qui.s ! Tuvois.c ; tuvois = Tuvois.s ! Ind} in
{s = table {
DirQ => qui ++ optStr (estCeQue Acc) ++ tuvois ;
IndirQ => ifCe Tuvois.c ++ qui ++ tuvois
}
} ;
-- An auxiliary to distinguish between
-- "je ne sais pas" ("ce qui dort" / "ce que tu veux" / "à qui tu penses").
ifCe : Case -> Str = \c -> case c of {
Nom => "ce" ;
Acc => "ce" ;
_ => []
} ;
questAdverbial = \quand, jean, dort ->
let {jeandort = (predVerbPhrase jean dort).s ! Ind} in
{s = table {
DirQ => quand.s ++ optStr (estCeQue Acc) ++ jeandort ;
IndirQ => quand.s ++ jeandort
}
} ;
----- moved from Morpho
--2 Articles
--
-- A macro for defining gender-dependent tables will be useful.
-- Its first application is in the indefinite article.
--
-- Notice that the plural genitive is special: "de femmes".
genForms : Str -> Str -> Gender => Str = \bon,bonne ->
table {Masc => bon ; Fem => bonne} ;
artIndef = \g,n,c -> case <n,c> of {
<Sg,_> => prepCase c ++ genForms "un" "une" ! g ;
<Pl,Gen> => elisDe ;
_ => prepCase c ++ "des"
} ;
artDef = \g,n,c -> artDefTable ! g ! n ! c ;
pronJe = mkPronoun
(elision "j")
(elision "m")
(elision "m")
"moi"
"mon" (elisPoss "m") "mes"
PNoGen -- gender cannot be known from pronoun alone
Sg
P1
Clit1 ;
pronTu = mkPronoun
"tu"
(elision "t")
(elision "t")
"toi"
"ton" (elisPoss "t") "tes"
PNoGen
Sg
P2
Clit1 ;
pronIl = mkPronoun
"il"
(elision "l")
"lui"
"lui"
"son" (elisPoss "s") "ses"
(PGen Masc)
Sg
P3
Clit2 ;
pronElle = mkPronoun
"elle"
elisLa
"lui"
"elle"
"son" (elisPoss "s") "ses"
(PGen Fem)
Sg
P3
Clit2 ;
pronNous = mkPronoun
"nous"
"nous"
"nous"
"nous"
"notre" "notre" "nos"
PNoGen
Pl
P1
Clit3 ;
pronVous = mkPronoun
"vous"
"vous"
"vous"
"vous"
"votre" "votre" "vos"
PNoGen
Pl --- depends!
P2
Clit3 ;
pronIls = mkPronoun
"ils"
"les"
"leur"
"eux"
"leur" "leur" "leurs"
(PGen Masc)
Pl
P3
Clit1 ;
pronElles = mkPronoun
"elles"
"les"
"leur"
"elles"
"leur" "leur" "leurs"
(PGen Fem)
Pl
P3
Clit1 ;
-- moved from ResFra
commentAdv = ss "comment" ;
quandAdv = ss "quand" ;
ouAdv = ss "où" ;
pourquoiAdv = ss "pourquoi" ;
etConj = ss "et" ** {n = Pl} ;
ouConj = ss "ou" ** {n = Sg} ;
etetConj = sd2 "et" "et" ** {n = Pl} ;
ououConj = sd2 "ou" "ou" ** {n = Sg} ;
niniConj = sd2 "ni" "ni" ** {n = Sg} ; --- requires ne !
siSubj = ss siSubj ;
quandSubj = ss "quand" ;
ouiPhr = ss ["Oui ."] ;
nonPhr = ss ["Non ."] ; --- and also Si!
}

View File

@@ -0,0 +1,34 @@
--# -path=.:../romance:../abstract:../../prelude
concrete TestFra of TestAbs = ResFra ** open Prelude, TypesFra, MorphoFra, SyntaxFra in {
flags startcat=Phr ; lexer=text ; parser=chart ; unlexer=text ;
lin
Big = mkAdjDegrReg "grand" adjPre ;
Small = mkAdjDegrReg "petit" adjPre ;
Old = mkAdjDegrLong (mkAdj "vieux" "vieux" "vieille") adjPre ;
Young = mkAdjDegrLong (adjJeune "jeune") adjPre ;
Man = mkCNomReg "homme" Masc ;
Woman = mkCNomReg "femme" Fem ;
Car = mkCNomReg "voiture" Fem ;
Light = mkCNomReg "lumière" Fem ;
House = mkCNomReg "maison" Fem ;
Walk = verbPres (conj1aimer "marcher") ;
Run = verbPres (conj3courir "courir") ;
Send = mkTransVerbDir (verbPres (conj1envoyer "envoyer")) ;
Love = mkTransVerbDir (verbPres (conj1aimer "aimer")) ;
Wait = mkTransVerbDir (verbPres (conj3rendre "attendre")) ;
Say = verbSent (verbPres (conj3dire "dire")) Ind Ind ;
Prove = verbSent (verbPres (conj1aimer "démontrer")) Ind Ind ;
SwitchOn = mkTransVerbDir (verbPres (conj1aimer "allumer")) ;
SwitchOff = mkTransVerbDir (verbPres (conj3peindre "éteindre")) ;
Mother = funDe (mkCNomReg "mère" Fem) ;
Uncle = funDe (mkCNomReg "oncle" Masc) ;
Well = ss "bien" ;
Always = ss "toujours" ;
John = mkProperName "Jean" Masc ;
Mary = mkProperName "Marie" Fem ;
}

View File

@@ -0,0 +1,160 @@
--1 French Word Classes and Morphological Parameters
--
-- This is a resource module for Italian morphology, defining the
-- morphological parameters and word classes of Italian.
-- The morphology is so far only
-- complete w.r.t. the syntax part of the resource grammar.
-- It does not include those parameters that are not needed for
-- analysing individual words: such parameters are defined in syntax modules.
instance TypesFra of TypesRomance = {
-- Now we can give values to the abstract types.
param
Case = Nom | Acc | Gen | Dat ; -- corresp. to prepositions de and à
NPForm = Ton Case | Aton Case | Poss Number Gender ;
oper
CaseA = Case ;
NPFormA = NPForm ;
nominative = Nom ;
accusative = Acc ;
genitive = Gen ;
dative = Dat ;
stressed = Ton ;
unstressed = Aton ;
------------------------- move this somewhere else!
--2 Some phonology
--
--3 Elision
--
-- The phonological rule of *elision* can be defined as follows in GF.
-- There is one thing that is not treated properly: the "h aspiré",
-- which is not separated orthographically from the "h muet".
-- Our definition works correctly only for the "h muet".
oper
voyelle : Strs = strs {
"a" ; "â" ; "à" ; "e" ; "ê" ; "é" ; "è" ;
"h" ;
"i" ; "î" ; "o" ; "ô" ; "u" ; "û" ; "y"
} ;
elision : Str -> Str = \d -> d + pre {"e" ; "'" / voyelle} ;
-- The following morphemes are the most common uses of elision.
elisDe = elision "d" ;
elisLa = pre {"la" ; "l'" / voyelle} ;
elisLe = elision "l" ;
elisNe = elision "n" ;
elisQue = elision "qu" ;
-- The subjunction "si" has a special kind of elision. The rule is
-- only approximatively correct, for "si" is not really elided before
-- the string "il" in general, but before the pronouns "il" and "ils".
siSubj = pre {"si" ; "s'" / strs {"il"}} ;
--2 Prepositions
--
-- The type $Cas$ in $types.Fra.gf$ has the dative and genitive
-- cases, which are relevant for pronouns and the definite article,
-- but which are otherwise expressed by prepositions.
prepCase = \c -> case c of {
Nom => [] ;
Acc => [] ;
Gen => elisDe ;
Dat => "à"
} ;
--2 Relative pronouns
--
-- The simple (atonic) relative pronoun shows genuine variation in all of the
-- cases.
relPronForms = table {
Nom => "qui" ; Gen => "dont" ; Dat => ["à qui"] ; Acc => elisQue
} ;
-- Usually the comparison forms are built by prefixing the word
-- "plus". The definite article needed in the superlative is provided in
-- $syntax.Fra.gf$.
adjCompLong : Adj -> AdjComp = \cher ->
mkAdjComp
cher.s
(\\g,n => "plus" ++ cher.s ! g ! n) ;
-- Comparative adjectives are only sometimes formed morphologically
-- (actually: by different morphemes).
mkAdjComp : (_,_ : Gender => Number => Str) -> AdjComp =
\bon, meilleur ->
{s = table {Pos => bon ; _ => meilleur}} ;
------------------------------
-- Their inflection tables has tonic and atonic forms, as well as
-- the possessive forms, which are inflected like determiners.
--
-- Example: "lui, de lui, à lui" - "il,le,lui" - "son,sa,ses".
--
-- Examples of each: "Jean" ; "je"/"te" ; "il"/"elle"/"ils"/"elles" ; "nous"/"vous".
-- The following coercions are useful:
oper
pform2case = \p -> case p of {
Ton x => x ;
Aton x => x ;
Poss _ _ => Gen
} ;
case2pform = \c -> case c of {
Nom => Aton Nom ;
Acc => Aton Acc ;
_ => Ton c
} ;
-- Relative pronouns: the case-dependent parameter type.
param RelForm = RSimple Case | RComplex Gender Number Case ;
oper RelFormA = RelForm ;
-- Verbs: conversion from full verbs to present-tense verbs.
verbPres = \aller -> {s = table {
VInfin => aller ! Inf ;
VFin Ind n p => aller ! Indic Pres n p ;
VFin Sub n p => aller ! Subjo SPres n p ;
VImper np => aller ! Imper np
}} ;
-- The full conjunction is a table on $VForm$:
param
Temps = Pres | Imparf | Passe | Futur ;
TSubj = SPres | SImparf ;
TPart = PPres | PPasse Gender Number ;
VForm = Inf
| Indic Temps Number Person
| Cond Number Person
| Subjo TSubj Number Person
| Imper NumPersI
| Part TPart ;
-- This is the full verb type.
oper
Verbum : Type = VForm => Str ;
}