Skip to content

Commit

Permalink
Merge pull request #445 from hleiss/ordinals
Browse files Browse the repository at this point in the history
(Ger) ordinal endings of Digits fixed
  • Loading branch information
inariksit authored Nov 29, 2023
2 parents 64ef1d9 + 88be4ca commit 074f065
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/german/CatGer.gf
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ concrete CatGer of Cat =
-- Numeral

Numeral = {s : CardOrd => Str ; n : Number } ;
Digits = {s : CardOrd => Str ; n : Number } ;
Digits = {s : CardOrd => Str ; n : Number ; isDig, tail1to19 : Bool} ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;

-- Structural
Expand Down
68 changes: 45 additions & 23 deletions src/german/NumeralGer.gf
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ lincat
lin
num x = x ;

n2 = mkDigit "zwei" "zwölf" "zwanzig" "zweite" ;
n2 = mkDigit "zwei" "zwölf" "zwanzig" "zweite" ;
n3 = mkDigit "drei" "dreizehn" "dreissig" "dritte" ;
n4 = regDigit "vier" ;
n5 = regDigit "fünf" ;
n6 = regDigit "sechs" ;
n7 = mkDigit "sieben" "siebzehn" "siebzig" "siebte" ;
n8 = mkDigit "acht" "achzehn" "achzig" "achte" ;
n9 = regDigit "neun" ;
n4 = regDigit "vier" ;
n5 = regDigit "fünf" ;
n6 = mkDigit "sechs" "sechzehn" "sechzig" "sechste" ;
n7 = mkDigit "sieben" "siebzehn" "siebzig" "siebte" ;
n8 = mkDigit "acht" "achtzehn" "achtzig" "achte" ;
n9 = regDigit "neun" ;

pot01 = {
s = \\f => table {
Expand Down Expand Up @@ -69,17 +69,33 @@ oper
Dig = TDigit ;

lin
IDig d = d ;

IIDig d i = {
s = \\o => d.s ! invNum ++ BIND ++ i.s ! o ;
n = Pl
} ;
IDig d = {s = table{NCard g c => d.s ! NCard g c ;
NOrd APred => "am" ++ d.s ! invNum ++ BIND ++ "ten";
NOrd amod => d.s ! NOrd amod} ;
n = d.n ;
isDig = True ;
tail1to19 = notB d.isZero} ;

-- HL 11/2023 added case endings or ordinals to digits
-- NCard Masc Nom (= invNum): 0,1, 19, 20,21,...
-- NOrd (AMid (GSg Masc) Nom): 0ter,1ter,...,19ter, 20ster,21ster,...,99ster, 100ster
-- 101ter,...,119ter,120ster,... , 200ster
IIDig d i =
let isPld : Bool = case d.n of {Sg => False ; _ => True} ;
b : Bool = case i.isDig of {True => isPld ; _ => notB i.tail1to19} ;
i' : Digits = case b of {True => IDig (mkDig (i.s ! invNum ++ BIND ++ "s")) ;
_ => i }
in {s = table {NCard g c => d.s ! invNum ++ BIND ++ i.s ! NCard g c ;
NOrd APred => "am" ++ d.s ! invNum ++ BIND ++ i'.s ! invNum ++ BIND ++ "ten" ;
NOrd af => d.s ! invNum ++ BIND ++ i'.s ! NOrd af} ;
n = Pl ;
isDig = False ;
tail1to19 = case i.isDig of {True => notB isPld ; False => i.tail1to19}
} ;

---- TODO: case endings of ordinals
D_0 = mkDig "0" ;
D_1 = mk3Dig "1" "1e" Sg ;
D_2 = mk2Dig "2" "2e" ;
D_0 = mk2Dig "0" Sg ** {isZero = True} ;
D_1 = mk2Dig "1" Sg ;
D_2 = mkDig "2" ;
D_3 = mkDig "3" ;
D_4 = mkDig "4" ;
D_5 = mkDig "5" ;
Expand All @@ -90,7 +106,9 @@ oper

PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
s = \\o => case o of {
NOrd APred => "am" ++ "-" ++ BIND ++ d.s ! NOrd (AMod GPl Dat) ;
_ => "-" ++ BIND ++ d.s ! o} ;
n = Pl ;
hasDot=False
} ;
Expand All @@ -103,17 +121,21 @@ oper
} ;

oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + "e") ;
mkDig : Str -> TDigit = \c -> mk2Dig c Pl ;

mk2Dig : Str -> Number -> TDigit = \c,n -> mk3Dig c (c + "t") n ; -- like Duden 464 (4.Auflage)

mk3Dig : Str -> Str -> Number -> TDigit = \c,o,n -> {
s = table {NCard _ _ => c ; NOrd _ => o} ;
n = n
s = table {NCard _ _ => c ; -- 0,...,9
NOrd af => (regA o).s ! Posit ! af} ; -- (ein) 0ter .. 9ter | (der) 0te ... 9te
n = n ; -- NOrd APred: "0",... or "am 0ten",... ?
isZero = False
} ;

TDigit = {
n : Number ;
s : CardOrd => Str
s : CardOrd => Str ;
isZero : Bool
} ;

}

0 comments on commit 074f065

Please sign in to comment.