1 ;;; lao-util.el --- utilities for Lao -*- coding: iso-2022-7bit; -*-
3 ;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5 ;; Copyright (C) 2001 Free Software Foundation, Inc.
7 ;; Keywords: multilingual, Lao, i18n
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 ;; Setting information of Thai characters.
32 (defconst lao-category-table (make-category-table))
33 (define-category ?c "Lao consonant" lao-category-table)
34 (define-category ?s "Lao semi-vowel" lao-category-table)
35 (define-category ?v "Lao upper/lower vowel" lao-category-table)
36 (define-category ?t "Lao tone" lao-category-table)
38 ;; Fixme: Should `invalid' entries below be preserved? (See also
40 (let ((l '((?
\e(1!
\e(B consonant "LETTER KOR KAI'" "CHICKEN")
41 (?
\e(1"
\e(B consonant "LETTER KHOR KHAI'" "EGG")
42 (?
\e(1#
\e(B invalid nil)
43 (?
\e(1$
\e(B consonant "LETTER QHOR QHWARGN" "BUFFALO")
44 (?
\e(1%
\e(B invalid nil)
46 (?
\e(1'
\e(B consonant "LETTER NGOR NGUU" "SNAKE")
47 (?
\e(1(
\e(B consonant "LETTER JOR JUA" "BUDDHIST NOVICE")
48 (?
\e(1)
\e(B invalid nil)
49 (?
\e(1*
\e(B consonant "LETTER XOR X\"ARNG" "ELEPHANT")
50 (?
\e(1+
\e(B invalid nil)
51 (?
\e(1,
\e(B invalid nil)
52 (?
\e(1-
\e(B consonant "LETTER YOR YUNG" "MOSQUITO")
53 (?
\e(1.
\e(B invalid nil)
54 (?
\e(1.
\e(B invalid nil)
55 (?
\e(1.
\e(B invalid nil)
56 (?
\e(1.
\e(B invalid nil)
57 (?
\e(1.
\e(B invalid nil)
58 (?
\e(1.
\e(B invalid nil)
59 (?
\e(14
\e(B consonant "LETTER DOR DANG" "NOSE")
60 (?
\e(15
\e(B consonant "LETTER TOR TAR" "EYE")
61 (?
\e(16
\e(B consonant "LETTER THOR THUNG" "TO ASK,QUESTION")
62 (?
\e(17
\e(B consonant "LETTER DHOR DHARM" "FLAG")
63 (?
\e(18
\e(B invalid nil)
64 (?
\e(19
\e(B consonant "LETTER NOR NOK" "BIRD")
65 (?
\e(1:
\e(B consonant "LETTER BOR BED" "FISHHOOK")
66 (?
\e(1;
\e(B consonant "LETTER POR PAR" "FISH")
67 (?
\e(1<
\e(B consonant "LETTER HPOR HPER\"" "BEE")
68 (?
\e(1=
\e(B consonant "LETTER FHOR FHAR" "WALL")
69 (?
\e(1>
\e(B consonant "LETTER PHOR PHUU" "MOUNTAIN")
70 (?
\e(1?
\e(B consonant "LETTER FOR FAI" "FIRE")
71 (?
\e(1@
\e(B invalid nil)
72 (?
\e(1A
\e(B consonant "LETTER MOR MAR\"" "HORSE")
73 (?
\e(1B
\e(B consonant "LETTER GNOR GNAR" "MEDICINE")
74 (?
\e(1C
\e(B consonant "LETTER ROR ROD" "CAR")
75 (?
\e(1D
\e(B invalid nil)
76 (?
\e(1E
\e(B consonant "LETTER LOR LIING" "MONKEY")
77 (?
\e(1F
\e(B invalid nil)
78 (?
\e(1G
\e(B consonant "LETTER WOR WII" "HAND FAN")
79 (?
\e(1H
\e(B invalid nil)
80 (?
\e(1I
\e(B invalid nil)
81 (?
\e(1J
\e(B consonant "LETTER SOR SEA" "TIGER")
82 (?
\e(1K
\e(B consonant "LETTER HHOR HHAI" "JAR")
83 (?
\e(1L
\e(B invalid nil)
84 (?
\e(1M
\e(B consonant "LETTER OR OOW" "TAKE")
85 (?
\e(1N
\e(B consonant "LETTER HOR HEA" "BOAT")
86 (?
\e(1O
\e(B special "ELLIPSIS")
87 (?
\e(1P
\e(B vowel-base "VOWEL SIGN SARA A")
88 (?
\e(1Q
\e(B vowel-upper "VOWEL SIGN MAI KAN")
89 (?
\e(1R
\e(B vowel-base "VOWEL SIGN SARA AR")
90 (?
\e(1S
\e(B vowel-base "VOWEL SIGN SARA AM")
91 (?
\e(1T
\e(B vowel-upper "VOWEL SIGN SARA I")
92 (?
\e(1U
\e(B vowel-upper "VOWEL SIGN SARA II")
93 (?
\e(1V
\e(B vowel-upper "VOWEL SIGN SARA EU")
94 (?
\e(1W
\e(B vowel-upper "VOWEL SIGN SARA UR")
95 (?
\e(1X
\e(B vowel-lower "VOWEL SIGN SARA U")
96 (?
\e(1Y
\e(B vowel-lower "VOWEL SIGN SARA UU")
97 (?
\e(1Z
\e(B invalid nil)
98 (?
\e(1[
\e(B vowel-upper "VOWEL SIGN MAI KONG")
99 (?
\e(1\
\e(B semivowel-lower "SEMIVOWEL SIGN LO")
100 (?
\e(1]
\e(B vowel-base "SEMIVOWEL SIGN SARA IA")
101 (?
\e(1^
\e(B invalid nil)
102 (?
\e(1_
\e(B invalid nil)
103 (?
\e(1`
\e(B vowel-base "VOWEL SIGN SARA EE")
104 (?
\e(1a
\e(B vowel-base "VOWEL SIGN SARA AA")
105 (?
\e(1b
\e(B vowel-base "VOWEL SIGN SARA OO")
106 (?
\e(1c
\e(B vowel-base "VOWEL SIGN SARA EI MAI MUAN\"")
107 (?
\e(1d
\e(B vowel-base "VOWEL SIGN SARA AI MAI MAY")
108 (?
\e(1e
\e(B invalid nil)
109 (?
\e(1f
\e(B special "KO LA (REPETITION)")
110 (?
\e(1g
\e(B invalid nil)
111 (?
\e(1h
\e(B tone "TONE MAI EK")
112 (?
\e(1i
\e(B tone "TONE MAI THO")
113 (?
\e(1j
\e(B tone "TONE MAI TI")
114 (?
\e(1k
\e(B tone "TONE MAI JADTAWAR")
115 (?
\e(1l
\e(B tone "CANCELLATION MARK")
116 (?
\e(1m
\e(B vowel-upper "VOWEL SIGN SARA OR")
117 (?
\e(1n
\e(B invalid nil)
118 (?
\e(1o
\e(B invalid nil)
119 (?
\e(1p
\e(B special "DIGIT ZERO")
120 (?
\e(1q
\e(B special "DIGIT ONE")
121 (?
\e(1r
\e(B special "DIGIT TWO")
122 (?
\e(1s
\e(B special "DIGIT THREE")
123 (?
\e(1t
\e(B special "DIGIT FOUR")
124 (?
\e(1u
\e(B special "DIGIT FIVE")
125 (?
\e(1v
\e(B special "DIGIT SIX")
126 (?
\e(1w
\e(B special "DIGIT SEVEN")
127 (?
\e(1x
\e(B special "DIGIT EIGHT")
128 (?
\e(1y
\e(B special "DIGIT NINE")
129 (?
\e(1z
\e(B invalid nil)
130 (?
\e(1{
\e(B invalid nil)
131 (?
\e(1|
\e(B consonant "LETTER NHOR NHUU" "MOUSE")
132 (?
\e(1}
\e(B consonant "LETTER MHOR MHAR" "DOG")
133 (?
\e(1~
\e(B invalid nil)))
136 (setq elm (car l) l (cdr l))
137 (let ((char (car elm))
139 (cond ((eq ptype 'consonant)
140 (modify-category-entry char ?c lao-category-table))
141 ((memq ptype '(vowel-upper vowel-lower))
142 (modify-category-entry char ?v lao-category-table))
143 ((eq ptype 'semivowel-lower)
144 (modify-category-entry char ?s lao-category-table))
146 (modify-category-entry char ?t lao-category-table)))
147 (put-char-code-property char 'phonetic-type ptype)
148 (put-char-code-property char 'name (nth 2 elm))
149 (put-char-code-property char 'meaning (nth 3 elm)))))
151 ;; The general composing rules are as follows:
155 ;; CV -> C, CT -> C, CVT -> C, Cv -> C, CvT -> C
159 ;; CsV -> C, CsT -> C, CsVT -> C, Csv -> C, CsvT -> C
164 ;; where C: consonant, V: vowel upper, v: vowel lower,
165 ;; T: tone mark, s: semivowel lower
167 (defvar lao-composition-pattern
168 "\\cc\\(\\ct\\|\\cv\\ct?\\|\\cs\\(\\ct\\|\\cv\\ct?\\)?\\)"
169 "Regular expression matching a Lao composite sequence.")
172 (defun lao-compose-string (str)
173 (with-category-table lao-category-table
175 (while (setq idx (string-match lao-composition-pattern str idx))
176 (compose-string str idx (match-end 0))
177 (setq idx (match-end 0))))
180 ;;; LRT: Lao <-> Roman Transcription
182 ;; Upper vowels and tone-marks are put on the letter.
183 ;; Semi-vowel-sign-lo and lower vowels are put under the letter.
185 (defconst lao-transcription-consonant-alist
186 (sort '(;; single consonants
217 ("lh" . ["
\e(1K\
\e(B"])
219 ("ngh" . ["
\e(1K'
\e(B"])
220 ("yh" . ["
\e(1K]
\e(B"])
221 ("wh" . ["
\e(1KG
\e(B"])
222 ("hl" . ["
\e(1KE
\e(B"])
223 ("hy" . ["
\e(1K-
\e(B"])
224 ("hn" . ["
\e(1K9
\e(B"])
225 ("hm" . ["
\e(1KA
\e(B"])
227 (function (lambda (x y) (> (length (car x)) (length (car y)))))))
229 (defconst lao-transcription-semi-vowel-alist
230 '(("r" . "
\e(1\
\e(B")))
232 (defconst lao-transcription-vowel-alist
233 (sort '(("a" . "
\e(1P
\e(B")
241 ("e" . ["
\e(1`P
\e(B"])
243 ("ae" . ["
\e(1aP
\e(B"])
245 ("o" . ["
\e(1bP
\e(B"])
247 ("oe" . ["
\e(1`RP
\e(B"])
249 ("er" . ["
\e(1`T
\e(B"])
250 ("ir" . ["
\e(1`U
\e(B"])
251 ("ua" . ["
\e(1[GP
\e(B"])
252 ("uaa" . ["
\e(1[G
\e(B"])
253 ("ie" . ["
\e(1`Q]P
\e(B"])
254 ("ia" . ["
\e(1`Q]
\e(B"])
255 ("ea" . ["
\e(1`VM
\e(B"])
256 ("eaa" . ["
\e(1`WM
\e(B"])
259 ("ao" . ["
\e(1`[R
\e(B"])
260 ("aM" . "
\e(1S
\e(B"))
261 (function (lambda (x y) (> (length (car x)) (length (car y)))))))
263 ;; Maa-sakod is put at the tail.
264 (defconst lao-transcription-maa-sakod-alist
265 '(("k" . "
\e(1!
\e(B")
276 (defconst lao-transcription-tone-alist
277 '(("'" . "
\e(1h
\e(B")
281 ("~" . "
\e(1l
\e(B")))
283 (defconst lao-transcription-punctuation-alist
284 '(("\\0" . "
\e(1p
\e(B")
285 ("\\1" . "
\e(1q
\e(B")
286 ("\\2" . "
\e(1r
\e(B")
287 ("\\3" . "
\e(1s
\e(B")
288 ("\\4" . "
\e(1t
\e(B")
289 ("\\5" . "
\e(1u
\e(B")
290 ("\\6" . "
\e(1v
\e(B")
291 ("\\7" . "
\e(1w
\e(B")
292 ("\\8" . "
\e(1x
\e(B")
293 ("\\9" . "
\e(1y
\e(B")
294 ("\\\\" . "
\e(1f
\e(B")
295 ("\\$" . "
\e(1O
\e(B")))
297 (defconst lao-transcription-pattern
300 (mapconcat 'car lao-transcription-consonant-alist "\\|")
302 (mapconcat 'car lao-transcription-semi-vowel-alist "\\|")
304 (mapconcat 'car lao-transcription-vowel-alist "\\|")
306 (mapconcat 'car lao-transcription-maa-sakod-alist "\\|")
308 (mapconcat (lambda (x) (regexp-quote (car x)))
309 lao-transcription-tone-alist "\\|")
311 (mapconcat (lambda (x) (regexp-quote (car x)))
312 lao-transcription-punctuation-alist "\\|")
314 "Regexp of Roman transcription pattern for one Lao syllable.")
316 (defconst lao-transcription-pattern
319 (regexp-opt (mapcar 'car lao-transcription-consonant-alist))
321 (regexp-opt (mapcar 'car lao-transcription-semi-vowel-alist))
323 (regexp-opt (mapcar 'car lao-transcription-vowel-alist))
325 (regexp-opt (mapcar 'car lao-transcription-maa-sakod-alist))
327 (regexp-opt (mapcar 'car lao-transcription-tone-alist))
329 (regexp-opt (mapcar 'car lao-transcription-punctuation-alist))
331 "Regexp of Roman transcription pattern for one Lao syllable.")
333 (defconst lao-vowel-reordering-rule
334 '(("
\e(1P
\e(B" (0 ?
\e(1P
\e(B) (0 ?
\e(1Q
\e(B))
335 ("
\e(1R
\e(B" (0 ?
\e(1R
\e(B))
336 ("
\e(1T
\e(B" (0 ?
\e(1U
\e(B))
337 ("
\e(1U
\e(B" (0 ?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1b
\e(B 0 ?
\e(1Q
\e(B) (?
\e(1G
\e(B ?
\e(1b
\e(B 0 ?
\e(1Q
\e(B))
377 ("
\e(1b
\e(B" (?
\e(1b
\e(B 0))
378 ("
\e(1`RP
\e(B" (?
\e(1`
\e(B 0 ?
\e(1R
\e(B ?
\e(1P
\e(B) (0 ?
\e(1Q
\e(B ?
\e(1M
\e(B))
379 ("
\e(1m
\e(B" (0 ?
\e(1m
\e(B) (0 ?
\e(1M
\e(B))
380 ("
\e(1`T
\e(B" (?
\e(1`
\e(B 0 ?
\e(1T
\e(B))
381 ("
\e(1`U
\e(B" (?
\e(1`
\e(B 0 ?
\e(1U
\e(B))
382 ("
\e(1[GP
\e(B" (0 ?
\e(1[
\e(B ?
\e(1G
\e(B ?
\e(1P
\e(B) (0 ?
\e(1Q
\e(B ?
\e(1G
\e(B))
383 ("
\e(1[G
\e(B" (0 ?
\e(1[
\e(B ?
\e(1G
\e(B) (0 ?
\e(1G
\e(B))
384 ("
\e(1`Q]P
\e(B" (?
\e(1`
\e(B 0 ?
\e(1Q
\e(B ?
\e(1]
\e(B ?
\e(1P
\e(B) (0 ?
\e(1Q
\e(B ?
\e(1]
\e(B))
385 ("
\e(1`Q]
\e(B" (?
\e(1`
\e(B 0 ?
\e(1Q
\e(B ?
\e(1]
\e(B) (0 ?
\e(1]
\e(B))
386 ("
\e(1`VM
\e(B" (?
\e(1`
\e(B 0 ?
\e(1V
\e(B ?
\e(1M
\e(B))
387 ("
\e(1`WM
\e(B" (?
\e(1`
\e(B 0 ?
\e(1W
\e(B ?
\e(1M
\e(B))
388 ("
\e(1d
\e(B" (?
\e(1d
\e(B 0))
389 ("
\e(1c
\e(B" (?
\e(1c
\e(B 0))
390 ("
\e(1`[R
\e(B" (?
\e(1`
\e(B 0 ?
\e(1[
\e(B ?
\e(1R
\e(B))
391 ("
\e(1S
\e(B" (0 ?
\e(1S
\e(B)))
392 "Alist of Lao vowel string vs the corresponding re-ordering rule.
393 Each element has this form:
394 (VOWEL NO-MAA-SAKOD-RULE WITH-MAA-SAKOD-RULE (MAA-SAKOD-0 RULE-0) ...)
396 VOWEL is a vowel string (e.g. \"
\e(1`Q]P
\e(B\").
398 NO-MAA-SAKOD-RULE is a rule to re-order and modify VOWEL following a
399 consonant. It is a list vowel characters or 0. The element 0
400 indicate the place to embed a consonant.
402 Optional WITH-MAA-SAKOD-RULE is a rule to re-order and modify VOWEL
403 follwoing a consonant and preceding a maa-sakod character. If it is
404 nil, NO-MAA-SAKOD-RULE is used. The maa-sakod character is alwasy
405 appended at the tail.
407 For instance, rule `(\"
\e(1`WM
\e(B\" (?
\e(1`
\e(B t ?
\e(1W
\e(B ?
\e(1M
\e(B))' tells that this vowel
408 string following a consonant `
\e(1!
\e(B' should be re-ordered as \"
\e(1`!WM
\e(B\".
410 Optional (MAA-SAKOD-n RULE-n) are rules specially applied to maa-sakod
411 character MAA-SAKOD-n.")
414 (defun lao-transcribe-single-roman-syllable-to-lao (from to &optional str)
415 "Transcribe a Romanized Lao syllable in the region FROM and TO to Lao string.
416 Only the first syllable is transcribed.
417 The value has the form: (START END LAO-STRING), where
418 START and END are the beggining and end positions of the Roman Lao syllable,
419 LAO-STRING is the Lao character transcription of it.
421 Optional 3rd arg STR, if non-nil, is a string to search for Roman Lao
422 syllable. In that case, FROM and TO are indexes to STR."
424 (if (setq from (string-match lao-transcription-pattern str from))
428 (setq to (match-end 0)))))
431 (if (setq to (re-search-forward lao-transcription-pattern to t))
432 (setq from (match-beginning 0))
435 (let* ((consonant (match-string 1 str))
436 (semivowel (match-string 3 str))
437 (vowel (match-string 5 str))
438 (maa-sakod (match-string 8 str))
439 (tone (match-string 9 str))
440 lao-consonant lao-semivowel lao-vowel lao-maa-sakod lao-tone
442 (setq to (match-end 0))
444 (setq str (cdr (assoc (match-string 0 str)
445 lao-transcription-punctuation-alist)))
447 (cdr (assoc consonant lao-transcription-consonant-alist)))
448 (if (vectorp lao-consonant)
449 (setq lao-consonant (aref lao-consonant 0)))
450 (setq clen (length lao-consonant))
452 ;; Include semivowel in STR.
454 (cdr (assoc semivowel lao-transcription-semi-vowel-alist))
456 (concat lao-consonant lao-semivowel)
457 (concat (substring lao-consonant 0 1) lao-semivowel
458 (substring lao-consonant 1))))
459 (setq str lao-consonant))
463 (cdr (assoc vowel lao-transcription-vowel-alist)))
464 (if (vectorp lao-vowel)
465 (setq lao-vowel (aref lao-vowel 0)))
466 (setq rule (assoc lao-vowel lao-vowel-reordering-rule))
468 (setq rule (nth 1 rule))
470 (cdr (assoc maa-sakod lao-transcription-maa-sakod-alist))
472 (or (cdr (assq (aref lao-maa-sakod 0) (nthcdr 2 rule)))
476 (error "Lao vowel %S has no re-ordering rule" lao-vowel))
477 (setq lao-consonant str str "")
480 (setq str (concat str lao-consonant)
482 (setq str (concat str (list (car rule)))))
483 (setq rule (cdr rule)))
485 (error "Lao vowel %S has malformed re-ordering rule" vowel))
486 ;; Set CIDX to after upper or lower vowel if any.
487 (let ((len (length str)))
488 (while (and (< cidx len)
489 (memq (get-char-code-property (aref str cidx)
491 '(vowel-lower vowel-upper)))
492 (setq cidx (1+ cidx))))
494 (setq str (concat str lao-maa-sakod)))
497 (cdr (assoc tone lao-transcription-tone-alist))
498 str (concat (substring str 0 cidx) lao-tone
499 (substring str cidx)))))))
500 (list from to (lao-compose-string str)))))
503 (defun lao-transcribe-roman-to-lao-string (str)
504 "Transcribe Romanized Lao string STR to Lao character string."
509 (while (setq val (lao-transcribe-single-roman-syllable-to-lao from to str))
510 (let ((start (car val))
514 (setq lao-str (concat lao-str (substring str from start) lao))
515 (setq lao-str (concat lao-str lao)))
518 (concat lao-str (substring str from to))
522 (defun lao-composition-function (pos &optional string)
524 (with-category-table lao-category-table
527 (eq (string-match lao-composition-pattern string pos) pos))
529 (compose-string string pos (match-end 0))))
530 (if (>= pos (point-min))
533 (if (looking-at lao-composition-pattern)
535 (compose-region pos (match-end 0)))))))))
538 (defun lao-compose-region (from to)
541 (narrow-to-region from to)
542 (goto-char (point-min))
543 (with-category-table lao-category-table
544 (while (re-search-forward lao-composition-pattern nil t)
545 (compose-region (match-beginning 0) (point))))))
550 ;;; lao-util.el ends here