thai phrasebook example started

This commit is contained in:
aarne
2007-01-09 14:53:19 +00:00
parent 312e477169
commit 61e932e797
5 changed files with 273 additions and 1 deletions

54
examples/travel/Travel.gf Normal file
View File

@@ -0,0 +1,54 @@
abstract Travel = {
flags startcat=Phrase ;
cat
Phrase ;
Greeting ;
Order ;
Question ;
Sentence ;
Object ;
Kind ;
Quality ;
Number ;
Speaker ;
Hearer ;
Gender ;
Quantity ;
fun
PGreeting : Greeting -> Speaker -> Hearer -> Phrase ;
POrder : Order -> Speaker -> Hearer -> Phrase ;
PQuestion : Question -> Speaker -> Hearer -> Phrase ;
PSentence : Sentence -> Speaker -> Hearer -> Phrase ;
MkSpeaker : Gender -> Quantity -> Speaker ;
MkHearer : Gender -> Quantity -> Hearer ;
Male, Female : Gender ;
Single, Many : Quantity ;
Hello : Greeting ;
Thanks : Greeting ;
IWant : Object -> Order ;
DoYouHave : Kind -> Question ;
IsIt : Object -> Quality -> Sentence ;
ItIs : Object -> Quality -> Sentence ;
Indef : Kind -> Object ;
This : Kind -> Object ;
NumberObjects : Number -> Kind -> Object ;
One, Two, Five, Ten : Number ;
Mango : Kind ;
Green : Quality ;
}

View File

@@ -0,0 +1,73 @@
--# -path=.:prelude
concrete TravelTha of Travel = open Prelude in {
flags coding=utf8 ;
-- this file is processed by
-- GF.Text.Thai.thaiFile "../examples/travel/TravelTha.gf"
(Just "../examples/travel/TravelThai.gf")
-- GF.Text.Thai.thaiPronFile "../examples/travel/TravelTha.gf"
(Just "../examples/travel/TravelThaiPron.gf")
-- to produce target Thai script and pronunciation files.
lincat
Phrase,
Greeting,
Order,
Question,
Sentence,
Object = SS ;
Kind = {s,c : Str} ; -- c is classifier
Quality,
Number,
Speaker,
Hearer,
Gender,
Quantity = SS ;
lin
PGreeting g s h = ss (g.s ++ s.s ++ h.s) ;
POrder g s h = ss (g.s ++ s.s ++ h.s) ;
PQuestion g s h = ss (g.s ++ s.s ++ h.s) ;
PSentence g s h = ss (g.s ++ s.s ++ h.s) ;
MkSpeaker = cc2 ;
MkHearer _ _ = ss [] ;
Male = ss "k2rab" ;
Female = ss "k2T1a" ;
Single, Many = ss [] ;
Hello = ss ["swa.s di:"] ;
Thanks = ss ["k1Ob k2un'"] ;
IWant = prefixSS "eOa:" ;
DoYouHave = postfixSS ["mi: a&hm"] ;
IsIt x q = ss (x.s ++ q.s ++ "a&hm") ;
ItIs = cc2 ;
Indef k = ss (k.s ++ k.c ++ "nvT1g") ;
This k = ss (k.s ++ k.c ++ "ni:T2") ;
NumberObjects n k = ss (k.s ++ n.s ++ k.c) ;
One = ss "nvT1g" ;
Two = ss "sOg" ;
Five = ss "ha:" ;
Ten = ss "sib" ;
Mango = cls ["ma mT1wg"] "lu:k" ;
Green = ss ["si: ek1i:yw"] ;
oper
cls : Str -> Str -> {s,c : Str} = \s,c -> {s = s ; c = c} ;
}

View File

