Skip to content

Instantly share code, notes, and snippets.

@Yoxem
Created April 16, 2020 13:40
Show Gist options
  • Save Yoxem/571632af2c69a55ae700491337d0f6bc to your computer and use it in GitHub Desktop.
Save Yoxem/571632af2c69a55ae700491337d0f6bc to your computer and use it in GitHub Desktop.
Test m17n-input method-table
-test.mim
;; zh-pinyin.mim -- Input method for Chinese Pinyin characters
;; Copyright (C) 2004, 2005
;; National Institute of Advanced Industrial Science and Technology (AIST)
;; Registration Number H15PRO112
;; This file is part of the m17n database; a sub-part of the m17n
;; library.
;; The m17n library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public License
;; as published by the Free Software Foundation; either version 2.1 of
;; the License, or (at your option) any later version.
;; The m17n library is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; Lesser General Public License for more details.
;; You should have received a copy of the GNU Lesser General Public
;; License along with the m17n library; if not, write to the Free
;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
(input-method nan poj-test)
(description "test")
(map
(consonants ;; onset n,m excluded
("b" "b") ("c" "c") ("g" "g") ("h" "h") ("j" "j") ("k" "k")
("l" "l") ("p" "p") ("s" "s") ("t" "t")
("B" "B") ("C" "C") ("G" "G") ("H" "H") ("J" "J") ("K" "K")
("L" "L") ("P" "P") ("S" "S") ("T" "T")
)
; non-poj alphabet
(non-poj
("d" "d") ("f" "f") ("q" "q") ("r" "r") ("v" "v")
("w" "w") ("x" "x") ("y" "y") ("z" "z")
("D" "D") ("F" "F") ("Q" "Q") ("R" "R") ("V" "V")
("W" "W") ("X" "X") ("Y" "Y") ("Z" "Z")
)
;including nasal small n
(vowel
("a" "a") ("e" "e") ("i" "i") ("o" "o") ("u" "u")
("A" "A") ("E" "E") ("I" "I") ("O" "O") ("U" "U")
("ou" "o͘") ("OU" "O͘") ("Ou" "O͘")
("nn" "ⁿ") ("NN" "ⁿ") ("Nn" "ⁿ")
)
(alnum ;; alpha_num
("a" ?a) ("b" ?b) ("c" ?c) ("d" ?d) ("e" ?e) ("f" ?f) ("g" ?g)
("h" ?h) ("i" ?i) ("j" ?j) ("k" ?k) ("l" ?l) ("m" ?m) ("n" ?n)
("o" ?o) ("p" ?p) ("q" ?q) ("r" ?r) ("s" ?s) ("t" ?t) ("u" ?u)
("v" ?v) ("w" ?w) ("x" ?x) ("y" ?y) ("z" ?z)
("A" ?A) ("B" ?B) ("C" ?C) ("D" ?D) ("E" ?E) ("F" ?F) ("G" ?G)
("H" ?H) ("I" ?I) ("J" ?J) ("K" ?K) ("L" ?L) ("M" ?M) ("N" ?N)
("O" ?O) ("P" ?P) ("Q" ?Q) ("R" ?R) ("S" ?S) ("T" ?T) ("U" ?U)
("V" ?V) ("W" ?W) ("X" ?X) ("Y" ?Y) ("Z" ?Z)
("0" ?0) ("1" ?1) ("2" ?2) ("3" ?3) ("4" ?4)
("5" ?5) ("6" ?6) ("7" ?7) ("8" ?8) ("9" ?9))
)
(state
(init
; OC-n: ith Onset consonant
(set OC-1t 0)(set OC-2 0)(set OC-3 0)
(set onset-count 0)
(consonants
(set onset-count (+ onset-count 1))
(set OC-3 OC-2)(set OC-2 OC-1)(set OC-1 @-1) ; refreshing OC-n var
(cond
((= onset-count 2)
; CH,PH,TH,KH
(cond
((& (|(= OC-2 ?C) (= OC-2 ?c)) (|(= @-1 ?H)(= OC-1 ?h))) (shift C-Vowel))
((& (|(= OC-2 ?P) (= OC-2 ?p)) (|(= @-1 ?H)(= OC-1 ?h))) (shift C-Vowel))
((& (|(= OC-2 ?T) (= OC-2 ?t)) (|(= @-1 ?H)(= OC-1 ?h))) (shift C-Vowel))
((& (|(= OC-2 ?K) (= OC-2 ?k)) (|(= @-1 ?H)(= OC-1 ?h))) (shift C-Vowel))
(1 (shift escape))))
((= onset-count 3) ; CHH
(cond
((&(& (|(= OC-3 ?C) (= OC-3 ?c))
(|(= OC-2 ?H) (= OC-2 ?h)))
(|(= OC-1 ?H) (= OC-1 ?h)))
(shift C-Vowel))
(1 (shift escape))
)
)
((> onset-count 4)(shift escape))
(1 (shift C-vowel))
)
)
(vowel (insert "test"))
(non-poj (shift escape))
)
(C-vowel
(set a 40)
(vowel (insert "C-VOWEL")
(shift init))
)
;; Non-poj mode
(escape
"en"
(set onset-count 0)
(set OC-1t 0)(set OC-2 0)(set OC-3 0)
(alnum (commit))
(nil (state init))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment