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

@@ -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 + ".") ;