diff --git a/grammars/resource/french/MorphoFra.gf b/grammars/resource/french/MorphoFra.gf new file mode 100644 index 000000000..4b3c8ff2b --- /dev/null +++ b/grammars/resource/french/MorphoFra.gf @@ -0,0 +1,1231 @@ +--# -path=.:../romance:../../prelude + +--1 A Simple French Resource Morphology +-- +-- Aarne Ranta 2002--2003 +-- +-- This resource morphology contains definitions needed in the resource +-- syntax. It moreover contains the most usual inflectional patterns. +-- The patterns for verbs contain the complete "Bescherelle" conjugation +-- tables. +-- +-- We use the parameter types and word classes defined in $types.Fra.gf$. + +resource MorphoFra = open (Predef=Predef), Prelude, TypesFra in { + + +--3 Front vowels +-- +-- In verb conjugation, we will need the concept of frontal vowel. + +oper + voyelleFront : Strs = strs {"e" ; "i" ; "y" ; "é" ; "è"} ; + preVoyelleFront : (_,_ : Str) -> Str = \t,u -> pre {t ; u / voyelleFront} ; + + +--2 Nouns +-- +-- The following macro is useful for creating the forms of number-dependent +-- tables, such as common nouns. + + numForms : Str -> Str -> Number => Str = \bon,bons -> + table {Sg => bon ; Pl => bons} ; + +-- For example, the regular noun forms are defined as follows: + + nomReg : Str -> Number => Str = \bu -> numForms bu (bu + "s") ; + +-- Common nouns are inflected in number and have an inherent gender. + + mkCNom : (Number => Str) -> Gender -> CNom = \mecmecs,gen -> + {s = mecmecs ; g = gen} ; + + mkCNomIrreg : Str -> Str -> Gender -> CNom = \mec,mecs -> + mkCNom (numForms mec mecs) ; + + mkCNomReg : Str -> Gender -> CNom = \mec -> + mkCNom (nomReg mec) ; + + mkCNomNiveau : Str -> Gender -> CNom = \niveau -> + mkCNomIrreg niveau (niveau + "x") ; + + mkCNomCheval : Str -> Gender -> CNom = \cheval -> + let {cheva = Predef.tk 1 cheval} in + mkCNomIrreg cheval (cheva + "ux") ; + + mkCNomInvar : Str -> Gender -> CNom = \cas -> + mkCNomIrreg cas cas ; + + + +-- The definite article has quite some variation: three parameters and +-- elision. This is the simples definition we have been able to find. + + artDef : Gender -> Number -> Case -> Str = \g,n,c -> artDefTable ! g ! n ! c ; + + artDefTable : Gender => Number => Case => Str = \\g,n,c => case of { + => elisLe ; + => pre {"du" ; ["de l'"] / voyelle} ; + => pre {"au" ; ["à l'"] / voyelle} ; + => elisLe ; + => prepCase c ++ elisLa ; + <_, Pl, Gen> => "des" ; + <_, Pl, Dat> => "aux" ; + <_, Pl, _ > => "les" + } ; + + +--2 Adjectives +-- +-- Adjectives are conveniently seen as gender-dependent nouns. +-- Here are some patterns. First one that describes the worst case. + + mkAdj : (_,_,_ : Str) -> Adj = \vieux,vieuxs,vieille -> + {s = table { + Masc => numForms vieux vieuxs ; + Fem => nomReg vieille + } + } ; + +-- Then the regular and invariant patterns. + + adjReg : Str -> Gender => Number => Str = \bu -> table { + Masc => nomReg bu ; + Fem => nomReg (bu + "e") + } ; + + adjInvar : Str -> Gender => Number => Str = \bien -> + \\_,_ => bien ; + +-- Adjectives themselves are records. Here the most common cases: + + adjGrand : Str -> Adj = \grand -> + {s = adjReg grand} ; + + adjHeureux : Str -> Adj = \heureux -> + let {heureu = Predef.tk 1 heureux} in + mkAdj heureux heureu (heureu+"se") ; + + adjJeune : Str -> Adj = \jeune -> + mkAdj jeune (jeune+"s") jeune ; + + adjIndien : Str -> Adj = \indien -> + mkAdj indien (indien+"s") (indien+"ne") ; + + adjFrancais : Str -> Adj = \francais -> + mkAdj francais francais (francais+"e") ; + + adjCher : Str -> Adj = \cher -> + let {ch = Predef.tk 2 cher} in + mkAdj cher (cher + "s") (ch + "ère") ; + + + +--2 Personal pronouns +-- +-- All the eight personal pronouns can be built by the following macro. +-- The use of "en" as atonic genitive is debatable. + + mkPronoun : (_,_,_,_,_,_,_ : Str) -> + PronGen -> Number -> Person -> ClitType -> Pronoun = + \il,le,lui,Lui,son,sa,ses,g,n,p,c -> + {s = table { + Ton x => prepCase x ++ Lui ; + Aton Nom => il ; + Aton Acc => le ; + Aton Gen => "en" ; --- hmm + Aton Dat => lui ; + Poss Sg Masc => son ; + Poss Sg Fem => sa ; + Poss Pl _ => ses + } ; + g = g ; + n = n ; + p = p ; + c = c + } ; + + elisPoss : Str -> Str = \s -> + pre {s + "a" ; s + "on" / voyelle} ; + + 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 ; + +--2 Reflexive pronouns +-- +-- It is simply a function depending on number and person. + + pronRefl : Number -> Person -> Str = \n,p -> case of { + => elision "m" ; + => elision "t" ; + <_, P3> => elision "s" ; + => "nous" ; + => "vous" + } ; + + + +-- The composable pronoun "lequel" is inflected by varying the definite +-- article and the determiner "quel" in the expected way. + + lequelPron : Gender -> Number -> Case -> Str = \g,n,c -> + artDef g n c + quelPron g n ; + + +--2 Determiners +-- +-- Determiners, traditionally called indefinite pronouns, are inflected +-- in gender and number. It is usually enough to give the two singular +-- forms to form the plurals. + + pronForms : Str -> Str -> Gender -> Number -> Str = \tel,telle,g,n -> case g of { + Masc => nomReg tel ! n ; + Fem => nomReg telle ! n + } ; + + quelPron : Gender -> Number -> Str = pronForms "quel" "quelle" ; + + telPron : Gender -> Number -> Str = pronForms "tel" "telle" ; + + toutPron : Gender -> Number -> Str = \g,n -> case g of { + Masc => numForms "tout" "tous" ! n ; + Fem => nomReg "toutee" ! n + } ; + +-- The following macro generates the phrases "est-ce que", "est-ce qu'", +-- and "est-ce qui" (the last one used e.g. in "qu'est-ce qui"). + + estCeQue : Case -> Str = \c -> + "est-ce" ++ case c of { + Nom => "qui" ; + Acc => elisQue ; + _ => nonExist --- dont? + } ; + + +--2 Verbs +-- +--3 The present tense +-- +-- We first define some macros for the special case of present tense. +-- +-- The verb "être" is often used in syntax. + + verbEtre = verbPres (conjÊtre "être") ; + +-- We very often form the verb stem by dropping out the infinitive ending. + + troncVerb : Tok -> Tok = Predef.tk 2 ; + + + +--3 Affixes +-- +-- It is convenient to have sets of affixes as data objects. + + Affixe : Type = Person => Str ; + + lesAffixes : (_,_,_ : Str) -> Affixe = \x,y,z -> table { + P1 => x ; + P2 => y ; + P3 => z + } ; + +-- Much of variation can be described in terms of affix sets: + + affixSgE : Affixe = lesAffixes "e" "es" "e" ; + + affixSgS : Affixe = lesAffixes "s" "s" "t" ; + + affixSgSsansT : Affixe = lesAffixes "s" "s" [] ; + + affixSgX : Affixe = lesAffixes "x" "x" "t" ; + + affixPlOns : Affixe = lesAffixes "ons" "ez" "ent" ; + + affixSgAi : Affixe = lesAffixes "ai" "as" "a" ; + + affixSgAis : Affixe = \\p => "ai" + affixSgS ! p ; + + affixPlIons : Affixe = table { + P3 => "aient" ; + p => "i" + affixPlOns ! p + } ; + +-- Often affix sets come in pairs, for the singular and the plural. + + affixImparf : Number => Affixe = table { + Sg => affixSgAis ; + Pl => affixPlIons + } ; + + affixFutur : Number => Affixe = table { + Sg => affixSgAi ; + Pl => table { + P3 => "ont" ; + p => affixPlOns ! p + } + } ; + + affixSPres : Number => Affixe = table { + Sg => affixSgE ; + Pl => table { + P3 => "ent" ; + p => affixPlIons ! p + } + } ; + + affixPlMes : (_,_ : Str) -> Affixe = + \è, â -> lesAffixes (â + "mes") (â + "tes") (è + "rent") ; + + affixPasseAi : Number => Affixe = table { + Sg => affixSgAi ; + Pl => affixPlMes "è" "â" + } ; + + affixPasseS : (i,î : Str) -> Number => Affixe = \i,î -> table { + Sg => table {p => i + affixSgS ! p} ; + Pl => affixPlMes i î + } ; + + affixSImparfSse : (i,î : Str) -> Number => Affixe = \i,î -> table { + Sg => table { + P3 => î + "t" ; + p => i + "ss" + affixSgE ! p + } ; + Pl => table {p => i + "ss" + affixSPres ! Pl ! p} + } ; + + AffixPasse : Type = {ps : Number => Affixe ; si : Number => Affixe} ; + + affixPasse : (_,_ : Str) -> AffixPasse = \i, î -> + {ps = affixPasseS i î ; si = affixSImparfSse i î} ; + + affixPasseA : AffixPasse = {ps = affixPasseAi ; si = affixSImparfSse "a" "â"} ; + + affixPasseI : AffixPasse = affixPasse "i" "î" ; + + affixPasseU : AffixPasse = affixPasse "u" "û" ; + + affixPasseNonExist : AffixPasse = + let {aff : Number => Affixe = + table {_ => lesAffixes nonExist nonExist nonExist}} in + {ps = aff ; si = aff} ; + + affixImper : NumPersI => Str = table { + SgP2 => "e" ; + PlP1 => "ons" ; + PlP2 => "ez" + } ; + + formesPresAi : (v,all : Str) -> Number => Affixe = \v,all -> table { + Sg => \\p => v + affixSgAi ! p ; + Pl => table { + P3 => v + "ont" ; + p => all + affixPlOns ! p + } + } ; + +--3 Macros for the complete conjugation type +-- +-- The type $VForm$ has 55 forms, as defined in $types.Fra.gf$. +-- The worst-case macro takes 11 stems and two affix sets. +-- (We will actually never need all of these at the same time.) + + Verbe : Type = VForm => Str ; + + verbAffixes : + (a,b,c,d,e,f,g,h,i,j,k : Str) -> Affixe -> AffixPasse -> Verbe = + \tien, ten, tienn, t, tiendr, soi, soy, soie, tenu, tenus, tenir -> + \affpres, affpasse -> + table { + Inf => tenir ; + Indic Pres Sg p => tien + affpres ! p ; + Indic Pres Pl P3 => tienn + affixPlOns ! P3 ; + Indic Pres Pl p => ten + affixPlOns ! p ; + Indic Imparf n p => ten + affixImparf ! n ! p ; + Indic Passe n p => t + affpasse.ps ! n ! p ; + Indic Futur n p => tiendr + affixFutur ! n ! p ; + Cond n p => tiendr + affixImparf ! n ! p ; + Subjo SPres Sg p => soi + affixSPres ! Sg ! p ; + Subjo SPres Pl P3 => soi + "ent" ; + Subjo SPres Pl p => soy + affixSPres ! Pl ! p ; + Subjo SImparf n p => t + affpasse.si ! n ! p ; + Imper SgP2 => soie ; + Imper p => soy + affixImper ! p ; + Part PPres => ten + "ant" ; + Part (PPasse Masc Sg) => tenu ; + Part (PPasse Fem Sg) => tenu + "e" ; + Part (PPasse Masc Pl) => tenus ; + Part (PPasse Fem Pl) => tenu + "es" + } ; + +-- Almost always seven stems are more than enough. + + verbHabituel : + (a,b,c,d,e,f,g : Str) -> Affixe -> AffixPasse -> Verbe = + \tien, ten, tienn, t, tiendr, tenu, tenir -> + \affpres, affpasse -> + verbAffixes tien ten tienn t tiendr tienn ten + (tien + affpres ! P1) tenu (tenu+"s") tenir affpres affpasse ; + +--3 The first conjugation +-- +-- There is quite some phonologically explained variation in the first conjugation. +-- The worst case has three different stems. + + auxConj1 : Str -> Str -> Str -> Verbe = \jet, jett, jeter -> + verbHabituel jett jet jett jet jeter (jet+"é") (jet+"er") affixSgE affixPasseA ; + + conj1aimer : Str -> Verbe = \aimer -> + let {aim = troncVerb aimer} in + auxConj1 aim aim aimer ; + + conj1céder : Str -> Verbe = \céder -> + let { + ced = troncVerb céder ; + d = Predef.dp 1 ced ; + c = Predef.tk 2 ced ; + cèd = c + "è" + "d" ; + céd = c + "é" + "d" + } + in auxConj1 céd cèd céder ; + + conj1jeter : Str -> Verbe = \jeter -> + let { + jet = troncVerb jeter ; + jett = jet + Predef.dp 1 jet + } + in auxConj1 jet jett (jett + "er") ; + + conj1placer : Str -> Verbe = \placer -> + let { + pla = Predef.tk 3 placer ; + plac = preVoyelleFront (pla+"ç") (pla+"c") + } in + auxConj1 plac plac placer ; + + conj1manger : Str -> Verbe = \manger -> + let { + mang = Predef.tk 2 manger ; + mange = preVoyelleFront (mang+"e") mang + } in + auxConj1 mange mange manger ; + + conj1assiéger : Str -> Verbe = \assiéger -> + let {assi = Predef.tk 4 assiéger} in + auxConj1 (preVoyelleFront (assi+"ége") (assi+"ég")) (assi+"èg") assiéger ; + + conj1payer : Str -> Verbe = \payer -> + let {pa = Predef.tk 3 payer} in + auxConj1 (pa + "y") (pa + "i") (pa + "ier") ; + + conj1envoyer : Str -> Verbe = \envoyer -> + let {renv = Predef.tk 4 envoyer} in + auxConj1 (renv + "oy") (renv + "oi") (renv + "err") ; + + +--3 The second conjugation +-- +-- There are just two different cases. + + conj2finir : Str -> Verbe = \finir -> + let { + fin = troncVerb finir ; + fini = fin + "i" ; + finiss = fin + "iss" + } in + verbHabituel fini finiss finiss fin finir fini finir affixSgS affixPasseI ; + + conj2haïr : Str -> Verbe = \haïr -> + let {ha = troncVerb haïr ; + hai = ha + "i" ; + haï = ha + "ï" ; + haiss = ha + "ïss" + } in + verbHabituel hai haiss haiss ha haïr haï haïr affixSgS (affixPasse "ï" "ï") ; + + +--3 The third conjugation +-- +-- This group is very heterogeneous. Most verbs have "re" in the infinitive, +-- but the first example does not! + + conj3tenir : Str -> Verbe = \tenir -> + let {t = Predef.tk 4 tenir} in + verbHabituel + (t+"ien") (t+"en") (t+"ienn") t (t+"iendr") (t+"enu") tenir + affixSgS (affixPasse "in" "în") ; + +-- Many verbs have "is" in the past participle. But there is so much variation +-- that the worst-case macro needs seven forms. + + auxConj3is : (_,_,_,_,_,_,_ : Str) -> Verbe = + \quier, quér, quièr, qu, querr, quis, quiss -> + verbAffixes + quier quér quièr qu querr quièr quér + (quier + "s") quis quiss (quér + "ir") affixSgS affixPasseI ; + + auxConj3ir : (_,_,_ : Str) -> Verbe = \sen, sent, i -> + auxConj3is sen sent sent sent (sent+"ir") (sent+i) (sent+i+"s") ; + + conj3quérir : Str -> Verbe = \quérir -> + let {qu = Predef.tk 4 quérir} in + auxConj3is (qu+"ier") (qu+"ér") (qu+"ièr") qu (qu+"err") (qu+"is") (qu+"is") ; + + conj3sentir : Str -> Verbe = \sentir -> + let { + sent = troncVerb sentir ; + sen = Predef.tk 1 sent + } in + auxConj3ir sen sent "i" ; + + conj3vêtir : Str -> Verbe = \vêtir -> + let { + s = Predef.tk 5 vêtir ; + vet = auxConj3ir "vêt" "vêt" "u" + } in + table { + Indic Pres Sg P3 => s + "vêt" ; + p => s + vet ! p + }; + + auxConj3vrir : (_,_,_ : Str) -> Verbe = \ouvr, i, ouvert -> + verbAffixes + ouvr ouvr ouvr ouvr (ouvr + i + "r") ouvr ouvr + (ouvr + "e") ouvert (ouvert + "s") (ouvr + "ir") affixSgE affixPasseI ; + + conj3couvrir : Str -> Verbe = \couvrir -> + let {couv = Predef.tk 3 couvrir} in + auxConj3vrir (couv+"r") "i" (couv+"ert") ; + + conj3cueillir : Str -> Verbe = \cueillir -> + let {cueill = troncVerb cueillir} in + auxConj3vrir cueill "e" (cueill + "i") ; + + conj3assaillir : Str -> Verbe = \assaillir -> + let {assaill = troncVerb assaillir} in + auxConj3vrir assaill "i" (assaill + "i") ; + +-- The verb "faillir" has lots of alternatives forms. + + conj3faillir : Str -> Verbe = \faillir -> + let { + fa = Predef.tk 5 faillir ; + faudr = fa + "udr" ; + tfa = conj3assaillir faillir + } in + table { + Indic Pres Sg p => fa + "u" + affixSgX ! p ; + Subjo SPres n p => fa + variants {"illiss" ; "ill"} + affixSPres ! n ! p ; + + Indic Futur n p => variants {tfa ! Indic Futur n p ; faudr + affixFutur ! n ! p} ; + Cond n p => variants {tfa ! Cond n p ; faudr + affixImparf ! n ! p} ; + + Imper _ => nonExist ; + p => tfa ! p + }; + + conj3bouillir : Str -> Verbe = \bouillir -> + let { + bou = Predef.tk 5 bouillir ; + tbou = conj3assaillir bouillir + } in + table { + Indic Pres Sg p => bou + affixSgS ! p ; + Imper SgP2 => bou + "s" ; + p => tbou ! p + }; + +-- Notice that here we don't need another conjugation, as Bescherelle does. + + conj3dormir : Str -> Verbe = conj3sentir ; + +-- The verbs "mourir" and "courir" have much in common, except the first two +-- persons in the present indicative singular, and the past participles. + + auxConj3ourir : (_,_,_ : Str) -> Verbe = \meur, mour, mort -> + verbAffixes + meur mour meur mour (mour + "r") meur mour + (meur + "s") mort (mort + "s") (mour + "ir") affixSgS affixPasseU ; + + conj3courir : Str -> Verbe = \courir -> + let {cour = troncVerb courir} in + auxConj3ourir cour cour (cour + "u") ; + + conj3mourir : Str -> Verbe = \mourir -> + let {m = Predef.tk 5 mourir} in + auxConj3ourir (m + "eur") (m + "our") (m + "ort") ; + +-- A little auxiliary to cover "fuir" and "ouïr". +-- *N.B.* some alternative forms for "ouïr" are still missing. + + auxConj3ui : AffixPasse -> (_,_,_ : Str) -> Verbe = \affpasse, o, ou, ouï -> + let {oi : Str = o + "i" ; oy : Str = o + "y" ; ouïr : Str = ouï + "r"} in + verbHabituel oi oy oi ou ouïr ouï ouïr affixSgS affpasse ; + + conj3fuir : Str -> Verbe = \fuir -> + let {fu = troncVerb fuir} in + auxConj3ui affixPasseI fu fu (fu + "i") ; + + conj3ouïr : Str -> Verbe = \ouir -> + let {o = Predef.tk 3 ouir} in + auxConj3ui (affixPasse "ï" "ï") o (o + "u") (o + "uï") ; + +-- The verb "gésir" lacks many forms. + + conj3gésir : Str -> Verbe = \gésir -> + let {g = Predef.tk 4 gésir} in + table { + Inf => g + "ésir" ; + Indic Pres Sg p => g + lesAffixes "is" "is" "ît" ! p ; + Indic Pres Pl p => g + "is" + affixPlOns ! p ; + Indic Imparf n p => g + "is" + affixImparf ! n ! p ; + Part PPres => g + "isant" ; + _ => nonExist + } ; + +-- Here is an auxiliary for a large, and heterogeneous, group of verbs whose +-- infinitive ends in "oir". It has two special cases, depending on the ending +-- of the first two persions in the present indicative singular. + + auxConj3oir : Affixe -> AffixPasse -> (_,_,_,_,_,_,_,_ : Str) -> Verbe = + \affpres, affpasse -> + \peu, pouv, peuv, p, pourr, veuill, voul, v -> + let {pu : Str = p + "u"} in + verbAffixes + peu pouv peuv p pourr veuill voul (peu+affpres!P1) pu (pu+"s") (v+"oir") + affpres affpasse ; + + auxConj3usX : (_,_,_,_,_,_,_,_ : Str) -> Verbe = + auxConj3oir affixSgX affixPasseU ; + auxConj3usS : (_,_,_,_,_,_,_,_ : Str) -> Verbe = + auxConj3oir affixSgS affixPasseU ; + + conj3cevoir : Str -> Verbe = \cevoir -> + let {re = Predef.tk 6 cevoir} in + auxConj3usS (re+"çoi") (re+"cev") (re+"çoiv") (re+"ç") + (re+"cevr") (re+"çoiv") (re+"cev") (re+"cev") ; + + conj3voir : Str -> Verbe = \voir -> + let { + v = Predef.tk 3 voir ; + voi = v + "oi" + } in + auxConj3oir + affixSgS affixPasseI voi (v + "oy") voi v (v + "err") voi (v + "oy") v ; + + conj3pourvoir : Str -> Verbe = \pourvoir -> + let { + pourv = Predef.tk 3 pourvoir ; + pourvoi = pourv + "oi" ; + pourvoy = pourv + "oy" + } in + auxConj3usS pourvoi pourvoy pourvoi pourv pourvoir pourvoi pourvoy pourv ; + + conj3savoir : Str -> Verbe = \savoir -> + let { + s = Predef.tk 5 savoir ; + tsavoir = auxConj3usS "ai" "av" "av" "" "aur" "ach" "ach" "av" + } in + table { + Imper p => s + "ach" + affixImper ! p ; + Part PPres => s + "achant" ; + p => s + tsavoir ! p + } ; + + conj3devoir : Str -> Verbe = \devoir -> + let { + s = Predef.tk 6 devoir ; + tdevoir = auxConj3usS "doi" "dev" "doiv" "d" "devr" "doiv" "dev" "dev" + } in + table { + Part (PPasse Masc Sg) => s + "dû" ; + p => s + tdevoir ! p + } ; + + conj3pouvoir : Str -> Verbe = \pouvoir -> + let { + p = Predef.tk 6 pouvoir ; + tpouvoir = auxConj3usX "eu" "ouv" "euv" "" "ourr" "uiss" "uiss" "ouv" + } in + table { + Indic Pres Sg P1 => p + variants {"eux" ; "uis"} ; + t => p + tpouvoir ! t + } ; + + conj3mouvoir : Str -> Verbe = \mouvoir -> + let { + s = Predef.tk 7 mouvoir ; + mu = adjReg "mû" ; + tmouvoir = auxConj3usS "meu" "mouv" "meuv" "m" "mouvr" "meuv" "mouv" "mouv" + } in + table { + Part (PPasse g n) => s + mu ! g ! n ; + p => s + tmouvoir ! p + } ; + + auxConj3seul3sg : (_,_,_,_,_ : Str) -> Verbe = + \faut, fall, pl, faudr, faill -> table { + Inf => fall + "oir" ; + Indic Pres Sg P3 => faut ; + Indic Imparf Sg P3 => fall + "ait" ; + Indic Passe Sg P3 => pl + "ut" ; + Indic Futur Sg P3 => faudr + "a" ; + Cond Sg P3 => faudr + "ait" ; + Subjo SPres Sg P3 => faill + "e" ; + Subjo SImparf Sg P3 => pl + "ût" ; + Part PPres => fall + "ant" ; + Part (PPasse g n) => adjReg (pl + "u") ! g ! n ; + _ => nonExist + } ; + + conj3pleuvoir : Str -> Verbe = \pleuvoir -> + let { + pleuv = Predef.tk 3 pleuvoir ; + pl = Predef.tk 3 pleuv + } in + auxConj3seul3sg (pl + "eut") pleuv pl (pleuv + "r") pleuv ; + + conj3falloir : Str -> Verbe = \falloir -> + let { + fa = Predef.tk 5 falloir ; + fau = fa + "u" ; + fall = Predef.tk 3 falloir + } in + auxConj3seul3sg (fau + "t") fall fall (fau + "dr") (fa + "ill") ; + + conj3valoir : Str -> Verbe = \valoir -> + let { + va = Predef.tk 4 valoir ; + val = va + "l" + } in + auxConj3usX (va + "u") val val val (va + "udr") (va + "ill") val val ; + + conj3vouloir : Str -> Verbe = \vouloir -> + let { + v = Predef.tk 6 vouloir ; + vo = v + "o" ; + voul = vo + "ul" ; + veul = v + "eul" + } in + auxConj3usX (v + "eu") voul veul voul (vo + "udr") (v + "euill") voul voul ; + +-- The following two are both "asseoir" in the Bescherelle, which however +-- points out that the latter conjugation has an infinitive form without "e" +-- since the orthographic rectifications of 1990. + + conj3asseoir : Str -> Verbe = \asseoir -> + let { + ass = Predef.tk 4 asseoir ; + tasseoir = auxConj3is "ied" "ey" "ey" "" "iér" "is" "is" + } in + table { + Inf => ass + "eoir" ; + Indic Pres Sg P3 => ass + "ied" ; + t => ass + tasseoir ! t + } ; + + conj3assoir : Str -> Verbe = \assoir -> + let { + ass = Predef.tk 3 assoir ; + tassoir = auxConj3is "oi" "oy" "oi" "" "oir" "is" "is" + } in + table { + Inf => ass + variants {"oir" ; "eoir"} ; + t => ass + tassoir ! t + } ; + + conj3seoir : Str -> Verbe = \seoir -> + let { + s = Predef.tk 4 seoir ; + tseoir = conj3asseoir seoir + } in + table { + Indic Pres Pl P3 => s + "iéent" ; + Indic _ _ P1 => nonExist ; + Indic _ _ P2 => nonExist ; + Indic Passe _ _ => nonExist ; + Cond _ P1 => nonExist ; + Cond _ P2 => nonExist ; + Subjo SPres Sg P3 => s + "iée" ; + Subjo SPres Pl P3 => s + "iéent" ; + Subjo _ _ _ => nonExist ; + Imper _ => nonExist ; + Part PPres => s + "éant" ; + t => tseoir ! t + } ; + +-- Here we don't need a new conjugation. + + conj3messeoir : Str -> Verbe = \messeoir -> + let {tmesseoir = conj3seoir messeoir} in + table { + Part (PPasse _ _) => nonExist ; + p => tmesseoir ! p + } ; + + conj3surseoir : Str -> Verbe = \surseoir -> + let { + surs = Predef.tk 4 surseoir ; + tsurseoir = auxConj3is "oi" "oy" "oi" "" "eoir" "is" "is" + } in + table { + Inf => surseoir ; + t => surs + tsurseoir ! t + } ; + +-- Here we interpolate and include the imperfect and subjunctive forms, +-- which Bescherelle leaves out. + + conj3choir : Str -> Verbe = \choir -> + let { + ch = Predef.tk 3 choir ; + tchoir = auxConj3usS "oi" "oy" "oi" "" (variants {"oir" ; "err"}) "oi" "oy" "" + } in + \\p => ch + tchoir ! p ; + + conj3échoir : Str -> Verbe = \échoir -> + let {techoir = conj3choir échoir} in + table { + Indic _ _ P1 => nonExist ; + Indic _ _ P2 => nonExist ; + Indic Pres Pl P3 => Predef.tk 3 échoir + variants {"oient" ; "éent"} ; + Subjo _ _ P1 => nonExist ; + Subjo _ _ P2 => nonExist ; + Cond _ P1 => nonExist ; + Cond _ P2 => nonExist ; + Imper _ => nonExist ; + Part PPres => Predef.tk 3 échoir + "éant" ; + t => techoir ! t + } ; + +-- Verbs with the infinitive ending "re" are a major group within the third +-- conjugation. The worst-case macro takes 2 sets of affixes and 7 stems. + + auxConj3re : Affixe -> AffixPasse -> (_,_,_,_,_,_,_ : Str) -> Verbe = + \affpr, affp -> \prend, pren, prenn, pr, prendr, pris, priss -> + verbAffixes prend pren prenn pr prendr prenn pren + (prend + affpr ! P1) pris priss (prendr + "e") affpr affp ; + + auxConj3tre : (_,_ : Str) -> Verbe = \bat, batt -> + auxConj3re affixSgSsansT affixPasseI + bat batt batt batt (batt + "r") (batt + "u") (batt + "us") ; + + conj3rendre : Str -> Verbe = \rendre -> + let {rend = troncVerb rendre} in + auxConj3tre rend rend ; + + conj3battre : Str -> Verbe = \battre -> + let {bat = Predef.tk 3 battre} in + auxConj3tre bat (bat + "t") ; + + conj3prendre : Str -> Verbe = \prendre -> + let {pr = Predef.tk 5 prendre} in + auxConj3re + affixSgSsansT affixPasseI (pr + "end") (pr + "en") + (pr + "enn") pr (pr + "endr") (pr + "is") (pr + "is") ; + + conj3mettre : Str -> Verbe = \mettre -> + let {m = Predef.tk 5 mettre ; met = m + "et"} in + auxConj3re + affixSgSsansT affixPasseI met (met + "t") + (met + "t") m (met + "tr") (m + "is") (m + "is") ; + + conj3peindre : Str -> Verbe = \peindre -> + let {pe = Predef.tk 5 peindre ; peign = pe + "ign"} in + auxConj3re + affixSgS affixPasseI + (pe + "in") peign peign peign (pe + "indr") (pe + "int") (pe + "ints") ; + +-- We don't need a separate conjugation for "joindre" and "craindre". + + conj3joindre = conj3peindre ; + + conj3craindre = conj3peindre ; + + conj3vaincre : Str -> Verbe = \vaincre -> + let { + vainc = troncVerb vaincre ; + vainqu = Predef.tk 1 vainc + "qu" + } in + auxConj3re + affixSgSsansT affixPasseI + vainc vainqu vainqu vainqu (vainc + "r") (vainc + "u") (vainc + "us") ; + + conj3traire : Str -> Verbe = \traire -> + let { + tra = Predef.tk 3 traire ; + trai = tra + "i" ; + tray = tra + "y" + } in + auxConj3re + affixSgS affixPasseNonExist + trai tray trai [] (trai + "r") (trai + "t") (trai + "ts") ; + +-- The verb "faire" has a great many irregularities. Following Bescherelle, +-- we have left out the plural 2nd person variant "faisez", which is a +-- 'grossier barbarisme'. + + conj3faire : Str -> Verbe = \faire -> + let { + fai = troncVerb faire ; + fais = fai + "s" ; + f = Predef.tk 2 fai ; + tfaire = auxConj3re + affixSgS affixPasseI + fai fais (f + "ass") f (f + "er") (fai + "t") (fai + "ts") + } in + table { + Inf => faire ; + Indic Pres Pl P2 => fai + "tes" ; + Indic Pres Pl P3 => f + "ont" ; + Subjo SPres Pl p => f + "ass" + affixSPres ! Pl ! p ; + Imper PlP2 => fai + "tes" ; + t => tfaire ! t + } ; + + auxConj3oire : (_,_,_,_ : Str) -> Verbe = \boi, buv, boiv, b -> + auxConj3re + affixSgS affixPasseU boi buv boiv b (boi + "r") (b + "u") (b + "us") ; + + auxConj3ît : Verbe -> Str -> Verbe = \conj,plaît -> + table { + Indic Pres Sg P3 => plaît ; + t => conj ! t + } ; + + conj3plaire : Str -> Verbe = \plaire -> + let { + pl = Predef.tk 4 plaire ; + tplaire = auxConj3oire (pl + "ai") (pl + "ais") (pl + "ais") pl + } in + auxConj3ît tplaire (pl + "aît") ; + + conj3connaître : Str -> Verbe = \connaître -> + let { + conn = Predef.tk 5 connaître ; + connaiss = conn + "aiss" ; + tconnaitre = + auxConj3re + affixSgS affixPasseU (conn + "ai") connaiss connaiss + conn (conn + "aîtr") (conn + "u") (conn + "us") + } in + auxConj3ît tconnaitre (conn + "aît") ; + + conj3naître : Str -> Verbe = \naître -> + let { + n = Predef.tk 5 naître ; + tnaitre = auxConj3re + affixSgS affixPasseI + (n + "ai") (n + "aiss") (n + "aiss") (n + "aqu") + (n + "aîtr") (n + "é") (n + "és") + } in + auxConj3ît tnaitre (n + "aît") ; + +-- The conjugation of "paître" is defective in a curious way, especially +-- if compared with "repaître". According to Bescherelle, the invariable +-- past participle is only used as a term of "fauconnerie" (one would expect it +-- to be defective rather than invariable). + + conj3paître : Str -> Verbe = \paître -> + let {tpaitre = conj3connaître paître} in + table { + Indic Passe _ _ => nonExist ; + Subjo SImparf _ _ => nonExist ; + Part (PPasse _ _) => Predef.tk 5 paître + "u" ; + p => tpaitre ! p + } ; + + conj3repaître = conj3connaître ; + + conj3croître : Str -> Verbe = \croître -> + let {cr = Predef.tk 5 croître} in + auxConj3re + affixSgS (affixPasse "û" "û") (cr + "oî") (cr + "oiss") + (cr + "oiss") cr (cr + "oîtr") (cr + "û") (cr + "ûs") ; + + conj3croire : Str -> Verbe = \croire -> + let {cr = Predef.tk 4 croire} in + auxConj3oire (cr + "oi") (cr + "oy") (cr + "oi") cr ; + + conj3boire : Str -> Verbe = \boire -> + let {b = Predef.tk 4 boire} in + auxConj3oire (b + "oi") (b + "uv") (b + "oiv") b ; + +-- The verb "clore" shows a systematic absence of past forms, +-- including the imperfect indicative. What is more capricious, is the absence +-- of the plural first and second persons in the present indicative and +-- the imperative. + + conj3clore : Str -> Verbe = \clore -> + let { + clo = troncVerb clore ; + clos = clo + "s" ; + tclore = auxConj3re + affixSgS affixPasseNonExist clo clos clos + nonExist (clo + "r") clos clos + } in + table { + Indic Pres Sg P3 => Predef.tk 1 clo + "ôt" ; + Indic Pres Pl P1 => nonExist ; + Indic Pres Pl P2 => nonExist ; + Indic Imparf _ _ => nonExist ; + Imper PlP1 => nonExist ; + Imper PlP2 => nonExist ; + t => tclore ! t + } ; + + conj3conclure : Str -> Verbe = \conclure -> + let { + conclu = troncVerb conclure ; + concl = Predef.tk 1 conclu + } in + auxConj3re + affixSgS affixPasseU + conclu conclu conclu concl (conclu + "r") conclu (conclu + "s") ; + + conj3absoudre : Str -> Verbe = \absoudre -> + let { + abso = Predef.tk 4 absoudre ; + tabsoudre = conj3résoudre absoudre + } in + table { + Indic Passe _ _ => nonExist ; + Subjo SImparf _ _ => nonExist ; + Part (PPasse Masc _) => abso + "us" ; + Part (PPasse Fem n) => nomReg (abso + "ute") ! n ; + p => tabsoudre ! p + } ; + + conj3résoudre : Str -> Verbe = \résoudre -> + let {reso = Predef.tk 4 résoudre} in + auxConj3re + affixSgS affixPasseU (reso + "u") (reso + "lv") (reso + "lv") + (reso + "l") (reso + "udr") (reso + "lu") (reso + "lus") ; + + conj3coudre : Str -> Verbe = \coudre -> + let { + cou = Predef.tk 3 coudre ; + cous = cou + "s" + } in + auxConj3re + affixSgSsansT affixPasseI + (cou +"d") cous cous cous (cou + "dr") (cous + "u") (cous + "us") ; + + conj3moudre : Str -> Verbe = \moudre -> + let { + mou = Predef.tk 3 moudre ; + moul = mou + "l" + } in + auxConj3re + affixSgSsansT affixPasseU + (mou + "d") moul moul moul (mou + "dr") (moul + "u") (moul + "us") ; + + conj3suivre : Str -> Verbe = \suivre -> + let { + suiv = troncVerb suivre ; + sui = Predef.tk 1 suiv ; + suivi = suiv + "i" + } in + auxConj3re + affixSgS affixPasseI sui suiv suiv suiv (suiv + "r") suivi (suivi+"s") ; + + conj3vivre : Str -> Verbe = \vivre -> + let { + viv = troncVerb vivre ; + vi = Predef.tk 1 viv ; + véc = Predef.tk 1 vi + "éc" + } in + auxConj3re + affixSgS affixPasseU vi viv viv véc (viv + "r") (véc + "u") (véc + "us") ; + + conj3lire : Str -> Verbe = \lire -> + let { + li = troncVerb lire ; + lis = li + "s" ; + l = Predef.tk 1 li + } in + auxConj3re affixSgS affixPasseU li lis lis l (li + "r") (l + "u") (l + "us") ; + + conj3dire : Str -> Verbe = \dire -> + let { + di = troncVerb dire ; + dis = di + "s" ; + dit = di + "t" ; + d = Predef.tk 1 di ; + tdire = auxConj3re + affixSgS affixPasseI di dis dis d (di + "r") dit (dit+"s") + } in + table { + Indic Pres Pl P2 => di + "tes" ; + Imper PlP2 => di + "tes" ; + t => tdire ! t + } ; + + conj3rire : Str -> Verbe = \rire -> + let { + ri = troncVerb rire ; + r = Predef.tk 1 ri + } in + auxConj3re affixSgS affixPasseI ri ri ri r (ri + "r") ri (ri+"s") ; + + auxConj3scrire : (_,_,_,_: Str) -> Verbe = \ecri, ecriv, ecrivi, ecrit -> + auxConj3re + affixSgS affixPasseI ecri ecriv ecriv ecrivi (ecri + "r") ecrit (ecrit+"s") ; + + conj3écrire : Str -> Verbe = \écrire -> + let {écri = troncVerb écrire} in + auxConj3scrire écri (écri + "v") (écri + "v") (écri + "t") ; + + conj3confire : Str -> Verbe = \confire -> + let {confi = troncVerb confire} in + auxConj3scrire confi (confi + "s") (Predef.tk 1 confi) (confi + "t") ; + + conj3cuire : Str -> Verbe = \cuire -> + let {cui = troncVerb cuire} in + auxConj3scrire cui (cui + "s") (cui + "s") (cui + "t") ; + + +--3 Very irregular verbs +-- +-- Here we cannot do even with the 'worst case macro'. + + conj3aller : Str -> Verbe = \aller -> + let { + s = Predef.tk 5 aller ; + pres = formesPresAi "v" "all" ; + taller = verbHabituel + "all" "all" "aill" "all" "ir" "allé" "aller" + affixSgS affixPasseA + } in + table { + Indic Pres Sg P1 => s + "vais" ; + Indic Pres n p => s + pres ! n ! p ; + Indic Imparf n p => s + "all" + affixImparf ! n ! p ; + Imper SgP2 => s + "va" ; + t => s + taller ! t + } ; + + conjÊtre : Str -> Verbe = \etre -> + let { + s = Predef.tk 4 etre ; + sg = lesAffixes "suis" "es" "est" ; + pl = lesAffixes "sommes" "êtes" "sont" ; + tetre = verbHabituel + "soi" "soy" "soi" "f" "ser" "été" "être" affixSgS affixPasseU + } in + table { + Indic Pres Sg p => s + sg ! p ; + Indic Pres Pl p => s + pl ! p ; + Indic Imparf n p => s + "ét" + affixImparf ! n ! p ; + Subjo SPres Sg p => s + "soi" + affixSgS ! p ; + Subjo SPres Pl P3 => s + "soient" ; + Subjo SPres Pl p => s + "soy" + affixPlOns ! p ; + Part PPres => s + "étant" ; + t => s + tetre ! t + } ; + + conjAvoir : Str -> Verbe = \avoir -> + let { + s = Predef.tk 5 avoir ; + pres = formesPresAi [] "av" ; + tavoir = verbHabituel + "ai" "ay" "ai" "e" "aur" "eu" "avoir" affixSgS affixPasseU + } in + table { + Indic Pres n p => s + pres ! n ! p ; + Indic Imparf n p => s + "av" + affixImparf ! n ! p ; + Subjo SPres Sg P3 => s + "ait" ; + Subjo SPres Pl P3 => s + "aient" ; + Subjo SPres Pl p => s + "ay" + affixPlOns ! p ; + Imper SgP2 => s + "aie" ; + t => s + tavoir ! t + } ; + +} diff --git a/grammars/resource/french/ResFra.gf b/grammars/resource/french/ResFra.gf new file mode 100644 index 000000000..549a12f55 --- /dev/null +++ b/grammars/resource/french/ResFra.gf @@ -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! + +} diff --git a/grammars/resource/french/SyntaxFra.gf b/grammars/resource/french/SyntaxFra.gf new file mode 100644 index 000000000..98cec2966 --- /dev/null +++ b/grammars/resource/french/SyntaxFra.gf @@ -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 of { + => prepCase c ++ genForms "un" "une" ! g ; + => 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! + +} diff --git a/grammars/resource/french/TestFra.gf b/grammars/resource/french/TestFra.gf new file mode 100644 index 000000000..7193a6d5c --- /dev/null +++ b/grammars/resource/french/TestFra.gf @@ -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 ; +} diff --git a/grammars/resource/french/TypesFra.gf b/grammars/resource/french/TypesFra.gf new file mode 100644 index 000000000..5517ce6ec --- /dev/null +++ b/grammars/resource/french/TypesFra.gf @@ -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 ; +} diff --git a/grammars/resource/romance/ResRomance.gf b/grammars/resource/romance/ResRomance.gf new file mode 100644 index 000000000..067048d11 --- /dev/null +++ b/grammars/resource/romance/ResRomance.gf @@ -0,0 +1,203 @@ +--# -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$. + +incomplete concrete ResRomance of ResAbs = open Prelude, SyntaxRomance in { + +flags + startcat=Phr ; + parser=chart ; + +lincat + N = CommNoun ; + -- = {s : Number => Str ; g : Gender} ; + CN = CommNoun ; + NP = {s : NPFormA => 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 : CaseA} ; + AdjDeg = {s : Degree => Gender => Number => Str ; p : Bool} ; + AP = Adjective ; + Fun = CommNoun ** {s2 : Preposition ; c : CaseA} ; + + V = Verb ; + -- = {s : VF => Str} ; + VP = {s : Gender => VF => Str} ; + TV = Verb ** {s2 : Preposition ; c : CaseA} ; + VS = Verb ** {mp,mn : Mode} ; + AdV = {s : Str} ; + + S = Sentence ; + -- = {s : Mode => Str} ; + Slash = Sentence ** {s2 : Preposition ; c : CaseA} ; + + RP = {s : RelForm => Str ; g : RelGen} ; + RC = {s : Mode => Gender => Number => Str} ; + + IP = {s : CaseA => 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 : CaseA => 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 ; + WhichDet = quelDet ; + MostDet = plupartDet ; + + HowIAdv = commentAdv ; + WhenIAdv = quandAdv ; + WhereIAdv = ouAdv ; + WhyIAdv = pourquoiAdv ; + + AndConj = etConj ; + OrConj = ouConj ; + BothAnd = etetConj ; + EitherOr = ououConj ; + NeitherNor = niniConj ; --- requires ne ! + IfSubj = siSubj ; + WhenSubj = quandSubj ; + + PhrYes = ouiPhr ; + PhrNo = nonPhr ; --- and also Si! +} diff --git a/grammars/resource/romance/SyntaxRomance.gf b/grammars/resource/romance/SyntaxRomance.gf new file mode 100644 index 000000000..74af5a867 --- /dev/null +++ b/grammars/resource/romance/SyntaxRomance.gf @@ -0,0 +1,871 @@ +--1 A Small Romance Resource Syntax +-- +-- Aarne Ranta 2002 +-- +-- This resource grammar contains definitions needed to construct +-- indicative, interrogative, and imperative sentences in Romance languages. +-- We try to share as much as possible. Even if the definitions of certain +-- operations are different in $syntax.Fra.gf$ and $syntax.Ita.gf$, we can +-- often give their type signatures in this file. +-- +-- The following files are presupposed: + +interface SyntaxRomance = TypesRomance ** open Prelude, (CO=Coordination) in { + +--2 Common Nouns +-- +-- Common nouns are defined as number-dependent strings with a gender. +-- Complex common noun ($CommNounPhrase$) have the same type as simple ones. +-- (The distinction is made just because of uniformity with other languages.) + +oper + CommNoun : Type = {s : Number => Str ; g : Gender} ; + CommNounPhrase = CommNoun ; + noun2CommNounPhrase : CommNounPhrase -> CommNoun = \x -> x ; + + commonNounComp : CommNoun -> Str -> CommNoun = \numero, detelephone -> + {s = \\n => numero.s ! n ++ detelephone ; + g = numero.g + } ; + + +--2 Noun phrase +-- +-- The worst case is pronouns, which have inflection in the possessive +-- forms. Other noun phrases express all possessive forms with the genitive case. +-- Proper names are the simples example. + + ProperName : Type = {s : Str ; g : Gender} ; + + NounPhrase : Type = Pronoun ; -- the worst case + + nameNounPhrase : ProperName -> NounPhrase ; + + mkProperName : Str -> Gender -> ProperName = \jean,m -> + {s = jean ; g = m} ; + + mkNameNounPhrase : Str -> Gender -> NounPhrase = \jean,m -> + nameNounPhrase (mkProperName jean m) ; + + normalNounPhrase : (CaseA => Str) -> Gender -> Number -> NounPhrase = \cs,g,n -> + {s = \\p => cs ! (pform2case p) ; + g = PGen g ; + n = n ; + p = P3 ; -- third person + c = Clit0 -- not clitic + } ; + + pronNounPhrase : Pronoun -> NounPhrase = \pro -> pro ; + + +--2 Determiners +-- +-- Determiners are inflected according to the gender of the nouns they determine. +-- The determiner determines the number of the argument noun. + + Determiner : Type = {s : Gender => Str ; n : Number} ; + + detNounPhrase : Determiner -> CommNoun -> NounPhrase = \tout, homme -> + normalNounPhrase + (\\c => prepCase c ++ tout.s ! homme.g ++ homme.s ! tout.n) + homme.g + tout.n ; + +-- The following macros are sufficient to define most determiners, +-- as shown by the examples that follow. + + mkDeterminer : Number -> Str -> Str -> Determiner = \n,tous,toutes -> + {s = genForms tous toutes ; n = n} ; + + mkDeterminer1 : Number -> Str -> Determiner = \n,chaque -> + mkDeterminer n chaque chaque ; + + +-- Indefinite and definite noun phrases are treated separately, +-- which strictly speaking is not necessary in Romance languages, since +-- articles could be treated as determiners. + + indefNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,mec -> + normalNounPhrase + (\\c => artIndef mec.g n c ++ mec.s ! n) + mec.g + n ; + + defNounPhrase : Number -> CommNounPhrase -> NounPhrase = \n,mec -> + normalNounPhrase + (\\c => artDef mec.g n c ++ mec.s ! n) + mec.g + n ; + +-- We often need indefinite noun phrases synacategorematically. + + indefNoun : Number -> CommNounPhrase -> Str = \n,mec -> + (indefNounPhrase n mec).s ! case2pform nominative ; + +-- Genitives of noun phrases can be used like determiners, to build noun phrases. +-- The number argument makes the difference between "ma maison" - "mes maisons". +-- The clitic type of the NP decides between "ma maison" and "la maison de Jean". + + npGenDet : Number -> NounPhrase -> CommNounPhrase -> NounPhrase = \n,jeanne,mec -> + let {str : CaseA => Str = case jeanne.c of { + Clit0 => npGenDe n jeanne mec ; + _ => npGenPoss n jeanne mec + } + } in + normalNounPhrase str mec.g n ; + +-- These auxiliary rules define the genitive with "de" and with the possessive. +-- Here there is a difference between French and Italian: Italian has a definite +-- article before possessives (with certain exceptions). + + npGenDe : Number -> NounPhrase -> CommNounPhrase -> CaseA => Str = + \n,jeanne,mec -> + \\c => artDef mec.g n c ++ mec.s ! n ++ jeanne.s ! case2pform genitive ; + + npGenPoss : Number -> NounPhrase -> CommNounPhrase -> CaseA => Str ; + +--2 Adjectives +-- +-- Adjectives have a parameter $p$ telling if postposition is +-- allowed (complex APs). There is no real need in Romance languages to distinguish +-- between simple adjectives and adjectival phrases. + + Adjective : Type = Adj ** {p : Bool} ; + + adjPre = True ; adjPost = False ; + + AdjPhrase : Type = Adjective ; + + adj2adjPhrase : Adjective -> AdjPhrase = \x -> x ; + + mkAdjective : Adj -> Bool -> Adjective = \adj,p -> adj ** {p = p} ; + + +--3 Comparison adjectives +-- +-- The type is defined in $types.Romance.gf$. Syntax adds to lexicon the position +-- information. + + AdjDegr = AdjComp ** {p : Bool} ; + + mkAdjDegr : AdjComp -> Bool -> AdjDegr = \adj,p -> + adj ** {p = p} ; + + mkAdjDegrLong : Adj -> Bool -> AdjDegr = \adj,p -> + adjCompLong adj ** {p = p} ; + + +-- Each of the comparison forms has a characteristic use: +-- +-- Positive forms are used alone, as adjectival phrases ("bon"). + + positAdjPhrase : AdjDegr -> AdjPhrase = \bon -> + {s = bon.s ! Pos ; + p = bon.p + } ; + +-- Comparative forms are used with an object of comparison, as +-- adjectival phrases ("meilleur que toi"). The comparing conjunction +-- is of course language-dependent; Italian moreover has the free +-- variants "che" and "di". + + comparAdjPhrase : AdjDegr -> NounPhrase -> AdjPhrase = \bon, toi -> + {s = \\g,n => bon.s ! Comp ! g ! n ++ comparConj ++ + toi.s ! stressed accusative ; + p = False + } ; + + comparConj : Str ; + +-- Superlative forms are used with a common noun, picking out the +-- maximal representative of a domain +-- ("le meilleur mec", "le mec le plus intelligent"). + + superlNounPhrase : AdjDegr -> CommNoun -> NounPhrase = \bon, mec -> + normalNounPhrase + (\\c => artDef mec.g Sg c ++ if_then_else Str bon.p + (bon.s ! Sup ! mec.g ! Sg ++ mec.s ! Sg) + (mec.s ! Sg ++ artDef mec.g Sg nominative ++ bon.s ! Sup ! mec.g ! Sg) + ) + mec.g + Sg ; + + +--3 Prepositions and complements +-- +-- Most prepositions are just strings. But "à" and "de" are treated as cases in +-- French. In Italian, there are more prepositions treated in this way: +-- "a", "di", "da", "in", "su", "con". +-- An invariant is that, if the preposition is not empty ($[]$), then the case +-- is $Acc$. + + Preposition = Str ; + + Complement = {s2 : Preposition ; c : CaseA} ; + + complement : Str -> Complement = \par -> + {s2 = par ; c = nominative} ; + + complementDir : Complement = complement [] ; + + complementCas : CaseA -> Complement = \c -> + {s2 = [] ; c = c} ; + + +--3 Two-place adjectives +-- +-- A two-place adjective is an adjective with a preposition used before +-- the complement, and the complement case. + + AdjCompl = AdjPhrase ** Complement ; + + mkAdjCompl : Adj -> Bool -> Complement -> AdjCompl = \adj,p,c -> + mkAdjective adj p ** c ; + + complAdj : AdjCompl -> NounPhrase -> AdjPhrase = \relie,jean -> + {s = \\g,n => relie.s ! g ! n ++ relie.s2 ++ jean.s ! case2pform relie.c ; + p = False + } ; + + +--3 Modification of common nouns +-- +-- The two main functions of adjective are in predication ("Jean est jeune") +-- and in modification ("un jeune homme"). Predication will be defined +-- later, in the chapter on verbs. +-- +-- Modification must pay attention to pre- and post-noun +-- adjectives: "jeune homme"; "homme intelligent". + + modCommNounPhrase : AdjPhrase -> CommNounPhrase -> CommNounPhrase = \bon,mec -> + {s = \\n => if_then_else Str bon.p + (bon.s ! mec.g ! n ++ mec.s ! n) + (mec.s ! n ++ bon.s ! mec.g ! n) ; + g = mec.g + } ; + +--2 Function expressions + +-- A function expression is a common noun together with the +-- preposition prefixed to its argument ("mère de x"). +-- The type is analogous to two-place adjectives and transitive verbs. + + Function : Type = CommNounPhrase ** Complement ; + +-- The application of a function gives, in the first place, a common noun: +-- "mor/mödrar till Johan". From this, other rules of the resource grammar +-- give noun phrases, such as "la mère de Jean", "les mères de Jean", +-- "les mères de Jean et de Marie", and "la mère de Jean et de Marie" (the +-- latter two corresponding to distributive and collective functions, +-- respectively). Semantics will eventually tell when each +-- of the readings is meaningful. + + appFunComm : Function -> NounPhrase -> CommNounPhrase = \mere,jean -> + noun2CommNounPhrase + {s = \\n => mere.s ! n ++ mere.s2 ++ jean.s ! case2pform mere.c ; + g = mere.g + } ; + +-- It is possible to use a function word as a common noun; the semantics is +-- often existential or indexical. + + funAsCommNounPhrase : Function -> CommNounPhrase = + noun2CommNounPhrase ; + +-- The following is an aggregate corresponding to the original function application +-- producing "ma mère" and "la mère de Jean". It does not appear in the +-- resource grammar API any longer. + + appFun : Bool -> Function -> NounPhrase -> NounPhrase = \coll, mere, jean -> + let {n = jean.n ; g = mere.g ; nf = if_then_else Number coll Sg n} in + variants { + defNounPhrase nf (appFunComm mere jean) ; + npGenDet nf jean mere + } ; + + +--2 Verbs +-- +--3 Verb phrases +-- +-- Unlike many other languages, verb phrases in Romance languages +-- are not discontinuous. +-- We use clitic parameters instead. +-- +-- (It is not quite sure, though, whether this +-- will suffice in French for examples like "je n'*y* vais pas": one may want to +-- add "y" to "ne vais pas" instead of "ne - pas" to "y vais".) +-- +-- So far we restrict the syntax to present-tense verbs, even though +-- morphology has complete conjugations. + + VerbPhrase = {s : Gender => VF => Str} ; + + Verb = VerbPres ; + +-- Predication is language-dependent in the negative case. + + predVerb : Bool -> VerbPres -> VerbPhrase = \b,aller -> + if_then_else VerbPhrase b + {s = \\_ => aller.s} + {s = \\_,v => negVerb (aller.s ! v)} ; + + negVerb : Str -> Str ; + +-- Verb phrases can also be formed from adjectives ("est bon"), +-- common nouns ("est un homme"), and noun phrases ("est Jean"). +-- We need a copula, which is of course language-dependent. + + copula : Bool -> VF => Str ; + +-- The third rule is overgenerating: "est chaque homme" has to be ruled out +-- on semantic grounds. + + predAdjective : Bool -> AdjPhrase -> VerbPhrase = \b,bon -> + {s = \\g,v => copula b ! v ++ bon.s ! g ! nombreVerb v} ; + + predCommNoun : Bool -> CommNounPhrase -> VerbPhrase = \b,homme -> + {s = \\g,v => copula b ! v ++ indefNoun (nombreVerb v) homme} ; + + predNounPhrase : Bool -> NounPhrase -> VerbPhrase = \b,jean -> + {s = \\g,v => copula b ! v ++ jean.s ! stressed nominative} ; + + +-- complement a verb with noun phrase and optional preposition + + TransVerb : Type = VerbPres ** Complement ; + + verbOfTransVerb : TransVerb -> VerbPres = \v -> {s = v.s} ; + complementOfTransVerb : TransVerb -> Complement = \v -> {s2 = v.s2 ; c = v.c} ; + + isNounPhraseClit : NounPhrase -> Bool = \n -> case n.c of { + Clit0 => False ; + _ => True + } ; + +-- This function is language-dependent, because it uses the language-dependent +-- type of case. + + isTransVerbClit : TransVerb -> Bool ; + + +--3 Transitive verbs +-- +-- Transitive verbs are verbs with a preposition for the complement, +-- in analogy with two-place adjectives and functions. +-- One might prefer to use the term "2-place verb", since +-- "transitive" traditionally means that the inherent preposition is empty. +-- Such a verb is one with a *direct object* - which may still be accusative, +-- dative, or genitive. +-- +-- In complementation, we do need some dispatching of clitic types: +-- "aime Jean" ; "n'aime pas Jean" ; "l'aime" ; "ne l'aime pas". +-- More will be needed when we add ditransitive verbs. + + complTransVerb : Bool -> TransVerb -> NounPhrase -> VerbPhrase = \b,aime,jean -> + {s = \\g,w => ---- BUG: v gives stack overflow + let {Jean = jean.s ! (case2pform aime.c) ; Aime = aime.s ! w} in + if_then_else Str (andB (isNounPhraseClit jean) (isTransVerbClit aime)) + (posNeg b (Jean ++ Aime) []) + (posNeg b Aime Jean) + } ; + + mkTransVerb : Verb -> Preposition -> CaseA -> TransVerb = \v,p,c -> + v ** {s2 = p ; c = c} ; + + mkTransVerbPrep : Verb -> Preposition -> TransVerb = \passer,par -> + mkTransVerb passer par accusative ; + + mkTransVerbCas : Verb -> CaseA -> TransVerb = \penser,a -> + mkTransVerb penser [] a ; + + mkTransVerbDir : Verb -> TransVerb = \aimer -> + mkTransVerbCas aimer accusative ; + +-- The following macro builds the "ne - pas" or "non" negation. The second +-- string argument is used for the complement of a verb phrase. In Italian, +-- one string argument would actually be enough. + + posNeg : Bool -> (verb, compl : Str) -> Str ; + + +--2 Adverbials +-- +-- Adverbials are not inflected (we ignore comparison, and treat +-- compared adverbials as separate expressions; this could be done another way). +-- +-- (We should also take into account clitic ones, like "y", +-- as well as the position: "est toujours heureux" / "est heureux à Paris".) + + Adverb : Type = SS ; + + adVerbPhrase : VerbPhrase -> Adverb -> VerbPhrase = \chante, bien -> + {s = \\g,v => chante.s ! g ! v ++ bien.s} ; + +-- Adverbials are typically generated by prefixing prepositions. +-- The rule for creating locative noun phrases by the preposition "dans" +-- in French and "in" in Italian. This is of course shaky, since other +-- prepositions may be preferred ("en", "à" ; "a", "su"). + + locativeNounPhrase : NounPhrase -> Adverb ; + +-- This is a source of the "homme avec un téléscope" ambiguity, and may produce +-- strange things, like "les voitures toujours". +-- Semantics will have to make finer distinctions among adverbials. +-- French moreover says "les voitures d'hier" rather than "les voitures hier". + + advCommNounPhrase : CommNounPhrase -> Adverb -> CommNounPhrase = \mec,aparis -> + {s = \\n => mec.s ! n ++ aparis.s ; + g = mec.g + } ; + +--2 Sentences +-- +-- Sentences depend on a *mode parameter* selecting between +-- indicative and subjunctive forms. + + Sentence : Type = SS1 Mode ; + +-- This is the traditional $S -> NP VP$ rule. It takes care of both +-- mode and agreement. + + predVerbPhrase : NounPhrase -> VerbPhrase -> Sentence = \jean,dort -> + {s = \\m => jean.s ! unstressed nominative ++ + dort.s ! pgen2gen jean.g ! VFin m jean.n jean.p + } ; + + +--3 Sentence-complement verbs +-- +-- Sentence-complement verbs take sentences as complements. +-- The mode of the complement depends on the verb, and can be different +-- for positive and negative uses of the verb +-- ("je crois qu'elle vient" -"je ne crois pas qu'elle vienne"), + + SentenceVerb : Type = VerbPres ** {mp, mn : Mode} ; + + complSentVerb : Bool -> SentenceVerb -> Sentence -> VerbPhrase = + \b,croire,jeanboit -> + let {m = if_then_else Mode b croire.mp croire.mn} in + {s = \\_,w => posNeg b (croire.s ! w) (embedConj ++ jeanboit.s ! m)} ; ----w + + verbSent : Verb -> Mode -> Mode -> SentenceVerb = \v,mp,mn -> + v ** {mp = mp ; mn = mn} ; + +-- The embedding conjunction is language dependent. + + embedConj : Str ; + + +--2 Sentences missing noun phrases +-- +-- This is one instance of Gazdar's *slash categories*, corresponding to his +-- $S/NP$. +-- We cannot have - nor would we want to have - a productive slash-category former. +-- Perhaps a handful more will be needed. +-- +-- Notice that the slash category has the same relation to sentences as +-- transitive verbs have to verbs: it's like a *sentence taking a complement*. + + SentenceSlashNounPhrase = Sentence ** Complement ; + + slashTransVerb : Bool -> NounPhrase -> TransVerb -> SentenceSlashNounPhrase = + \b,jean,aimer -> + predVerbPhrase jean (predVerb b (verbOfTransVerb aimer)) ** + complementOfTransVerb aimer ; + + +--2 Relative pronouns and relative clauses +-- +-- Relative pronouns are inflected in +-- gender, number, and case. They can also have an inherent case, +-- but this case if 'variable' in the sense that it +-- is sometimes just mediated from the correlate +-- ("homme qui est bon"), sometimes inherent to the +-- pronominal phrase itself ("homme dont la mère est bonne"). + +oper + + RelPron : Type = {s : RelFormA => Str ; g : RelGen} ; + RelClause : Type = {s : Mode => Gender => Number => Str} ; + + mkGenRel : RelGen -> Gender -> Gender = \rg,g -> case rg of { + RG gen => gen ; + _ => g + } ; + +-- Simple relative pronouns ("qui", "dont", "par laquelle") +-- have no inherent gender. + + identRelPron : RelPron ; + + composRelPron : Gender -> Number -> CaseA -> Str ; + +-- Complex relative pronouns ("dont la mère") do have an inherent gender. + + funRelPron : Function -> RelPron -> RelPron ; + +-- There are often variants, i.e. short and long forms +-- ("que" - "lequel", "dont" -"duquel"), etc. + + allRelForms : RelPron -> Gender -> Number -> CaseA -> Str ; + +-- Relative clauses can be formed from both verb phrases ("qui dort") and +-- slash expressions ("que je vois", "dont je parle"). + + relVerbPhrase : RelPron -> VerbPhrase -> RelClause = \qui,dort -> + {s = \\m,g,n => allRelForms qui g n nominative ++ dort.s ! g ! VFin m n P3 + } ; + + relSlash : RelPron -> SentenceSlashNounPhrase -> RelClause = \dont,jeparle -> + {s = \\m,g,n => jeparle.s2 ++ allRelForms dont g n jeparle.c ++ jeparle.s ! m + } ; + +-- A 'degenerate' relative clause is the one often used in mathematics, e.g. +-- "nombre x tel que x soit pair". + + relSuch : Sentence -> RelClause = \A -> + {s = \\m,g,n => suchPron g n ++ embedConj ++ A.s ! m + } ; + + suchPron : Gender -> Number -> Str ; + +-- The main use of relative clauses is to modify common nouns. +-- The result is a common noun, out of which noun phrases can be formed +-- by determiners. A comma is used before the relative clause. +-- +-- N.B. subjunctive relative clauses +-- ("je cherche un mec qui sache chanter") must have another structure +-- (unless common noun phrases are given a mode parameter...). + + modRelClause : CommNounPhrase -> RelClause -> CommNounPhrase = \mec,quidort -> + {s = \\n => mec.s ! n ++ quidort.s ! Ind ! mec.g ! n ; + g = mec.g + } ; + +--2 Interrogative pronouns +-- +-- If relative pronouns are adjective-like, interrogative pronouns are +-- noun-phrase-like. We use a simplified type, since we don't need the possessive +-- forms. +-- +-- N.B. "est-ce que", etc, will be added below +-- when pronouns are used in direct questions. + + IntPron : Type = {s : CaseA => Str ; g : Gender ; n : Number} ; + +-- In analogy with relative pronouns, we have a rule for applying a function +-- to a relative pronoun to create a new one. + + funIntPron : Function -> IntPron -> IntPron = \mere,qui -> + {s = \\c => + artDef mere.g qui.n c ++ mere.s ! qui.n ++ mere.s2 ++ qui.s ! mere.c ; + g = mere.g ; + n = qui.n + } ; + +-- There is a variety of simple interrogative pronouns: +-- "quelle maison", "qui", "quoi". Their definitions are language-dependent. + + nounIntPron : Number -> CommNounPhrase -> IntPron ; + intPronWho : Number -> IntPron ; + intPronWhat : Number -> IntPron ; + +--2 Utterances + +-- By utterances we mean whole phrases, such as +-- 'can be used as moves in a language game': indicatives, questions, imperative, +-- and one-word utterances. The rules are far from complete. +-- +-- N.B. we have not included rules for texts, which we find we cannot say much +-- about on this level. In semantically rich GF grammars, texts, dialogues, etc, +-- will of course play an important role as categories not reducible to utterances. +-- An example is proof texts, whose semantics show a dependence between premises +-- and conclusions. Another example is intersentential anaphora. + + Utterance = SS ; + + indicUtt : Sentence -> Utterance = \x -> ss (x.s ! Ind ++ ".") ; + interrogUtt : Question -> Utterance = \x -> ss (x.s ! DirQ ++ "?") ; + +--2 Questions +-- +-- Questions are either direct ("qui a pris la voiture") or indirect +-- ("ce qui a pris la voiture"). + +param + QuestForm = DirQ | IndirQ ; + +oper + Question = SS1 QuestForm ; + + +--3 Yes-no questions +-- +-- Yes-no questions are used both independently ("Tu es fatigué?") +-- and after interrogative adverbials ("Pourquoi tu es fatigué?"). +-- It is economical to handle with these two cases by the one +-- rule, $questVerbPhrase'$. The only difference is if "si" appears +-- in the indirect form. +-- +-- N.B. the inversion variant ("Es-tu fatigué?") is missing, mainly because our +-- verb morphology does not support the intervening "t" ("Marche-t-il?"). +-- The leading "est-ce que" is recognized as a variant, and requires +-- direct word order. + + questVerbPhrase : NounPhrase -> VerbPhrase -> Question ; + +--3 Wh-questions +-- +-- Wh-questions are of two kinds: ones that are like $NP - VP$ sentences, +-- others that are line $S/NP - NP$ sentences. +-- +-- N.B. inversion variants and "est-ce que" are treated as above. + + intVerbPhrase : IntPron -> VerbPhrase -> Question ; + + intSlash : IntPron -> SentenceSlashNounPhrase -> Question ; + + +--3 Interrogative adverbials +-- +-- These adverbials will be defined in the lexicon: they include +-- "quand", "où", "comment", "pourquoi", etc, which are all invariant one-word +-- expressions. In addition, they can be formed by adding prepositions +-- to interrogative pronouns, in the same way as adverbials are formed +-- from noun phrases. +-- +-- N.B. inversion variants and "est-ce que" are treated as above. + + IntAdverb = SS ; + + questAdverbial : IntAdverb -> NounPhrase -> VerbPhrase -> Question ; + + +--2 Imperatives +-- +-- We only consider second-person imperatives. +-- +-- N.B. following the API, we don't distinguish between +-- singular and plural "vous", nor between masculine and feminine. +-- when forming utterances. +-- +-- TODO: clitics, Italian negated imperative. + + Imperative = {s : Gender => Number => Str} ; + + imperVerbPhrase : VerbPhrase -> Imperative = \dormir -> + {s = \\g,n => dormir.s ! g ! vImper n P2 + } ; + + imperUtterance : Number -> Imperative -> Utterance = \n,I -> + ss (I.s ! Masc ! n ++ "!") ; + + + +--2 Coordination +-- +-- Coordination is to some extent orthogonal to the rest of syntax, and +-- has been treated in a generic way in the module $CO$ in the file +-- $coordination.gf$. The overall structure is independent of category, +-- but there can be differences in parameter dependencies. +-- +--3 Conjunctions +-- +-- Coordinated phrases are built by using conjunctions, which are either +-- simple ("et", "ou") or distributed ("et - et", "pu - ou"). + + Conjunction = CO.Conjunction ** {n : Number} ; + ConjunctionDistr = CO.ConjunctionDistr ** {n : Number} ; + +--3 Coordinating sentences +-- +-- We need a category of lists of sentences. It is a discontinuous +-- category, the parts corresponding to 'init' and 'last' segments +-- (rather than 'head' and 'tail', because we have to keep track of the slot between +-- the last two elements of the list). A list has at least two elements. +-- +-- N.B. we don't have repetion of "que" in subordinate coordinated sentences. + + ListSentence : Type = {s1,s2 : Mode => Str} ; + + twoSentence : (_,_ : Sentence) -> ListSentence = + CO.twoTable Mode ; + + consSentence : ListSentence -> Sentence -> ListSentence = + CO.consTable Mode CO.comma ; + +-- To coordinate a list of sentences by a simple conjunction, we place +-- it between the last two elements; commas are put in the other slots, +-- e.g. "Pierre fume, Jean boit et les autres regardsnt". + + conjunctSentence : Conjunction -> ListSentence -> Sentence = + CO.conjunctTable Mode ; + +-- To coordinate a list of sentences by a distributed conjunction, we place +-- the first part in front of the first element, the second +-- part between the last two elements, and commas in the other slots. +-- For sentences this is really not used. + + conjunctDistrSentence : ConjunctionDistr -> ListSentence -> Sentence = + CO.conjunctDistrTable Mode ; + +--3 Coordinating adjective phrases +-- +-- The structure is the same as for sentences. The result is a prefix adjective +-- if and only if all elements are prefix. + + ListAdjPhrase : Type = + {s1,s2 : Gender => Number => Str ; p : Bool} ; + + twoAdjPhrase : (_,_ : AdjPhrase) -> ListAdjPhrase = \x,y -> + CO.twoTable2 Gender Number x y ** {p = andB x.p y.p} ; + + consAdjPhrase : ListAdjPhrase -> AdjPhrase -> ListAdjPhrase = \xs,x -> + CO.consTable2 Gender Number CO.comma xs x ** {p = andB xs.p x.p} ; + + conjunctAdjPhrase : Conjunction -> ListAdjPhrase -> AdjPhrase = \c,xs -> + CO.conjunctTable2 Gender Number c xs ** {p = xs.p} ; + + conjunctDistrAdjPhrase : ConjunctionDistr -> ListAdjPhrase -> AdjPhrase = \c,xs -> + CO.conjunctDistrTable2 Gender Number c xs ** {p = xs.p} ; + + +--3 Coordinating noun phrases +-- +-- The structure is the same as for sentences. The result is either always plural +-- or plural if any of the components is, depending on the conjunction. +-- The gender is masculine if any of the components is. A coordinated noun phrase +-- cannot be clitic. + + ListNounPhrase : Type = + {s1,s2 : CaseA => Str ; g : PronGen ; n : Number ; p : Person} ; + + twoNounPhrase : (_,_ : NounPhrase) -> ListNounPhrase = \x,y -> + {s1 = \\c => x.s ! stressed c ; s2 = \\c => y.s ! stressed c} ** + {n = conjNumber x.n y.n ; g = conjGender x.g y.g ; p = conjPers x.p y.p} ; + + consNounPhrase : ListNounPhrase -> NounPhrase -> ListNounPhrase = \xs,x -> + {s1 = \\c => xs.s1 ! c ++ CO.comma ++ xs.s2 ! c ; + s2 = \\c => x.s ! stressed c} ** + {n = conjNumber xs.n x.n ; g = conjGender xs.g x.g ; p =conjPers xs.p x.p} ; + + conjunctNounPhrase : Conjunction -> ListNounPhrase -> NounPhrase = \co,xs -> + {s = \\c => xs.s1 ! pform2case c ++ co.s ++ xs.s2 ! pform2case c} ** + {n = conjNumber co.n xs.n ; g = xs.g ; p = xs.p ; c = Clit0 } ; + + conjunctDistrNounPhrase : ConjunctionDistr -> ListNounPhrase -> NounPhrase = + \co,xs -> + {s = \\c => co.s1++ xs.s1 ! pform2case c ++ co.s2 ++ xs.s2 ! pform2case c} ** + {n = conjNumber co.n xs.n ; g = xs.g ; p = xs.p ; c = Clit0} ; + +-- We have to define a calculus of numbers of genders. For numbers, +-- it is like the conjunction with $Pl$ corresponding to $False$. For genders, +-- $Masc$ corresponds to $False$. + + conjNumber : Number -> Number -> Number = \m,n -> case of { + => Sg ; + _ => Pl + } ; + + conjGen : Gender -> Gender -> Gender = \m,n -> case of { + => Fem ; + _ => Masc + } ; + + conjGender : PronGen -> PronGen -> PronGen = \m,n -> case of { + => PGen Fem ; + _ => PNoGen + } ; + +-- For persons, we go in the descending order: +-- "moi et toi sommes forts", "lui ou toi es fort". +-- This is not always quite clear. + + conjPers : Person -> Person -> Person = \p,q -> case of { + => P3 ; + => P1 ; + <_,P1> => P1 ; + _ => P2 + } ; + + + +--2 Subjunction +-- +-- Subjunctions ("si", "quand", etc) +-- are a different way to combine sentences than conjunctions. +-- The main clause can be a sentences, an imperatives, or a question, +-- but the subjoined clause must be a sentence. + + Subjunction = SS ; + + subjunctSentence : Subjunction -> Sentence -> Sentence -> Sentence = \si,A,B -> + {s = \\m => subjunctVariants si A (B.s ! m) + } ; + + subjunctImperative : Subjunction -> Sentence -> Imperative -> Imperative = + \si,A,B -> + {s = \\g,n => subjunctVariants si A (B.s ! g ! n) + } ; + + subjunctQuestion : Subjunction -> Sentence -> Question -> Question = \si,A,B -> + {s = \\q => subjunctVariants si A (B.s ! q) + } ; + +-- There are uniformly two variant word orders, e.g. +-- "si tu fume je m'en vais" +-- and "je m'en vais si tu fume". + + subjunctVariants : Subjunction -> Sentence -> Str -> Str = \si,A,B -> + let {As = A.s ! Ind} in + variants { + si.s ++ As ++ B ; + B ++ si.s ++ As + } ; + +--2 One-word utterances +-- +-- An utterance can consist of one phrase of almost any category, +-- the limiting case being one-word utterances. These +-- utterances are often (but not always) in what can be called the +-- default form of a category, e.g. the nominative. +-- This list is far from exhaustive. + + useNounPhrase : NounPhrase -> Utterance = \jean -> + postfixSS "." (defaultNounPhrase jean) ; + useCommonNounPhrase : Number -> CommNounPhrase -> Utterance = \n,mec -> + useNounPhrase (indefNounPhrase n mec) ; + + +-- one-form variants + + defaultNounPhrase : NounPhrase -> SS = \jean -> + ss (jean.s ! stressed nominative) ; + + defaultQuestion : Question -> SS = \quiesttu -> + ss (quiesttu.s ! DirQ) ; + + defaultSentence : Sentence -> SS = \x -> ss (x.s ! Ind) ; + +----- moved from Types + + artDef : Gender -> Number -> CaseA -> Str ; + artIndef : Gender -> Number -> CaseA -> Str ; + genForms : Str -> Str -> Gender => Str ; + +----- moved from Res + + pronJe, pronTu, pronIl, pronElle, pronNous, pronVous, pronIls, pronElles : + Pronoun ; + chaqueDet, tousDet, quelDet, plupartDet : Determiner ; + + commentAdv, quandAdv, ouAdv, pourquoiAdv : Adverb ; + + etConj, ouConj : Conjunction ; + etetConj, ououConj : ConjunctionDistr ; + siSubj, quandSubj : Subjunction ; + + ouiPhr, noPhr : Utterance ; + +} diff --git a/grammars/resource/romance/TypesRomance.gf b/grammars/resource/romance/TypesRomance.gf new file mode 100644 index 000000000..e15f453f6 --- /dev/null +++ b/grammars/resource/romance/TypesRomance.gf @@ -0,0 +1,175 @@ +--1 Romance Word Classes and Morphological Parameters +-- +-- This is a resource module for French and Italian morphology, defining the +-- morphological parameters and parts of speech of Romance languages. +-- It is used as the major part of language-specific type systems, +-- defined in $types.Fra.gf$ and $types.Ita.gf$. The guiding principle has been +-- to share as much as possible, which has two advantages: it saves work in +-- encoding, and it shows how the languages are related. + +interface TypesRomance = { + +--2 Enumerated parameter types for morphology +-- +-- These types are the ones found in school grammars. +-- Their parameter values are atomic. + +param + Number = Sg | Pl ; + Gender = Masc | Fem ; + Person = P1 | P2 | P3 ; + Mode = Ind | Con ; + Degree = Pos | Comp | Sup ; + +-- The case must be made an abstract type, since it varies from language to +-- language. The same concerns those parameter types that depend on case. +-- Certain cases can however be defined. + +param + RelGen = RNoGen | RG Gender ; + +oper + CaseA : PType ; + NPFormA : PType ; + + nominative : CaseA ; + accusative : CaseA ; + genitive : CaseA ; + dative : CaseA ; + + stressed : CaseA -> NPFormA ; + unstressed : CaseA -> NPFormA ; + + RelFormA : PType ; + +-- The genitive and dative cases are expressed by prepositions, except for +-- clitic pronouns. The accusative case only makes a difference for pronouns. + +-- Personal pronouns are the following type: + +oper + Pronoun : Type = { + s : NPFormA => Str ; + g : PronGen ; + n : Number ; + p : Person ; + c : ClitType + } ; + +-- The following coercions are useful: + +oper + pform2case : NPFormA -> CaseA ; + case2pform : CaseA -> NPFormA ; + + prepCase : CaseA -> Str ; + + + adjCompLong : Adj -> AdjComp ; + + relPronForms : CaseA => Str ; + +-- For abstraction and API compatibility, we define two synonyms: + +oper + singular = Sg ; + plural = Pl ; + + +--2 Word classes and hierarchical parameter types +-- +-- Real parameter types (i.e. ones on which words and phrases depend) +-- are mostly hierarchical. The alternative is cross-products of +-- simple parameters, but this cannot be always used since it overgenerates. +-- + +--3 Common nouns +-- +-- Common nouns are inflected in number, and they have an inherent gender. + + CNom : Type = {s : Number => Str ; g : Gender} ; + +--3 Pronouns +-- +-- Pronouns are an example - the worst-case one of noun phrases, +-- which are defined in $syntax.Ita.gf$. +-- 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". + +-- Tonic forms are divided into four classes of clitic type. +-- The first value is used for never-clitic noun phrases. +-- This classification is incomplete, since we do not (yet) treat +-- ditransitive verbs. +-- +-- Examples of each: "Giovanni" ; "io" ; "lui" ; "noi". + + param ClitType = Clit0 | Clit1 | Clit2 | Clit3 ; + +-- Gender is not morphologically determined for first and second person pronouns. + + PronGen = PGen Gender | PNoGen ; + +-- The following coercion is useful: + +oper + pgen2gen : PronGen -> Gender = \p -> case p of { + PGen g => g ; + PNoGen => variants {Masc ; Fem} --- the best we can do for je, tu, nous, vous + } ; + +--3 Adjectives +-- +-- Adjectives are inflected in gender and number. +-- Comparative adjectives are moreover inflected in degree +-- (which in French and Italian is usually syntactic, though). + + Adj : Type = {s : Gender => Number => Str} ; + AdjComp : Type = {s : Degree => Gender => Number => Str} ; + + +--3 Verbs +-- +-- In the current syntax, we use +-- a reduced conjugation with only the present tense infinitive, +-- indicative, subjunctive, and imperative forms. +-- But our morphology has full Bescherelle conjunctions: +-- so we use a coercion between full and reduced verbs. +-- The full conjugations and the coercions are defined separately for French +-- and Italian, since they are not identical. The differences are mostly due +-- to Bescherelle structuring the forms in different groups; the +-- gerund and the present participles show real differences. + +param + VF = + VFin Mode Number Person + | VImper NumPersI + | VInfin + ; + + NumPersI = SgP2 | PlP1 | PlP2 ; + +-- It is sometimes useful to derive the number of a verb form. + +oper + nombreVerb : VF -> Number = \v -> case v of { + VFin _ n _ => n ; + _ => singular --- + } ; + +-- The imperative forms depend on number and person. + + vImper : Number -> Person -> VF = \n,p -> case of { + => VImper SgP2 ; + => VImper PlP1 ; + => VImper PlP2 ; + _ => VInfin + } ; + + Verbum : Type ; + + VerbPres : Type = {s : VF => Str} ; + + verbPres : Verbum -> VerbPres ; +}