1
0
forked from GitHub/gf-rgl

The new Decimal API

This commit is contained in:
Krasimir Angelov
2023-08-21 20:14:26 +02:00
parent 58da8deca8
commit fb398c603e
147 changed files with 918 additions and 188 deletions

View File

@@ -93,6 +93,7 @@ abstract Cat = Common ** {
Numeral ; -- cardinal or ordinal in words e.g. "five/fifth"
Digits ; -- cardinal or ordinal in digits e.g. "1,000/1,000th"
Decimal ; -- decimal number e.g. "1/2/3.14/-1"
--2 Structural words

View File

@@ -58,7 +58,7 @@ abstract Noun = Cat ** {
data
NumDigits : Digits -> Card ; -- 51
NumFloat : Digits -> Digits -> Card ; -- 3.14
NumDecimal : Decimal -> Card ; -- 3.14, -1, etc
NumNumeral : Numeral -> Card ; -- fifty-one
-- The construction of numerals is defined in [Numeral Numeral.html].
@@ -158,7 +158,6 @@ abstract Noun = Cat ** {
--2 Quantities
QuantityNP : Digits -> MU -> NP ;
QuantityFloatNP : Digits -> Digits -> MU -> NP ;
QuantityNP : Decimal -> MU -> NP ;
}

View File

@@ -17,7 +17,7 @@
-- parts of a numeral, which is often incorrect - more work on
-- (un)lexing is needed to solve this problem.
abstract Numeral = Cat [Numeral,Digits] ** {
abstract Numeral = Cat [Numeral,Digits,Decimal] ** {
cat
Digit ; -- 2..9
@@ -53,18 +53,18 @@ data
pot3 : Sub1000 -> Sub1000000 ; -- m * 1000
pot3plus : Sub1000 -> Sub1000 -> Sub1000000 ; -- m * 1000 + n
pot3as4 : Sub1000000 -> Sub1000000000 ; -- coercion of 1..999999
pot3float : Float -> Sub1000000 ; -- 3.5 thousand
pot3decimal : Decimal -> Sub1000000 ; -- 3.5 thousand
pot41 : Sub1000000000 ; -- a million instead of one million
pot4 : Sub1000 -> Sub1000000000 ; -- m * 1000000000
pot4plus : Sub1000 -> Sub1000000 -> Sub1000000000 ; -- m * 1000000000 + n
pot4as5 : Sub1000000000 -> Sub1000000000000 ; -- coercion of 1..999999999
pot4float : Float -> Sub1000000000 ; -- 3.5 million
pot4decimal : Decimal -> Sub1000000000 ; -- 3.5 million
pot51 : Sub1000000000000 ; -- a billion instead of one billion
pot5 : Sub1000 -> Sub1000000000000 ; -- m * 1000000000
pot5plus : Sub1000 -> Sub1000000000 -> Sub1000000000000 ; -- m * 1000000000 + n
pot5float : Float -> Sub1000000000000 ; -- 3.5 billion
pot5decimal : Decimal -> Sub1000000000000 ; -- 3.5 billion
-- Numerals as sequences of digits have a separate, simpler grammar
@@ -77,4 +77,8 @@ data
D_0, D_1, D_2, D_3, D_4, D_5, D_6, D_7, D_8, D_9 : Dig ;
PosDecimal : Digits -> Decimal ; -- 8
NegDecimal : Digits -> Decimal ; -- -8
IFrac : Decimal -> Dig -> Decimal ; -- 3.14 -> 3.141
}

View File

@@ -62,6 +62,7 @@ concrete CatAfr of Cat =
Numeral = {s : CardOrd => Str ; n : Number } ;
Digits = {s : CardOrd => Str ; n : Number } ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
-- Structural

View File

@@ -77,7 +77,7 @@ concrete NounAfr of Noun = CatAfr ** open ResAfr, Prelude in {
NumDigits numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
OrdDigits numeral = {s = \\af => numeral.s ! NOrd af} ;
NumFloat n1 n2 = {s = \\g,c => n1.s ! NCard Neutr Nom ++ BIND ++ "." ++ BIND ++ n1.s ! NCard g c; n = Pl } ;
NumDecimal dec = {s = \\g,c => dec.s ! NCard g c; n = dec.n } ;
NumNumeral numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
OrdNumeral numeral = {s = \\af => numeral.s ! NOrd af} ;
@@ -185,10 +185,4 @@ concrete NounAfr of Noun = CatAfr ** open ResAfr, Prelude in {
isPron = False
} ;
QuantityFloatNP n1 n2 m = {
s = \\c => preOrPost m.isPre m.s (n1.s ! NCard Neutr Nom ++ BIND ++ "." ++ BIND ++ n1.s ! NCard Neutr Nom) ;
a = agrP3 Pl ;
isPron = False
} ;
}

View File

@@ -1,5 +1,5 @@
concrete NumeralAfr of Numeral = CatAfr [Numeral,Digits] ** open ResAfr, Prelude in {
concrete NumeralAfr of Numeral = CatAfr [Numeral,Digits,Decimal] ** open ResAfr, Prelude in {
flags optimize = all_subs ;
coding=utf8 ;
@@ -75,6 +75,20 @@ lin
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! invNum ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o;
n = Pl ;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + "e") ;

View File

@@ -22,6 +22,7 @@ lincat
Prep = ResAmh.Prep;
Numeral = ResAmh.Numeral; --{s : CardOrd => Case => Str ; n : Number} ;
Digits = ResAmh.Digits;--{s : CardOrd => Case => Str ; n : Number ; tail : DTail} ;
Decimal = ResAmh.Decimal;
Ord = ResAmh.Ord ; --{ s : Case => Str } ;
Num = ResAmh.Num;--{s : Case => Str ; n : Number ; hasCard : Bool} ;
Card = ResAmh.Card;--{s : Case => Str ; n : Number} ;

View File

@@ -94,6 +94,7 @@ lin
NumCard n = {s = \\s,c => n.s!Masc!Sg!s!c ; n = Pl; hasCard = True} ;
NumDigits n = {s = n.s ! NCard } ;
NumDecimal n = {s = n.s ! NCard } ;
NumNumeral numeral = {s = numeral.s ! NCard} ;

View File

@@ -1,5 +1,5 @@
concrete NumeralAmh of Numeral = CatAmh [Numeral,Digits] ** open ResAmh,ParamX,Prelude in {
concrete NumeralAmh of Numeral = CatAmh [Numeral,Digits,Decimal] ** open ResAmh,ParamX,Prelude in {
flags coding = utf8;
lincat
@@ -91,6 +91,18 @@ lin pot3plus n m = {
D_8 = mkDig "8" ;
D_9 = mk2Dig "9" "9ኛ";
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o,g,n,s,c => "-" ++ BIND ++ d.s !o!g!n!s!c ;
hasDot=False
} ;
IFrac d i = {
s = \\o,g,n,s,c => d.s!NCard!Masc!Sg!Indef!c ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ! g ! n ! s ! c;
hasDot=True
} ;
oper
commaIf : DTail -> Str = \t -> case t of {
T3 => BIND++","++BIND ;

View File

@@ -161,6 +161,10 @@ resource ResAmh = PatternsAmh** open Prelude,MorphoAmh,ParamX in {
s : CardOrd=>Gender=>Number=>Species=>Case => Str ;
tail : DTail
} ;
Decimal = {
s : CardOrd=>Gender=>Number=>Species=>Case => Str ;
hasDot : Bool
} ;
Ord = {s : Gender=>Number=>Species=>Case => Str} ;

View File

@@ -90,6 +90,7 @@ concrete CatGrc of Cat = CommonX - [Temp,Tense] ** open ResGrc, Prelude in {
Numeral = {s : CardOrd => Str ; n : Number} ;
Digits = {s : Str ; unit : Unit} ;
Decimal = {s : Str ; unit : Unit ; hasDot : Bool} ;
-- Structural

View File

@@ -83,6 +83,8 @@ concrete NounGrc of Noun = CatGrc ** open Prelude, ResGrc, (M = MorphoGrc) in {
-- TODO: check the following two:
NumDigits digits = let num : Number = case digits.unit of {one => Sg ; _ => Pl}
in {s = \\g,c => digits.s ++ "'"; n = num ; isCard = True} ;
NumDecimal digits = let num : Number = case digits.unit of {one => Sg ; _ => Pl}
in {s = \\g,c => digits.s ++ "'"; n = num ; isCard = True} ;
NumNumeral numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
AdNum adn num = {s = \\g,c => adn.s ++ num.s ! g ! c ; n = num.n} ;

View File

@@ -1,6 +1,6 @@
--# -path=.:../abstract:../common:../prelude:
concrete NumeralGrc of Numeral = CatGrc ** open ResGrc, MorphoGrc in {
concrete NumeralGrc of Numeral = CatGrc ** open ResGrc, MorphoGrc, Prelude in {
lincat
Digit = {s : DForm => CardOrd => Str} ;
@@ -81,6 +81,8 @@ lin -- mkDigit d (d+10) (d*10) d-th d-times
D_8 = mkDig "h" "p" "w" ;
D_9 = mkDig "v" "K" "P" ; -- TODO: replace K by koppa, P by sampi (not in ut -ancientgreek)
PosDecimal d = d ** {hasDot=False} ;
oper
TDigit = {
s : Unit => Str

View File

@@ -67,6 +67,8 @@ concrete CatAra of Cat = CommonX - [Utt] ** open ResAra, Prelude, ParamX in {
n : Size } ;
Digits = {s : Str;
n : Size};
Decimal = {s : Str;
n : Size; hasDot : Bool};
-- Structural

View File

@@ -130,6 +130,10 @@ lin
s = \\_,_,_ => digits.s ;
isNum = True
};
NumDecimal dec = dec ** {
s = \\_,_,_ => dec.s ;
isNum = True
};
NumNumeral numeral = numeral ** {
s = numeral.s ! NCard ;

View File

@@ -1,4 +1,4 @@
concrete NumeralAra of Numeral = CatAra [Numeral,Digits] **
concrete NumeralAra of Numeral = CatAra [Numeral,Digits,Decimal] **
open Predef, Prelude, ResAra, MorphoAra in {
flags coding=utf8 ;
@@ -136,6 +136,20 @@ lincat
D_8 = mk1Dig "8" ;
D_9 = mk1Dig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ BIND ++ d.s;
n = ThreeTen ;
hasDot=False
} ;
IFrac d i = {
s = d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ;
n = ThreeTen ;
hasDot=True
} ;
oper

View File

@@ -62,6 +62,7 @@ incomplete concrete CatBantu of Cat =
Numeral = {s : CardOrd => Gender => Str ; n : Number} ;
Digits = {s : CardOrd => Gender => Str ; n : Number} ;
Decimal = {s : CardOrd => Gender => Str ; n : Number ; hasDot : Bool} ;
-- Structural

View File

@@ -77,6 +77,7 @@ lin
NumCard n = n ;--** {hasCard = True} ;
NumDigits n = {s = n.s ! NCard ; n = n.n} ;
NumDecimal n = {s = n.s ! NCard ; n = n.n} ;
OrdDigits n = { s = n.s ! NOrd} ;
NumNumeral numeral = {s = numeral.s ! NCard; n = numeral.n} ;

View File

@@ -85,6 +85,7 @@ concrete CatEus of Cat = CommonX ** open ResEus, Prelude in {
Numeral = { s : Str ; n : Number } ;
Digits = { s : CardOrd => Str ; n : Number } ;
Decimal = { s : CardOrd => Str ; n : Number ; hasDot : Bool} ;

View File

@@ -125,6 +125,7 @@ concrete NounEus of Noun = CatEus ** open ResEus, Prelude in {
-- : Digits -> Card ;
NumDigits dig = { s = dig.s ! NCard ; n = dig.n } ;
NumDecimal dec = { s = dec.s ! NCard ; n = dec.n } ;
-- : Numeral -> Card ;
NumNumeral num = num ;

View File

@@ -1,4 +1,4 @@
concrete NumeralEus of Numeral = CatEus [Numeral,Digits] ** open Prelude, ResEus, ParamX in {
concrete NumeralEus of Numeral = CatEus [Numeral,Digits,Decimal] ** open Prelude, ResEus, ParamX in {
oper LinDigit : Type = { s : DForm => Str ;
n : Number ;
@@ -112,5 +112,18 @@ lin D_9 = mkDig "9" ;
lin IDig dig = dig ;
-- : Dig -> Digits -> Digits ;
lin IIDig dig digs = digs ** {s = \\co => glue (dig.s ! co) (digs.s ! co) } ;
lin PosDecimal d = d ** {hasDot=False} ;
lin NegDecimal d = {
s = \\co => glue "-" (d.s ! co) ;
n = Pl ;
hasDot=False
} ;
lin IFrac d i = {
s = \\co => d.s ! co ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! co ;
n = Pl ;
hasDot=False
} ;
}

View File

@@ -64,6 +64,7 @@ concrete CatBul of Cat = CommonX - [IAdv,AdV] ** open ResBul, Prelude, Predef, (
Numeral = {s : CardOrd => Str; n : Number} ;
Digits = {s : CardOrd => Str; n : Number; tail : DTail} ;
Decimal = {s : CardOrd => Str; n : Number; hasDot : Bool} ;
-- Structural

View File

@@ -116,10 +116,9 @@ concrete NounBul of Noun = CatBul ** open ResBul, Prelude in {
NumCard n = {s=n.s; nn=n.nn; nonEmpty = True} ;
NumDigits n = {s = \\gspec => n.s ! NCard gspec; nn = case n.n of {Sg => NNum Sg; Pl => NCountable}} ;
NumDecimal n = {s = \\gspec => n.s ! NCard gspec; nn = case n.n of {Sg => NNum Sg; Pl => NCountable}} ;
OrdDigits n = {s = \\aform => n.s ! NOrd aform} ;
NumFloat n1 n2 = {s = \\gspec => n1.s ! NCard (CFMasc Indef NonHuman) ++ BIND ++ "." ++ BIND ++ n2.s ! NCard gspec ; nn = NCountable} ;
NumNumeral numeral = {s = \\gspec => numeral.s ! NCard gspec; nn = case numeral.n of {Sg => NNum Sg; Pl => NCountable}} ;
OrdNumeral numeral = {s = \\aform => numeral.s ! NOrd aform} ;
@@ -247,10 +246,4 @@ concrete NounBul of Noun = CatBul ** open ResBul, Prelude in {
p = NounP3 Pos
} ;
QuantityFloatNP n1 n2 m = {
s = \\role => preOrPost m.isPre m.s (n1.s ! NCard (CFMasc Indef NonHuman) ++ BIND ++ "." ++ BIND ++ n2.s ! NCard (CFMasc Indef NonHuman)) ;
gn = gennum (AMasc NonHuman) Pl ;
p = NounP3 Pos
} ;
}

View File

@@ -1,5 +1,5 @@
--# -coding=utf8
concrete NumeralBul of Numeral = CatBul [Numeral,Digits] ** open Prelude, ResBul in {
concrete NumeralBul of Numeral = CatBul [Numeral,Digits,Decimal] ** open Prelude, ResBul in {
flags coding=utf8 ;
@@ -97,8 +97,11 @@ lin pot3plus n m = {
n = Pl
} ;
lin pot3as4 n = n ;
lin pot3float f = {
s = \\c,nf => f.s ++ mkCardOrd100 "хиляди" "хилядите" "хиляден" ! c ;
lin pot3decimal d = {
s = \\c,nf => case d.n of {
Sg => mkCardOrd100 "хиляда" "хилядата" "хиляден" ! NCard (CFMasc Indef NonHuman) ;
Pl => d.s ! NCard (CFFem Indef) ++ mkCardOrd100 "хиляди" "хилядите" "хиляден" ! c
} ;
n = Pl
} ;
@@ -118,8 +121,17 @@ lin pot4plus n1 n2 = {
n = Pl
} ;
lin pot4as5 n = n ;
lin pot4float f = {
s = \\c,nf => f.s ++ mkCardOrd100 "милиона" "милиона" "милионен" ! c ;
lin pot4decimal d = {
s = \\c,nf => case c of {
NCard (CFMasc s a) => d.s ! NCard (CFMasc s NonHuman) ;
NCard (CFMascDefNom a) => d.s ! NCard (CFMascDefNom NonHuman) ;
NCard cf => d.s ! NCard cf ;
NOrd _ => d.s ! NCard (CFMasc Indef NonHuman)
} ++
case d.n of {
Sg => "милион" ;
Pl => "милиона"
} ;
n = Pl
} ;
@@ -138,8 +150,12 @@ lin pot5plus n1 n2 = {
s = \\o,f => (pot5 n1).s ! o ! f ++ "и" ++ n2.s ! o ! f;
n = Pl
} ;
lin pot5float f = {
s = \\c,nf => f.s ++ mkCardOrd100 "милиярда" "милиярда" "милиярден" ! c ;
lin pot5decimal d = {
s = \\c,nf => d.s ! NCard (CFFem Indef) ++
case d.n of {
Sg => mkCardOrd100 "милиярд" "милиярда" "милиярден" ! c ;
Pl => mkCardOrd100 "милиярди" "милиярдите" "милиярден" ! c
} ;
n = Pl
} ;
@@ -168,6 +184,16 @@ lin pot5float f = {
D_8 = mk3Dig "8" "8на" "8ми" Pl ;
D_9 = mk3Dig "9" "9има" "9ти" Pl ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {s=\\o=>"-" ++ BIND ++ d.s ! o; hasDot=False; n = Pl} ;
IFrac d i = {
s = \\o => d.s ! NCard (CFMasc Indef NonHuman) ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o;
n = Pl ;
hasDot=True
} ;
oper
spaceIf : DTail -> Str = \t -> case t of {
T3 => SOFT_BIND ;

View File

@@ -1,4 +1,4 @@
concrete NumeralCat of Numeral = CatCat [Numeral,Digits] **
concrete NumeralCat of Numeral = CatCat [Numeral,Digits,Decimal] **
open CommonRomance, ResRomance, MorphoCat, Prelude in {
flags coding=utf8 ;
@@ -158,6 +158,20 @@ param
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard Masc ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + ":o") ;

View File

@@ -57,6 +57,7 @@ concrete CatChi of Cat = CommonX - [Tense, Temp, Ant, Adv] ** open ResChi, Prelu
Numeral = {s,p : Str} ;
Card, Digits = {s : Str} ;
Decimal = {s : Str ; hasDot : Bool} ;
-- Structural

View File

@@ -62,6 +62,7 @@ concrete NounChi of Noun = CatChi ** open ResChi, Prelude in {
NumCard n = n ** {numType = NTFull} ;
NumDigits d = d ** {numType = NTFull} ;
NumDecimal d = d ** {numType = NTFull} ;
OrdDigits d = {s = ordinal_s ++ d.s} ;
NumNumeral numeral = {s = numeral.p} ; -- liang instead of yi

View File

@@ -1,4 +1,4 @@
concrete NumeralChi of Numeral = CatChi [Numeral,Digits] ** open ResChi, Prelude in {
concrete NumeralChi of Numeral = CatChi [Numeral,Digits,Decimal] ** open ResChi, Prelude in {
flags coding = utf8 ;
@@ -162,4 +162,16 @@ lin pot4as5 n = n ;
D_8 = ss "8" ;
D_9 = ss "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ BIND ++ d.s ;
hasDot=False
} ;
IFrac d i = {
s=d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s;
hasDot=True
} ;
}

View File

@@ -160,4 +160,16 @@ lin pot3plus n m =
D_8 = ss "8" ;
D_9 = ss "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ BIND ++ d.s ;
hasDot=False
} ;
IFrac d i = {
s=d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s;
hasDot=True
} ;
}

View File

@@ -68,5 +68,6 @@ concrete CatHrv of Cat =
lincat Numeral = {s : AdjForms ; size : NumSize} ;
lincat Digits = {s : Str ; size : NumSize} ;
lincat Decimal = {s : Str ; size : NumSize ; hasDot : Bool} ;
}

View File

@@ -89,6 +89,7 @@ lin
NumCard c = c ;
NumDigits ds = ds ** {s = \\_,_ => ds.s} ;
NumDecimal dec = dec ** {s = \\_,_ => dec.s} ;
NumNumeral nu = {
s = \\g,c => (adjFormsAdjective nu.s).s ! g ! Sg ! c ; ---- TODO Sg?
size = nu.size

View File

@@ -1,6 +1,6 @@
concrete NumeralHrv of Numeral =
CatHrv [Numeral, Digits] **
CatHrv [Numeral, Digits, Decimal] **
open
ResHrv,
@@ -125,6 +125,20 @@ oper mkThousand : Str -> NumSize -> Str = \attr,size ->
IIDig d dd = {s = d.s ++ Predef.BIND ++ dd.s ; size = dd.size} ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ Predef.BIND ++ d.s ;
size = d.size ;
hasDot=False
} ;
IFrac d i = {
s = d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s;
size = d.size ;
hasDot=True
} ;
D_0 = { s = "0" ; size = NS_1} ; ---- ??
D_1 = { s = "1" ; size = NS_1} ;
D_2 = { s = "2" ; size = NS_2_4} ;

View File

@@ -66,6 +66,7 @@ concrete CatCze of Cat =
lincat Numeral = Determiner ; ---- TODO: should contain Ord as well
lincat Digits = {s:Str ; size : NumSize} ;
lincat Decimal = {s:Str ; size : NumSize ; hasDot : Bool} ;
}

View File

@@ -96,6 +96,7 @@ lin
NumCard c = c ;
NumDigits ds = ds ** {s = \\_,_ => ds.s} ;
NumDecimal ds = ds ** {s = \\_,_ => ds.s} ;
NumNumeral nu = nu ;

View File

@@ -1,6 +1,6 @@
concrete NumeralCze of Numeral =
CatCze [Numeral,Digits] **
CatCze [Numeral,Digits,Decimal] **
open
ResCze,
@@ -117,4 +117,18 @@ oper determinerStr : Determiner -> Str = \d -> d.s ! Masc Anim ! Nom ;
D_8 = { s = "8" ; size = Num5} ;
D_9 = { s = "9" ; size = Num5} ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ Predef.BIND ++ d.s ;
size = Num5 ;
hasDot=False
} ;
IFrac d i = {
s = d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ;
size = Num5 ;
hasDot=True
} ;
}

View File

@@ -1,4 +1,4 @@
concrete NumeralDan of Numeral = CatDan [Numeral,Digits] ** open MorphoDan,Prelude in {
concrete NumeralDan of Numeral = CatDan [Numeral,Digits,Decimal] ** open MorphoDan,Prelude in {
flags coding=utf8 ;
@@ -67,6 +67,20 @@ lin n9 = mkTal "ni" "nitten" "halvfems" "niende" "halvfemsindstyvende" ;
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s=\\o=>d.s ! NCard neutrum ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o;
hasDot=True;
n = Pl
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + ":e") ;

View File

@@ -59,6 +59,7 @@ concrete CatDut of Cat =
Numeral = {s : CardOrd => Str ; n : Number } ;
Digits = {s : CardOrd => Str ; n : Number } ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
-- Structural

View File

@@ -85,7 +85,7 @@ concrete NounDut of Noun = CatDut ** open ResDut, Prelude in {
NumDigits numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
OrdDigits numeral = {s = \\af => numeral.s ! NOrd af} ;
NumFloat n1 n2 = {s = \\g,c => n1.s ! NCard Utr Nom ++ BIND ++ "." ++ BIND ++ n2.s ! NCard g c; n = Pl } ;
NumDecimal numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
NumNumeral numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
OrdNumeral numeral = {s = let tiende : AForm => Str = \\af => numeral.s ! NOrd af
@@ -207,10 +207,4 @@ concrete NounDut of Noun = CatDut ** open ResDut, Prelude in {
isPron = False
} ;
QuantityFloatNP n1 n2 m = noMerge ** {
s = \\role => preOrPost m.isPre m.s (n1.s ! NCard Utr Nom ++ BIND ++ "." ++ BIND ++ n2.s ! NCard Utr Nom) ;
a = agrP3 Pl ;
isPron = False
} ;
}

View File

@@ -1,4 +1,4 @@
concrete NumeralDut of Numeral = CatDut [Numeral,Digits] ** open ResDut, Prelude in {
concrete NumeralDut of Numeral = CatDut [Numeral,Digits,Decimal] ** open ResDut, Prelude in {
flags optimize = all_subs ;
coding=utf8 ;
@@ -74,6 +74,20 @@ lin
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! invNum ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + "e") ;

View File

@@ -71,6 +71,20 @@ lin pot3plus n m = { s = table {
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o,g => "-" ++ BIND ++ d.s ! o ! g ;
n = Pl
hasDot=False
} ;
IFrac d i = {
s = \\o,g => d.s ! NCard ! g ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ! g;
n = Pl ;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c ) ;

View File

@@ -81,6 +81,7 @@ concrete CatEng of Cat = CommonX - [Pol,CAdv] ** open ResEng, Prelude in {
Numeral = {s : Bool => CardOrd => Case => Str ; n : Number} ;
Digits = {s : CardOrd => Case => Str ; n : Number ; tail : DTail} ;
Decimal = {s : CardOrd => Case => Str ; n : Number ; hasDot : Bool} ;
-- Structural

View File

@@ -1,6 +1,7 @@
--# -path=.:../abstract:../common
concrete DocumentationEng of Documentation = CatEng ** open
ResEng, Prelude,
ResEng,
Prelude,
HTML in {
lincat

View File

@@ -77,7 +77,7 @@ concrete NounEng of Noun = CatEng ** open MorphoEng, ResEng, Prelude in {
NumDigits n = {s,sp = \\_ => n.s ! NCard ; n = n.n} ;
OrdDigits n = {s = n.s ! NOrd} ;
NumFloat n1 n2 = {s,sp = \\_,c => n1.s ! NCard ! Nom ++ BIND ++ "." ++ BIND ++ n2.s ! NCard ! c ; n = Pl} ;
NumDecimal d = {s,sp = \\_ => d.s ! NCard ; n = d.n} ;
NumNumeral numeral = {s,sp = \\d => numeral.s ! d ! NCard; n = numeral.n} ;
OrdNumeral numeral = {s = numeral.s ! True ! NOrd} ;
@@ -181,9 +181,4 @@ concrete NounEng of Noun = CatEng ** open MorphoEng, ResEng, Prelude in {
a = agrgP3 n.n Neutr
} ;
QuantityFloatNP n1 n2 m = {
s = \\c => preOrPost m.isPre m.s (n1.s ! NCard ! Nom ++ BIND ++ "." ++ BIND ++ n2.s ! NCard ! Nom) ;
a = agrgP3 Pl Neutr
} ;
}

View File

@@ -1,4 +1,4 @@
concrete NumeralEng of Numeral = CatEng [Numeral,Digits] ** open Prelude, ResEng in {
concrete NumeralEng of Numeral = CatEng [Numeral,Digits,Decimal] ** open Prelude, ResEng in {
lincat
Digit = {s : DForm => CardOrd => Case => Str} ;
@@ -57,8 +57,8 @@ lin pot3 n = {
lin pot3plus n m = {
s = \\d,o,c => n.s ! d ! NCard ! Nom ++ "thousand" ++ m.s ! False ! o ! c; n = Pl} ;
lin pot3as4 n = n ;
lin pot3float f = {
s = \\d,o,c => f.s ++ mkCard o "thousand" ! c ; n = Pl} ;
lin pot3decimal f = {
s = \\d,o,c => f.s ! NCard ! Nom ++ mkCard o "thousand" ! c ; n = Pl} ;
lin pot41 = {
s = \\d,o,c => case d of {True => []; False => "a"} ++
@@ -74,8 +74,8 @@ lin pot4plus n1 n2 = {
n = Pl
} ;
lin pot4as5 n = n ;
lin pot4float f = {
s = \\d,o,c => f.s ++ pot41.s ! True ! o ! c ; n = Pl} ;
lin pot4decimal f = {
s = \\d,o,c => f.s ! NCard ! Nom ++ pot41.s ! True ! o ! c ; n = Pl} ;
lin pot51 = {
s = \\d,o,c => case d of {True => []; False => "a"} ++
@@ -90,8 +90,8 @@ lin pot5plus n1 n2 = {
s = \\d,o,c => n1.s ! d ! NCard ! Nom ++ pot51.s ! True ! NCard ! Nom ++ "and" ++ n2.s ! True ! o ! c;
n = Pl
} ;
lin pot5float f = {
s = \\d,o,c => f.s ++ pot51.s ! True ! o ! c ; n = Pl} ;
lin pot5decimal f = {
s = \\d,o,c => f.s ! NCard ! Nom ++ pot51.s ! True ! o ! c ; n = Pl} ;
-- numerals as sequences of digits
@@ -118,6 +118,16 @@ lin pot5float f = {
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
lin PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {s=\\o,c=>"-" ++ BIND ++ d.s ! o ! c; hasDot=False; n = Pl} ;
IFrac d i = {
s=\\o,c=>d.s ! NCard ! Nom ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ! c ;
hasDot=True;
n = Pl
} ;
oper
commaIf : DTail -> Str = \t -> case t of {
T3 => BIND ++ "," ++ BIND ;

View File

@@ -63,6 +63,7 @@ concrete CatEst of Cat = CommonX ** open HjkEst, ResEst, Prelude in {
Numeral = {s : CardOrd => Str ; n : Number} ;
Digits = {s : CardOrd => Str ; n : Number} ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
-- Structural

View File

@@ -120,9 +120,9 @@ concrete NounEst of Noun = CatEst ** open ResEst, HjkEst, MorphoEst, Prelude in
} ;
OrdDigits numeral = {s = \\nc => numeral.s ! NOrd nc} ;
NumFloat n1 n2 = {
s = \\n,c => n1.s ! NCard (NCase Sg Nom) ++ BIND ++ "." ++ BIND ++ n2.s ! NCard (NCase n c) ;
n = Pl
NumDecimal numeral = {
s = \\n,c => numeral.s ! NCard (NCase n c) ;
n = numeral.n
} ;
NumNumeral numeral = {
@@ -225,12 +225,6 @@ concrete NounEst of Noun = CatEst ** open ResEst, HjkEst, MorphoEst, Prelude in
isPron = False
} ;
QuantityFloatNP n1 n2 m = emptyNP ** {
s = \\role => preOrPost m.isPre m.s (n1.s ! NCard (NCase Sg Nom) ++ BIND ++ "." ++ BIND ++ n2.s ! NCard (NCase Sg Nom)) ;
a = agrP3 Pl ;
isPron = False
} ;
oper
numN : NForm -> Number = \nf -> case nf of {
NCase n _ => n

View File

@@ -1,4 +1,4 @@
concrete NumeralEst of Numeral = CatEst [Numeral,Digits] ** open Prelude, ParadigmsEst, MorphoEst in {
concrete NumeralEst of Numeral = CatEst [Numeral,Digits,Decimal] ** open Prelude, ParadigmsEst, MorphoEst in {
-- Notice: possessive forms are not used. They get wrong, since every
-- part is made to agree in them.
@@ -146,6 +146,20 @@ oper
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard (NCase Sg Nom) ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=False
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o MorphoEst.Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + ".") ;

View File

@@ -72,6 +72,7 @@ concrete CatFin of Cat = CommonX ** open ResFin, StemFin, Prelude in {
Numeral = {s : CardOrd => Str ; n : Number} ;
Digits = {s : CardOrd => Str ; n : Number} ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
-- Structural

View File

@@ -143,9 +143,9 @@ concrete NounFin of Noun = CatFin ** open ResFin, MorphoFin, StemFin, Prelude in
} ;
OrdDigits numeral = {s = \\f => numeral.s ! NOrd f} ;
NumFloat n1 n2 = {
s = \\n,c => n1.s ! NCard (NCase Sg Nom) ++ BIND ++ "." ++ BIND ++ n2.s ! NCard (NCase n c) ;
n = Pl
NumDecimal numeral = {
s = \\n,c => numeral.s ! NCard (NCase n c) ;
n = numeral.n
} ;
NumNumeral numeral = {
@@ -303,13 +303,6 @@ concrete NounFin of Noun = CatFin ** open ResFin, MorphoFin, StemFin, Prelude in
isNeg = False
} ;
QuantityFloatNP n1 n2 m = {
s = \\role => preOrPost m.isPre m.s (n1.s ! NCard (NCase Sg Nom) ++ BIND ++ "." ++ BIND ++ n2.s ! NCard (NCase Sg Nom)) ;
a = agrP3 Pl ;
isPron = False ;
isNeg = False
} ;
oper
numN : NForm -> Number = \nf -> case nf of {
NCase n _ => n ;

View File

@@ -1,4 +1,4 @@
concrete NumeralFin of Numeral = CatFin [Numeral,Digits] ** open Prelude, ParadigmsFin, MorphoFin, StemFin in {
concrete NumeralFin of Numeral = CatFin [Numeral,Digits,Decimal] ** open Prelude, ParadigmsFin, MorphoFin, StemFin in {
-- Notice: possessive forms are not used. They get wrong, since every
-- part is made to agree in them.
@@ -73,10 +73,10 @@ lin
s = \\c => d.s ! NumAttr ! c ++ nBIND d.n ++ tuhattaN.s ! d.n ! c ++ e.s ! NumIndep ! c
} ;
pot3as4 n = n ;
pot3float f = {n = Pl ; s = \\c => f.s ++ BIND ++ tuhattaN.s ! Pl ! c} ;
pot3decimal d = {n = Pl ; s = \\c => d.s ! NCard (NCase Sg Nom) ++ BIND ++ tuhattaN.s ! Pl ! c} ;
pot4as5 n = n ;
pot4float f = {n = Pl ; s = \\c => f.s ++ "miljoonaa"} ; -- KA: case inflection missing
pot4decimal d = {n = Pl ; s = \\c => d.s ! NCard (NCase Sg Nom) ++ "miljoonaa"} ; -- KA: case inflection missing
pot51 = {n = Pl ; s = \\c => "miljardi"} ; -- KA: case inflection missing
@@ -180,6 +180,20 @@ oper
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard (NCase Sg Nom) ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=False
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o MorphoFin.Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + ".") ;

View File

@@ -1,4 +1,4 @@
concrete NumeralFre of Numeral = CatFre [Numeral,Digits] **
concrete NumeralFre of Numeral = CatFre [Numeral,Digits,Decimal] **
open CommonRomance, ResRomance, MorphoFre, Prelude in {
flags coding=utf8 ;
@@ -171,6 +171,20 @@ oper hyphen = BIND ++ "-" ++ BIND ;
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard Masc ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + "ème") ;

View File

@@ -88,6 +88,7 @@ concrete CatGer of Cat =
Numeral = {s : CardOrd => Str ; n : Number } ;
Digits = {s : CardOrd => Str ; n : Number } ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
-- Structural

View File

@@ -117,7 +117,7 @@ concrete NounGer of Noun = CatGer ** open ResGer, MorphoGer, Prelude in {
NumDigits numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
OrdDigits numeral = {s = \\af => numeral.s ! NOrd af} ;
NumFloat dig1 dig2 = {s = \\g,c => dig1.s ! invNum ++ BIND ++ "." ++ BIND ++ dig2.s ! NCard g c ; n = Pl } ;
NumDecimal numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
NumNumeral numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
OrdNumeral numeral = {s = \\af => numeral.s ! NOrd af} ;
@@ -262,12 +262,4 @@ concrete NounGer of Noun = CatGer ** open ResGer, MorphoGer, Prelude in {
ext = "" ;
} ;
QuantityFloatNP dig1 dig2 m = {
s = \\_,c => preOrPost m.isPre m.s (dig1.s ! invNum ++ BIND ++ "." ++ BIND ++ dig2.s ! invNum) ;
a = agrP3 Pl ;
w = WLight ;
rc = "" ;
ext = "" ;
} ;
}

View File

@@ -1,4 +1,4 @@
concrete NumeralGer of Numeral = CatGer [Numeral,Digits] ** open MorphoGer, Prelude in {
concrete NumeralGer of Numeral = CatGer [Numeral,Digits,Decimal] ** open MorphoGer, Prelude in {
flags optimize = all_subs ;
coding=utf8 ;
@@ -50,12 +50,12 @@ lin
pot3plus n m = {s = \\g =>
multiple n.s n.n ++ "tausend" ++ m.s ! g ; n = Pl} ;
pot3as4 n = n ;
pot3float f = {s = \\g =>
f.s ++ cardOrd "tausend" "tausendte" ! g ; n = Pl} ; ----
pot3decimal d = {s = \\g =>
d.s ! invNum ++ cardOrd "tausend" "tausendte" ! g ; n = Pl} ; ----
pot4as5 n = n ;
pot4float f = {s = \\g =>
f.s ++ cardOrd "Millionen" "Millionte" ! g ; n = Pl} ; ----
pot4decimal d = {s = \\g =>
d.s ! invNum ++ cardOrd "Millionen" "Millionte" ! g ; n = Pl} ; ----
pot51 = {s = \\g => "einer Milliarde"; n = Pl} ; -- KA: case inflection missing
@@ -88,6 +88,20 @@ oper
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s=\\o=>d.s ! invNum ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o;
n = Pl;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + "e") ;

View File

@@ -69,6 +69,8 @@ concrete CatGre of Cat = CommonGre ** open ResGre, Prelude in {
Digits = {s : CardOrd => Str ; n : Number} ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
-- Structural
Conj = {s1,s2 : Str ; n : Number} ;

View File

@@ -111,6 +111,7 @@ concrete NounGre of Noun = CatGre ** open ResGre, ParadigmsGre, Prelude in {
NumNumeral numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
NumDigits numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
NumDecimal numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
AdNum adn num = {s = \\g,c => adn.s ++ num.s!g!c; n = num.n } ;

View File

@@ -1,4 +1,4 @@
concrete NumeralGre of Numeral = CatGre [Numeral,Digits] ** open ResGre,Prelude in {
concrete NumeralGre of Numeral = CatGre [Numeral,Digits,Decimal] ** open ResGre,Prelude in {
flags coding= utf8 ;
@@ -291,6 +291,20 @@ Xilias : CardOrd -> (CardOrd => Str) -> Number -> Str = \co,d,n ->
D_8 = mk2Dig "8" Pl;
D_9 = mk2Dig "9" Pl ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard Neut Nom ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=False
} ;
oper
mk3Dig : Str -> Number -> TDigit = \c,n -> {

View File

@@ -89,6 +89,20 @@ lin pot1 d = {s = \\nf => d.s ! NInstr ++ "qulillit"} ; ---- inflection of quli
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard neutrum ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + ":e") ;

View File

@@ -34,6 +34,7 @@ concrete CatHeb of Cat = CommonX - [Utt,Tense,Temp] ** open ResHeb, Prelude, Pa
A2 = {s : Str} ;
Conj = {s : Str} ;
Digits = {s : Str} ;
Decimal = {s : Str; hasDot : Bool} ;
IComp = {s : Str} ;
IDet = {s : Str} ;
IP = {s : Str} ;

View File

@@ -2,7 +2,7 @@
-- Modification for Urdu Shafqat Virk
concrete NumeralHin of Numeral = CatHin [Numeral,Digits] ** open ResHin,CommonHindustani,ParamX, Prelude in {
concrete NumeralHin of Numeral = CatHin [Numeral,Digits,Decimal] ** open ResHin,CommonHindustani,ParamX, Prelude in {
flags coding=utf8 ;
param DForm = unit | ten ;
@@ -110,6 +110,7 @@ lin D_8 = { s = "८" ; n = Pl};
lin D_9 = { s = "९" ; n = Pl};
lin IDig d = { s = \\_ => d.s ; n = d.n} ;
lin IIDig d dg = { s = \\df => Prelude.glue (dg.s ! df) d.s ; n = Pl };
lin PosDecimal d = d ** {hasDot=False} ;
oper ekhazar : Str = variants {"हज़ार" ; "एक" ++ "हज़ार"} ;
oper mkhazar : Str -> Size -> Str = \s -> \sz -> table {singl => ekhazar ; _ => s ++ "हज़ार"} ! sz ;

View File

@@ -70,6 +70,7 @@ incomplete concrete CatHindustani of Cat =
Numeral = {s : CardOrd => Str ; n : Number} ;
Digits = {s : CardOrd => Str ; n : Number } ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
---- Structural

View File

@@ -64,6 +64,7 @@ incomplete concrete NounHindustani of Noun =
NumCard n = n ** {hasCard = True} ;
NumDigits n = {s = n.s ! NCard ; n = n.n} ;
NumDecimal n = {s = n.s ! NCard ; n = n.n} ;
OrdDigits n = {s = n.s ! NOrd; n = n.n} ;
NumNumeral numeral = {s = numeral.s ! NCard; n = numeral.n} ;

View File

@@ -79,6 +79,7 @@ concrete CatHun of Cat = CommonX - [Adv] ** open ResHun, Prelude in {
Card = ResHun.Numeral ;
Numeral = ResHun.Numeral ;
Digits = {s : CardOrd => Str} ;
Decimal = {s : CardOrd => Str; hasDot : Bool} ;

View File

@@ -137,6 +137,10 @@ concrete NounHun of Noun = CatHun ** open
s = \\place => dig.s ! NCard ;
} ;
NumDecimal dec = dec ** {
s = \\place => dec.s ! NCard ;
} ;
-- : Numeral -> Card ;
NumNumeral num = num ;

View File

@@ -1,4 +1,4 @@
concrete NumeralHun of Numeral = CatHun [Numeral,Digits] **
concrete NumeralHun of Numeral = CatHun [Numeral,Digits,Decimal] **
open Prelude, ResHun in {
lincat
@@ -115,6 +115,13 @@ oper
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecinal d = {
s = \\x => "-" ++ BIND ++ d.s ! x ;
n = numNumber ;
hasDot=False
} ;
oper
mkDig : Str -> TDigit = \s -> {
s = s ;

View File

@@ -126,6 +126,7 @@ concrete CatIce of Cat = CommonX ** open ResIce, Prelude in {
Numeral = {s : CardOrd => Str ; n : Number} ;
Digits = {s : CardOrd => Str ; n : Number} ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
--2 Structural words

View File

@@ -86,6 +86,10 @@ concrete NounIce of Noun = CatIce ** open MorphoIce, ResIce, Prelude in {
s = \\g,c => d.s ! NCard d.n g c;
n = d.n
} ;
NumDecimal d = {
s = \\g,c => d.s ! NCard d.n g c;
n = d.n
} ;
NumNumeral d = {
s = \\g,c => d.s ! NCard Sg g c;

View File

@@ -1,4 +1,4 @@
concrete NumeralIce of Numeral = CatIce [Numeral,Digits] ** open Prelude, ResIce in {
concrete NumeralIce of Numeral = CatIce [Numeral,Digits,Decimal] ** open Prelude, ResIce in {
param
DForm = unit | teen | ten ;
@@ -203,6 +203,20 @@ concrete NumeralIce of Numeral = CatIce [Numeral,Digits] ** open Prelude, ResIce
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard Sg Masc Nom ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=True
} ;
oper
mkDig : Str -> TDigit = \c -> mk2Dig c (c + ".") ;

View File

@@ -55,6 +55,7 @@ concrete CatIna of Cat = CommonX ** open ResIna, Prelude in {
Numeral = {s : CardOrd => Str ; n : Number} ;
Digits = {s : CardOrd => Str ; n : Number ; tail : DTail} ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
-- Structural

View File

@@ -61,6 +61,7 @@ concrete NounIna of Noun = CatIna ** open ResIna, Prelude in {
NumCard c = c ;
NumDigits n = {s = n.s ! NCard ; n = n.n} ;
NumDecimal n = {s = n.s ! NCard ; n = n.n} ;
OrdDigits n = {s = n.s ! NOrd} ;

View File

@@ -1,4 +1,4 @@
concrete NumeralIna of Numeral = CatIna [Numeral,Digits] ** open ResIna,Prelude in {
concrete NumeralIna of Numeral = CatIna [Numeral,Digits,Decimal] ** open ResIna,Prelude in {
lincat
Digit = {s : DForm => CardOrd => Str} ;
@@ -66,6 +66,20 @@ concrete NumeralIna of Numeral = CatIna [Numeral,Digits] ** open ResIna,Prelude
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o;
n = Pl ;
hasDot=True
} ;
oper
commaIf : DTail -> Str = \t -> case t of {
T3 => BIND++","++BIND ;

View File

@@ -1,4 +1,4 @@
concrete NumeralIta of Numeral = CatIta [Numeral,Digits] **
concrete NumeralIta of Numeral = CatIta [Numeral,Digits,Decimal] **
open CommonRomance, ResRomance, MorphoIta, PhonoIta, Prelude in {
lincat
@@ -138,6 +138,20 @@ param Pred = pred | indip ;
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard Masc ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o;
n = Pl ;
hasDot=True
} ;
oper
mkDig : Str -> TDigit = \c -> mk2Dig c Pl ;

View File

@@ -54,6 +54,7 @@ flags coding = utf8 ;
DAP = Det ;
Numeral = {s : Str ; n : Number ; tenPlus : Bool} ;
Digits = {s : Str ; n : Number ; tenPlus : Bool ; tail : DTail} ;
Decimal = {s : Str ; n : Number ; tenPlus : Bool ; hasDot : Bool} ;
Conj = Conjunction ; -- {s : Str ; null : Str ; type : ConjType} ;
Subj = Subjunction ; -- {s : Str ; type : SubjType} ;
Prep = Preposition ; -- {s : Str ; null : Str} ;

View File

@@ -134,6 +134,7 @@ flags coding = utf8 ;
NumCard card = card ** {inclCard = True} ;
NumDigits num = num ** {postpositive = []} ;
NumDecimal num = num ** {postpositive = []} ;
NumNumeral num = num ** {postpositive = []} ;

View File

@@ -1,4 +1,4 @@
concrete NumeralJpn of Numeral = CatJpn [Numeral,Digits] ** open ResJpn, ParadigmsJpn, Prelude in {
concrete NumeralJpn of Numeral = CatJpn [Numeral,Digits,Decimal] ** open ResJpn, ParadigmsJpn, Prelude in {
flags coding = utf8 ;
@@ -203,6 +203,22 @@ flags coding = utf8 ;
D_8 = {s = "8" ; n = Pl ; is0 = False} ;
D_9 = {s = "9" ; n = Pl ; is0 = False} ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ BIND ++ d.s ;
n = Pl ;
tenPlus = d.tenPlus ;
hasDot=False
} ;
IFrac d i = {
s = d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s;
n = Pl ;
tenPlus = d.tenPlus ;
hasDot=True
} ;
oper
commaIf : DTail -> Str = \t -> case t of {
T3 => "," ;

View File

@@ -69,6 +69,20 @@ lin pot3plus n m = { s = table {
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o,g => "-" ++ BIND ++ d.s ! o ! g ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o,g => d.s ! NCard ! g ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ! g ;
n = Pl ;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c ) ;

View File

@@ -78,8 +78,7 @@ concrete CatKor of Cat = CommonX ** open ResKor, Prelude in {
Card = ResKor.Num ;
Numeral = ResKor.Numeral ;
Digits = {s : CardOrd => Str ; n : Number} ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
--2 Structural words

View File

@@ -107,9 +107,9 @@ concrete NounKor of Noun = CatKor ** open ResKor, Prelude in {
numtype = IsDig
} ;
NumFloat dig1 dig2 = baseNum ** {
s = \\_,_ => dig1.s ! NCard ++ BIND ++ "." ++ BIND ++ dig2.s ! NCard ;
n = Pl ;
NumDecimal dec = baseNum ** {
s = \\_,_ => dec.s ! NCard ;
n = dec.n ;
numtype = IsDig
} ;

View File

@@ -1,4 +1,4 @@
concrete NumeralKor of Numeral = CatKor [Numeral,Digits] **
concrete NumeralKor of Numeral = CatKor [Numeral,Digits,Decimal] **
open Prelude, ResKor in {
lincat
@@ -155,6 +155,16 @@ lin
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {s=\\o=>"-" ++ BIND ++ d.s ! o; hasDot=False; n = Pl} ;
IFrac d i = {
s=\\o=>d.s ! NCard ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
hasDot=True;
n = Pl
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o numNumber ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + "번째") ;

View File

@@ -63,6 +63,7 @@ concrete CatLat of Cat = CommonX-[Adv] ** open ResLat, ParamX, Prelude in {
--
Numeral = ResLat.TNumeral ;
Digits = {s : Str ; unit : Unit} ;
Decimal = {s : Str ; unit : Unit ; hasDot : Bool} ;
--
---- Structural
--

View File

@@ -209,6 +209,8 @@ concrete NumeralLat of Numeral = CatLat, ParamX[Number] ** open ParadigmsLat, Pr
D_8 = mkDig "VIII" "XVIII" "LXXX" "DCCC" "(VIII)" "(LXXX)" "(DCCC)" ;
D_9 = mkDig "IX" "XIX" "XC" "CM" "(IX)" "(XC)" "(CM)" ;
PosDecimal d = d ** {hasDot=False} ;
oper
TDig = {
s : Unit => Str

View File

@@ -78,6 +78,7 @@ lincat
Numeral = {s : CardOrd => Gender => Case => Str ; num : Number} ;
Digits = {s : CardOrd => Str ; num : Number} ;
Decimal = {s : CardOrd => Str ; num : Number ; hasDot : Bool} ;
-- Structural words

View File

@@ -138,6 +138,7 @@ lin
-- Digits -> Card
-- e.g. '51'
NumDigits digits = { s = \\_,_ => digits.s ! NCard ; num = digits.num } ;
NumDecimal dec = { s = \\_,_ => dec.s ! NCard ; num = dec.num } ;
-- Numeral -> Card
-- e.g. 'fifty-one'

View File

@@ -1,6 +1,6 @@
--# -path=.:abstract:common:prelude
concrete NumeralLav of Numeral = CatLav [Numeral,Digits] ** open ResLav, ParadigmsLav, Prelude in {
concrete NumeralLav of Numeral = CatLav [Numeral,Digits,Decimal] ** open ResLav, ParadigmsLav, Prelude in {
flags coding = utf8 ;
@@ -109,6 +109,20 @@ lin
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
num = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! NCard ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o;
num = Pl ;
hasDot=True
} ;
oper
mkDig : Str -> Dig = \c -> mk2Dig c Pl ;

View File

@@ -75,6 +75,7 @@ concrete CatLit of Cat = CommonX - [CAdv, Adv] ** open ResLit, Prelude, (R = Par
numAgr:NumComb; nb:Number };
Ord = { s:AForm => Str };
Digits = { s:Str; o:Str; numAgr:NumComb; nb:Number };
Decimal = { s:Str; o:Str; numAgr:NumComb; nb:Number; hasDot : Bool };
---- Structural

View File

@@ -249,6 +249,7 @@ concrete NounLit of Noun = CatLit ** open ResLit, Prelude, MorphoLit, Predef in
-- NumDigits : Digits -> Card ; -- 51
NumDigits n = { s=\\_,_ => n.s; numAgr=n.numAgr; nb=n.nb };
NumDecimal n = { s=\\_,_ => n.s; numAgr=n.numAgr; nb=n.nb };
-- NumCard : Card -> Num ;
NumCard c = c ** { hasCard = True };

View File

@@ -345,4 +345,21 @@ oper simtas : Case * Number => Str
D_8 = { s = "8"; o="8."; nb=Pl; numAgr=AgrComb };
D_9 = { s = "9"; o="9."; nb=Pl; numAgr=AgrComb };
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ BIND ++ d.s;
o = "-" ++ BIND ++ d.o;
nb=Pl;
numAgr=d.numAgr;
hasDot=False
} ;
IFrac d i = {
s = d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s;
nb = Pl ;
numAgr=d.numAgr;
hasDot=True
} ;
}

View File

@@ -80,6 +80,7 @@ concrete CatMay of Cat = CommonX - [IAdv] ** open ResMay, Prelude in {
Card = ResMay.CardNum ;
Numeral = ResMay.CardOrdNum ;
Digits = ResMay.DigNum ;
Decimal = ResMay.DigNum**{hasDot : Bool} ;

View File

@@ -101,6 +101,10 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
s = dig.s ! NCard
} ;
NumDecimal dec = {
s = dec.s ! NCard
} ;
-- : Numeral -> Card ;
NumNumeral num = num ;

View File

@@ -1,6 +1,6 @@
-- David Wahlstedt 2002 (cardinal numbers)
-- Inari Listenmaa 2020 (ordinals + cosmetic changes)
concrete NumeralMay of Numeral = CatMay [Numeral,Digits] **
concrete NumeralMay of Numeral = CatMay [Numeral,Digits,Decimal] **
open Prelude, ResMay in {
lincat
@@ -151,6 +151,16 @@ oper
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {s=\\o=>"-" ++ BIND ++ d.s ! o; hasDot=False} ;
IFrac d i = {
s=\\o=>d.s ! NCard ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
hasDot=True;
n = Pl
} ;
oper
mkDig : Str -> DigNum = \s -> {
s = table {

View File

@@ -98,6 +98,11 @@ concrete CatMlt of Cat = CommonX - [Adv] ** open ResMlt, Prelude in {
n : NumForm ;
tail : DTail ;
} ;
Decimal = {
s : NumCase => Str ; -- No need for CardOrd, i.e. no 1st, 2nd etc in Maltese
n : NumForm ;
hasDot : Bool ;
} ;
-- Structural

View File

@@ -189,9 +189,7 @@ concrete NounMlt of Noun = CatMlt ** open ResMlt, Prelude, Maybe in {
-- 51
NumDigits d = {s = d.s ; n = d.n} ;
-- Digits -> Digits -> Card
-- 3.14
NumFloat d1 d2 = {s = \\c => d1.s ! NumNom ++ BIND ++ "." ++ BIND ++ d2.s ! c ; n = d1.n} ;
NumDecimal d = {s = d.s ; n = d.n} ;
-- Digits -> Ord
-- 51st

View File

@@ -4,7 +4,7 @@
-- John J. Camilleri 2011 -- 2013
-- Licensed under LGPL
concrete NumeralMlt of Numeral = CatMlt [Numeral,Digits] ** open Prelude,ResMlt in {
concrete NumeralMlt of Numeral = CatMlt [Numeral,Digits,Decimal] ** open Prelude,ResMlt in {
flags coding=utf8 ;
@@ -437,4 +437,18 @@ concrete NumeralMlt of Numeral = CatMlt [Numeral,Digits] ** open Prelude,ResMlt
tail = inc i.tail
} ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = d.n ;
hasDot=False
} ;
IFrac d i = {
s=\\o=>d.s ! NumNom ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o;
n = d.n;
hasDot=True
} ;
}

View File

@@ -85,6 +85,7 @@ lincat
Card = {s : Str ; sp : RCase => Str ; n : Number} ;
Numeral = {s : CardOrd => Str; n : Number} ;
Digits = {s : CardOrd => Str ; n : Number} ;
Decimal = {s : CardOrd => Str ; n : Number; hasDot : Bool} ;
-- Structural

View File

@@ -109,7 +109,7 @@ lin
NumCard n = n ** {isNum = True} ;
NumDigits,NumNumeral = \numeral -> {
NumDigits,NumNumeral,NumDecimal = \numeral -> {
s = numeral.s ! NCard ;
sp = \\_ => numeral.s ! NCard ;
n = numeral.n

View File

@@ -1,6 +1,6 @@
--# -path=.:../abstract:../common:../prelude
concrete NumeralMon of Numeral = CatMon [Numeral,Digits] ** open ResMon, MorphoMon, Prelude in {
concrete NumeralMon of Numeral = CatMon [Numeral,Digits,Decimal] ** open ResMon, MorphoMon, Prelude in {
flags coding=utf8 ;
@@ -158,6 +158,20 @@ lin
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\co => "-" ++ BIND ++ d.s ! co ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\co => d.s ! NCard ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! co;
n = Pl ;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + "-р") ;

View File

@@ -68,6 +68,7 @@ concrete CatNep of Cat = CommonX - [Adv] ** open ResNep, Prelude in {
Numeral = {s : CardOrd => Str ; n : Number} ;
Digits = {s : CardOrd => Str ; n : Number } ;
Decimal = {s : CardOrd => Str ; n : Number; hasDot : Bool} ;
---- Structural

View File

@@ -72,6 +72,7 @@ concrete NounNep of Noun = CatNep ** open ResNep, Prelude in {
PossPron p = {s = \\_,_ => p.ps } ;
NumDigits n = {s = n.s ! NCard ; n = n.n} ;
NumDecimal n = {s = n.s ! NCard ; n = n.n} ;
OrdDigits n = {s = n.s ! NOrd ; n = n.n} ;
NumNumeral numeral = {s = numeral.s ! NCard; n = numeral.n} ;

View File

@@ -1,4 +1,4 @@
concrete NumeralNep of Numeral = CatNep [Numeral,Digits] ** open ResNep, Prelude in {
concrete NumeralNep of Numeral = CatNep [Numeral,Digits,Decimal] ** open ResNep, Prelude in {
-- By Harald Hammarstroem
-- Modification for Nepali by Dinesh Simkhada and Shafqat Virk - 2011
flags coding=utf8 ;
@@ -114,6 +114,16 @@ lin IDig d = { s = \\_ => d.s ; n = d.n} ;
lin IIDig d dg = { s = \\df => Prelude.glue d.s (dg.s ! df) ; n = Pl };
lin PosDecimal d = d ** {hasDot=False} ;
lin NegDecimal d = { s = \\df => Prelude.glue "-" (d.s ! df) ; n = Pl ; hasDot=False } ;
IFrac d i = {
s=\\df=>d.s ! df ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ;
hasDot=True;
n = Pl
} ;
oper ekhazar : Str = variants {"एक" ++ "हजार" ; "हजार"} ;
oper mkhazar : Str -> Size -> Str = \s -> \sz -> table {singl => ekhazar ; _ => s ++ "हजार"} ! sz ;
oper mksau : Str -> DSize -> Str = \s -> \sz -> table {sg => "एक" ++ "सय" ; _ => s ++ "सय"} ! sz ;

View File

@@ -114,6 +114,8 @@ lin IDig d = { s = \\_ => d.s ; n = d.n} ;
lin IIDig d dg = { s = \\df => Prelude.glue d.s (dg.s ! df) ; n = Pl };
lin PosDecimal d = d ** {hasDot=False} ;
oper ekhazar : Str = variants {"e:k" ++ "hjar" ; "hjar"} ;
oper mkhazar : Str -> Size -> Str = \s -> \sz -> table {singl => ekhazar ; _ => s ++ "hjar"} ! sz ;
oper mksau : Str -> DSize -> Str = \s -> \sz -> table {sg => "e:k" ++ "sy" ; _ => s ++ "sy"} ! sz ;

Some files were not shown because too many files have changed in this diff Show More