mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-05-27 17:08:54 -06:00
work on ordinal numbers
This commit is contained in:
@@ -105,8 +105,10 @@ concrete NounLat of Noun = CatLat ** open ResLat, Prelude, ConjunctionLat in {
|
|||||||
-- OrdDigits n = {s = n.s ! NOrd} ;
|
-- OrdDigits n = {s = n.s ! NOrd} ;
|
||||||
--
|
--
|
||||||
lin
|
lin
|
||||||
-- NumNumeral numeral = numeral.s ;
|
-- NumNumeral : Numeral -> Card ; -- fifty-one
|
||||||
-- OrdNumeral numeral = numeral.ord ;
|
NumNumeral numeral = { s = numeral.s ; n = numeral.n } ;
|
||||||
|
-- OrdNumeral : Numeral -> Ord ; -- fifty-first
|
||||||
|
OrdNumeral numeral = { s = numeral.ord } ;
|
||||||
--
|
--
|
||||||
-- AdNum adn num = {s = adn.s ++ num.s ; n = num.n} ;
|
-- AdNum adn num = {s = adn.s ++ num.s ; n = num.n} ;
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -18,111 +18,136 @@ concrete NumeralLat of Numeral = CatLat, ParamX[Number] ** open ParadigmsLat, Pr
|
|||||||
n9 = lin Digit ( mkDigit "novem" "undeviginti" "nonaginta" "nongenti" "nonus" "centum" No9 ) ;
|
n9 = lin Digit ( mkDigit "novem" "undeviginti" "nonaginta" "nongenti" "nonus" "centum" No9 ) ;
|
||||||
|
|
||||||
-- 1
|
-- 1
|
||||||
pot01 = { s = n1.s ! one ; d = n1.s ; n = singular ; below8 = n1.below8 } ;
|
pot01 = {
|
||||||
|
s = n1.s ! one ;
|
||||||
|
d = { num, ord = n1.s } ;
|
||||||
|
n = singular ;
|
||||||
|
below8 = n1.below8 ;
|
||||||
|
ord = n1.ord ! one
|
||||||
|
} ;
|
||||||
-- d * 1
|
-- d * 1
|
||||||
pot0 d = {
|
pot0 d = {
|
||||||
s = d.s ! one ;
|
s = d.s ! one ;
|
||||||
d = table {
|
d = { num,ord = table {
|
||||||
thousand => \\g,c => d.s ! one ! g ! c ++ d.s ! thousand ! g ! c ;
|
thousand => \\g,c => d.s ! one ! g ! c ++ d.s ! thousand ! g ! c ;
|
||||||
u => \\g,c => d.s ! u ! g ! c
|
u => \\g,c => d.s ! u ! g ! c
|
||||||
} ;
|
}
|
||||||
|
};
|
||||||
n = plural ;
|
n = plural ;
|
||||||
below8 = d.below8
|
below8 = d.below8 ;
|
||||||
|
ord = d.ord ! one ;
|
||||||
} ;
|
} ;
|
||||||
-- 10
|
-- 10
|
||||||
pot110 = {
|
pot110 = {
|
||||||
s = n1.s ! ten ;
|
s = n1.s ! ten ;
|
||||||
d = table {
|
d = { num, ord = table {
|
||||||
thousand => \\g,c => n1.s ! ten ! g ! c ++ n1.s ! thousand ! g ! c ;
|
thousand => \\g,c => n1.s ! ten ! g ! c ++ n1.s ! thousand ! g ! c ;
|
||||||
u => \\g,c => n1.s ! u ! g ! c
|
u => \\g,c => n1.s ! u ! g ! c
|
||||||
} ;
|
}
|
||||||
|
};
|
||||||
n = singular ;
|
n = singular ;
|
||||||
below8 = Yes
|
below8 = Yes ;
|
||||||
|
ord = n1.ord ! ten
|
||||||
} ;
|
} ;
|
||||||
-- 11
|
-- 11
|
||||||
pot111 = pot1to19 n1 ;
|
pot111 = pot1to19 n1 ;
|
||||||
-- 10 + d
|
-- 10 + d
|
||||||
pot1to19 d = {
|
pot1to19 d = {
|
||||||
s = d.s ! eleven ;
|
s = d.s ! eleven ;
|
||||||
d = table {
|
d = { num, ord = table {
|
||||||
thousand => \\g,c => d.s ! eleven ! g ! c ++ n1.s ! thousand ! g ! c ;
|
thousand => \\g,c => d.s ! eleven ! g ! c ++ n1.s ! thousand ! g ! c ;
|
||||||
u => \\g,c => d.s ! u ! g ! c
|
u => \\g,c => d.s ! u ! g ! c
|
||||||
} ;
|
}
|
||||||
|
};
|
||||||
n = plural ;
|
n = plural ;
|
||||||
below8 = Ign
|
below8 = Ign ;
|
||||||
|
ord = n1.ord ! eleven
|
||||||
} ;
|
} ;
|
||||||
-- coercion of 1..9
|
-- coercion of 1..9
|
||||||
pot0as1 n = n ;
|
pot0as1 n = n ;
|
||||||
-- d * 10
|
-- d * 10
|
||||||
pot1 d = {
|
pot1 d = {
|
||||||
s = d.s ! ten ;
|
s = d.s ! ten ;
|
||||||
d = table {
|
d = { num, ord = table {
|
||||||
thousand => \\g,c => d.s ! ten ! g ! c ++ n1.s ! thousand ! g ! c ;
|
thousand => \\g,c => d.s ! ten ! g ! c ++ n1.s ! thousand ! g ! c ;
|
||||||
u => \\g,c => d.s ! u ! g ! c
|
u => \\g,c => d.s ! u ! g ! c
|
||||||
} ;
|
}
|
||||||
|
};
|
||||||
n = plural ;
|
n = plural ;
|
||||||
below8 = Yes
|
below8 = Yes ;
|
||||||
|
ord = d.ord ! ten
|
||||||
} ;
|
} ;
|
||||||
-- d * 10 + n
|
-- d * 10 + n
|
||||||
pot1plus d n =
|
pot1plus d n =
|
||||||
let
|
let
|
||||||
newS : Gender => Case => Str = \\g,c => case n.below8 of {
|
newS : Gender => Case => Str = \\g,c => case n.below8 of {
|
||||||
No8 => "duo" ++ Prelude.BIND ++ "-" ++ Prelude.BIND ++ "de" ++ Prelude.BIND ++ "-" ++ Prelude.BIND ++ d.tenNext ;
|
No8 => "duo" ++ Prelude.BIND ++ "de" ++ Prelude.BIND ++ d.tenNext ;
|
||||||
No9 => "un" ++ Prelude.BIND ++ "-" ++ Prelude.BIND ++ "de" ++ Prelude.BIND ++ "-" ++ Prelude.BIND ++ d.tenNext ;
|
No9 => "un" ++ Prelude.BIND ++ "de" ++ Prelude.BIND ++ d.tenNext ;
|
||||||
_ => d.s ! ten ! g ! c ++ n.s ! g ! c
|
_ => d.s ! ten ! g ! c ++ n.s ! g ! c
|
||||||
} in
|
} in
|
||||||
{
|
{
|
||||||
s = newS ;
|
s = newS ;
|
||||||
d = table {
|
d = { num, ord = table {
|
||||||
thousand => \\g,c => newS ! g ! c ++ n1.s ! thousand ! g ! c ;
|
thousand => \\g,c => newS ! g ! c ++ n1.s ! thousand ! g ! c ;
|
||||||
u => \\g,c => n.d ! u ! g ! c
|
u => \\g,c => n.d.num ! u ! g ! c
|
||||||
} ;
|
}
|
||||||
|
};
|
||||||
below8 = Ign ;
|
below8 = Ign ;
|
||||||
n = plural
|
n = plural ;
|
||||||
|
ord = \\_,_,_ => nonExist -- TODO
|
||||||
} ;
|
} ;
|
||||||
-- coercion of 1..99
|
-- coercion of 1..99
|
||||||
pot1as2 n = n ;
|
pot1as2 n = n ;
|
||||||
-- m * 100
|
-- m * 100
|
||||||
pot2 n = {
|
pot2 n = {
|
||||||
s = n.d ! hundred ;
|
s = n.d.num ! hundred ;
|
||||||
d = table {
|
d = { num, ord = table {
|
||||||
thousand => \\g,c => n.d ! hundred ! g ! c ++ n1.s ! thousand ! g ! c ;
|
thousand => \\g,c => n.d.num ! hundred ! g ! c ++ n1.s ! thousand ! g ! c ;
|
||||||
u => \\g,c => n.d ! u ! g ! c
|
u => \\g,c => n.d.num ! u ! g ! c
|
||||||
} ;
|
}
|
||||||
|
};
|
||||||
n = plural ;
|
n = plural ;
|
||||||
below8 = Yes} ;
|
below8 = Yes ;
|
||||||
|
ord = \\_,_,_ => nonExist -- TODO
|
||||||
|
} ;
|
||||||
-- d * 100 + n
|
-- d * 100 + n
|
||||||
pot2plus d n =
|
pot2plus d n =
|
||||||
let
|
let
|
||||||
newS : Gender => Case => Str = \\g,c => d.d ! hundred ! g ! c ++ "et" ++ n.s ! g ! c
|
newS : Gender => Case => Str = \\g,c => d.d.num ! hundred ! g ! c ++ "et" ++ n.s ! g ! c
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
s = newS ;
|
s = newS ;
|
||||||
d = table {
|
d = { num, ord = table {
|
||||||
thousand => \\g,c => newS ! g ! c ++ n1.s ! thousand ! g ! c ;
|
thousand => \\g,c => newS ! g ! c ++ n1.s ! thousand ! g ! c ;
|
||||||
u => \\g,c => n.d ! u ! g ! c
|
u => \\g,c => n.d.num ! u ! g ! c
|
||||||
} ;
|
}
|
||||||
|
};
|
||||||
below8 = Ign ;
|
below8 = Ign ;
|
||||||
n = plural
|
n = plural;
|
||||||
|
ord = \\_,_,_ => nonExist -- TODO
|
||||||
} ;
|
} ;
|
||||||
-- coercion of 1..999
|
-- coercion of 1..999
|
||||||
pot2as3 n = n ;
|
pot2as3 n = n ;
|
||||||
-- m * 1000
|
-- m * 1000
|
||||||
pot3 n = {
|
pot3 n = {
|
||||||
s = \\g,c => n.s ! g ! c ++ n.d ! thousand ! g ! c ;
|
s = \\g,c => n.s ! g ! c ++ n.d.num ! thousand ! g ! c ;
|
||||||
d = table { thousand => \\g,c => n.s ! g ! c ++ n.d ! thousand ! g ! c ;
|
d = { num,ord = table {
|
||||||
u => \\g,c => n.d ! u ! g ! c
|
thousand => \\g,c => n.s ! g ! c ++ n.d.num ! thousand ! g ! c ;
|
||||||
|
u => \\g,c => n.d.num ! u ! g ! c
|
||||||
|
}
|
||||||
} ;
|
} ;
|
||||||
below8 = Ign ;
|
below8 = Ign ;
|
||||||
n = plural
|
n = plural ;
|
||||||
|
ord = \\_,_,_ => nonExist -- TODO
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
-- d * 1000 + n
|
-- d * 1000 + n
|
||||||
pot3plus d n = {
|
pot3plus d n = {
|
||||||
s = \\g,c => d.d ! thousand ! g ! c ++ "et" ++ n.s ! g ! c ;
|
s = \\g,c => d.d.num ! thousand ! g ! c ++ "et" ++ n.s ! g ! c ;
|
||||||
d = n.d ;
|
d = n.d ; -- ???
|
||||||
below8 = Ign ;
|
below8 = Ign ;
|
||||||
n = plural
|
n = plural ;
|
||||||
|
ord = \\_,_,_ => nonExist -- TODO
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
oper
|
oper
|
||||||
@@ -146,14 +171,15 @@ concrete NumeralLat of Numeral = CatLat, ParamX[Number] ** open ParadigmsLat, Pr
|
|||||||
hundred_thousand => \\_,_ => nonExist
|
hundred_thousand => \\_,_ => nonExist
|
||||||
} ;
|
} ;
|
||||||
-- n = case ones of { "unus" => singular ; _ => plural } ;
|
-- n = case ones of { "unus" => singular ; _ => plural } ;
|
||||||
-- ord =
|
ord =
|
||||||
-- \\_,_ => [] ;
|
table { one => ordFlex ord1 ;
|
||||||
-- -- table { one => (mkA ord1).s ! Posit;
|
eleven => \\_,_,_ => nonExist ;
|
||||||
-- -- ten => (mkA ord10).s ! Posit ;
|
ten => ordFlex ord10 ;
|
||||||
-- -- hundred => (mkA ord100).s ! Posit ;
|
hundred => ordFlex ord100 ;
|
||||||
-- -- thousand => \\_,_ => nonExist ;
|
thousand => \\_,_,_ => nonExist ;
|
||||||
-- -- ten_thousand => \\_ => nonExist ;
|
ten_thousand => \\_,_,_ => nonExist ;
|
||||||
-- -- hundred_thousand => \\_ => nonExist } ;
|
hundred_thousand => \\_,_,_ => nonExist
|
||||||
|
} ;
|
||||||
tenNext = tenNext ;
|
tenNext = tenNext ;
|
||||||
below8 = b8
|
below8 = b8
|
||||||
} ;
|
} ;
|
||||||
|
|||||||
@@ -1472,8 +1472,8 @@ oper
|
|||||||
Below8 = Yes | No8 | No9 | Ign ;
|
Below8 = Yes | No8 | No9 | Ign ;
|
||||||
oper
|
oper
|
||||||
-- Numerals are by default cardinal numbers but have a field for ordinal numbers
|
-- Numerals are by default cardinal numbers but have a field for ordinal numbers
|
||||||
TDigit : Type = { s : Unit => Gender => Case => Str ; tenNext : Str ; below8 : Below8 } ; -- ord : Unit => Agr => Str } ;
|
TDigit : Type = { s : Unit => Gender => Case => Str ; tenNext : Str ; below8 : Below8 ; ord : Unit => Gender => Number => Case => Str } ;
|
||||||
TNumeral : Type = { s : Gender => Case => Str ; d : Unit => Gender => Case => Str ; n : Number ; below8 : Below8 } ; -- ord : Unit => Agr => Str } ;
|
TNumeral : Type = { s : Gender => Case => Str ; d : { num, ord : Unit => Gender => Case => Str } ; n : Number ; below8 : Below8 ; ord : Gender => Number => Case => Str } ;
|
||||||
|
|
||||||
-- Inflection for cardinal numbers
|
-- Inflection for cardinal numbers
|
||||||
cardFlex : Str -> Gender => Case => Str =
|
cardFlex : Str -> Gender => Case => Str =
|
||||||
@@ -1496,21 +1496,21 @@ oper
|
|||||||
} ;
|
} ;
|
||||||
_ => \\_,_ => c
|
_ => \\_,_ => c
|
||||||
} ;
|
} ;
|
||||||
-- ordFlex : Gender => Number => Case => Str =
|
ordFlex : Str -> Gender => Number => Case => Str =
|
||||||
-- case o of {
|
\o -> case o of {
|
||||||
-- stem + "us" => table {
|
stem + "us" => table {
|
||||||
-- Masc => table Number [ table Case [ stem + "us" ; stem + "um" ; stem + "i" ; stem + "o" ; stem + "o" ; stem + "e" ] ;
|
Masc => table Number [ table Case [ stem + "us" ; stem + "um" ; stem + "i" ; stem + "o" ; stem + "o" ; stem + "e" ] ;
|
||||||
-- table Case [ stem + "i" ; stem + "os" ; stem + "orum" ; stem + "is" ; stem + "is" ; stem + "i" ] ;
|
table Case [ stem + "i" ; stem + "os" ; stem + "orum" ; stem + "is" ; stem + "is" ; stem + "i" ] ;
|
||||||
-- ];
|
];
|
||||||
-- Fem => table Number [ table Case [ stem + "a" ; stem + "am" ; stem + "ae" ; stem + "ae" ; stem + "a" ; stem + "a" ] ;
|
Fem => table Number [ table Case [ stem + "a" ; stem + "am" ; stem + "ae" ; stem + "ae" ; stem + "a" ; stem + "a" ] ;
|
||||||
-- table Case [ stem + "ae" ; stem + "as" ; stem + "arum" ; stem + "is" ; stem + "is" ; stem + "ae" ] ;
|
table Case [ stem + "ae" ; stem + "as" ; stem + "arum" ; stem + "is" ; stem + "is" ; stem + "ae" ] ;
|
||||||
-- ] ;
|
] ;
|
||||||
-- Neutr => table Number [ table Case [ stem + "um" ; stem + "um" ; stem + "i" ; stem + "o" ; stem + "o" ; stem + "um" ] ;
|
Neutr => table Number [ table Case [ stem + "um" ; stem + "um" ; stem + "i" ; stem + "o" ; stem + "o" ; stem + "um" ] ;
|
||||||
-- table Case [ stem + "a" ; stem + "a" ; stem + "orum" ; stem + "is" ; stem + "is" ; stem + "a" ] ;
|
table Case [ stem + "a" ; stem + "a" ; stem + "orum" ; stem + "is" ; stem + "is" ; stem + "a" ] ;
|
||||||
-- ]
|
]
|
||||||
-- } ;
|
} ;
|
||||||
-- _ => error "unsupported ordinal form"
|
_ => error "unsupported ordinal form"
|
||||||
-- }
|
} ;
|
||||||
-- in
|
-- in
|
||||||
-- { s = cardFlex ; n = case c of { "unus" => Sg ; _ => Pl } ; ord = ordFlex } ;
|
-- { s = cardFlex ; n = case c of { "unus" => Sg ; _ => Pl } ; ord = ordFlex } ;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user