1
0
forked from GitHub/gf-core

refactored Thai pronunciation; not perfect yet

This commit is contained in:
aarne
2011-11-10 16:15:09 +00:00
parent bbe42d1e90
commit 845bf3f8b3
2 changed files with 154 additions and 76 deletions

View File

@@ -1,6 +1,7 @@
module ThaiScript where
import Data.Char
import Data.List
import qualified Data.Map as Map
test = do
@@ -53,27 +54,27 @@ thai2uni = map fromEnum
uni2thai :: [Int] -> String
uni2thai = map toEnum
{-
uni2pron :: [Int] -> String
uni2pron is = case is of
0xe40:c:0xe32 :cs -> pron c ++ tone c cs "aw" ++ uni2pron cs
0xe40:c:0xe34 :cs -> pron c ++ tone c cs "\601\601" ++ uni2pron cs
0xe40:c:0xe35:0xe22:cs -> pron c ++ tone c cs "iia" ++ uni2pron cs
0xe40:c:0xe37:0xe2d:cs -> pron c ++ tone c cs "\649\649" ++ uni2pron cs
0xe40:c:0xe47 :cs -> pron c ++ tone c cs "e" ++ uni2pron cs
0xe41:c:0xe47 :cs -> pron c ++ tone c cs "\x25b" ++ uni2pron cs
v:0xe2b:c:cs | isConsonant c && bvow v
v:0xe2b:c:cs | bvow v && isConsonant c
-> pron c ++ tone 0xe2b cs (pron v) ++ uni2pron cs -- h-
v:b:c:cs | clust b c && bvow v -- kr- etc
-> pron b ++ pron c ++ tone c cs (pron v) ++ uni2pron cs
-> pron b ++ pron c ++ tone b (c:cs) (pron v) ++ uni2pron cs
v:c:cs | bvow v -> pron c ++ tone c cs (pron v) ++ uni2pron cs -- e .. ay
c:0xe31:0xe27:cs -> pron c ++ tone c cs "uua" ++ uni2pron cs
c:0xe31:0xe27:cs -> pron c ++ tone c cs "ua" ++ uni2pron cs
0xe2b:c:v:cs | isConsonant c && cvow v
-> pron c ++ tone 0xe2b cs (pron v) ++ uni2pron cs -- h-
b:c:v:cs | clust b c && cvow v -- kr- etc
-> pron b ++ pron c ++ tone c cs (pron v) ++ uni2pron cs
-> pron b ++ pron c ++ tone b (c:cs) (pron v) ++ uni2pron cs
0xe2d:v:cs | cvow v -> tone 0xe2d cs (pron v) ++ uni2pron cs -- O-
c:v:cs | cvow v -> pron c ++ tone c cs (pron v) ++ uni2pron cs -- a .. u:
@@ -85,10 +86,82 @@ uni2pron is = case is of
pron c = lookThai [] pronunc c
cvow v = (0xe30 <= v && v <= 0xe39) || v == 0xe2d -- central vowels
bvow v = 0xe40 <= v && v <= 0xe44 -- begin vowels
clust b c = isConsonant b && (elem c [0xe23, 0xe25])
tone :: Int -> [Int] -> String -> String
tone c cs v = case (lookThai Low cclass c, isLive cs, toneMark (c:cs)) of
clust b c = isConsonant b && (elem c [0xe23, 0xe25, 0xe27])
-}
uni2pron :: [Int] -> String
uni2pron is = case getSyllable is of
-- diph order as in Smyth, p. 15
[0xe40] : cc : [] : d : cs | kill d -> prons cc ++ tone cc d cs "e" ++ endWith cs -- e-8 -> e
[0xe41] : cc : [] : d : cs | kill d -> prons cc ++ tone cc d cs "\x25b" ++ endWith cs -- ä-8 -> ä
[v] : cc : [] : d : cs -> prons cc ++ tone cc d cs (pron v) ++ endWith cs -- e/ä/o/ay/ay
[0xe40] : cc : [0xe22] : d : cs -> prons cc ++ tone cc d cs "\601\601y" ++ endWith cs -- e-y -> ööy
[0xe40] : cc : [0xe2d] : d : cs -> prons cc ++ tone cc d cs "\601\601" ++ endWith cs -- e-O -> öö
[0xe40] : cc : [0xe2d,0xe30] : d : cs -> prons cc ++ tone cc d cs "\601" ++ endWith cs -- e-Oa -> ö
[0xe40] : cc : [0xe30] : d : cs -> prons cc ++ tone cc d cs "e" ++ endWith cs -- e-a
[0xe40] : cc : [0xe32] : d : cs -> prons cc ++ tone cc d cs "aw" ++ endWith cs -- e-a
[0xe40] : cc : [0xe32,0xe30] : d : cs -> prons cc ++ tone cc d cs "\596" ++ endWith cs -- e-Aa -> O
[0xe40] : cc : [0xe34] : d : cs -> prons cc ++ tone cc d cs "\601\601" ++ endWith cs -- e-i -> öö
[0xe40] : cc : [0xe35,0xe22] : d : cs -> prons cc ++ tone cc d cs "ia" ++ endWith cs -- e-iiy-> ia
[0xe40] : cc : [0xe34,0xe22,0xe30] : d : cs -> prons cc ++ tone cc d cs "ia" ++ endWith cs -- e-iya-> ia
[0xe40] : cc : [0xe35,0xe2d] : d : cs -> prons cc ++ tone cc d cs "\x289a" ++ endWith cs -- e-iiO-> üa
--[0xe40] : cc : [0xe37,0xe2d] : d : cs -> prons cc ++ tone cc d cs "\649\649" ++ endWith cs
[0xe41] : cc : [0xe30] : d : cs -> prons cc ++ tone cc d cs "\x25b" ++ endWith cs -- ä-a -> ä
[0xe42] : cc : [0xe30] : d : cs -> prons cc ++ tone cc d cs "o" ++ endWith cs -- o-a -> o
[] : [0xe2d] : v : d : cs -> tone [0xe2d] d cs (prons v) ++ endWith cs -- Ov -> v
[] : cc : [0xe31,0xe27] : d : cs -> prons cc ++ tone cc d cs "ua" ++ endWith cs -- Caw -> Cua
[] : bb : [] : cc : [] : d : cs -> prons bb ++ "a" ++ prons cc ++ tone cc [] cs "o" ++ endWith cs -- CaCoC
[] : bb : [] : cc : [] -> prons bb ++ "o" ++ endWith [cc] -- CoC
[] : cc : v : d : cs -> prons cc ++ tone cc d cs (prons v) ++ endWith cs -- Cv- (normal)
_ -> prons is --- shouldn't happen
where
prons cc = case cc of
c:0xe4c:cs -> prons cs
0xe2b:c:cs | isConsonant c -> concatMap pron (c:cs) ---- only some conss
_ -> concatMap pron cc
endWith ss = case ss of
(c:cs) -> encs c ++ uni2pron (concat cs)
_ -> []
encs cs = case cs of
[] -> []
_ -> prons (init cs) ++ enc (last cs)
enc c = lookThai [] pronunc_end c
pron c = lookThai [] pronunc c
kill d = elem 0xe47 d
getSyllable :: [Int] -> [[Int]] -- (V?),(C|CC|hC),(V*),(D*),(C*),[[],C]?
getSyllable s = case s of
v:cs | preVowel v -> [v]:getCons v cs
[] -> []
c:_ -> []:getCons c s
where
getCons v s = case s of
b:c:cs | b == 0xe2b && isConsonant c -> [b,c]:getVow v cs -- hC
b:cs | b == 0xe2d -> [b] :getVow v cs -- O
b:c:cs | isConsonant b && (elem c [0xe23, 0xe25, 0xe27]) -> [b,c]:getVow v cs -- C(l|r|w) cluster
b:c:d:[] | isConsonant b && isConsonant c && isConsonant d -> [b] :[]:[c]:[]:[d]:[] -- CaCoC
b:c:[] | isConsonant b && isConsonant c -> [b] :[]:[c]:[] -- CoC
b:cs | isConsonant b -> [b] :getVow v cs -- C
_ -> [s] --- shouldn't happen ??
getVow v0 s = case span (\x -> inVow v0 x || diacritic x) s of
(v,c:cs) -> let (d,w) = partition diacritic v in w:d:[c]:getSyllable cs
(v,_) -> let (d,w) = partition diacritic v in [w,d]
inVow v0 x = inVowel x || case v0 of
0xe40 -> elem x [0xe22] -- after e-, also y is a part of a vowel
_ -> False
inVowel v = (0xe30 <= v && v <= 0xe39) || v == 0xe2d -- infix vowels
preVowel v = 0xe40 <= v && v <= 0xe44 -- prefix vowels
diacritic x = 0xe47 <= x && x <= 0xe4d -- tones, killers
tone :: [Int] -> [Int] -> [[Int]] -> String -> String
tone cc@(c:_) d cs v = case (lookThai Low cclass c, isLive cs1, toneMark d) of
(_,_,3) -> high v
(_,_,4) -> rising v
(Low,_,1) -> falling v
@@ -103,6 +176,8 @@ tone c cs v = case (lookThai Low cclass c, isLive cs, toneMark (c:cs)) of
(Mid,False,_) -> low v
(High,True,_) -> rising v
(High,False,_) -> low v
where
cs1 = concat (take 1 cs)
toneMark :: [Int] -> Int
toneMark is = case is of
@@ -115,6 +190,9 @@ toneMark is = case is of
isLong :: String -> Bool
isLong s = case s of
'i':'a':_ -> True
'u':'a':_ -> True
'\x289':a:_ -> True
c:d:_ | c == d -> True --- must be vowels
_:cs -> isLong cs
_ -> False
@@ -215,18 +293,18 @@ allThaiChars = [
TC {unicode = 3626, translit = "s", cclass = High, liveness = False, pronunc = "s", pronunc_end = "t"},
TC {unicode = 3627, translit = "h", cclass = High, liveness = True, pronunc = "h", pronunc_end = ""},
TC {unicode = 3628, translit = "l'", cclass = Low, liveness = True, pronunc = "l", pronunc_end = "n"},
TC {unicode = 3629, translit = "O", cclass = Mid, liveness = True, pronunc = "\596", pronunc_end = "\596"},
TC {unicode = 3629, translit = "O", cclass = Mid, liveness = True, pronunc = "\596\596", pronunc_end = "\596\596"},
TC {unicode = 3630, translit = "h'", cclass = Low, liveness = True, pronunc = "h", pronunc_end = ""},
TC {unicode = 3632, translit = "a.", cclass = Low, liveness = True, pronunc = "a", pronunc_end = "a"},
TC {unicode = 3633, translit = "a", cclass = Low, liveness = True, pronunc = "a", pronunc_end = "a"},
TC {unicode = 3632, translit = "a.", cclass = Low, liveness = False, pronunc = "a", pronunc_end = "a"},
TC {unicode = 3633, translit = "a", cclass = Low, liveness = False, pronunc = "a", pronunc_end = "a"},
TC {unicode = 3634, translit = "a:", cclass = Low, liveness = True, pronunc = "aa", pronunc_end = "aa"},
TC {unicode = 3635, translit = "a+", cclass = Low, liveness = True, pronunc = "am", pronunc_end = "am"},
TC {unicode = 3636, translit = "i", cclass = Low, liveness = True, pronunc = "i", pronunc_end = "i"},
TC {unicode = 3636, translit = "i", cclass = Low, liveness = False, pronunc = "i", pronunc_end = "i"},
TC {unicode = 3637, translit = "i:", cclass = Low, liveness = True, pronunc = "ii", pronunc_end = "ii"},
TC {unicode = 3638, translit = "v", cclass = Low, liveness = True, pronunc = "\x289", pronunc_end = "\x289"},
TC {unicode = 3638, translit = "v", cclass = Low, liveness = False, pronunc = "\x289", pronunc_end = "\x289"},
TC {unicode = 3639, translit = "v:", cclass = Low, liveness = True, pronunc = "\x289\x289", pronunc_end = "\x289\x289"},
TC {unicode = 3640, translit = "u", cclass = Low, liveness = True, pronunc = "u", pronunc_end = "u"},
TC {unicode = 3640, translit = "u", cclass = Low, liveness = False, pronunc = "u", pronunc_end = "u"},
TC {unicode = 3641, translit = "u:", cclass = Low, liveness = True, pronunc = "uu", pronunc_end = "uu"},
TC {unicode = 3648, translit = "e", cclass = Low, liveness = True, pronunc = "ee", pronunc_end = "ee"},
TC {unicode = 3649, translit = "e'", cclass = Low, liveness = True, pronunc = "\x25b\x25b", pronunc_end = "0x25b\x25b"},

View File

@@ -1,7 +1,7 @@
-- http://en.wiktionary.org/wiki/Appendix:Thai_Swadesh_list, 7/11/2011
1 I ฉัน, กู chǎn, kuu
2 you (singular) เธอ, มึง thəə, mʉŋ
1 I ฉัน , กู chǎn , kuu
2 you (singular) เธอ , มึง thəə , mʉŋ
3 he เขา kháo
4 we เรา rao
5 you (plural) พวกคุณ phûakkhun
@@ -26,45 +26,45 @@
24 three สาม sǎam
25 four สี่ sìi
26 five ห้า hâa
27 big ใหญ่, โต yày, too
27 big ใหญ่ , โต yày , too
28 long ยาว yaaw
29 wide กว้าง kwâaŋ
30 thick หนา nǎa
31 heavy หนัก nàk
32 small เล็ก, น้อย lék, nɔ́ɔy
33 short สั้น, เตี้ย sân, tîa
32 small เล็ก , น้อย lék , nɔ́ɔy
33 short สั้น , เตี้ย sân , tîa
34 narrow แคบ khâeaep
35 thin บาง baaŋ
36 woman หญิง yǐŋ
37 man (adult male) ชาย chaay
38 man (human being) ผู้, คน phûu, khon
39 child เด็ก, ศิศุ dèk, sìsù
40 wife เมีย, ภรรยา mia, phanrayaa
41 husband ผัว, สามี phǔa, sǎamii
38 man (human being) ผู้ , คน phûu , khon
39 child เด็ก , ศิศุ dèk , sìsù
40 wife เมีย , ภรรยา mia , phanrayaa
41 husband ผัว , สามี phǔa , sǎamii
42 mother แม่ mâeae
43 father พ่อ, บิดา phɔ̂ɔ, bìdaa
43 father พ่อ , บิดา phɔ̂ɔ , bìdaa
44 animal สัตว์ sàt
45 fish ปลา plaa
46 bird นก; วิหค (Sanskrit) nók, wíhòk
47 dog หมา; สุนัข (Sanskrit) mǎa, sùnák
48 louse เล็น, เหา len, hǎo
46 bird นก; วิหค (Sanskrit) nók , wíhòk
47 dog หมา; สุนัข (Sanskrit) mǎa , sùnák
48 louse เล็น , เหา len , hǎo
49 snake งู ŋuu
50 worm หนอน nɔ̌ɔn
51 tree ไม้ máay
52 forest ดง, ป่า doŋ, pàa
52 forest ดง , ป่า doŋ , pàa
53 stick กิ่ง kìŋ
54 fruit หมาก màak
55 seed เม็ด mét
56 leaf ใบ bay
57 root ราก râak
58 bark (of a tree) เปลือก, ผิว plʉ̀ak, phǐw
59 flower ดอก, ปลี dɔ̀ɔk, plii
58 bark (of a tree) เปลือก , ผิว plʉ̀ak , phǐw
59 flower ดอก , ปลี dɔ̀ɔk , plii
60 grass หญ้า yâa
61 rope เชือก chʉ̂ak
62 skin หนัง nǎŋ
63 meat เนื้อ nʉ́a
64 blood เลือด, โลหิต lʉ̂at, loohìt
65 bone กระดูก, ก้าง kradùuk, kâaŋ
64 blood เลือด , โลหิต lʉ̂at , loohìt
65 bone กระดูก , ก้าง kradùuk , kâaŋ
66 fat (noun) มัน man
67 egg ไข่ khày
68 horn เขา khǎo
@@ -79,14 +79,14 @@
77 tooth ฟัน fan
78 tongue (organ) ลิ้น lín
79 fingernail เล็บ lép
80 foot เท้า, ตีน tháaw, tiin
80 foot เท้า , ตีน tháaw , tiin
81 leg ขา khǎa
82 knee เข่า khào
83 hand มือ mʉʉ
84 wing ปิก pìik
85 belly พุง phuŋ
86 guts ไส้ sây
87 neck คอ, ศอ khɔɔ, sɔ̌ɔ
87 neck คอ , ศอ khɔɔ , sɔ̌ɔ
88 back หลัง lǎŋ
89 breast นม nom
90 heart ใจ cay
@@ -95,27 +95,27 @@
93 to eat กิน kin
94 to bite กัด kàt
95 to suck ดูด dùut
96 to spit ถ่ม, คาย thòm, khaay
97 to vomit อ้วก, อาเจียน ?ûak, ?aacian
96 to spit ถ่ม , คาย thòm , khaay
97 to vomit อ้วก , อาเจียน ?ûak , ?aacian
98 to blow พัด phát
99 to breathe หายใจ hǎaycay
100 to laugh หัวเราะ hǔarɔ́
101 to see เห็น hěn
102 to hear ยิน, ฟัง yin, faŋ
102 to hear ยิน , ฟัง yin , faŋ
103 to know รู้ rúu
104 to think คิด khít, ?àan
104 to think คิด khít , ?àan
105 to smell มีกลิ่น miiklìn
106 fear กลัว, ยั่น klua, yân
106 fear กลัว , ยั่น klua , yân
107 to sleep นอน nɔɔn
108 to live อยู่, อาศัย yùu, ?aasǎi
109 to die ตาย, วาย taay, waay
110 to kill ฆ่า, มล้าง khâa, maláaŋ
111 to fight สู้, รบ sûu, róp
108 to live อยู่ , อาศัย yùu , ?aasǎi
109 to die ตาย , วาย taay , waay
110 to kill ฆ่า , มล้าง khâa , maláaŋ
111 to fight สู้ , รบ sûu , róp
112 to hunt ล่า lâa
113 to hit ตี tii
114 to cut ตัด, บาด tàt, bàat
114 to cut ตัด , บาด tàt , bàat
115 to split ผ่า phàa
116 to stab แทง, เสียบ thaeaeŋ, sìap
116 to stab แทง , เสียบ thaeaeŋ , sìap
117 to scratch เกา kao
118 to dig ขุด khùt
119 to swim ว่าย wâay
@@ -126,51 +126,51 @@
124 to sit นั่ง nâŋ
125 to stand ยืน yʉʉn
126 to turn (intransitive) หัน hǎn
127 to fall ตก, หล่น tòk, lòn
127 to fall ตก , หล่น tòk , lòn
128 to give ให้ hây
129 to hold อุ้ม ?ûm
130 to squeeze คั้น khán
131 to rub ถู, นวด thǔu, nûat
131 to rub ถู , นวด thǔu , nûat
132 to wash ล้าง láaŋ
133 to wipe เช็ด chét
134 to pull ดึง, ลาก dʉŋ, lâak
134 to pull ดึง , ลาก dʉŋ , lâak
135 to push ผลัก phlàk
136 to throw ขว้าง, ปา khwâaŋ, paa
137 to tie ผูก, ล่าม phùuk, lâam
136 to throw ขว้าง , ปา khwâaŋ , paa
137 to tie ผูก , ล่าม phùuk , lâam
138 to sew เย็บ yép
139 to count นับ náp
140 to say พูด, บอก phûut, bɔ̀ɔk
141 to sing ร้อง rɔ́ɔŋ, khàp
140 to say พูด , บอก phûut , bɔ̀ɔk
141 to sing ร้อง rɔ́ɔŋ , khàp
142 to play เล่น lên
143 to float ลอย lɔɔy
144 to flow ไหล lǎy
145 to freeze แข็ง khǎeŋ
146 to swell ตุ่ม tùm
147 sun ตะวัน; พระอาทิตย์ (Sanskrit) tawan, phrá?aathít
148 moon เดือน; พระจันทร์ (Sanskrit) dʉan, phrácan
149 star ดาว; ดารา (Sanskrit) daaw, daaraa
150 water น้ำ; ชล (Sanskrit) náam, chon
147 sun ตะวัน; พระอาทิตย์ (Sanskrit) tawan , phrá?aathít
148 moon เดือน; พระจันทร์ (Sanskrit) dʉan , phrácan
149 star ดาว; ดารา (Sanskrit) daaw , daaraa
150 water น้ำ; ชล (Sanskrit) náam , chon
151 rain ฝน fǒn
152 river แม่น้ำ, นที (Sanskrit) mâenáam, náthii
152 river แม่น้ำ , นที (Sanskrit) mâenáam , náthii
153 lake ทะเลสาบ thaleesàap
154 sea ทะเล; มหาสมุทร (Sanskrit) thalee, mahǎasamùt
154 sea ทะเล; มหาสมุทร (Sanskrit) thalee , mahǎasamùt
155 salt เกลือ klʉa
156 stone หิน hǐn
157 sand ทราย saay
158 dust ฝุ่น; ธุลี (Sanskrit) fùn, thúlii
158 dust ฝุ่น; ธุลี (Sanskrit) fùn , thúlii
159 earth ดิน din
160 cloud เมฆ mêek
161 fog หมอก mɔ̀ɔk
162 sky ฟ้า, นภา fáa, napā
162 sky ฟ้า , นภา fáa , napā
163 wind ลม lom
164 snow หิมะ himá
165 ice น้ำแข็ง náamkhǎeŋ
166 smoke ควัน khwan
167 fire ไฟ, อัคนี fay, akkhanii
167 fire ไฟ , อัคนี fay , akkhanii
168 ash เถ้า thâo
169 to burn เผา phǎo
170 road ทาง, หน thaaŋ, hǒn
171 mountain เขา, ภู, ดอย, คิริ phuu, khǎo, dɔɔy, khìrì
170 road ทาง , หน thaaŋ , hǒn
171 mountain เขา , ภู , ดอย , คิริ phuu , khǎo , dɔɔy , khìrì
172 red แดง daeaeŋ
173 green เขียว khǐaw
174 yellow เหลือง lʉ̌aŋ
@@ -178,32 +178,32 @@
176 black ดำ dam
177 night กลางคืน klaaŋkhʉʉn
178 day กลางวัน klaaŋwan
179 year ปี,ขวบ pii, khùap
180 warm ร้อน, อุ่น rɔ́ɔn, ?ùn
181 cold หนาว, เซ็ง nǎaw, sen
179 year ปี ,ขวบ pii , khùap
180 warm ร้อน , อุ่น rɔ́ɔn , ?ùn
181 cold หนาว , เซ็ง nǎaw , sen
182 full เต็ม tem
183 new ใหม่ mày
184 old แก่, เฒ่า kàeae, thâo
184 old แก่ , เฒ่า kàeae , thâo
185 good ดี dii
186 bad เลว, ร้้าย leew, ráay
186 bad เลว , ร้้าย leew , ráay
187 rotten เน่า nâo
188 dirty สกปรก sòkkapròk
189 straight ดิ่ง, ตรง dìŋ, troŋ
190 round กลม, มน klom, mon
189 straight ดิ่ง , ตรง dìŋ , troŋ
190 round กลม , มน klom , mon
191 sharp (as a knife) คม khom
192 dull (as a knife) ทื่อ thʉ̂ʉ
193 smooth ละมุน lamun
194 wet เปียก pìak
195 dry แห้ง hâeaeŋ
196 correct แท้, แม่น tháeae, mâeaen
196 correct แท้ , แม่น tháeae , mâeaen
197 near ใกล้ klây
198 far ไกล klay
199 right ขวา khwǎa
200 left ซ้าย sáay
201 at ที่ thîi
202 in ใน nay
203 with กับ, ด้วย kàp, dûay
203 with กับ , ด้วย kàp , dûay
204 and และ láe
205 if ถ้า, เผื่อ thâa, phʉ̀a
206 because เพราะ, ด้วย phrɔ́, dûay
207 name ชื่อ, เรียก chʉ̂ʉ, rîak
205 if ถ้า , เผื่อ thâa , phʉ̀a
206 because เพราะ , ด้วย phrɔ́ , dûay
207 name ชื่อ , เรียก chʉ̂ʉ , rîak