From: ntakahas Date: Wed, 16 May 2007 12:54:16 +0000 (+0000) Subject: Add new variable LEVEL. X-Git-Tag: REL-1-4-0~91 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=f56970c479b8a93156b4fa1775b625973eef387c;p=m17n%2Fm17n-db.git Add new variable LEVEL. Use state-list identical to kesmenee's. --- diff --git a/th-pattachote.mim b/th-pattachote.mim index da6e672..717ede5 100644 --- a/th-pattachote.mim +++ b/th-pattachote.mim @@ -1,5 +1,5 @@ ;; th-pattachote.mim -- Thai input method with Pattachote keyboard layout -;; Copyright (C) 2006 +;; Copyright (C) 2006, 2007 ;; National Institute of Advanced Industrial Science and Technology (AIST) ;; Registration Number H15PRO112 @@ -24,11 +24,18 @@ (input-method th pattachote) (description "Thai input method simulating the Pattachote keyboard -with WTT 2.0 level 1 input sequence correction. +with WTT 2.0 input sequence correction. The correction algorithm follows the one shown in the following ") +(variable + (level (_"Acceptance level +The level of character sequence acceptance defined in WTT 2.0. +0 accepts any key sequence. 2 accepts only orthographic ones. +1 is somewhere between.") + 1 (0 2))) + (title "ท") (map @@ -136,31 +143,23 @@ The correction algorithm follows the one shown in the following (map (delete @<) (pushback 1) - (cond - ((= @-1 -2) (shift nst)) - (1 (shift st))))) + (shift main))) - ;; no surrounding text - (nst - (t - (set x -1) - (set y -1)) - + (main (map - (set z @-) + (set x @-3) + (set y @-2) + (set z @-1) + (set arg1 y) (set arg2 z) (cp) (cond - ((= ret 1) ;; CP(y,z) succeeded. - (set x y) - (set y z)) + ((= ret 1)) ;; CP(y,z) succeeded. (1 (ac) (cond - ((= ret 1) ;; AC(y,z) succeeded. - (set x y) - (set y z)) + ((= ret 1)) ;; AC(y,z) succeeded. (1 ;; WTT-based input sequence correction starts here. @@ -180,11 +179,9 @@ The correction algorithm follows the one shown in the following ((= ret 1) ;; reorder(y -> zy) - (delete @-) - (delete @-) + (delete @-2) (insert z) - (insert y) - (set x z)) + (insert y)) ;; elif CP(x,y) then (1 @@ -195,10 +192,8 @@ The correction algorithm follows the one shown in the following ((= ret 1) ;; replace(y -> z) - (delete @-) - (delete @-) - (insert z) - (set y z)) + (delete @-2) + (insert z)) ;; elif y is FV1 and z is TONE then ((& (| (= y 0x0E30) (= y 0x0E32) (= y 0x0E33)) @@ -206,16 +201,14 @@ The correction algorithm follows the one shown in the following (<= z 0x0E4B)) ;; reorder(y -> zy) - (delete @-) - (delete @-) + (delete @-2) (insert z) - (insert y) - (set x z)) + (insert y)) ;; else ;; reject(z) (1 - (delete @-)) + (delete @-1)) ;;endif )))) @@ -227,28 +220,18 @@ The correction algorithm follows the one shown in the following (ac) (cond ((& (= ret 1) - ;; CTRL, NON and CONS should not be replaced. - (| (= y 0x0E24) - (= y 0x0E26) - (& (>= y 0x0E30) (<= y 0x0E3A)) - (& (>= y 0x0E40) (<= y 0x0E45)) - (& (>= y 0x0E47) (<= y 0x0E4E))) - (| (= z 0x0E24) - (= z 0x0E26) - (& (>= z 0x0E30) (<= z 0x0E3A)) - (& (>= z 0x0E40) (<= z 0x0E45)) - (& (>= z 0x0E47) (<= z 0x0E4E)))) + ;; Only Thai characters should be replaced. + (& (>= y 0x0E01) (<= y 0x0E5B)) + (& (>= z 0x0E01) (<= z 0x0E5B))) ;; replace(y -> z) - (delete @-) - (delete @-) - (insert z) - (set y z)) + (delete @-2) + (insert z)) ;; else ;; reject(z) (1 - (delete @-)) + (delete @-1)) ;; endif ))) @@ -256,9 +239,13 @@ The correction algorithm follows the one shown in the following )))) - ;; Commit the preedit chars as soon as fixed. - (set w @-) + ;; Now we commit the preedit chars that are fixed. + (set w @-1) (cond + ;; If surrounding text is supported, commit the only char in preedit. + ((> @-0 -2) + (commit)) + ;; If the last char is CTRL or NON, we can commit everything. ((| (& (>= w 0x0000) (<= w 0x0E00)) (= w 0x0E2F) @@ -267,18 +254,33 @@ The correction algorithm follows the one shown in the following (>= w 0x0E4F)) (commit)) - ;; If the last char is CONS, LV, FV2 or FV3, we can commit + ;; If the last char is CONS, we can commit everything but the last + ;; unless the second last is FV3. + ((| (& (>= w 0x0E01) (<= w 0x0E23)) + (= w 0x0E25) + (& (>= w 0x0E27) (<= w 0x0E2E))) + (cond + ((| (= @-2 0x0E24) (= @-2 0x0E26)) + ; not commit yet + ) + (1 + (delete @-1) + (commit) + (insert w)))) + + ;; If the last char is LV, FV2 or FV3, we can commit ;; everything but the last. - ((| (& (>= w 0x0E01) (<= w 0x0E2E)) - (& (>= w 0x0E40) (<= w 0x0E45))) - (delete @-) + ((| (& (>= w 0x0E40) (<= w 0x0E45)) + (= w 0x0E24) + (= w 0x0E26)) + (delete @-1) (commit) (insert w)) ;; If the last char is FV1 (excluding AM) and ... ((| (= w 0x0E30) (= w 0x0E32)) - (delete @-) - (set v @-) + (delete @-1) + (set v @-1) (cond ;; ... the before last is CONS, we can commit other than the @@ -286,7 +288,7 @@ The correction algorithm follows the one shown in the following ((| (& (>= v 0x0E01) (<= v 0x0E23)) (= v 0x0E25) (& (>= v 0x0E27) (<= v 0x0E2E))) - (delete @-) + (delete @-1) (commit) (insert v) (insert w)) @@ -296,119 +298,7 @@ The correction algorithm follows the one shown in the following (1 (commit) (insert w)))) - ))) - - ;; with surrounding text - (st - (map - ;; z = next character - (set z @-) - ;; y = previous character - (set y @-1) - ;; x = character previous to y - (set x @-2) - - (set arg1 y) - (set arg2 z) - (cp) - (cond - ((= ret 1)) ;; CP(y,z) succeeded. - (1 - (ac) - (cond - ((= ret 1)) ;; AC(y,z) succeeded. - (1 - ;; WTT-based input sequence correction starts here. - - ;; begin - ;; if CP(x,z) then - (set arg1 x) - (set arg2 z) - (cp) - (cond - ((= ret 1) - - ;; if CP(z,y) then - (set arg1 z) - (set arg2 y) - (cp) - (cond - ((= ret 1) - - ;; reorder(y -> zy) - (delete @-) - (delete @-1) - (insert z) - (insert y)) - - ;; elif CP(x,y) then - (1 - (set arg1 x) - (set arg2 y) - (cp) - (cond - ((= ret 1) - - ;; replace(y -> z) - (delete @-) - (delete @-1) - (insert z)) - - ;; elif y is FV1 and z is TONE then - ((& (| (= y 0x0E30) (= y 0x0E32) (= y 0x0E33)) - (>= z 0x0E48) - (<= z 0x0E4B)) - - ;; reorder(y -> zy) - (delete @-) - (delete @-1) - (insert z) - (insert y)) - - ;; else - ;; reject(z) - (1 - (delete @-)) - - ;;endif - )))) - - ;; elif AC(x,z) then - (1 - (set arg1 x) - (set arg2 z) - (ac) - (cond - ((& (= ret 1) - ;; CTRL, NON and CONS should not be replaced. - (| (= y 0x0E24) - (= y 0x0E26) - (& (>= y 0x0E30) (<= y 0x0E3A)) - (& (>= y 0x0E40) (<= y 0x0E45)) - (& (>= y 0x0E47) (<= y 0x0E4E))) - (| (= z 0x0E24) - (= z 0x0E26) - (& (>= z 0x0E30) (<= z 0x0E3A)) - (& (>= z 0x0E40) (<= z 0x0E45)) - (& (>= z 0x0E47) (<= z 0x0E4E)))) - - ;; replace(y -> z) - (delete @-) - (delete @-1) - (insert z)) - - ;; else - ;; reject(z) - (1 - (delete @-)) - - ;; endif - ))) - ;; end - - )))) - (commit) - ))) + )))) ;; Local Variables: ;; coding: utf-8 diff --git a/th-tis820.mim b/th-tis820.mim index 644ba5f..4065363 100644 --- a/th-tis820.mim +++ b/th-tis820.mim @@ -1,5 +1,5 @@ ;; th-tis820.mim -- Thai input method with TIS-820.2538 keyboard layout -;; Copyright (C) 2006 +;; Copyright (C) 2006, 2007 ;; National Institute of Advanced Industrial Science and Technology (AIST) ;; Registration Number H15PRO112 @@ -24,11 +24,18 @@ (input-method th tis820) (description "Thai input method simulating the TIS-820.2538 keyboard -with WTT 2.0 level 1 input sequence correction. +with WTT 2.0 input sequence correction. The correction algorithm follows the one shown in the following ") +(variable + (level (_"Acceptance level +The level of character sequence acceptance defined in WTT 2.0. +0 accepts any key sequence. 2 accepts only orthographic ones. +1 is somewhere between.") + 1 (0 2))) + (title "ท") (map @@ -136,31 +143,23 @@ The correction algorithm follows the one shown in the following (map (delete @<) (pushback 1) - (cond - ((= @-1 -2) (shift nst)) - (1 (shift st))))) + (shift main))) - ;; no surrounding text - (nst - (t - (set x -1) - (set y -1)) - + (main (map - (set z @-) + (set x @-3) + (set y @-2) + (set z @-1) + (set arg1 y) (set arg2 z) (cp) (cond - ((= ret 1) ;; CP(y,z) succeeded. - (set x y) - (set y z)) + ((= ret 1)) ;; CP(y,z) succeeded. (1 (ac) (cond - ((= ret 1) ;; AC(y,z) succeeded. - (set x y) - (set y z)) + ((= ret 1)) ;; AC(y,z) succeeded. (1 ;; WTT-based input sequence correction starts here. @@ -180,11 +179,9 @@ The correction algorithm follows the one shown in the following ((= ret 1) ;; reorder(y -> zy) - (delete @-) - (delete @-) + (delete @-2) (insert z) - (insert y) - (set x z)) + (insert y)) ;; elif CP(x,y) then (1 @@ -195,10 +192,8 @@ The correction algorithm follows the one shown in the following ((= ret 1) ;; replace(y -> z) - (delete @-) - (delete @-) - (insert z) - (set y z)) + (delete @-2) + (insert z)) ;; elif y is FV1 and z is TONE then ((& (| (= y 0x0E30) (= y 0x0E32) (= y 0x0E33)) @@ -206,16 +201,14 @@ The correction algorithm follows the one shown in the following (<= z 0x0E4B)) ;; reorder(y -> zy) - (delete @-) - (delete @-) + (delete @-2) (insert z) - (insert y) - (set x z)) + (insert y)) ;; else ;; reject(z) (1 - (delete @-)) + (delete @-1)) ;;endif )))) @@ -227,28 +220,18 @@ The correction algorithm follows the one shown in the following (ac) (cond ((& (= ret 1) - ;; CTRL, NON and CONS should not be replaced. - (| (= y 0x0E24) - (= y 0x0E26) - (& (>= y 0x0E30) (<= y 0x0E3A)) - (& (>= y 0x0E40) (<= y 0x0E45)) - (& (>= y 0x0E47) (<= y 0x0E4E))) - (| (= z 0x0E24) - (= z 0x0E26) - (& (>= z 0x0E30) (<= z 0x0E3A)) - (& (>= z 0x0E40) (<= z 0x0E45)) - (& (>= z 0x0E47) (<= z 0x0E4E)))) + ;; Only Thai characters should be replaced. + (& (>= y 0x0E01) (<= y 0x0E5B)) + (& (>= z 0x0E01) (<= z 0x0E5B))) ;; replace(y -> z) - (delete @-) - (delete @-) - (insert z) - (set y z)) + (delete @-2) + (insert z)) ;; else ;; reject(z) (1 - (delete @-)) + (delete @-1)) ;; endif ))) @@ -256,9 +239,13 @@ The correction algorithm follows the one shown in the following )))) - ;; Commit the preedit chars as soon as fixed. - (set w @-) + ;; Now we commit the preedit chars that are fixed. + (set w @-1) (cond + ;; If surrounding text is supported, commit the only char in preedit. + ((> @-0 -2) + (commit)) + ;; If the last char is CTRL or NON, we can commit everything. ((| (& (>= w 0x0000) (<= w 0x0E00)) (= w 0x0E2F) @@ -267,18 +254,33 @@ The correction algorithm follows the one shown in the following (>= w 0x0E4F)) (commit)) - ;; If the last char is CONS, LV, FV2 or FV3, we can commit + ;; If the last char is CONS, we can commit everything but the last + ;; unless the second last is FV3. + ((| (& (>= w 0x0E01) (<= w 0x0E23)) + (= w 0x0E25) + (& (>= w 0x0E27) (<= w 0x0E2E))) + (cond + ((| (= @-2 0x0E24) (= @-2 0x0E26)) + ; not commit yet + ) + (1 + (delete @-1) + (commit) + (insert w)))) + + ;; If the last char is LV, FV2 or FV3, we can commit ;; everything but the last. - ((| (& (>= w 0x0E01) (<= w 0x0E2E)) - (& (>= w 0x0E40) (<= w 0x0E45))) - (delete @-) + ((| (& (>= w 0x0E40) (<= w 0x0E45)) + (= w 0x0E24) + (= w 0x0E26)) + (delete @-1) (commit) (insert w)) ;; If the last char is FV1 (excluding AM) and ... ((| (= w 0x0E30) (= w 0x0E32)) - (delete @-) - (set v @-) + (delete @-1) + (set v @-1) (cond ;; ... the before last is CONS, we can commit other than the @@ -286,7 +288,7 @@ The correction algorithm follows the one shown in the following ((| (& (>= v 0x0E01) (<= v 0x0E23)) (= v 0x0E25) (& (>= v 0x0E27) (<= v 0x0E2E))) - (delete @-) + (delete @-1) (commit) (insert v) (insert w)) @@ -296,120 +298,9 @@ The correction algorithm follows the one shown in the following (1 (commit) (insert w)))) - ))) - - ;; with surrounding text - (st - (map - ;; z = next character - (set z @-) - ;; y = previous character - (set y @-1) - ;; x = character previous to y - (set x @-2) - - (set arg1 y) - (set arg2 z) - (cp) - (cond - ((= ret 1)) ;; CP(y,z) succeeded. - (1 - (ac) - (cond - ((= ret 1)) ;; AC(y,z) succeeded. - (1 - ;; WTT-based input sequence correction starts here. - - ;; begin - ;; if CP(x,z) then - (set arg1 x) - (set arg2 z) - (cp) - (cond - ((= ret 1) - - ;; if CP(z,y) then - (set arg1 z) - (set arg2 y) - (cp) - (cond - ((= ret 1) - - ;; reorder(y -> zy) - (delete @-) - (delete @-1) - (insert z) - (insert y)) - - ;; elif CP(x,y) then - (1 - (set arg1 x) - (set arg2 y) - (cp) - (cond - ((= ret 1) - - ;; replace(y -> z) - (delete @-) - (delete @-1) - (insert z)) - - ;; elif y is FV1 and z is TONE then - ((& (| (= y 0x0E30) (= y 0x0E32) (= y 0x0E33)) - (>= z 0x0E48) - (<= z 0x0E4B)) - - ;; reorder(y -> zy) - (delete @-) - (delete @-1) - (insert z) - (insert y)) - - ;; else - ;; reject(z) - (1 - (delete @-)) - - ;;endif - )))) - - ;; elif AC(x,z) then - (1 - (set arg1 x) - (set arg2 z) - (ac) - (cond - ((& (= ret 1) - ;; CTRL, NON and CONS should not be replaced. - (| (= y 0x0E24) - (= y 0x0E26) - (& (>= y 0x0E30) (<= y 0x0E3A)) - (& (>= y 0x0E40) (<= y 0x0E45)) - (& (>= y 0x0E47) (<= y 0x0E4E))) - (| (= z 0x0E24) - (= z 0x0E26) - (& (>= z 0x0E30) (<= z 0x0E3A)) - (& (>= z 0x0E40) (<= z 0x0E45)) - (& (>= z 0x0E47) (<= z 0x0E4E)))) - - ;; replace(y -> z) - (delete @-) - (delete @-1) - (insert z)) - - ;; else - ;; reject(z) - (1 - (delete @-)) - - ;; endif - ))) - ;; end - - )))) - (commit) - ))) + )))) ;; Local Variables: +;; coding: utf-8 ;; mode: emacs-lisp ;; End: