summaryrefslogtreecommitdiff
path: root/examples/numerals
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2006-12-28 13:16:05 +0000
committeraarne <aarne@cs.chalmers.se>2006-12-28 13:16:05 +0000
commitcef20174f620357c932b59d544034e3c38054295 (patch)
tree542c2122fd3981013bc5f7bb4b3e9da0da41cb7f /examples/numerals
parentf74d2e3928b683d25da19d0bb868ef97c6466295 (diff)
more thai transliteration; numeral thai grammars
Diffstat (limited to 'examples/numerals')
-rw-r--r--examples/numerals/mkThai.gfs5
-rw-r--r--examples/numerals/thai.gf67
-rw-r--r--examples/numerals/thaiDU.gf48
-rw-r--r--examples/numerals/thaiP.gf69
-rw-r--r--examples/numerals/thaiU.gf68
5 files changed, 257 insertions, 0 deletions
diff --git a/examples/numerals/mkThai.gfs b/examples/numerals/mkThai.gfs
new file mode 100644
index 000000000..8f29d4e24
--- /dev/null
+++ b/examples/numerals/mkThai.gfs
@@ -0,0 +1,5 @@
+i -old -optimize=none -abs=Numerals -cnc=decimal decimal.gf
+i -old -optimize=none -abs=Numerals -cnc=thai_decimal thaiDU.gf
+i -old -optimize=none -abs=Numerals -cnc=thai thaiU.gf
+i -old -optimize=none -abs=Numerals -cnc=thai_pronounce thaiP.gf
+sf -unlexer=unwords
diff --git a/examples/numerals/thai.gf b/examples/numerals/thai.gf
new file mode 100644
index 000000000..da6648a42
--- /dev/null
+++ b/examples/numerals/thai.gf
@@ -0,0 +1,67 @@
+include numerals.Abs.gf ;
+
+-- Thai transliteration, produces thaiU.gf by GF/Text/Thai.hs
+-- AR 28/12/2006
+
+lincat
+ Numeral = {s : Str} ;
+ Digit = {s : DForm => Str} ;
+ Sub10 = {s : DForm => Str} ;
+ Sub100 = {s : NForm => Str} ;
+ Sub1000 = {s : NForm => Str} ;
+ Sub1000000 = {s : Str} ;
+
+lin
+ num x = x ;
+
+ pot01 = mkNum "hnvg" "hnvg" "eOMd'" ;
+
+ n2 = mkNum "s-Og" "y'i:E" "s-Og" ;
+ n3 = regNum "s-a:m" ;
+ n4 = regNum "s-i:E" ;
+ n5 = regNum "ha:E" ;
+ n6 = regNum "ho?k" ;
+ n7 = regNum "ecMd'" ;
+ n8 = regNum "e:pd'" ;
+ n9 = regNum "eka:" ;
+
+
+ pot0 d = d ;
+
+ pot110 = {s = sip} ;
+ pot111 = {s = table {
+ Unit => ["s'ib et"] ;
+ Thousand => ["hnvg hmv:En hnvg p2an"]
+ }
+ } ;
+ pot1to19 d = {s = table {
+ Unit => "s'ib" ++ d.s ! After ;
+ Thousand => ["hnvg hmv:En"] ++ d.s ! Indep ++ "p2an"
+ }
+ } ;
+ pot0as1 d = {s = \\n => d.s ! Indep ++ phan ! n} ;
+ pot1 d = {s = \\n => d.s ! ModTen ++ sip ! n} ;
+ pot1plus d e = {
+ s = \\n => d.s ! ModTen ++ sip ! n ++ e.s ! After ++ phan ! n
+ } ;
+ pot1as2 n = n ;
+ pot2 d = {s = \\n => d.s ! Indep ++ roy ! n} ;
+ pot2plus d e = {s = \\n => d.s ! Indep ++ roy ! n ++ e.s ! n} ;
+ pot2as3 n = {s = n.s ! Unit} ;
+ pot3 n = {s = n.s ! Thousand} ;
+ pot3plus n m = {s = n.s ! Thousand ++ m.s ! Unit} ;
+
+param
+ DForm = Indep | ModTen | After ;
+ NForm = Unit | Thousand ;
+
+oper
+ mkNum : Str -> Str -> Str -> {s : DForm => Str} = \x,y,z ->
+ {s = table {Indep => x ; ModTen => y ; After => z}} ;
+ regNum : Str -> {s : DForm => Str} = \x ->
+ mkNum x x x ;
+
+
+ sip = table {Unit => "s'ib" ; Thousand => "hmv:En"} ;
+ roy = table {Unit => "rEOy'" ; Thousand => "se:n"} ;
+ phan = table {Unit => [] ; Thousand => "p2an"} ;
diff --git a/examples/numerals/thaiDU.gf b/examples/numerals/thaiDU.gf
new file mode 100644
index 000000000..1cbf81fbc
--- /dev/null
+++ b/examples/numerals/thaiDU.gf
@@ -0,0 +1,48 @@
+include numerals.Abs.gf ;
+
+-- Thai digits. AR 28/12/2006
+
+flags lexer=chars ; unlexer=concat ; flags coding=utf8 ;
+
+param Zeros = noz | zz ;
+
+lincat Numeral = { s : Str } ;
+lincat Digit = { s : Str } ;
+lincat Sub10 = { s : Str } ;
+lincat Sub100 = {s : Zeros => Str} ;
+lincat Sub1000 = {s : Zeros => Str} ;
+lincat Sub1000000 = {s : Zeros => Str} ;
+
+oper ss : Str -> {s : Str} = \s -> {s = s} ;
+oper mkz : Str -> {s : Zeros => Str} = \s -> {s = table {_ => s}} ;
+
+lin num n = {s = n.s ! noz} ;
+lin n2 = ss "๒" ;
+lin n3 = ss "๓" ;
+lin n4 = ss "๔" ;
+lin n5 = ss "๕" ;
+lin n6 = ss "๖" ;
+lin n7 = ss "๗" ;
+lin n8 = ss "๘" ;
+lin n9 = ss "๙" ;
+
+lin pot01 = ss "๑" ;
+lin pot0 d = d ;
+
+lin pot110 = mkz ("๑" ++ "๐") ;
+lin pot111 = mkz ("๑" ++ "๑") ;
+lin pot1to19 d = mkz ("๑" ++ d.s) ;
+
+lin pot0as1 n = {s = table {noz => n.s ; zz => "๐" ++ n.s}} ;
+
+lin pot1 d = mkz (d.s ++ "๐") ;
+lin pot1plus d e = mkz (d.s ++ e.s) ;
+
+lin pot1as2 n = {s = table {noz => n.s ! noz ; zz => "๐" ++ n.s ! zz}} ;
+lin pot2 d = mkz (d.s ++ "๐" ++ "๐") ;
+lin pot2plus d e = mkz (d.s ++ e.s ! zz) ;
+
+lin pot2as3 n = {s = table {noz => n.s ! noz ; zz => "๐" ++ n.s ! zz}} ;
+
+lin pot3 n = mkz (n.s ! noz ++ "๐" ++ "๐" ++ "๐") ;
+lin pot3plus n m = {s = table {z => n.s ! z ++ m.s ! zz}} ;
diff --git a/examples/numerals/thaiP.gf b/examples/numerals/thaiP.gf
new file mode 100644
index 000000000..c35b2dfbf
--- /dev/null
+++ b/examples/numerals/thaiP.gf
@@ -0,0 +1,69 @@
+include numerals.Abs.gf ;
+
+-- Thai pronunciation (mostly following Smyth's Essential Grammar)
+-- AR 28/12/2006
+
+flags coding=utf8 ;
+
+lincat
+ Numeral = {s : Str} ;
+ Digit = {s : DForm => Str} ;
+ Sub10 = {s : DForm => Str} ;
+ Sub100 = {s : NForm => Str} ;
+ Sub1000 = {s : NForm => Str} ;
+ Sub1000000 = {s : Str} ;
+
+lin
+ num x = x ;
+
+ pot01 = mkNum "nỳng" "nỳng" "èt" ;
+
+ n2 = mkNum "söong" "yîi" "söong" ;
+ n3 = regNum "säam" ;
+ n4 = regNum "sìi" ;
+ n5 = regNum "hâa" ;
+ n6 = regNum "hòk" ;
+ n7 = regNum "cèt" ;
+ n8 = regNum "pèet" ;
+ n9 = regNum "kâaw" ;
+
+
+ pot0 d = d ;
+
+ pot110 = {s = sip} ;
+ pot111 = {s = table {
+ Unit => ["sìp èt"] ;
+ Thousand => ["nỳng mỳyn nỳng phan"]
+ }
+ } ;
+ pot1to19 d = {s = table {
+ Unit => "sìp" ++ d.s ! After ;
+ Thousand => ["nỳng mỳyn"] ++ d.s ! Indep ++ "phan"
+ }
+ } ;
+ pot0as1 d = {s = \\n => d.s ! Indep ++ phan ! n} ;
+ pot1 d = {s = \\n => d.s ! ModTen ++ sip ! n} ;
+ pot1plus d e = {
+ s = \\n => d.s ! ModTen ++ sip ! n ++ e.s ! After ++ phan ! n
+ } ;
+ pot1as2 n = n ;
+ pot2 d = {s = \\n => d.s ! Indep ++ roy ! n} ;
+ pot2plus d e = {s = \\n => d.s ! Indep ++ roy ! n ++ e.s ! n} ;
+ pot2as3 n = {s = n.s ! Unit} ;
+ pot3 n = {s = n.s ! Thousand} ;
+ pot3plus n m = {s = n.s ! Thousand ++ m.s ! Unit} ;
+
+param
+ DForm = Indep | ModTen | After ;
+ NForm = Unit | Thousand ;
+
+oper
+ mkNum : Str -> Str -> Str -> {s : DForm => Str} = \x,y,z ->
+ {s = table {Indep => x ; ModTen => y ; After => z}} ;
+ regNum : Str -> {s : DForm => Str} = \x ->
+ mkNum x x x ;
+
+
+ sip = table {Unit => "sìp" ; Thousand => "mỳyn"} ;
+ roy = table {Unit => "róoy" ; Thousand => "sëen"} ;
+ phan = table {Unit => [] ; Thousand => "phan"} ;
diff --git a/examples/numerals/thaiU.gf b/examples/numerals/thaiU.gf
new file mode 100644
index 000000000..61777416d
--- /dev/null
+++ b/examples/numerals/thaiU.gf
@@ -0,0 +1,68 @@
+include numerals.Abs.gf ;
+
+-- Thai UTF8, produced from thai.gf by GF/Text/Thai.hs. AR 28/12/2006
+
+flags coding=utf8 ;
+
+lincat
+ Numeral = {s : Str} ;
+ Digit = {s : DForm => Str} ;
+ Sub10 = {s : DForm => Str} ;
+ Sub100 = {s : NForm => Str} ;
+ Sub1000 = {s : NForm => Str} ;
+ Sub1000000 = {s : Str} ;
+
+lin
+ num x = x ;
+
+ pot01 = mkNum "หนึง" "หนึง" "เอ็ด" ;
+
+ n2 = mkNum "สอง" "ยี่" "สอง" ;
+ n3 = regNum "สาม" ;
+ n4 = regNum "สี่" ;
+ n5 = regNum "หา่" ;
+ n6 = regNum "หก" ;
+ n7 = regNum "เจ็ด" ;
+ n8 = regNum "แปด" ;
+ n9 = regNum "เกา" ;
+
+
+ pot0 d = d ;
+
+ pot110 = {s = sip} ;
+ pot111 = {s = table {
+ Unit => ["ศิบเฏ"] ;
+ Thousand => ["หนึงหมื่นหนึงพะน"]
+ }
+ } ;
+ pot1to19 d = {s = table {
+ Unit => "ศิบ" ++ d.s ! After ;
+ Thousand => ["หนึงหมื่น"] ++ d.s ! Indep ++ "พะน"
+ }
+ } ;
+ pot0as1 d = {s = \\n => d.s ! Indep ++ phan ! n} ;
+ pot1 d = {s = \\n => d.s ! ModTen ++ sip ! n} ;
+ pot1plus d e = {
+ s = \\n => d.s ! ModTen ++ sip ! n ++ e.s ! After ++ phan ! n
+ } ;
+ pot1as2 n = n ;
+ pot2 d = {s = \\n => d.s ! Indep ++ roy ! n} ;
+ pot2plus d e = {s = \\n => d.s ! Indep ++ roy ! n ++ e.s ! n} ;
+ pot2as3 n = {s = n.s ! Unit} ;
+ pot3 n = {s = n.s ! Thousand} ;
+ pot3plus n m = {s = n.s ! Thousand ++ m.s ! Unit} ;
+
+param
+ DForm = Indep | ModTen | After ;
+ NForm = Unit | Thousand ;
+
+oper
+ mkNum : Str -> Str -> Str -> {s : DForm => Str} = \x,y,z ->
+ {s = table {Indep => x ; ModTen => y ; After => z}} ;
+ regNum : Str -> {s : DForm => Str} = \x ->
+ mkNum x x x ;
+
+
+ sip = table {Unit => "ศิบ" ; Thousand => "หมื่น"} ;
+ roy = table {Unit => "ร่อย" ; Thousand => "ซแน"} ;
+ phan = table {Unit => [] ; Thousand => "พะน"} ;