forked from GitHub/gf-rgl
ongoing work on numerals
This commit is contained in:
@@ -53,7 +53,7 @@ concrete CatLat of Cat = CommonX-[Adv] ** open ResLat, ParamX, Prelude in {
|
||||
Pron = ResLat.Pronoun ;
|
||||
Det = Determiner ;
|
||||
Predet = {s : Str} ;
|
||||
Ord = Ordinal ;
|
||||
Ord = { s : Gender => Number => Case => Str } ;
|
||||
Num = {s : Gender => Case => Str ; n : Number} ;
|
||||
Card = {s : Gender => Case => Str ; n : Number} ;
|
||||
Quant = Quantifier ;
|
||||
|
||||
@@ -111,8 +111,8 @@ concrete NounLat of Noun = CatLat ** open ResLat, Prelude, ConjunctionLat in {
|
||||
-- OrdDigits n = {s = n.s ! NOrd} ;
|
||||
--
|
||||
lin
|
||||
NumNumeral numeral = numeral.card ;
|
||||
OrdNumeral numeral = numeral.ord ;
|
||||
-- NumNumeral numeral = numeral.s ;
|
||||
-- OrdNumeral numeral = numeral.ord ;
|
||||
--
|
||||
-- AdNum adn num = {s = adn.s ++ num.s ; n = num.n} ;
|
||||
--
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
concrete NumeralLat of Numeral = CatLat ** open ResLat,ParadigmsLat in {
|
||||
concrete NumeralLat of Numeral = CatLat ** open ResLat,ParadigmsLat,Prelude in {
|
||||
lincat
|
||||
Digit = Numeral ;
|
||||
Digit = TDigit ;
|
||||
Sub10 = Numeral ;
|
||||
Sub100 = Numeral ;
|
||||
Sub1000 = Numeral ;
|
||||
@@ -8,38 +8,81 @@ concrete NumeralLat of Numeral = CatLat ** open ResLat,ParadigmsLat in {
|
||||
|
||||
lin
|
||||
num x = x ;
|
||||
n2 = lin Numeral ( mkNum "duo" "secundus" ) ;
|
||||
n3 = lin Numeral ( mkNum "tres" "tertius" ) ;
|
||||
n4 = lin Numeral ( mkNum "quattuor" "quartus" ) ;
|
||||
n5 = lin Numeral ( mkNum "quinque" "quintus" ) ;
|
||||
n6 = lin Numeral ( mkNum "sex" "sextus" ) ;
|
||||
n7 = lin Numeral ( mkNum "septem" "septimus" ) ;
|
||||
n8 = lin Numeral ( mkNum "octo" "ocatvus" ) ;
|
||||
n9 = lin Numeral ( mkNum "novem" "nonus" ) ;
|
||||
-- n2 = lin Digit ( mkDigit "duo" "viginti" "ducenti" "secundus" ) ;
|
||||
-- n3 = lin Numeral ( mkNum "tres" "triginta" "trecenti" "tertius" ) ;
|
||||
-- n4 = lin Numeral ( mkNum "quattuor" "quadraginta" "quadringenti" "quartus" ) ;
|
||||
-- n5 = lin Numeral ( mkNum "quinque" "quinquaginta" "quingenti" "quintus" ) ;
|
||||
-- n6 = lin Numeral ( mkNum "sex" "sexaginta" "sescenti" "sextus" ) ;
|
||||
-- n7 = lin Numeral ( mkNum "septem" "septuaginta" "septingenti" "septimus" ) ;
|
||||
-- n8 = lin Numeral ( mkNum "octo" "octoginta" "octingenti" "ocatvus" ) ;
|
||||
-- n9 = lin Numeral ( mkNum "novem" "nonaginta" "nongenti" "nonus") ;
|
||||
|
||||
lin pot01 = lin Numeral ( mkNum "unus" "primus" ) ;
|
||||
lin pot0 d = d ;
|
||||
--lin pot110 = regCardOrd "ten" ** {n = Pl} ;
|
||||
--lin pot111 = regCardOrd "eleven" ** {n = Pl} ;
|
||||
--lin pot1to19 d = {s = d.s ! teen} ** {n = Pl} ;
|
||||
lin pot0as1 n = n ;
|
||||
--lin pot1 d = {s = d.s ! ten} ** {n = Pl} ;
|
||||
--lin pot1plus d e = {
|
||||
-- s = \\c => d.s ! ten ! NCard ++ "-" ++ e.s ! unit ! c ; n = Pl} ;
|
||||
pot1as2 n = n ;
|
||||
--lin pot2 d = {s = \\c => d.s ! unit ! NCard ++ mkCard c "hundred"} ** {n = Pl} ;
|
||||
--lin pot2plus d e = {
|
||||
-- s = \\c => d.s ! unit ! NCard ++ "hundred" ++ "and" ++ e.s ! c ; n = Pl} ;
|
||||
pot2as3 n = n ;
|
||||
--lin pot3 n = {
|
||||
-- s = \\c => n.s ! NCard ++ mkCard c "thousand" ; n = Pl} ;
|
||||
--lin pot3plus n m = {
|
||||
-- s = \\c => n.s ! NCard ++ "thousand" ++ m.s ! c ; n = Pl} ;
|
||||
--
|
||||
-- -- 1
|
||||
-- pot01 =
|
||||
-- -- d * 1
|
||||
-- pot0 d = d ;
|
||||
-- -- 10
|
||||
-- pot110 = pot01 ;
|
||||
-- -- 11
|
||||
-- -- pot111 = pot1to19 pot01 ;
|
||||
-- -- 10 + d
|
||||
-- -- pot1to19 d = mkNum "" "" "" "" ; -- {s = d.s ! teen} ** {n = Pl} ;
|
||||
-- -- coercion of 1..9
|
||||
-- pot0as1 n = n ;
|
||||
-- -- d * 10
|
||||
-- --lin pot1 d = {s = d.s ! ten} ** {n = Pl} ;
|
||||
-- -- d * 10 + n
|
||||
-- --lin pot1plus d e = {
|
||||
-- -- s = \\c => d.s ! ten ! NCard ++ "-" ++ e.s ! unit ! c ; n = Pl} ;
|
||||
-- -- coercion of 1..99
|
||||
-- pot1as2 n = n ;
|
||||
-- -- m * 100
|
||||
-- --lin pot2 d = {s = \\c => d.s ! unit ! NCard ++ mkCard c "hundred"} ** {n = Pl} ;
|
||||
-- -- m * 100 + n
|
||||
-- --lin pot2plus d e = {
|
||||
-- -- s = \\c => d.s ! unit ! NCard ++ "hundred" ++ "and" ++ e.s ! c ; n = Pl} ;
|
||||
-- -- coercion of 1..999
|
||||
-- pot2as3 n = n ;
|
||||
-- -- m * 1000
|
||||
-- --lin pot3 n = {
|
||||
-- -- s = \\c => n.s ! NCard ++ mkCard c "thousand" ; n = Pl} ;
|
||||
-- -- m * 1000 + n
|
||||
-- --lin pot3plus n m = {
|
||||
-- -- s = \\c => n.s ! NCard ++ "thousand" ++ m.s ! c ; n = Pl} ;
|
||||
|
||||
oper
|
||||
n1 : Digit = lin Digit ( fullDigit "unus" "decem" "primus" "decimus" "centesimus" "millesimus" ) ;
|
||||
|
||||
mkDigit : (ones, tens, hundreds, ord : Str) -> TDigit =
|
||||
\ones, tens, hundreds, ord ->
|
||||
case <tens,hundreds> of {
|
||||
-- <"decem",_> => fullDigit ones tens hundreds ord "decimus" "centesimus" ;
|
||||
-- <"viginta",_> => fullDigit ones tens hundreds ord "vicesimus" "ducentesimus" ;
|
||||
-- <"triginta",_> => fullDigit ones tens hundreds ord "tricesimus" "trecentesimus" ;
|
||||
<quadra + "ginta",quadringent + "i"> => fullDigit ones tens hundreds ord (quadra + "gesimus") (quadringent + "esimus")
|
||||
} ;
|
||||
fullDigit : (ones, tens, hundreds, ord1,ord10,ord100 : Str) -> TDigit =
|
||||
\ones, tens, hundreds, ord1,ord10,ord100 ->
|
||||
{ s = table { one => cardFlex ones ;
|
||||
ten => cardFlex tens ;
|
||||
hundred => cardFlex hundreds ;
|
||||
thousand => \\_,_ => nonExist ;
|
||||
ten_thousand => \\_,_ => nonExist ;
|
||||
hundred_thousand => \\_,_ => nonExist }
|
||||
-- n = case ones of { "unus" => Sg ; _ => Pl } ;
|
||||
-- ord =
|
||||
-- \\_,_ => [] ;
|
||||
-- -- table { one => (mkA ord1).s ! Posit;
|
||||
-- -- ten => (mkA ord10).s ! Posit ;
|
||||
-- -- hundred => (mkA ord100).s ! Posit ;
|
||||
-- -- thousand => \\_,_ => nonExist ;
|
||||
-- -- ten_thousand => \\_ => nonExist ;
|
||||
-- -- hundred_thousand => \\_ => nonExist } ;
|
||||
} ;
|
||||
-- numerals as sequences of digits
|
||||
|
||||
lincat
|
||||
Dig = TDigit ;
|
||||
Dig = TDig ;
|
||||
|
||||
lin
|
||||
IDig d = {s = d.s ! one; unit = ten} ;
|
||||
@@ -61,11 +104,11 @@ concrete NumeralLat of Numeral = CatLat ** open ResLat,ParadigmsLat in {
|
||||
D_9 = mkDig "IX" "XC" "CM" "(IX)" "(XC)" "(CM)" ;
|
||||
|
||||
oper
|
||||
TDigit = {
|
||||
TDig = {
|
||||
s : Unit => Str
|
||||
} ;
|
||||
|
||||
mkDig : Str -> Str -> Str -> Str -> Str -> Str -> TDigit =
|
||||
mkDig : Str -> Str -> Str -> Str -> Str -> Str -> TDig =
|
||||
\one,ten,hundred,thousand,ten_thousand,hundred_thousand -> {
|
||||
s = table Unit [one;ten;hundred;thousand;ten_thousand;hundred_thousand]
|
||||
} ;
|
||||
|
||||
@@ -114,7 +114,11 @@ oper
|
||||
|
||||
mkPron = mkPronoun ;
|
||||
|
||||
mkNum = mkNumeral ;
|
||||
-- mkNum = overload {
|
||||
-- mkNum : Str -> Str -> Str -> Str -> Num = \s1,s2,s3,s4 -> lin Num (mkNumeral s1 s2 s3 s4 );
|
||||
-- mkNum : Str -> Str -> Str -> Str -> Str -> Str -> Num = \s1,s2,s3,s4,s5,s6 -> lin Num (fullNumeral s1 s2 s3 s4 s5 s6 ) ;
|
||||
-- } ;
|
||||
|
||||
-- To be implemented, just place holders
|
||||
mkPN : N -> PN = \n -> lin PN n ;
|
||||
mkN2 : N -> Prep -> N2 = \n,p -> lin N2 ( n ** { c = p } );
|
||||
|
||||
@@ -152,7 +152,8 @@ param
|
||||
AdjectivePhrase : Type = {
|
||||
s : Agr => Str ;
|
||||
-- isPre : Bool ; -- should have no use in latin because adjectives can appear variably before and after nouns
|
||||
} ;
|
||||
} ;
|
||||
|
||||
mkAdjective : (bonus,bona,bonum : Noun) ->
|
||||
( (Agr => Str) * Str ) ->
|
||||
( (Agr => Str) * Str ) ->
|
||||
@@ -187,7 +188,7 @@ param
|
||||
audaces audaces (audac + "ium") (audac + "ibus")
|
||||
g ;
|
||||
|
||||
|
||||
|
||||
emptyAdj : Adjective =
|
||||
{ s = \\_,_ => "" ; comp_adv = "" ; super_adv = "" ; adv = { s = \\_ => "" } } ;
|
||||
|
||||
@@ -1401,49 +1402,54 @@ oper
|
||||
{ s = table { Posit => p ; Compar => c ; Super => s } };
|
||||
-- numerals
|
||||
param
|
||||
CardOrd = NCard | NOrd ;
|
||||
-- CardOrd = NCard | NOrd ;
|
||||
Unit = one | ten | hundred | thousand | ten_thousand | hundred_thousand ;
|
||||
oper
|
||||
Cardinal : Type = {s : Gender => Case => Str ; n : Number};
|
||||
Ordinal : Type = { s : Gender => Number => Case => Str } ;
|
||||
Numeral : Type = { card : Cardinal ; ord : Ordinal } ;
|
||||
-- Numerals are by default cardinal numbers but have a field for ordinal numbers
|
||||
TDigit : Type = { s : Unit => Gender => Case => Str } ; -- ord : Unit => Agr => Str } ;
|
||||
Numeral : Type = { s : Gender => Case => Str ; n : Number ; ord : Unit => Agr => Str } ;
|
||||
|
||||
-- Inflection for cardinal numbers
|
||||
cardFlex : Str -> Gender => Case => Str =
|
||||
\c -> case c of { "unus" => \\gen,cas => case <gen,cas> of {
|
||||
<Masc, Nom | Voc> => "unus" ; <Masc, Acc> => "unum" ; <Masc, Abl> => "uno" ;
|
||||
<Fem, Nom | Abl | Voc> => "una" ; <Fem, Acc> => "unam" ;
|
||||
<Neutr, Nom | Acc | Voc> => "unum" ; <Neutr, Abl> => "uno" ;
|
||||
<_, Gen> => "unius" ; <_, Dat> => "uni"
|
||||
} ;
|
||||
"duo" => table {
|
||||
Masc | Neutr => table Case [ "duo" ; "duo" ; "duorum" ; "duobus" ; "duobus" ; "duo" ] ;
|
||||
Fem => table Case [ "duae" ; "duas" ; "duarum" ; "duabus" ; "duabus" ; "duae" ] } ;
|
||||
"tres" => \\gen,cas => case <gen,cas> of {
|
||||
<Neutr, Nom | Acc | Voc > => "tria" ; <_, Nom | Acc | Voc > => "tres" ;
|
||||
<_, Gen> => "trium" ; <_, Dat | Abl > => "tribus"
|
||||
} ;
|
||||
"milia" => table {
|
||||
Neutr => table Case [ "milia" ; "milia" ; "milium" ; "milibus" ; "milibus" ; "milia" ] ;
|
||||
_ => \\_ => nonExist
|
||||
} ;
|
||||
_ => \\_,_ => c
|
||||
} ;
|
||||
-- ordFlex : Gender => Number => Case => Str =
|
||||
-- case o of {
|
||||
-- stem + "us" => table {
|
||||
-- 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" ] ;
|
||||
-- ];
|
||||
-- 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" ] ;
|
||||
-- ] ;
|
||||
-- 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" ] ;
|
||||
-- ]
|
||||
-- } ;
|
||||
-- _ => error "unsupported ordinal form"
|
||||
-- }
|
||||
-- in
|
||||
-- { s = cardFlex ; n = case c of { "unus" => Sg ; _ => Pl } ; ord = ordFlex } ;
|
||||
|
||||
-- fixedNumeral : Str -> Str -> Numeral = \c,o ->
|
||||
-- { s = \\_,_,_=> c ; n = Pl ; ord = \\g,n,c => (mkA o).s ! Posit ! Ag g n c} ;
|
||||
|
||||
|
||||
mkNumeral : Str -> Str -> Numeral = \c,o -> -- cardinal and ordinal form
|
||||
let
|
||||
cardFlex : Gender => Case => Str = case c of { "unus" => \\gen,cas => case <gen,cas> of {
|
||||
<Masc, Nom | Voc> => "unus" ; <Masc, Acc> => "unum" ; <Masc, Abl> => "uno" ;
|
||||
<Fem, Nom | Abl | Voc> => "una" ; <Fem, Acc> => "unam" ;
|
||||
<Neutr, Nom | Acc | Voc> => "unum" ; <Neutr, Abl> => "uno" ;
|
||||
<_, Gen> => "unius" ; <_, Dat> => "uni"
|
||||
} ;
|
||||
"duo" => table {
|
||||
Masc | Neutr => table Case [ "duo" ; "duo" ; "duorum" ; "duobus" ; "duobus" ; "duo" ] ;
|
||||
Fem => table Case [ "duae" ; "duas" ; "duarum" ; "duabus" ; "duabus" ; "duae" ] } ;
|
||||
"tres" => \\gen,cas => case <gen,cas> of {
|
||||
<Neutr, Nom | Acc | Voc > => "tria" ; <_, Nom | Acc | Voc > => "tres" ;
|
||||
<_, Gen> => "trium" ; <_, Dat | Abl > => "tribus"
|
||||
} ;
|
||||
"milia" => table {
|
||||
Neutr => table Case [ "milia" ; "milia" ; "milium" ; "milibus" ; "milibus" ; "milia" ] ;
|
||||
_ => \\_ => nonExist
|
||||
} ;
|
||||
_ => \\_,_ => c
|
||||
} ;
|
||||
ordFlex : Gender => Number => Case => Str =
|
||||
case o of {
|
||||
stem + "us" => table {
|
||||
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" ] ;
|
||||
];
|
||||
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" ] ;
|
||||
] ;
|
||||
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" ] ;
|
||||
]
|
||||
} ;
|
||||
_ => error "unsupported ordinal form"
|
||||
}
|
||||
in
|
||||
{ card = { s = cardFlex ; n = case c of { "unus" => Sg ; _ => Pl } } ; ord = { s = ordFlex } } ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user