Re: TIM - A Table-base Input Method Module

From: Hideki Hiura (hiura@sun.com)
Date: Mon Jul 22 2002 - 05:50:02 EDT


> From: Arthit Suriyawongkul <Arthit.Suriyawongkul@sun.com>
> anybody here interesting in this Table-based Input Method ?
> http://sourceforge.net/projects/wenju/
> i've got this site from gtk-i18n-list.

I have not looked at this one yet, but you may also want to take a look at
IIIMF(http://www.li18nux.org/subgroup/im/IIIMF) which has something similar,
called ude(user defined engine) as a table based IM.
Also recently, XML based IM, EIMIL(Extensible IM interface Language) is
ntroduced to IIIMF, which you can combine the table based IM, the
portable XML based logics, and backend dictionay lookup server.

You can retrive the source of this as follows;

cvs -d -d:pserver:anonymous@cvs.li18nux.org:/cvsroot co -r exp-EIMIL-1 im-sdk

The following is the sample XML based IM definition, which you can
find in im-sdk/server/programs/language_engines/canna.

This sample shows how you can combine those table/logic and backend
dictionary lookup server(in this case, Japanese Canna dictionary
lookup server).

-------------------------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE ccdef PUBLIC "-//Li18nux//DTD CCDEF 1.0//EN"
                "ccdef.dtd">

<ccdef name="default" class="org.li18nux.CannaLE" revision="0.1">
  <interface>
    <langinfo xml:lang="ja"></langinfo>
    <decldata name="edittext" type="mtext"/>
    <declop name="convert">
      <dependency depend="edittext" affect="edittext">
    </declop>
    <declop name="fixate">
      <dependency depend="edittext" affect="edittext">
    </declop>
  </interface>
  <engine name="ja-romakana" class="com.sun.iiim.pce1.s1">
    <PCE>
      <deftable name="romakana" from="mtext" to="mtext">
        "a" "$B$"(B"
        "i" "$B$$(B"
        "u" "$B$&(B"
        "e" "$B$((B"
        "o" "$B$*(B"

        "xa" "$B$!(B"
        "xi" "$B$#(B"
        "xu" "$B$%(B"
        "xe" "$B$'(B"
        "xo" "$B$)(B"

        "ka" "$B$+(B"
        "ki" "$B$-(B"
        "ku" "$B$/(B"
        "ke" "$B$1(B"
        "ko" "$B$3(B"

        "kya" "$B$-$c(B"
        "kyi" "$B$-$#(B"
        "kyu" "$B$-$e(B"
        "kye" "$B$-$'(B"
        "kyo" "$B$-$g(B"

        "ga" "$B$,(B"
        "gi" "$B$.(B"
        "gu" "$B$0(B"
        "ge" "$B$2(B"
        "go" "$B$4(B"

        "gya" "$B$.$c(B"
        "gyi" "$B$.$#(B"
        "gyu" "$B$.$e(B"
        "gye" "$B$.$'(B"
        "gyo" "$B$.$g(B"

        "sa" "$B$5(B"
        "si" "$B$7(B"
        "su" "$B$9(B"
        "se" "$B$;(B"
        "so" "$B$=(B"

        "sha" "$B$7$c(B"
        "shi" "$B$7(B"
        "shu" "$B$7$e(B"
        "she" "$B$7$'(B"
        "sho" "$B$7$g(B"

        "sya" "$B$7$c(B"
        "syi" "$B$7$#(B"
        "syu" "$B$7$e(B"
        "sye" "$B$7$'(B"
        "syo" "$B$7$g(B"

        "za" "$B$6(B"
        "zi" "$B$8(B"
        "zu" "$B$:(B"
        "ze" "$B$<(B"
        "zo" "$B$>(B"

        "ja" "$B$8$c(B"
        "ji" "$B$8(B"
        "ju" "$B$8$e(B"
        "je" "$B$8$'(B"
        "jo" "$B$8$g(B"

        "zya" "$B$8$c(B"
        "zyi" "$B$8$#(B"
        "zyu" "$B$8$e(B"
        "zye" "$B$8$'(B"
        "zyo" "$B$8$g(B"

        "ta" "$B$?(B"
        "ti" "$B$A(B"
        "tu" "$B$D(B"
        "te" "$B$F(B"
        "to" "$B$H(B"

        "cha" "$B$A$c(B"
        "chi" "$B$A(B"
        "chu" "$B$A$e(B"
        "che" "$B$A$'(B"
        "cho" "$B$A$g(B"

        "tya" "$B$A$c(B"
        "tyi" "$B$A$#(B"
        "tyu" "$B$A$e(B"
        "tye" "$B$A$'(B"
        "tyo" "$B$A$g(B"

        "da" "$B$@(B"
        "di" "$B$B(B"
        "du" "$B$E(B"
        "de" "$B$G(B"
        "do" "$B$I(B"

        "dha" "$B$G$c(B"
        "dhi" "$B$G$#(B"
        "dhu" "$B$G$e(B"
        "dhe" "$B$G$'(B"
        "dho" "$B$G$g(B"

        "dya" "$B$B$c(B"
        "dyi" "$B$B$#(B"
        "dyu" "$B$B$e(B"
        "dye" "$B$B$'(B"
        "dyo" "$B$B$g(B"

        "na" "$B$J(B"
        "ni" "$B$K(B"
        "nu" "$B$L(B"
        "ne" "$B$M(B"
        "no" "$B$N(B"

        "nya" "$B$K$c(B"
        "nyi" "$B$K$#(B"
        "nyu" "$B$K$e(B"
        "nye" "$B$K$'(B"
        "nyo" "$B$K$g(B"

        "ha" "$B$O(B"
        "hi" "$B$R(B"
        "hu" "$B$U(B"
        "he" "$B$X(B"
        "ho" "$B$[(B"

        "fa" "$B$U$!(B"
        "fi" "$B$U$#(B"
        "fu" "$B$U(B"
        "fe" "$B$U$'(B"
        "fo" "$B$U$)(B"

        "hya" "$B$R$c(B"
        "hyi" "$B$R$#(B"
        "hyu" "$B$R$e(B"
        "hye" "$B$R$'(B"
        "hyo" "$B$R$g(B"

        "ba" "$B$P(B"
        "bi" "$B$S(B"
        "bu" "$B$V(B"
        "be" "$B$Y(B"
        "bo" "$B$\(B"

        "bya" "$B$S$c(B"
        "byi" "$B$S$#(B"
        "byu" "$B$S$e(B"
        "bye" "$B$S$'(B"
        "byo" "$B$S$g(B"

        "pa" "$B$Q(B"
        "pi" "$B$T(B"
        "pu" "$B$W(B"
        "pe" "$B$Z(B"
        "po" "$B$](B"

        "pya" "$B$T$c(B"
        "pyi" "$B$T$#(B"
        "pyu" "$B$T$e(B"
        "pye" "$B$T$'(B"
        "pyo" "$B$T$g(B"

        "ma" "$B$^(B"
        "mi" "$B$_(B"
        "mu" "$B$`(B"
        "me" "$B$a(B"
        "mo" "$B$b(B"

        "mya" "$B$_$c(B"
        "myi" "$B$_$#(B"
        "myu" "$B$_$e(B"
        "mye" "$B$_$'(B"
        "myo" "$B$_$g(B"

        "ya" "$B$d(B"
        "yu" "$B$f(B"
        "yo" "$B$h(B"

        "ra" "$B$i(B"
        "ri" "$B$j(B"
        "ru" "$B$k(B"
        "re" "$B$l(B"
        "ro" "$B$m(B"

        "rya" "$B$j$c(B"
        "ryi" "$B$j$#(B"
        "ryu" "$B$j$e(B"
        "rye" "$B$j$'(B"
        "ryo" "$B$j$g(B"

        "wa" "$B$o(B"
        "wo" "$B$r(B"

        <!-- $B$s(B special rule -->
        "nb" "$B$s(Bb"
        "nc" "$B$s(Bc"
        "nd" "$B$s(Bd"
        "nf" "$B$s(Bf"
        "ng" "$B$s(Bg"
        "nh" "$B$s(Bh"
        "nj" "$B$s(Bj"
        "nk" "$B$s(Bk"
        "nl" "$B$s(Bl"
        "nm" "$B$s(Bm"
        "nn" "$B$s(B"
        "np" "$B$s(Bp"
        "nq" "$B$s(Bq"
        "nr" "$B$s(Br"
        "ns" "$B$s(Bs"
        "nt" "$B$s(Bt"
        "nv" "$B$s(Bv"
        "nw" "$B$s(Bw"
        "nx" "$B$s(Bx"
        "ny" "$B$s(By"
        "nz" "$B$s(Bz"
        "n'" "$B$s(B"

      </deftable>

      <defvar name="i" type="number"></defvar>
      <defvar name="kana" type="mtext"></defvar>
      <defvar name="sokuon" type="mtext"></defvar>
      <defun name="romatokana" type="bool" args="pos:number">
        <set v="kana"> nil </set>
        <set v="i"><sub> pos <tblkeymaxsize t="romakana"/></sub></set>
        <if><lt>i 0</lt><set v="i"> 0</set></if>

        <while> <and> <not> kana </not> <lt> i pos </lt> </and>
          <set v="kana">
            <tblref t="romakana"><substr> kanaoutput i pos </substr></tblref>
          </set>
          <set v="i"><add>i 1</add></set>
        </while>

        <if> kana
          <set v="i"><sub>i 1</sub></set>
          <!-- $B$C(B special rule -->
          <if>
            <and>
              <gt>i 0</gt>
              <ge><sub>pos i</sub>2</ge>
              <eql>
                <UCSval><strref>kanaoutput i </strref></UCSval>
                <UCSval><strref>kanaoutput <sub>i 1</sub></strref></UCSval>
              </eql>
            </and>
            <set v="sokuon"> "$B$C(B" </set>
            <set v="i"><sub>i 1</sub></set>
            <else>
              <set v="sokuon"> "" </set>
            </else>
          </if>

          <set v="kanaoutput">
            <concat>
              <!-- head -->
              <substr> kanaoutput 0 i </substr>
              sokuon
              kana
              <!-- tail -->
              <substr> kanaoutput pos </substr>
            </concat>
          </set>
          <return> t </return>
        </if>
        <return> nil </return>
      </defun>

      <defvar name="inputp" type="prop"> </defvar>
      <main>
        <!-- initialization. -->
        <if> <not> inputp </not>
          <set v="inputp"><makeprop p="feedback"/></set>
          <propadd>inputp 2</propadd>
        </if>

        <label name="replay"/>
        <select>
          <!-- return key always commit the uncomposed string. -->
          <keycase code="10">
            <commit> kanaoutput </commit>
            <set v="kanaoutput">""</set>
          </keycase>
          <keycase char="&#xD;">
            <commit> kanaoutput </commit>
            <set v="kanaoutput">""</set>
          </keycase>
          <!-- space key convert the current string. -->
          <keycase char=" ">
            <interact op="convert"/>
          </keycase>
          <default>
            <if> <evchar>curev</evchar>
              <set v="kanaoutput"><concat> kanaoutput <evchar>curev</evchar></concat></set>
              <e f="romatokana"> <strlen>kanaoutput</strlen> </e>
              <setmprop>kanaoutput inputp 0 <strlen> kanaoutput </strlen></setmprop>
              <else>
                <!-- I can't process this event -->
                <next> curev </next>
                <go to="replay"/>
              </else>
            </if>
          </default>
        </select>
      </main>
    </PCE>
  </engine>
</ccdef>
-------------------------------------------------------------------------------



This archive was generated by hypermail 2.1.2 : Mon Jul 22 2002 - 04:04:42 EDT