Mercurial > emacs
annotate lisp/language/lao-util.el @ 28095:087d75357c03
*** empty log message ***
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sun, 12 Mar 2000 12:36:51 +0000 |
parents | e0a13ff5901d |
children | bdf7581eb093 |
rev | line source |
---|---|
17315
a3ca5e15c82a
Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents:
17083
diff
changeset
|
1 ;;; lao-util.el --- utilities for Lao |
17083 | 2 |
3 ;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN. | |
18377
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
18309
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
17083 | 5 |
6 ;; Keywords: multilingual, Lao | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Code: | |
26 | |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
27 ;;;###autoload |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
28 (defun setup-lao-environment () |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
29 "Setup multilingual environment (MULE) for Lao." |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
30 (interactive) |
22987
708271862495
(setup-XXX-environment): Just call set-language-environment. If
Kenichi Handa <handa@m17n.org>
parents:
20737
diff
changeset
|
31 (set-language-environment "Lao")) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
32 |
26894 | 33 ;; Setting information of Thai characters. |
34 | |
35 (defconst lao-category-table (make-category-table)) | |
36 (define-category ?c "Lao consonant" lao-category-table) | |
37 (define-category ?s "Lao semi-vowel" lao-category-table) | |
38 (define-category ?v "Lao upper/lower vowel" lao-category-table) | |
39 (define-category ?t "Lao tone" lao-category-table) | |
40 | |
17083 | 41 (let ((l '((?(1!(B consonant "LETTER KOR KAI'" "CHICKEN") |
42 (?(1"(B consonant "LETTER KHOR KHAI'" "EGG") | |
43 (?(1#(B invalid nil) | |
44 (?(1$(B consonant "LETTER QHOR QHWARGN" "BUFFALO") | |
45 (?(1%(B invalid nil) | |
46 (? invalid nil) | |
47 (?(1'(B consonant "LETTER NGOR NGUU" "SNAKE") | |
48 (?(1((B consonant "LETTER JOR JUA" "BUDDHIST NOVICE") | |
49 (?(1)(B invalid nil) | |
50 (?(1*(B consonant "LETTER XOR X\"ARNG" "ELEPHANT") | |
51 (?(1+(B invalid nil) | |
52 (?(1,(B invalid nil) | |
53 (?(1-(B consonant "LETTER YOR YUNG" "MOSQUITO") | |
54 (?(1.(B invalid nil) | |
55 (?(1.(B invalid nil) | |
56 (?(1.(B invalid nil) | |
57 (?(1.(B invalid nil) | |
58 (?(1.(B invalid nil) | |
59 (?(1.(B invalid nil) | |
60 (?(14(B consonant "LETTER DOR DANG" "NOSE") | |
61 (?(15(B consonant "LETTER TOR TAR" "EYE") | |
19271
0caaca9020bc
Set t for Rao-SEMIVOWEL-SIGN-LO in
Kenichi Handa <handa@m17n.org>
parents:
18550
diff
changeset
|
62 (?(16(B consonant "LETTER THOR THUNG" "TO ASK,QUESTION") |
0caaca9020bc
Set t for Rao-SEMIVOWEL-SIGN-LO in
Kenichi Handa <handa@m17n.org>
parents:
18550
diff
changeset
|
63 (?(17(B consonant "LETTER DHOR DHARM" "FLAG") |
17083 | 64 (?(18(B invalid nil) |
65 (?(19(B consonant "LETTER NOR NOK" "BIRD") | |
66 (?(1:(B consonant "LETTER BOR BED" "FISHHOOK") | |
67 (?(1;(B consonant "LETTER POR PAR" "FISH") | |
68 (?(1<(B consonant "LETTER HPOR HPER\"" "BEE") | |
69 (?(1=(B consonant "LETTER FHOR FHAR" "WALL") | |
70 (?(1>(B consonant "LETTER PHOR PHUU" "MOUNTAIN") | |
71 (?(1?(B consonant "LETTER FOR FAI" "FIRE") | |
72 (?(1@(B invalid nil) | |
73 (?(1A(B consonant "LETTER MOR MAR\"" "HORSE") | |
74 (?(1B(B consonant "LETTER GNOR GNAR" "MEDICINE") | |
75 (?(1C(B consonant "LETTER ROR ROD" "CAR") | |
76 (?(1D(B invalid nil) | |
77 (?(1E(B consonant "LETTER LOR LIING" "MONKEY") | |
78 (?(1F(B invalid nil) | |
79 (?(1G(B consonant "LETTER WOR WII" "HAND FAN") | |
80 (?(1H(B invalid nil) | |
81 (?(1I(B invalid nil) | |
82 (?(1J(B consonant "LETTER SOR SEA" "TIGER") | |
83 (?(1K(B consonant "LETTER HHOR HHAI" "JAR") | |
84 (?(1L(B invalid nil) | |
85 (?(1M(B consonant "LETTER OR OOW" "TAKE") | |
86 (?(1N(B consonant "LETTER HOR HEA" "BOAT") | |
87 (?(1O(B special "ELLIPSIS") | |
88 (?(1P(B vowel-base "VOWEL SIGN SARA A") | |
89 (?(1Q(B vowel-upper "VOWEL SIGN MAI KAN") | |
90 (?(1R(B vowel-base "VOWEL SIGN SARA AR") | |
91 (?(1S(B vowel-base "VOWEL SIGN SARA AM") | |
92 (?(1T(B vowel-upper "VOWEL SIGN SARA I") | |
93 (?(1U(B vowel-upper "VOWEL SIGN SARA II") | |
94 (?(1V(B vowel-upper "VOWEL SIGN SARA EU") | |
95 (?(1W(B vowel-upper "VOWEL SIGN SARA UR") | |
96 (?(1X(B vowel-lower "VOWEL SIGN SARA U") | |
97 (?(1Y(B vowel-lower "VOWEL SIGN SARA UU") | |
98 (?(1Z(B invalid nil) | |
99 (?(1[(B vowel-upper "VOWEL SIGN MAI KONG") | |
100 (?(1\(B semivowel-lower "SEMIVOWEL SIGN LO") | |
101 (?(1](B vowel-base "SEMIVOWEL SIGN SARA IA") | |
102 (?(1^(B invalid nil) | |
103 (?(1_(B invalid nil) | |
104 (?(1`(B vowel-base "VOWEL SIGN SARA EE") | |
105 (?(1a(B vowel-base "VOWEL SIGN SARA AA") | |
106 (?(1b(B vowel-base "VOWEL SIGN SARA OO") | |
107 (?(1c(B vowel-base "VOWEL SIGN SARA EI MAI MUAN\"") | |
108 (?(1d(B vowel-base "VOWEL SIGN SARA AI MAI MAY") | |
109 (?(1e(B invalid nil) | |
110 (?(1f(B special "KO LA (REPETITION)") | |
111 (?(1g(B invalid nil) | |
112 (?(1h(B tone "TONE MAI EK") | |
113 (?(1i(B tone "TONE MAI THO") | |
114 (?(1j(B tone "TONE MAI TI") | |
115 (?(1k(B tone "TONE MAI JADTAWAR") | |
116 (?(1l(B tone "CANCELLATION MARK") | |
117 (?(1m(B vowel-upper "VOWEL SIGN SARA OR") | |
118 (?(1n(B invalid nil) | |
119 (?(1o(B invalid nil) | |
120 (?(1p(B special "DIGIT ZERO") | |
121 (?(1q(B special "DIGIT ONE") | |
122 (?(1r(B special "DIGIT TWO") | |
123 (?(1s(B special "DIGIT THREE") | |
124 (?(1t(B special "DIGIT FOUR") | |
125 (?(1u(B special "DIGIT FIVE") | |
126 (?(1v(B special "DIGIT SIX") | |
127 (?(1w(B special "DIGIT SEVEN") | |
128 (?(1x(B special "DIGIT EIGHT") | |
129 (?(1y(B special "DIGIT NINE") | |
130 (?(1z(B invalid nil) | |
131 (?(1{(B invalid nil) | |
132 (?(1|(B consonant "LETTER NHOR NHUU" "MOUSE") | |
133 (?(1}(B consonant "LETTER MHOR MHAR" "DOG") | |
134 (?(1~(B invalid nil) | |
135 )) | |
136 elm) | |
137 (while l | |
26894 | 138 (setq elm (car l) l (cdr l)) |
139 (let ((char (car elm)) | |
140 (ptype (nth 1 elm))) | |
141 (cond ((eq ptype 'consonant) | |
142 (modify-category-entry char ?c lao-category-table)) | |
143 ((memq ptype '(vowel-upper vowel-lower)) | |
144 (modify-category-entry char ?v lao-category-table)) | |
145 ((eq ptype 'semivowel-lower) | |
146 (modify-category-entry char ?s lao-category-table)) | |
147 ((eq ptype 'tone) | |
148 (modify-category-entry char ?t lao-category-table))) | |
149 (put-char-code-property char 'phonetic-type ptype) | |
150 (put-char-code-property char 'name (nth 2 elm)) | |
151 (put-char-code-property char 'meaning (nth 3 elm))))) | |
152 | |
153 ;; The general composing rules are as follows: | |
154 ;; | |
155 ;; T | |
156 ;; V T V T | |
157 ;; CV -> C, CT -> C, CVT -> C, Cv -> C, CvT -> C | |
158 ;; v v | |
159 ;; T | |
160 ;; V T V T | |
161 ;; CsV -> C, CsT -> C, CsVT -> C, Csv -> C, CvT -> C | |
162 ;; s s s s s | |
163 ;; v v | |
164 | |
165 | |
166 ;; where C: consonant, V: vowel upper, v: vowel lower, | |
167 ;; T: tone mark, s: semivowel lower | |
168 | |
169 (defvar lao-composition-pattern | |
170 "\\cc\\(\\ct\\|\\cv\\ct?\\|\\cs\\(\\ct\\|\\cv\\ct?\\)?\\)" | |
171 "Regular expression matching a Lao composite sequence.") | |
172 | |
173 ;;;###autoload | |
174 (defun lao-compose-string (str) | |
175 (with-category-table lao-category-table | |
176 (let ((idx 0)) | |
177 (while (setq idx (string-match lao-composition-pattern str idx)) | |
178 (compose-string str idx (match-end 0)) | |
179 (setq idx (match-end 0)))) | |
180 str)) | |
181 | |
182 ;;; LRT: Lao <-> Roman Transcription | |
183 | |
184 ;; Upper vowels and tone-marks are put on the letter. | |
185 ;; Semi-vowel-sign-lo and lower vowels are put under the letter. | |
186 | |
187 (defconst lao-transcription-consonant-alist | |
188 (sort '(;; single consonants | |
189 ("k" . "(1!(B") | |
190 ("kh" . "(1"(B") | |
191 ("qh" . "(1$(B") | |
192 ("ng" . "(1'(B") | |
193 ("j" . "(1((B") | |
194 ("s" . "(1J(B") | |
195 ("x" . "(1*(B") | |
196 ("y" . "(1-(B") | |
197 ("d" . "(14(B") | |
198 ("t" . "(15(B") | |
199 ("th" . "(16(B") | |
200 ("dh" . "(17(B") | |
201 ("n" . "(19(B") | |
202 ("b" . "(1:(B") | |
203 ("p" . "(1;(B") | |
204 ("hp" . "(1<(B") | |
205 ("fh" . "(1=(B") | |
206 ("ph" . "(1>(B") | |
207 ("f" . "(1?(B") | |
208 ("m" . "(1A(B") | |
209 ("gn" . "(1B(B") | |
210 ("l" . "(1E(B") | |
211 ("r" . "(1C(B") | |
212 ("v" . "(1G(B") | |
213 ("w" . "(1G(B") | |
214 ("hh" . "(1K(B") | |
215 ("O" . "(1M(B") | |
216 ("h" . "(1N(B") | |
217 ("nh" . "(1|(B") | |
218 ("mh" . "(1}(B") | |
219 ("lh" . ["(1K\(B"]) | |
220 ;; double consonants | |
221 ("ngh" . ["(1K'(B"]) | |
222 ("yh" . ["(1K](B"]) | |
223 ("wh" . ["(1KG(B"]) | |
224 ("hl" . ["(1KE(B"]) | |
225 ("hy" . ["(1K-(B"]) | |
226 ("hn" . ["(1K9(B"]) | |
227 ("hm" . ["(1KA(B"]) | |
228 ) | |
229 (function (lambda (x y) (> (length (car x)) (length (car y))))))) | |
230 | |
231 (defconst lao-transcription-semi-vowel-alist | |
232 '(("r" . "(1\(B"))) | |
233 | |
234 (defconst lao-transcription-vowel-alist | |
235 (sort '(("a" . "(1P(B") | |
236 ("ar" . "(1R(B") | |
237 ("i" . "(1T(B") | |
238 ("ii" . "(1U(B") | |
239 ("eu" . "(1V(B") | |
240 ("ur" . "(1W(B") | |
241 ("u" . "(1X(B") | |
242 ("uu" . "(1Y(B") | |
243 ("e" . ["(1`P(B"]) | |
244 ("ee" . "(1`(B") | |
245 ("ae" . ["(1aP(B"]) | |
246 ("aa" . "(1a(B") | |
247 ("o" . ["(1bP(B"]) | |
248 ("oo" . "(1b(B") | |
249 ("oe" . ["(1`RP(B"]) | |
250 ("or" . "(1m(B") | |
251 ("er" . ["(1`T(B"]) | |
252 ("ir" . ["(1`U(B"]) | |
253 ("ua" . ["(1[GP(B"]) | |
254 ("uaa" . ["(1[G(B"]) | |
255 ("ie" . ["(1`Q]P(B"]) | |
256 ("ia" . ["(1`Q](B"]) | |
257 ("ea" . ["(1`VM(B"]) | |
258 ("eaa" . ["(1`WM(B"]) | |
259 ("ai" . "(1d(B") | |
260 ("ei" . "(1c(B") | |
261 ("ao" . ["(1`[R(B"]) | |
262 ("aM" . "(1S(B")) | |
263 (function (lambda (x y) (> (length (car x)) (length (car y))))))) | |
264 | |
265 ;; Maa-sakod is put at the tail. | |
266 (defconst lao-transcription-maa-sakod-alist | |
267 '(("k" . "(1!(B") | |
268 ("g" . "(1'(B") | |
269 ("y" . "(1-(B") | |
270 ("d" . "(14(B") | |
271 ("n" . "(19(B") | |
272 ("b" . "(1:(B") | |
273 ("m" . "(1A(B") | |
274 ("v" . "(1G(B") | |
275 ("w" . "(1G(B") | |
276 )) | |
277 | |
278 (defconst lao-transcription-tone-alist | |
279 '(("'" . "(1h(B") | |
280 ("\"" . "(1i(B") | |
281 ("^" . "(1j(B") | |
282 ("+" . "(1k(B") | |
283 ("~" . "(1l(B"))) | |
284 | |
285 (defconst lao-transcription-punctuation-alist | |
286 '(("\\0" . "(1p(B") | |
287 ("\\1" . "(1q(B") | |
288 ("\\2" . "(1r(B") | |
289 ("\\3" . "(1s(B") | |
290 ("\\4" . "(1t(B") | |
291 ("\\5" . "(1u(B") | |
292 ("\\6" . "(1v(B") | |
293 ("\\7" . "(1w(B") | |
294 ("\\8" . "(1x(B") | |
295 ("\\9" . "(1y(B") | |
296 ("\\\\" . "(1f(B") | |
297 ("\\$" . "(1O(B"))) | |
298 | |
299 (defconst lao-transcription-pattern | |
300 (concat | |
301 "\\(" | |
302 (mapconcat 'car lao-transcription-consonant-alist "\\|") | |
303 "\\)\\(" | |
304 (mapconcat 'car lao-transcription-semi-vowel-alist "\\|") | |
305 "\\)?\\(\\(" | |
306 (mapconcat 'car lao-transcription-vowel-alist "\\|") | |
307 "\\)\\(" | |
308 (mapconcat 'car lao-transcription-maa-sakod-alist "\\|") | |
309 "\\)?\\(" | |
310 (mapconcat (lambda (x) (regexp-quote (car x))) | |
311 lao-transcription-tone-alist "\\|") | |
312 "\\)?\\)?\\|" | |
313 (mapconcat (lambda (x) (regexp-quote (car x))) | |
314 lao-transcription-punctuation-alist "\\|") | |
315 ) | |
316 "Regexp of Roman transcription pattern for one Lao syllable.") | |
317 | |
318 (defconst lao-transcription-pattern | |
319 (concat | |
320 "\\(" | |
321 (regexp-opt (mapcar 'car lao-transcription-consonant-alist)) | |
322 "\\)\\(" | |
323 (regexp-opt (mapcar 'car lao-transcription-semi-vowel-alist)) | |
324 "\\)?\\(\\(" | |
325 (regexp-opt (mapcar 'car lao-transcription-vowel-alist)) | |
326 "\\)\\(" | |
327 (regexp-opt (mapcar 'car lao-transcription-maa-sakod-alist)) | |
328 "\\)?\\(" | |
329 (regexp-opt (mapcar 'car lao-transcription-tone-alist)) | |
330 "\\)?\\)?\\|" | |
331 (regexp-opt (mapcar 'car lao-transcription-punctuation-alist)) | |
332 ) | |
333 "Regexp of Roman transcription pattern for one Lao syllable.") | |
334 | |
335 (defconst lao-vowel-reordering-rule | |
336 '(("(1P(B" (0 ?(1P(B) (0 ?(1Q(B)) | |
337 ("(1R(B" (0 ?(1R(B)) | |
338 ("(1T(B" (0 ?(1U(B)) | |
339 ("(1U(B" (0 ?(1U(B)) | |
340 ("(1V(B" (0 ?(1V(B)) | |
341 ("(1W(B" (0 ?(1W(B)) | |
342 ("(1X(B" (0 ?(1X(B)) | |
343 ("(1Y(B" (0 ?(1Y(B)) | |
344 ("(1`P(B" (?(1`(B 0 ?(1P(B) (?(1`(B 0 ?(1Q(B)) | |
345 ("(1`(B" (?(1`(B 0)) | |
346 ("(1aP(B" (?(1a(B 0 ?(1P(B) (?(1a(B 0 ?(1Q(B)) | |
347 ("(1a(B" (?(1a(B 0)) | |
348 ("(1bP(B" (?(1b(B 0 ?(1P(B) (0 ?(1[(B) (?(1-(B ?(1b(B 0 ?(1Q(B) (?(1G(B ?(1b(B 0 ?(1Q(B)) | |
349 ("(1b(B" (?(1b(B 0)) | |
350 ("(1`RP(B" (?(1`(B 0 ?(1R(B ?(1P(B) (0 ?(1Q(B ?(1M(B)) | |
351 ("(1m(B" (0 ?(1m(B) (0 ?(1M(B)) | |
352 ("(1`T(B" (?(1`(B 0 ?(1T(B)) | |
353 ("(1`U(B" (?(1`(B 0 ?(1U(B)) | |
354 ("(1[GP(B" (0 ?(1[(B ?(1G(B ?(1P(B) (0 ?(1Q(B ?(1G(B)) | |
355 ("(1[G(B" (0 ?(1[(B ?(1G(B) (0 ?(1G(B)) | |
356 ("(1`Q]P(B" (?(1`(B 0 ?(1Q(B ?(1](B ?(1P(B) (0 ?(1Q(B ?(1](B)) | |
357 ("(1`Q](B" (?(1`(B 0 ?(1Q(B ?(1](B) (0 ?(1](B)) | |
358 ("(1`VM(B" (?(1`(B 0 ?(1V(B ?(1M(B)) | |
359 ("(1`WM(B" (?(1`(B 0 ?(1W(B ?(1M(B)) | |
360 ("(1d(B" (?(1d(B 0)) | |
361 ("(1c(B" (?(1c(B 0)) | |
362 ("(1`[R(B" (?(1`(B 0 ?(1[(B ?(1R(B)) | |
363 ("(1S(B" (0 ?(1S(B))) | |
364 "Alist of Lao vowel string vs the corresponding re-ordering rule. | |
365 Each element has this form: | |
366 (VOWEL NO-MAA-SAKOD-RULE WITH-MAA-SAKOD-RULE (MAA-SAKOD-0 RULE-0) ...) | |
367 | |
368 VOWEL is a vowel string (e.g. \"(1`Q]P(B\"). | |
369 | |
370 NO-MAA-SAKOD-RULE is a rule to re-order and modify VOWEL following a | |
371 consonant. It is a list vowel characters or 0. The element 0 | |
372 indicate the place to embed a consonant. | |
373 | |
374 Optional WITH-MAA-SAKOD-RULE is a rule to re-order and modify VOWEL | |
375 follwoing a consonant and preceding a maa-sakod character. If it is | |
376 nil, NO-MAA-SAKOD-RULE is used. The maa-sakod character is alwasy | |
377 appended at the tail. | |
378 | |
379 For instance, rule `(\"(1`WM(B\" (?(1`(B t ?(1W(B ?(1M(B))' tells that this vowel | |
380 string following a consonant `(1!(B' should be re-ordered as \"(1`!WM(B\". | |
381 | |
382 Optional (MAA-SAKOD-n RULE-n) are rules specially applied to maa-sakod | |
383 character MAA-SAKOD-n.") | |
384 | |
385 ;;;###autoload | |
386 (defun lao-transcribe-single-roman-syllable-to-lao (from to &optional str) | |
387 "Transcribe a Romanized Lao syllable in the region FROM and TO to Lao string. | |
388 Only the first syllable is transcribed. | |
389 The value has the form: (START END LAO-STRING), where | |
390 START and END are the beggining and end positions of the Roman Lao syllable, | |
391 LAO-STRING is the Lao character transcription of it. | |
392 | |
393 Optional 3rd arg STR, if non-nil, is a string to search for Roman Lao | |
394 syllable. In that case, FROM and TO are indexes to STR." | |
395 (if str | |
396 (if (setq from (string-match lao-transcription-pattern str from)) | |
397 (progn | |
398 (if (>= from to) | |
399 (setq from nil) | |
400 (setq to (match-end 0))))) | |
401 (save-excursion | |
402 (goto-char from) | |
403 (if (setq to (re-search-forward lao-transcription-pattern to t)) | |
404 (setq from (match-beginning 0)) | |
405 (setq from nil)))) | |
406 (if from | |
407 (let* ((consonant (match-string 1 str)) | |
408 (semivowel (match-string 3 str)) | |
409 (vowel (match-string 5 str)) | |
410 (maa-sakod (match-string 8 str)) | |
411 (tone (match-string 9 str)) | |
412 lao-consonant lao-semivowel lao-vowel lao-maa-sakod lao-tone | |
413 clen cidx) | |
414 (setq to (match-end 0)) | |
415 (if (not consonant) | |
416 (setq str (cdr (assoc (match-string 0 str) | |
417 lao-transcription-punctuation-alist))) | |
418 (setq lao-consonant | |
419 (cdr (assoc consonant lao-transcription-consonant-alist))) | |
420 (if (vectorp lao-consonant) | |
421 (setq lao-consonant (aref lao-consonant 0))) | |
422 (setq clen (length lao-consonant)) | |
423 (if semivowel | |
424 ;; Include semivowel in STR. | |
425 (setq lao-semivowel | |
426 (cdr (assoc semivowel lao-transcription-semi-vowel-alist)) | |
427 str (if (= clen 1) | |
428 (concat lao-consonant lao-semivowel) | |
429 (concat (substring lao-consonant 0 1) lao-semivowel | |
430 (substring lao-consonant 1)))) | |
431 (setq str lao-consonant)) | |
432 (if vowel | |
433 (let (rule) | |
434 (setq lao-vowel | |
435 (cdr (assoc vowel lao-transcription-vowel-alist))) | |
436 (if (vectorp lao-vowel) | |
437 (setq lao-vowel (aref lao-vowel 0))) | |
438 (setq rule (assoc lao-vowel lao-vowel-reordering-rule)) | |
439 (if (null maa-sakod) | |
440 (setq rule (nth 1 rule)) | |
441 (setq lao-maa-sakod | |
442 (cdr (assoc maa-sakod lao-transcription-maa-sakod-alist)) | |
443 rule | |
444 (or (cdr (assq (aref lao-maa-sakod 0) (nthcdr 2 rule))) | |
445 (nth 2 rule) | |
446 (nth 1 rule)))) | |
447 (or rule | |
448 (error "Lao vowel %S has no re-ordering rule" lao-vowel)) | |
449 (setq lao-consonant str str "") | |
450 (while rule | |
451 (if (= (car rule) 0) | |
452 (setq str (concat str lao-consonant) | |
453 cidx (length str)) | |
454 (setq str (concat str (list (car rule))))) | |
455 (setq rule (cdr rule))) | |
456 (or cidx | |
457 (error "Lao vowel %S has malformed re-ordering rule" vowel)) | |
458 ;; Set CIDX to after upper or lower vowel if any. | |
459 (let ((len (length str))) | |
460 (while (and (< cidx len) | |
461 (memq (get-char-code-property (aref str cidx) | |
462 'phonetic-type) | |
463 '(vowel-lower vowel-upper))) | |
464 (setq cidx (1+ cidx)))) | |
465 (if lao-maa-sakod | |
466 (setq str (concat str lao-maa-sakod))) | |
467 (if tone | |
468 (setq lao-tone | |
469 (cdr (assoc tone lao-transcription-tone-alist)) | |
470 str (concat (substring str 0 cidx) lao-tone | |
471 (substring str cidx))))))) | |
472 (list from to (lao-compose-string str))))) | |
473 | |
474 ;;;###autoload | |
475 (defun lao-transcribe-roman-to-lao-string (str) | |
476 "Transcribe Romanized Lao string STR to Lao character string." | |
477 (let ((from 0) | |
478 (to (length str)) | |
479 (lao-str "") | |
480 val) | |
481 (while (setq val (lao-transcribe-single-roman-syllable-to-lao from to str)) | |
482 (let ((start (car val)) | |
483 (end (nth 1 val)) | |
484 (lao (nth 2 val))) | |
485 (if (> start from) | |
486 (setq lao-str (concat lao-str (substring str from start) lao)) | |
487 (setq lao-str (concat lao-str lao))) | |
488 (setq from end))) | |
489 (if (< from to) | |
490 (concat lao-str (substring str from to)) | |
491 lao-str))) | |
492 | |
493 ;;;###autoload | |
494 (defun lao-composition-function (from to pattern &optional string) | |
495 "Compose Lao text in the region FROM and TO. | |
496 The text matches the regular expression PATTERN. | |
497 Optional 4th argument STRING, if non-nil, is a string containing text | |
498 to compose. | |
499 | |
500 The return value is number of composed characters." | |
501 (if (< (1+ from) to) | |
502 (prog1 (- to from) | |
503 (if string | |
504 (compose-string from to) | |
505 (compose-region from to)) | |
506 (- to from)))) | |
17083 | 507 |
508 ;; | |
18309
bd8b521f5218
Provide XXX-util instead of
Kenichi Handa <handa@m17n.org>
parents:
18203
diff
changeset
|
509 (provide 'lao-util) |
17083 | 510 |
511 ;;; lao-util.el ends here |