mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
A tested version of Numerals
A bug is known in NP case agreement. The fix does not belong to this part of the resource grammar.
This commit is contained in:
@@ -65,7 +65,7 @@ concrete CatRus of Cat = CommonX ** open ResRus, Prelude in {
|
||||
|
||||
-- Numeral
|
||||
|
||||
Num, Numeral, Card = {s : Case => Gender => Str ; n : Number} ;
|
||||
Num, Numeral, Card = {s : Gender => Animacy => Case => Str ; n : Number} ;
|
||||
Digits = {s : Str ; n : Number} ; ----
|
||||
|
||||
-- Structural
|
||||
|
||||
@@ -82,7 +82,7 @@ concrete NounRus of Noun = CatRus ** open ResRus, Prelude, MorphoRus in {
|
||||
} ;
|
||||
|
||||
DetQuantOrd quant num ord = {
|
||||
s = \\af => quant.s !af ++ num.s! (caseAF af) ! (genAF af) ++ ord.s!af ;
|
||||
s = \\af => quant.s !af ++ num.s ! (genAF af) ! (animAF af) ! (caseAF af) ++ ord.s!af ;
|
||||
n = num.n ;
|
||||
g = quant.g;
|
||||
c = quant.c;
|
||||
@@ -91,7 +91,7 @@ concrete NounRus of Noun = CatRus ** open ResRus, Prelude, MorphoRus in {
|
||||
} ;
|
||||
|
||||
DetQuant quant num = {
|
||||
s = \\af => quant.s !af ++ num.s! (caseAF af) ! (genAF af) ;
|
||||
s = \\af => quant.s !af ++ num.s ! (genAF af) ! (animAF af) ! (caseAF af);
|
||||
n = num.n ;
|
||||
g = quant.g;
|
||||
c = quant.c;
|
||||
@@ -149,8 +149,8 @@ concrete NounRus of Noun = CatRus ** open ResRus, Prelude, MorphoRus in {
|
||||
PossPron p = {s = \\af => p.s ! mkPronForm (caseAF af) No (Poss (gennum (genAF af) (numAF af) )); c=Nom; g = PNoGen; q = False} ;
|
||||
|
||||
NumCard c = c ;
|
||||
NumSg = {s = \\_,_ => [] ; n = Sg} ;
|
||||
NumPl = {s = \\_,_ => [] ; n = Pl} ;
|
||||
NumSg = {s = \\_,_,_ => [] ; n = Sg} ;
|
||||
NumPl = {s = \\_,_,_ => [] ; n = Pl} ;
|
||||
|
||||
OrdNumeral numeral = variants {} ; ---- TODO; needed to compile Constructors
|
||||
OrdDigits numeral = variants {} ; ---- TODO; needed to compile Constructors
|
||||
@@ -158,9 +158,9 @@ concrete NounRus of Noun = CatRus ** open ResRus, Prelude, MorphoRus in {
|
||||
-- {s = \\ af => (uy_j_EndDecl (numeral.s ! caseAF af ! genAF af)).s!af} ;
|
||||
|
||||
NumNumeral n = n ;
|
||||
NumDigits n = {s = \\_,_ => n.s ; n = n.n} ;
|
||||
NumDigits n = {s = \\_,_,_ => n.s ; n = n.n} ;
|
||||
|
||||
AdNum adn num = {s = \\c,n => adn.s ++ num.s!c!n ; n = num.n} ;
|
||||
AdNum adn num = {s = \\c,a,n => adn.s ++ num.s!c!a!n ; n = num.n} ;
|
||||
|
||||
OrdSuperl a = {s = a.s!Posit};
|
||||
|
||||
|
||||
@@ -5,77 +5,201 @@ concrete NumeralRus of Numeral = CatRus ** open ResRus in {
|
||||
flags coding=utf8 ;
|
||||
|
||||
-- Toiska, 13/8/2000, AR with Arto Mustajoki.
|
||||
-- Nikita Frolov, 2011
|
||||
|
||||
lincat Digit = {s : DForm => Gender => Str ; size : Size} ;
|
||||
lincat Sub10 = {s : Place => DForm => Gender => Str ; size : Size} ;
|
||||
lincat Sub100 = {s : Place => Gender => Str ; size : Size} ;
|
||||
lincat Sub1000 = {s : Place => Gender => Str ; size : Size} ;
|
||||
lincat Sub1000000 = {s : Gender => Str} ;
|
||||
lincat Digit = {s : DForm => Gender => Animacy => Case => Str ; size : Size} ;
|
||||
lincat Sub10 = {s : Place => DForm => Gender => Animacy => Case => Str ; size : Size} ;
|
||||
lincat Sub100 = {s : Place => Gender => Animacy => Case => Str ; size : Size} ;
|
||||
lincat Sub1000 = {s : Place => Gender => Animacy => Case => Str ; size : Size} ;
|
||||
lincat Sub1000000 = {s : Gender => Animacy => Case => Str} ;
|
||||
|
||||
lin num x = {s = table{ _ => x.s } ; n = Pl}; ---- n TODO ; Size? AR 18/12/2007
|
||||
lin num x = {s = \\ g,a,c => x.s ! g ! a ! c; n = Pl}; ---- n TODO ; Size? AR 18/12/2007
|
||||
|
||||
lin n2 =
|
||||
{s = table {unit => table {Fem => "две" ; _ => "два"} ;
|
||||
teen => gg "двенадцать" ;
|
||||
ten => gg "двадцать" ;
|
||||
hund => gg "двести"} ;
|
||||
{s = table {unit => \\ g, a, c =>
|
||||
case <c, g, a> of {
|
||||
<(Nom|Acc), Fem, Inanimate > => "две";
|
||||
<(Nom|Acc), _, Inanimate > => "два";
|
||||
<(Nom|Acc), _, Animate > => "двух";
|
||||
<(Gen|Prepos _), _, _ > => "двух";
|
||||
<Dat, _, _ > => "двум";
|
||||
<Inst, _, _ > => "двумя"
|
||||
};
|
||||
teen => nadsat "две" ;
|
||||
ten => n2030 "два" ;
|
||||
hund => \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => "двести";
|
||||
<Gen, _ > => "двухсот";
|
||||
<Dat, _ > => "двумстам";
|
||||
<Inst, _ > => "двумяюстами";
|
||||
<Prepos _, _ > => "двухстах"} } ;
|
||||
size = sgg} ;
|
||||
lin n3 =
|
||||
{s = table {unit => gg "три" ;
|
||||
teen => gg "тринадцать" ;
|
||||
ten => gg "тридцать" ;
|
||||
hund => gg "триста"} ;
|
||||
{s = table {unit => tri ;
|
||||
teen => nadsat "три" ;
|
||||
ten => n2030 "три" ;
|
||||
hund => sta tri} ;
|
||||
size = sgg} ;
|
||||
lin n4 =
|
||||
{s = table {unit => gg "четыре" ;
|
||||
teen => gg "четырнадцать" ;
|
||||
ten => gg "сорок" ;
|
||||
hund => gg "четыреста"} ;
|
||||
{s = table {unit => chetyre ;
|
||||
teen => nadsat "четыр" ;
|
||||
ten => \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => "сорок";
|
||||
<(Gen|Dat|Inst|Prepos _), _ > => "сорока" } ;
|
||||
hund => sta chetyre } ;
|
||||
size = sgg} ;
|
||||
lin n5 =
|
||||
{s = table {unit => gg "пять" ;
|
||||
teen => gg "пятнадцать" ;
|
||||
ten => gg "пятьдесят" ;
|
||||
hund => gg "пятьсот"} ;
|
||||
{s = table {unit => n59 "пят" ;
|
||||
teen => nadsat "пят" ;
|
||||
ten => n5070 "пят" ;
|
||||
hund => sot (n59 "пят")} ;
|
||||
size = plg} ;
|
||||
lin n6 =
|
||||
{s = table {unit => gg "шесть" ;
|
||||
teen => gg "шестнадцать" ;
|
||||
ten => gg "шестьдесят" ;
|
||||
hund => gg "шестьсот"} ;
|
||||
{s = table {unit => n59 "шест" ;
|
||||
teen => nadsat "шест" ;
|
||||
ten => n5070 "шест" ;
|
||||
hund => sot (n59 "шест")} ;
|
||||
size = plg} ;
|
||||
lin n7 =
|
||||
{s = table {unit => gg "семь" ;
|
||||
teen => gg "семнадцать" ;
|
||||
ten => gg "семьдесят" ;
|
||||
hund => gg "семьсот"} ;
|
||||
{s = table {unit => n59 "сем" ;
|
||||
teen => nadsat "сем" ;
|
||||
ten => n5070 "сем" ;
|
||||
hund => sot (n59 "сем") } ;
|
||||
size = plg} ;
|
||||
lin n8 =
|
||||
{s = table {unit => gg "восемь" ;
|
||||
teen => gg "восемнадцать" ;
|
||||
ten => gg "восемьдесят" ;
|
||||
hund => gg "восемьсот"} ;
|
||||
{s = table {unit => vosem ;
|
||||
teen => nadsat "восем" ;
|
||||
ten => \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => "восемьдесят";
|
||||
<(Gen|Dat|Prepos _), _ > => "восьмидесяти" ;
|
||||
<Inst, _ > => "восемьюдесятью"
|
||||
};
|
||||
hund => sot vosem
|
||||
} ;
|
||||
size = plg} ;
|
||||
lin n9 =
|
||||
{s = table {unit => gg "девять" ;
|
||||
teen => gg "девятнадцать" ;
|
||||
ten => gg "девяносто" ;
|
||||
hund => gg "девятьсот"} ;
|
||||
{s = table {unit => n59 "девят" ;
|
||||
teen => nadsat "девят" ;
|
||||
ten => \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => "девяносто";
|
||||
<(Gen|Dat|Inst|Prepos _), _ > => "девяноста"
|
||||
};
|
||||
hund => sot (n59 "девят") } ;
|
||||
size = plg} ;
|
||||
|
||||
oper n59 : Str -> (Gender => Animacy => Case => Str) = \ n -> \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => n + "ь";
|
||||
<(Gen|Dat|Prepos _), _ > => n + "и";
|
||||
<Inst, _ > => n + "ью"
|
||||
};
|
||||
|
||||
oper n2030 : Str -> (Gender => Animacy => Case => Str) = \ n -> \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => n + "дцать";
|
||||
<(Gen|Dat|Prepos _), _ > => n + "дцати" ;
|
||||
<Inst, _ > => n + "дцатью"
|
||||
};
|
||||
|
||||
oper n5070 : Str -> (Gender => Animacy => Case => Str) = \ n -> \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => n + "ьдесят";
|
||||
<(Gen|Dat|Prepos _), _ > => n + "идесяти" ;
|
||||
<Inst, _ > => n + "ьюдесятью"
|
||||
};
|
||||
|
||||
oper tri : Gender => Animacy => Case => Str = \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => "три";
|
||||
<(Gen|Prepos _), _ > => "трех";
|
||||
<Dat, _ > => "трем";
|
||||
<Inst, _ > => "тремя"
|
||||
};
|
||||
|
||||
oper chetyre : Gender => Animacy => Case => Str = \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => "четыре";
|
||||
<(Gen|Prepos _), _ > => "четырех";
|
||||
<Dat, _ > => "четырем";
|
||||
<Inst, _ > => "четырьмя"
|
||||
};
|
||||
|
||||
oper vosem : Gender => Animacy => Case => Str = \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => "восемь";
|
||||
<(Gen|Dat|Prepos _), _ > => "восьми";
|
||||
<Inst, _ > => "восемью"
|
||||
};
|
||||
|
||||
-- a little tribute to Burgess
|
||||
oper nadsat : Str -> (Gender => Animacy => Case => Str) = \ n -> \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => n + "надцать";
|
||||
<(Gen|Dat|Prepos _), _ > => n + "надцати";
|
||||
<Inst, _ > => n + "надцатью"
|
||||
};
|
||||
|
||||
oper sta : (Gender => Animacy => Case => Str) -> (Gender => Animacy => Case => Str) = \ n -> \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => n ! Fem ! Animate ! c + "ста";
|
||||
<Gen, _ > => n ! Fem ! Animate ! c + "сот";
|
||||
<Dat, _ > => n ! Fem ! Animate ! c + "стам";
|
||||
<Inst, _ > => n ! Fem ! Animate ! c + "юстами";
|
||||
<Prepos _, _ > => n ! Fem ! Animate ! c + "стах"
|
||||
};
|
||||
|
||||
oper sot : (Gender => Animacy => Case => Str) -> (Gender => Animacy => Case => Str) = \ n -> \\ g, a, c =>
|
||||
case <c, g> of {
|
||||
<(Nom|Acc), _ > => n ! Fem ! Animate ! c + "сот";
|
||||
<Gen, _ > => n ! Fem ! Animate ! c + "сот";
|
||||
<Dat, _ > => n ! Fem ! Animate ! c + "стам";
|
||||
<Inst, _ > => n ! Fem ! Animate ! c + "юстами";
|
||||
<Prepos _, _ > => n ! Fem ! Animate ! c + "ста"
|
||||
};
|
||||
|
||||
lin pot01 =
|
||||
{s = table {attr => table {hund => gg "сто" ; _ => gg []} ;
|
||||
_ => table {hund => gg "сто" ;
|
||||
_ => table {Masc => "один" ; Fem => "одна" ; _ => "одно"}}} ;
|
||||
{s = table {attr => table {hund => \\ g, a, c =>
|
||||
case <g, a, c> of {
|
||||
<_, _, (Nom|Acc) > => "сто";
|
||||
<_, _, (Gen|Dat|Prepos _) > => "ста";
|
||||
<_, _, Inst > => "сотней"
|
||||
};
|
||||
_ => \\ g, a, c => []} ;
|
||||
_ => table {hund => \\ g, a, c =>
|
||||
case <g, a, c> of {
|
||||
<_, _, (Nom|Acc) > => "сто";
|
||||
<_, _, (Gen|Dat|Prepos _) > => "ста";
|
||||
-- TODO: case agreement with nouns
|
||||
<_, _, Inst > => "сотней"
|
||||
};
|
||||
_ => \\ g, a, c =>
|
||||
case <g, a, c> of {
|
||||
<Masc, Animate, Acc> => "одного";
|
||||
<Masc, Inanimate, Acc> => "один";
|
||||
<Masc, _, Nom > => "один";
|
||||
<Masc, _, Gen > => "одного";
|
||||
<Masc, _, Dat > => "одному";
|
||||
<Masc, _, Inst > => "одним";
|
||||
<Masc, _, Prepos _ > => "одном";
|
||||
<Fem, _, Nom > => "одна";
|
||||
<Fem, _, (Gen|Dat|Inst|Prepos _) > => "одной";
|
||||
<Fem, _, Acc> => "одну";
|
||||
<Neut, _, (Nom|Acc) > => "одно";
|
||||
<Neut, _, Gen > => "одного";
|
||||
<Neut, _, Dat > => "одному";
|
||||
<Neut, _, Inst > => "одним";
|
||||
<Neut, _, Prepos _ > => "одном"}}} ;
|
||||
size = nom} ;
|
||||
lin pot0 d =
|
||||
{s = table {_ => d.s} ; size = d.size} ;
|
||||
lin pot110 =
|
||||
{s = table {_ => gg "десяти"} ; size = plg} ;
|
||||
-- {s = table {_ => gg "десять"} ; size = plg} ;
|
||||
{s = \\ p => n59 "десять" ; size = plg} ;
|
||||
lin pot111 =
|
||||
{s = table {_ => gg "одиннадцать"} ; size = plg} ; --- 11
|
||||
{s = \\ p => nadsat "один" ; size = plg} ; --- 11
|
||||
lin pot1to19 d =
|
||||
{s = table {_ => d.s ! teen} ; size = plg} ;
|
||||
lin pot0as1 n =
|
||||
@@ -83,20 +207,19 @@ lin pot0as1 n =
|
||||
lin pot1 d =
|
||||
{s = table {_ => d.s ! ten} ; size = plg} ; ---
|
||||
lin pot1plus d e =
|
||||
{s = table {_ =>
|
||||
table {g => d.s ! ten ! g ++ e.s ! indep ! unit ! g}} ; size = e.size} ;
|
||||
{s = table {_ => \\ g, a, c => d.s ! ten ! g ! a ! c ++ e.s ! indep ! unit ! g ! a ! c} ; size = e.size} ;
|
||||
lin pot1as2 n =
|
||||
{s = n.s ; size = n.size} ;
|
||||
lin pot2 d =
|
||||
{s = table {p => d.s ! p ! hund} ; size = plg} ;
|
||||
lin pot2plus d e =
|
||||
{s = table {p => table {g => d.s ! p ! hund ! g ++ e.s ! indep ! g}} ; size = e.size} ;
|
||||
{s = \\ p, g, a, c => d.s ! p ! hund ! g ! a ! c ++ e.s ! indep ! g ! a ! c ; size = e.size} ;
|
||||
lin pot2as3 n =
|
||||
{s = n.s ! indep} ;
|
||||
lin pot3 n =
|
||||
{s = gg (n.s ! attr ! Fem ++ mille ! n.size)} ;
|
||||
{s = \\ g, a, c => n.s ! attr ! Fem ! a ! c ++ mille ! n.size} ;
|
||||
lin pot3plus n m =
|
||||
{s = table {g => n.s ! attr ! Fem ++ mille ! n.size ++ m.s ! indep ! g}} ;
|
||||
{s = \\ g, a, c => n.s ! attr ! Fem ! a ! c ++ mille ! n.size ++ m.s ! indep ! g ! a ! c} ;
|
||||
|
||||
--- TODO
|
||||
--- raz/odin
|
||||
|
||||
@@ -18,7 +18,7 @@ concrete PhraseRus of Phrase = CatRus ** open Prelude, ResRus in {
|
||||
UttVP vp = {s = vp.s ! ClInfinit ! GSg Masc ! P3} ;
|
||||
UttAdv adv = adv ;
|
||||
UttCN n = {s = n.s ! NF Sg Nom} ;
|
||||
UttCard n = {s = n.s ! Nom ! Neut} ;
|
||||
UttCard n = {s = n.s ! Neut ! Inanimate ! Nom} ;
|
||||
UttAP ap = {s = ap.s ! AF Nom Inanimate (GSg Neut)} ; ---- gennum ? (AR)
|
||||
|
||||
NoPConj = {s = []} ;
|
||||
|
||||
@@ -61,7 +61,7 @@ concrete QuestionRus of Question = CatRus ** open ResRus, Prelude in {
|
||||
IdetQuant kakoj pyat = -- okhotnik =
|
||||
{s = \\af =>
|
||||
kakoj.s ! pyat.n ! af ++
|
||||
pyat.s ! caseAF af ! genAF af ;
|
||||
pyat.s ! genAF af ! animAF af ! caseAF af ;
|
||||
n = pyat.n ;
|
||||
g = kakoj.g ;
|
||||
c = kakoj.c
|
||||
|
||||
@@ -317,6 +317,9 @@ oper genAF: AdjForm -> Gender = \af ->
|
||||
oper caseAF: AdjForm -> Case = \af ->
|
||||
case af of { AdvF => Nom; AFShort _ => Nom; AF c _ _ => c } ;
|
||||
|
||||
oper animAF: AdjForm -> Animacy = \af ->
|
||||
case af of { AF _ a _ => a ; _ => Inanimate } ;
|
||||
|
||||
-- The Degree parameter should also be more complex, since most Russian
|
||||
-- adjectives have two comparative forms:
|
||||
-- attributive (syntactic (compound), declinable) -
|
||||
|
||||
@@ -7,13 +7,13 @@ lin
|
||||
SymbPN i = {s = table {_ => i.s} ; g = Neut; anim = Inanimate } ;
|
||||
IntPN i = {s = table {_ => i.s} ; g = Neut; anim = Inanimate } ;
|
||||
FloatPN i = {s = table {_ => i.s} ; g = Neut; anim = Inanimate } ;
|
||||
NumPN n = {s = table {_ => n.s ! Nom ! Neut} ; g = Neut; anim = Inanimate } ;
|
||||
NumPN n = {s = table {_ => n.s ! Neut ! Nom} ; g = Neut; anim = Inanimate } ;
|
||||
|
||||
CNIntNP cn i = {s = \\cas => cn.s ! NF Sg (extCase cas) ++ i.s;
|
||||
n = Sg ; p = P3 ;
|
||||
g = PGen cn.g ; anim = cn.anim ; pron = False } ;
|
||||
CNNumNP cn n = {s = \\cas => cn.s ! NF Sg (extCase cas)
|
||||
++ n.s ! (extCase cas) ! cn.g;
|
||||
++ n.s ! cn.g ! (extCase cas) ;
|
||||
n = Sg ; p = P3 ;
|
||||
g = PGen cn.g ; anim = cn.anim ; pron = False } ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user