From 0d580d9418b38893e01929bb10802482e1874352 Mon Sep 17 00:00:00 2001 From: krasimir Date: Wed, 20 Feb 2008 15:06:29 +0000 Subject: [PATCH] make the numeral-noun inflection the right way --- lib/resource/bulgarian/CatBul.gf | 13 +++-- lib/resource/bulgarian/MorphoBul.gf | 19 +++---- lib/resource/bulgarian/NounBul.gf | 59 +++++++++++-------- lib/resource/bulgarian/NumeralBul.gf | 4 +- lib/resource/bulgarian/ResBul.gf | 75 ++++++++++++++++++------- lib/resource/bulgarian/StructuralBul.gf | 2 +- lib/resource/bulgarian/VerbBul.gf | 2 +- 7 files changed, 113 insertions(+), 61 deletions(-) diff --git a/lib/resource/bulgarian/CatBul.gf b/lib/resource/bulgarian/CatBul.gf index 5e5322cd9..3bdd0a28e 100644 --- a/lib/resource/bulgarian/CatBul.gf +++ b/lib/resource/bulgarian/CatBul.gf @@ -19,7 +19,7 @@ concrete CatBul of Cat = CommonX ** open ResBul, Prelude in { QCl = {s : ResBul.Tense => Anteriority => Polarity => QForm => Str} ; IP = {s : Str ; gn : GenNum} ; IComp = {s : Str} ; - IDet = {s : Gender => Str ; n : Number; spec : Species} ; + IDet = {s : DGender => Case => Str; n : Number; countable : Bool; spec : Species} ; -- Verb @@ -33,11 +33,12 @@ concrete CatBul of Cat = CommonX ** open ResBul, Prelude in { -- Noun - CN = {s : Number => Case => Species => Str; g : Gender} ; + CN = {s : NForm => Str; g : DGender} ; NP, Pron = {s : Case => Str ; a : Agr} ; - Det = {s : Gender => Str ; n : Number; spec : Species} ; - Num = {s : Str; n : Number } ; - Quant = {s : AForm => Str; spec : Species} ; + Det = {s : DGender => Case => Str ; n : Number; countable : Bool; spec : Species} ; + Predet, Ord = {s : AForm => Str; empty : Bool} ; + Num = {s : DGenderSpecies => Str; n : Number; empty : Bool} ; + Quant = {s : GenNum => Str; spec : Species} ; -- Numeral @@ -57,5 +58,5 @@ concrete CatBul of Cat = CommonX ** open ResBul, Prelude in { A = {s : AForm => Str} ; - N = {s : AForm => Str; g : Gender} ; + N = {s : NForm => Str; g : DGender} ; } \ No newline at end of file diff --git a/lib/resource/bulgarian/MorphoBul.gf b/lib/resource/bulgarian/MorphoBul.gf index 6f7770b44..4d5f72455 100644 --- a/lib/resource/bulgarian/MorphoBul.gf +++ b/lib/resource/bulgarian/MorphoBul.gf @@ -15,18 +15,17 @@ resource MorphoBul = ResBul ** open Prelude, (Predef=Predef) in { oper --2 Determiners - mkDeterminerSg : Str -> Str -> Str -> {s : Gender => Str; n : Number; spec : Species} = \vseki,vsiaka,vsiako -> - {s = table Gender [vseki;vsiaka;vsiako]; n = Sg; spec = Indef} ; - mkDeterminerPl : Str -> {s : Gender => Str ; n : Number; spec : Species} = \vsicki -> - {s = \\_ => vsicki; n = Sg; spec = Indef} ; + mkDeterminerSg : Str -> Str -> Str -> {s : DGender => Case => Str; n : Number; countable : Bool ; spec : Species} = \vseki,vsiaka,vsiako -> + {s = \\g,_ => table DGender [vseki;vseki;vsiaka;vsiako] ! g; n = Sg; countable = False; spec = Indef} ; + mkDeterminerPl : Str -> {s : DGender => Case => Str ; n : Number; countable : Bool ; spec : Species} = \vsicki -> + {s = \\_,_ => vsicki; n = Pl; countable = False; spec = Indef} ; - mkQuant : Str -> Str -> Str -> Str -> {s : AForm => Str; spec : Species} = \tozi,tazi,towa,tezi -> { + mkQuant : Str -> Str -> Str -> Str -> {s : GenNum => Str; spec : Species} = \tozi,tazi,towa,tezi -> { s = \\gn => case gn of { - ASg Masc _ => tozi ; - ASg Fem _ => tazi ; - ASg Neut _ => towa ; - APl _ => tezi ; - AFullDef => tozi + GSg Masc => tozi ; + GSg Fem => tazi ; + GSg Neut => towa ; + GPl => tezi }; spec = Indef } ; diff --git a/lib/resource/bulgarian/NounBul.gf b/lib/resource/bulgarian/NounBul.gf index 2f348c69d..692b89c4f 100644 --- a/lib/resource/bulgarian/NounBul.gf +++ b/lib/resource/bulgarian/NounBul.gf @@ -4,27 +4,49 @@ concrete NounBul of Noun = CatBul ** open ResBul, Prelude in { lin DetCN det cn = - { s = \\c => det.s ! cn.g ++ cn.s ! det.n ! c ! det.spec ; - a = agrP3 (gennum cn.g det.n) + { s = \\c => let nf = case of { + => case c of { + Nom => NFSgDefNom ; + _ => NF Sg Def + } ; + => case det.countable of { + True => NFPlCount ; + False => NF Pl Indef + } ; + _ => NF det.n det.spec + } ; + in det.s ! cn.g ! c ++ cn.s ! nf ; + a = {gn = gennum cn.g det.n; p = P3} ; } ; UsePron p = p ; DetSg quant ord = { - s = \\g => quant.s ! ASg g Indef ++ ord.s ; + s = \\g,c => quant.s ! gennum g Sg ++ + ord.s ! aform (gennum g Sg) quant.spec c ; n = Sg ; - spec=quant.spec + countable = False ; + spec=case ord.empty of {True => quant.spec; _ => Indef} } ; DetPl quant num ord = { - s = \\g => quant.s ! aformGenNum (gennum g num.n) ++ num.s ++ ord.s ; + s = \\g,c => quant.s ! gennum g num.n ++ + num.s ! dgenderSpecies g quant.spec c ++ + ord.s ! aform (gennum g num.n) (case num.empty of {True => quant.spec; _ => Indef}) c ; n = num.n ; - spec=quant.spec + countable = True ; + spec=case of { => quant.spec; _ => Indef} } ; - PossPron p = {s = \\aform => p.s ! Gen aform; spec = Indef} ; + PossPron p = { + s = \\gn => p.s ! Gen (aform gn Def Nom) ; + spec = Indef + } ; - NoNum = {s = []; n = Pl } ; - NoOrd = {s = []} ; + NoNum = {s = \\_ => []; n = Pl; empty = True} ; + NoOrd = {s = \\_ => []; empty = True} ; + + NumNumeral numeral = {s = \\gspec => numeral.s ! NCard gspec; n = numeral.n; empty = False} ; + OrdNumeral numeral = {s = \\aform => numeral.s ! NOrd aform; empty = False} ; DefArt = { s = \\_ => [] ; @@ -32,21 +54,14 @@ concrete NounBul of Noun = CatBul ** open ResBul, Prelude in { } ; IndefArt = { - s = \\_ => [] ; + s = \\_ => [] ; spec = ResBul.Indef } ; - MassDet = {s = \\_ => [] ; n = Sg ; spec = Indef} ; - - UseN noun = { - s = \\n,c,dt => let aform = case n of { - Sg => case of { - => AFullDef ; - _ => ASg noun.g dt - } ; - Pl => APl dt - } - in noun.s ! aform ; - g = noun.g + MassDet = { + s = \\_ => [] ; + spec = Indef } ; + + UseN noun = noun ; } diff --git a/lib/resource/bulgarian/NumeralBul.gf b/lib/resource/bulgarian/NumeralBul.gf index 44b972527..13e5b24c7 100644 --- a/lib/resource/bulgarian/NumeralBul.gf +++ b/lib/resource/bulgarian/NumeralBul.gf @@ -22,10 +22,10 @@ lin pot01 = unit => table { NCard DMascIndef => "един" ; NCard DMascDef => "единия" ; - NCard DMascNomDef => "единият" ; + NCard DMascDefNom => "единият" ; NCard DMascPersonalIndef => "един" ; NCard DMascPersonalDef => "единия" ; - NCard DMascPersonalNomDef => "единият" ; + NCard DMascPersonalDefNom => "единият" ; NCard DFemIndef => "една" ; NCard DFemDef => "едната" ; NCard DNeutIndef => "едно" ; diff --git a/lib/resource/bulgarian/ResBul.gf b/lib/resource/bulgarian/ResBul.gf index ccc21e456..ed7f897b8 100644 --- a/lib/resource/bulgarian/ResBul.gf +++ b/lib/resource/bulgarian/ResBul.gf @@ -19,7 +19,14 @@ resource ResBul = ParamX ** open Prelude in { param Case = Nom | Acc | Gen AForm ; - + + NForm = + NF Number Species + | NFSgDefNom + | NFPlCount + | NFVocative + ; + GenNum = GSg Gender | GPl ; -- Agreement of $NP$ is a record. We'll add $Gender$ later. @@ -56,19 +63,26 @@ resource ResBul = ParamX ** open Prelude in { AForm = ASg Gender Species + | ASgMascDefNom | APl Species - | AFullDef ; --2 For $Numeral$ + DGender = + DMasc + | DMascPersonal + | DFem + | DNeut + ; + DGenderSpecies = DMascIndef | DMascDef - | DMascNomDef + | DMascDefNom | DMascPersonalIndef | DMascPersonalDef - | DMascPersonalNomDef + | DMascPersonalDefNom | DFemIndef | DFemDef | DNeutIndef @@ -81,12 +95,14 @@ resource ResBul = ParamX ** open Prelude in { --2 Transformations between parameter types oper - agrP3 : GenNum -> Agr = \gn -> - {gn = gn ; p = P3} ; - - gennum : Gender -> Number -> GenNum = \g,n -> + gennum : DGender -> Number -> GenNum = \g,n -> case n of { - Sg => GSg g ; + Sg => GSg (case g of { + DMasc => Masc ; + DMascPersonal => Masc ; + DFem => Fem ; + DNeut => Neut + }) ; Pl => GPl } ; @@ -96,12 +112,33 @@ resource ResBul = ParamX ** open Prelude in { GPl => Pl } ; - aformGenNum : GenNum -> AForm = \gn -> + aform : GenNum -> Species -> Case -> AForm = \gn,spec,c -> case gn of { - GSg g => ASg g Indef ; - GPl => APl Indef + GSg g => case of { + => ASgMascDefNom ; + _ => ASg g spec + } ; + GPl => APl spec } ; + dgenderSpecies : DGender -> Species -> Case -> DGenderSpecies = + \g,spec,c -> case of { + => DMascIndef ; + => case c of { + Nom => DMascDefNom ; + _ => DMascDef + } ; + => DMascPersonalIndef ; + => case c of { + Nom => DMascPersonalDefNom ; + _ => DMascPersonalDef + } ; + => DFemIndef ; + => DFemDef ; + => DNeutIndef ; + => DNeutDef + } ; + oper -- For $Verb$. @@ -120,7 +157,7 @@ resource ResBul = ParamX ** open Prelude in { let pol : Polarity -> Str -> Str = \p,vf -> case p of { Pos => vf ; Neg => "не" ++ vf } in { s = \\t,a,p,agr => let present = verb.s ! (VPres (numGenNum agr.gn) agr.p) ; aorist = verb.s ! (VAorist (numGenNum agr.gn) agr.p) ; - perfect = verb.s ! (VPerfect (aformGenNum agr.gn)) ; + perfect = verb.s ! (VPerfect (aform agr.gn Indef Acc)) ; vf = case of { => present ; => auxBe.s ! (VPres (numGenNum agr.gn) agr.p) ++ perfect ; @@ -129,7 +166,7 @@ resource ResBul = ParamX ** open Prelude in { => "ще" ++ present ; => "ще" ++ auxBe.s ! (VPres (numGenNum agr.gn) agr.p) ++ perfect ; => auxWould.s ! (VAorist (numGenNum agr.gn) agr.p) ++ perfect ; - => auxWould.s ! (VAorist (numGenNum agr.gn) agr.p) ++ auxBe.s ! (VPerfect (aformGenNum agr.gn)) ++ perfect + => auxWould.s ! (VAorist (numGenNum agr.gn) agr.p) ++ auxBe.s ! (VPerfect (aform agr.gn Indef Acc)) ++ perfect } ; in pol p vf ; imp = \\p,n => pol p (verb.s ! VImperative n) ; @@ -210,7 +247,7 @@ resource ResBul = ParamX ** open Prelude in { s = table { ASg Masc Indef => dobyr ; ASg Masc Def => dobria ; - AFullDef => dobriat ; + ASgMascDefNom => dobriat ; ASg Fem Indef => dobra ; ASg Fem Def => dobrata ; ASg Neut Indef => dobro ; @@ -332,7 +369,7 @@ resource ResBul = ParamX ** open Prelude in { mkCardOrd : Str -> Str -> Str -> Str -> CardOrd => Str = \dva, dvama, dve, vtori -> table { - NCard dg => digitGender dva dvama dve ! dg ; + NCard dg => digitGenderSpecies dva dvama dve ! dg ; NOrd aform => let vtora = init vtori + "а" ; vtoro = init vtori + "о" in (mkAdjective vtori @@ -346,7 +383,7 @@ resource ResBul = ParamX ** open Prelude in { (vtori+"те")).s ! aform } ; - digitGender : Str -> Str -> Str -> DGenderSpecies => Str = + digitGenderSpecies : Str -> Str -> Str -> DGenderSpecies => Str = \dva, dvama, dve -> let addDef : Str -> Str = \s -> case s of { @@ -357,10 +394,10 @@ resource ResBul = ParamX ** open Prelude in { in table { DMascIndef => dva ; DMascDef => addDef dva ; - DMascNomDef => addDef dva ; + DMascDefNom => addDef dva ; DMascPersonalIndef => dvama ; DMascPersonalDef => addDef dvama ; - DMascPersonalNomDef => addDef dvama ; + DMascPersonalDefNom => addDef dvama ; DFemIndef => dve ; DFemDef => addDef dve ; DNeutIndef => dve ; diff --git a/lib/resource/bulgarian/StructuralBul.gf b/lib/resource/bulgarian/StructuralBul.gf index 7b9fcb7c8..6b19968b4 100644 --- a/lib/resource/bulgarian/StructuralBul.gf +++ b/lib/resource/bulgarian/StructuralBul.gf @@ -46,7 +46,7 @@ concrete StructuralBul of Structural = CatBul ** everything_NP = regNP "everything" Sg ; -} everywhere_Adv = ss "навсякъде" ; - few_Det = mkDeterminerPl "няколко" ; + few_Det = {s = \\_,_ => "няколко"; n = Pl; countable = True; spec = Indef} ; --- first_Ord = ss "first" ; DEPRECATED for_Prep = ss "за" ; from_Prep = ss "от" ; diff --git a/lib/resource/bulgarian/VerbBul.gf b/lib/resource/bulgarian/VerbBul.gf index 7534d39a9..28db621cc 100644 --- a/lib/resource/bulgarian/VerbBul.gf +++ b/lib/resource/bulgarian/VerbBul.gf @@ -14,7 +14,7 @@ concrete VerbBul of Verb = CatBul ** open ResBul in { ReflV2 v = insertObj (\\_ => v.c2 ++ ["себе си"]) (predV v) ; - PassV2 v = insertObj (\\a => v.s ! VPassive (aformGenNum a.gn)) (predV auxBe) ; + PassV2 v = insertObj (\\a => v.s ! VPassive (aform a.gn Indef Acc)) (predV auxBe) ; CompNP np = {s = \\_ => np.s ! Acc} ; CompAdv a = {s = \\_ => a.s} ;