summaryrefslogtreecommitdiff
path: root/examples/numerals/interlingua.gf
blob: acd431688bed136ecdb9d4fd6ee1ee62ff8d7f1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
include numerals.Abs.gf ;

param DForm = unit | ten  ;

lincat Numeral	  = { s : Str } ;
lincat Digit	  = { s : DForm => Str } ;
lincat Sub10	  = { s : DForm => Str } ;
lincat Sub100	  = { s : Str } ;
lincat Sub1000	  = { s : Str } ;
lincat Sub1000000 = { s : Str } ;

oper mkNum : Str -> Str -> Lin Digit = 
  \duo-> \vinti-> 
  {s = table {unit => duo ; ten => vinti}} ;

oper regNum : Str -> Lin Digit = 
  \cinque -> 
       case cinque of {
	 nov   + "em"=> mkNum cinque (nov   + "anta");
	 cinqu + "e" => mkNum cinque (cinqu + "anta");
	 cinqu + "o" => mkNum cinque (cinqu + "anta");
	 sex         => mkNum sex    (sex   + "anta")
       };

oper ss : Str -> {s : Str} = \s -> {s = s} ;

lin num x = x ;
lin n2 = mkNum  "duo"    "vinti";
lin n3 = mkNum  "tres"   "trenta";
lin n4 = mkNum  "quatro" "quaranta";
lin n5 = regNum "cinque";
lin n6 = regNum "sex"   ;
lin n7 = regNum "septe" ;
lin n8 = regNum "octo"  ;
lin n9 = regNum "novem"  ;

lin pot01 = {s = table {f => "un"}} ;
lin pot0 d = {s = table {f => d.s ! f}} ;
lin pot110 = ss "dece" ;
lin pot111 = ss ("dece" ++ "-" ++ "un");
lin pot1to19 d = {s = "dece" ++ "-" ++ d.s ! unit} ;
lin pot0as1 n = {s = n.s ! unit} ;

lin pot1 d       = {s = d.s ! ten} ;
lin pot1plus d e = {s = d.s ! ten ++ "-" ++ e.s ! unit} ;

lin pot1as2 n = n ;

lin pot2     d   = {s = d.s ! unit ++ "cento"} ;
lin pot2plus d e = {s = d.s ! unit ++ "cento" ++ e.s} ;

lin pot2as3 n = n ;

lin pot3     n   = {s = n.s ++ "mille"} ;
lin pot3plus n m = {s = n.s ++ "mille" ++ m.s} ;