Files
gf-core/lib/resource/bulgarian/ResBul.gf
2008-02-05 15:54:58 +00:00

329 lines
11 KiB
Plaintext

--# -path=.:../abstract:../common:../../prelude
--1 Bulgarian auxiliary operations.
-- This module contains operations that are needed to make the
-- resource syntax work. To define everything that is needed to
-- implement $Test$, it moreover contains regular lexical
-- patterns needed for $Lex$.
resource ResBul = ParamX ** open Prelude in {
flags optimize=all ;
-- Some parameters, such as $Number$, are inherited from $ParamX$.
--2 For $Noun$
-- This is the worst-case $Case$ needed for pronouns.
param
Case = Nom | Acc | Gen AForm;
GenNum = GSg Gender | GPl ;
-- Agreement of $NP$ is a record. We'll add $Gender$ later.
oper
Agr = {gn : GenNum ; p : Person} ;
param
Gender = Masc | Fem | Neut ;
Dt = NDet | Det ;
-- The plural never makes a gender distinction.
--2 For $Verb$
VForm =
VPres Number Person
| VAorist Number Person
| VImperfect Number Person
| VPerfect AForm
| VPluPerfect AForm
| VPassive AForm
| VPresPart AForm
| VImperative Number
| VGerund
;
-- The order of sentence is needed already in $VP$.
Order = ODir | OQuest ;
--2 For $Adjective$
AForm =
ASg Gender Dt
| APl Dt
| AFullDet
;
--2 Transformations between parameter types
oper
agrP3 : GenNum -> Agr = \gn ->
{gn = gn ; p = P3} ;
gennum : Gender -> Number -> GenNum = \g,n ->
case n of {
Sg => GSg g ;
Pl => GPl
} ;
numGenNum : GenNum -> Number = \gn ->
case gn of {
GSg _ => Sg ;
GPl => Pl
} ;
aformGenNum : GenNum -> AForm = \gn ->
case gn of {
GSg g => ASg g NDet ;
GPl => APl NDet
} ;
oper
-- For $Verb$.
Verb : Type = {
s : VForm => Str ;
} ;
VP : Type = {
s : Tense => Anteriority => Polarity => Agr => Str ;
imp : Polarity => Number => Str ;
s2 : Agr => Str
} ;
predV : Verb -> VP =
\verb ->
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)) ;
vf = case <t,a> of {
<Pres,Simul> => present ;
<Pres,Anter> => auxBe.s ! (VPres (numGenNum agr.gn) agr.p) ++ perfect ;
<Past,Simul> => aorist ;
<Past,Anter> => auxBe.s ! (VAorist (numGenNum agr.gn) agr.p) ++ perfect ;
<Fut, Simul> => "ùå" ++ present ;
<Fut, Anter> => "ùå" ++ auxBe.s ! (VPres (numGenNum agr.gn) agr.p) ++ perfect ;
<Cond,Simul> => auxWould.s ! (VAorist (numGenNum agr.gn) agr.p) ++ perfect ;
<Cond,Anter> => auxWould.s ! (VAorist (numGenNum agr.gn) agr.p) ++ auxBe.s ! (VPerfect (aformGenNum agr.gn)) ++ perfect
} ;
in pol p vf ;
imp = \\p,n => pol p (verb.s ! VImperative n) ;
s2 = \\_ => []
} ;
insertObj : (Agr => Str) -> VP -> VP = \obj,vp -> {
s = vp.s ;
imp = vp.imp ;
s2 = \\a => vp.s2 ! a ++ obj ! a
} ;
auxBe : Verb = {
s = table {
VPres Sg P1 => "ñúì" ;
VPres Sg P2 => "ñè" ;
VPres Sg P3 => "å" ;
VPres Pl P1 => "ñìå" ;
VPres Pl P2 => "ñòå" ;
VPres Pl P3 => "ñà" ;
VAorist Sg P1 => "áÿõ" ;
VAorist Sg _ => "áåøå" ;
VAorist Pl P1 => "áÿõìå" ;
VAorist Pl P2 => "áÿõòå" ;
VAorist Pl P3 => "áÿõà" ;
VImperfect Sg P1 => "áÿõ" ;
VImperfect Sg _ => "áåøå" ;
VImperfect Pl P1 => "áÿõìå" ;
VImperfect Pl P2 => "áÿõòå" ;
VImperfect Pl P3 => "áÿõà" ;
VPerfect aform => (regAdjective "áèë").s ! aform ;
VPluPerfect aform => (regAdjective "áèë").s ! aform ;
VPassive aform => (regAdjective "áúäåí").s ! aform ;
VPresPart aform => (regAdjective "áúäåù").s ! aform ;
VImperative Sg => "áúäè" ;
VImperative Pl => "áúäåòå" ;
VGerund => "áèäåéêè"
}
} ;
auxWould : Verb = {
s = table {
VPres Sg P1 => "áúäà" ;
VPres Sg P2 => "áúäåø" ;
VPres Sg P3 => "áúäå" ;
VPres Pl P1 => "áúäåì" ;
VPres Pl P2 => "áúäåòå" ;
VPres Pl P3 => "áúäàò" ;
VAorist Sg P1 => "áèõ" ;
VAorist Sg _ => "áè" ;
VAorist Pl P1 => "áèõìå" ;
VAorist Pl P2 => "áèõòå" ;
VAorist Pl P3 => "áèõà" ;
VImperfect Sg P1 => "áúäåõ" ;
VImperfect Sg _ => "áúäåøå" ;
VImperfect Pl P1 => "áúäåõìå" ;
VImperfect Pl P2 => "áúäåõòå" ;
VImperfect Pl P3 => "áúäåõà" ;
VPerfect aform => (regAdjective "áèë").s ! aform ;
VPluPerfect aform => (regAdjective "áúäåë").s ! aform ;
VPassive aform => (regAdjective "áúäåí").s ! aform ;
VPresPart aform => (regAdjective "áúäåù").s ! aform ;
VImperative Sg => "áúäè" ;
VImperative Pl => "áúäåòå" ;
VGerund => "áúäåéêè"
}
} ;
ia2e : Str -> Str = -- to be used when the next syllable has vowel different from "à","ú","î" or "ó"
\s -> case s of {
x@(_*+_) + "ÿ" + y@(("á"|"â"|"ã"|"ä"|"æ"|"ç"|"ê"|"ë"|"ì"|"í"|"ï"|"ð"|"ñ"|"ò"|"ô"|"õ"|"ö"|"÷"|"ø"|"ù")*)
=> x+"e"+y;
_ => s
};
mkAdjective : (_,_,_,_,_,_,_,_,_ : Str) -> {s : AForm => Str} =
\dobyr,dobria,dobriat,dobra,dobrata,dobro,dobroto,dobri,dobrite -> {
s = table {
ASg Masc NDet => dobyr ;
ASg Masc Det => dobria ;
AFullDet => dobriat ;
ASg Fem NDet => dobra ;
ASg Fem Det => dobrata ;
ASg Neut NDet => dobro ;
ASg Neut Det => dobroto ;
APl NDet => dobri ;
APl Det => dobrite
}
} ;
regAdjective : Str -> {s : AForm => Str} =
\base -> mkAdjective base
(base+"èÿ")
(base+"èÿò")
(base+"a")
(base+"àòà")
(base+"î")
(base+"îòî")
(ia2e base+"è")
(ia2e base+"èòå") ;
mkVerb : (_,_,_,_,_,_,_,_,_:Str) -> Verb =
\cheta,chete,chetoh,chetqh,chel,chetql,cheten,chetqst,cheti -> {
s = table {
VPres Sg P1 => cheta;
VPres Sg P2 => chete + "ø";
VPres Sg P3 => chete;
VPres Pl P1 => case chete of {
_ + ("à"|"ÿ") => chete + "ìå";
_ => chete + "ì"
};
VPres Pl P2 => chete + "òå";
VPres Pl P3 => case cheta of {
vika + "ì" => case chete of {
dad + "å" => dad + "àò";
vika => vika + "ò"
};
_ => cheta + "ò"
};
VAorist Sg P1 => chetoh;
VAorist Sg _ => case chetoh of {
chet+"îõ" => chete;
zova+ "õ" => zova
};
VAorist Pl P1 => chetoh + "ìå";
VAorist Pl P2 => chetoh + "òå";
VAorist Pl P3 => chetoh + "à";
VImperfect Sg P1 => chetqh;
VImperfect Sg _ => case chete of {
rabot + "è" => rabot + "eøå";
_ => chete + "øå"
};
VImperfect Pl P1 => chetqh + "ìå";
VImperfect Pl P2 => chetqh + "òå";
VImperfect Pl P3 => chetqh + "à";
VPerfect aform =>let chel1 : Str =
case chel of {
pas+"úë" => pas+"ë";
_ => chel
}
in (mkAdjective chel
(chel+"èÿ")
(chel+"èÿò")
(chel1+"a")
(chel1+"àòà")
(chel1+"î")
(chel1+"îòî")
(ia2e chel1+"è")
(ia2e chel1+"èòå")).s ! aform ;
VPluPerfect aform => (regAdjective chetql ).s ! aform ;
VPassive aform => (regAdjective cheten ).s ! aform ;
VPresPart aform => (regAdjective chetqst).s ! aform ;
VImperative Sg => cheti;
VImperative Pl => case cheti of {
chet + "è" => chet + "åòå";
ela => ela + "òå"
};
VGerund => case chete of {
rabot + "è" => rabot + "åéêè";
_ => chete + "éêè"
}
} ;
} ;
-- For $Sentence$.
Clause : Type = {
s : Tense => Anteriority => Polarity => Order => Str
} ;
mkClause : Str -> Agr -> VP -> Clause =
\subj,agr,vp -> {
s = \\t,a,b,o =>
let
verb = vp.s ! t ! a ! b ! agr ;
compl = vp.s2 ! agr
in case o of {
ODir => subj ++ verb ++ compl ;
OQuest => subj ++ verb ++ "ëè" ++ compl
}
} ;
mkIP : Str -> GenNum -> {s : Str ; gn : GenNum} =
\s,gn -> {
s = s ;
gn = gn
} ;
mkNP : (az,men,moj,moia,moiat,moia_,moiata,moe,moeto,moi,moite : Str) -> GenNum -> Person -> {s : Case => Str ; a : Agr} =
\az,men,moj,moia,moiat,moia_,moiata,moe,moeto,moi,moite,gn,p -> {
s = table {
Nom => az ;
Acc => men ;
Gen aform => (mkAdjective moj moia moiat moia_ moiata moe moeto moi moite).s ! aform
} ;
a = {
gn = gn ;
p = p
}
} ;
mkQuestion :
{s : Str} -> Clause ->
{s : Tense => Anteriority => Polarity => QForm => Str} = \wh,cl ->
{
s = \\t,a,p =>
let cls = cl.s ! t ! a ! p ;
why = wh.s
in table {
QDir => why ++ cls ! OQuest ;
QIndir => why ++ cls ! ODir
}
} ;
}