@@ -0,0 +1,71 @@
--# -path=.:prelude
concrete TravelThai of Travel = open Prelude in {
flags coding=utf8 ;
-- this file is processed by
-- GF.Text.Thai.thaiFile "À€À€เÀ€à¸°à¸¡à¸à¸¥à¹€À€à¸•ระึเÀ€À€ระึเลÀ€à¸«à¸±à¸‡à¸<C3A0>" (Just TGT)
-- GF.Text.Thai.thaiPronFile "À€À€เÀ€à¸°à¸¡à¸à¸¥à¹€À€à¸•ระึเÀ€À€ระึเลÀ€à¸«à¸±à¸‡à¸<C3A0>" (Just TGT)
-- to produce target Thai script and pronunciation files.
lincat
Phrase,
Greeting,
Order,
Question,
Sentence,
Object = SS ;
Kind = {s,c : Str} ; -- c is classifier
Quality,
Number,
Speaker,
Hearer,
Gender,
Quantity = SS ;
lin
PGreeting g s h = ss (g.s ++ s.s ++ h.s) ;
POrder g s h = ss (g.s ++ s.s ++ h.s) ;
PQuestion g s h = ss (g.s ++ s.s ++ h.s) ;
PSentence g s h = ss (g.s ++ s.s ++ h.s) ;
MkSpeaker = cc2 ;
MkHearer _ _ = ss [] ;
Male = ss "คระบ" ;
Female = ss "ค่ะ" ;
Single, Many = ss [] ;
Hello = ss ["สวัสดี"] ;
Thanks = ss ["ขอบคุณ"] ;
IWant = prefixSS "เอา" ;
DoYouHave = postfixSS ["มีไหม"] ;
IsIt x q = ss (x.s ++ q.s ++ "ไหม") ;
ItIs = cc2 ;
Indef k = ss (k.s ++ k.c ++ "นึ่ง") ;
This k = ss (k.s ++ k.c ++ "นี้") ;
NumberObjects n k = ss (k.s ++ n.s ++ k.c) ;
One = ss "นึ่ง" ;
Two = ss "สอง" ;
Five = ss "หา" ;
Ten = ss "สิบ" ;
Mango = cls ["มะม่วง"] "ลูà¸<C3A0>" ;
Green = ss ["สีเขียว"] ;
oper
cls : Str -> Str -> {s,c : Str} = \s,c -> {s = s ; c = c} ;
}

View File

@@ -0,0 +1,71 @@
--# -path=.:prelude
concrete TravelThaiPron of Travel = open Prelude in {
flags coding=utf8 ;
-- this file is processed by
-- GF.Text.Thai.thaiFile "m^eaeaveaveapltrrlhg-" (Just TGT)
-- GF.Text.Thai.thaiPronFile "m^eaeaveaveapltrrlhg-" (Just TGT)
-- to produce target Thai script and pronunciation files.
lincat
Phrase,
Greeting,
Order,
Question,
Sentence,
Object = SS ;
Kind = {s,c : Str} ; -- c is classifier
Quality,
Number,
Speaker,
Hearer,
Gender,
Quantity = SS ;
lin
PGreeting g s h = ss (g.s ++ s.s ++ h.s) ;
POrder g s h = ss (g.s ++ s.s ++ h.s) ;
PQuestion g s h = ss (g.s ++ s.s ++ h.s) ;
PSentence g s h = ss (g.s ++ s.s ++ h.s) ;
MkSpeaker = cc2 ;
MkHearer _ _ = ss [] ;
Male = ss "khr'ap" ;
Female = ss "kh^a" ;
Single, Many = ss [] ;
Hello = ss ["s`awt d-ii"] ;
Thanks = ss ["kh`Op kh-un"] ;
IWant = prefixSS "O-eaa" ;
DoYouHave = postfixSS ["m-ii m~ay"] ;
IsIt x q = ss (x.s ++ q.s ++ "m~ay") ;
ItIs = cc2 ;
Indef k = ss (k.s ++ k.c ++ "n^vg") ;
This k = ss (k.s ++ k.c ++ "n~ii") ;
NumberObjects n k = ss (k.s ++ n.s ++ k.c) ;
One = ss "n^vg" ;
Two = ss "s~Og" ;
Five = ss "h~aa" ;
Ten = ss "s`ip" ;
Mango = cls ["m'a m^owg"] "l^uuk" ;
Green = ss ["s~ii kh`eiiyw"] ;
oper
cls : Str -> Str -> {s,c : Str} = \s,c -> {s = s ; c = c} ;
}

View File

@@ -121,6 +121,7 @@ pronSyllable s =
vowel = case (initv s, midv s, finalv s, shorten s, tone s) of
([0x0e40],[0x0e30,0x0e2d],_,_,_) -> "ö" -- eOa
([0x0e40],[0x0e30,0x0e32],_,_,_) -> "o" -- ea:a
([],[],[],_,_) -> "o"
(i,m,f,_,_) -> concatMap pronThaiChar (reverse $ f ++ m ++ i) ----
initCons = concatMap pronThaiChar $ case (reverse $ initc s) of
@@ -179,12 +180,14 @@ getSyllable = foldl get (Syll [] [] [] [] [] [] False False) where
| isVowel c -> if null (initc syll)
then syll {initv = c : initv syll}
else syll {midv = c : midv syll}
| isCons c -> if null (midv syll)
| isCons c -> if null (initc syll) ||
(null (midv syll) && isCluster (initc syll) c)
then syll {initc = c : initc syll}
else syll {finalc = c : finalc syll}
| isTone c -> syll {tone = [c]}
_ -> syll ---- check this
isCluster s c = length s == 1 && (c == 0x0e23 || s == [0x0e2b])
-- to test