[Freewnn-users 307] Re: FreeWnn のクライアントを作成のもんだい

Back to archive index

ishikawa ishik****@yk*****
2018年 4月 5日 (木) 21:05:31 JST


Dear Alex,

It is very encouraging to know that someone is hacking FreeWnn by building a
client for it today (!).

[I have been using Wnn for more than20 years now. Once I used commercial
Omron Wnn server and client, but
nowadays I use FreeWnn under linux]

As a sample of client, have you looked at the source code of kinput2-wnn ?
kinput2 is a frontend used for input under X Windows.
I input Japanese characters to mozilla firefox and thunderbird using this
frontend, kinput2-wnn-V3.1.

But, wait, I found that somehow kinput2-wnn does NOT seem to use jl_add_dict
directly.
Come to think of it, adding dictionary seems to be done by the server
side... (Correct me if I am wrong.)
However, kinput2-wnn does take an argument to an environment setting using
its option -wnnenvrc4 as follows:
(FreeWnn is basically Wnn4 and thus -wnnenvrc4. Commercial omron Wnn has
progressed much and there v6, v7, v8, etc.

Under linux that uses FreeWnn (wnn4) I see the following script of my own:

$KINPUT2PROG -jserver localhost \
    -wnnenvrc4 /usr/share/wnn/ja_JP/wnnenvrc \
    -ccdef /etc/kinput2/ccdef.kinput2.egg.NEW \
     -xim

/usr/share/wnn/ja_JP/wnnenvrc includes lines such as follows to specify the
use of dictionary files (and its frequency/hindo files), tec.

confirm1
setfuzokugo pubdic/full.fzk
setdic pubdic/kihon.dic        usr/@USR/kihon.h    5 1 0 - - 0
setdic pubdic/setsuji.dic    usr/@USR/setsuji.h    5 1 0 - - 0
setdic pubdic/koyuu.dic        usr/@USR/koyuu.h    1 1 0 - - 0
setdic pubdic/chimei.dic    usr/@USR/chimei.h    1 1 0 - - 0
setdic pubdic/jinmei.dic    usr/@USR/jinmei.h    1 1 0 - - 0
setdic pubdic/special.dic    usr/@USR/special.h    5 1 0 - - 0
setdic pubdic/computer.dic    usr/@USR/computer.h    5 1 0 - - 0
setdic pubdic/symbol.dic    usr/@USR/symbol.h    1 1 0 - - 0
setdic pubdic/tankan.dic    -            1 1 1 - - 0
setdic pubdic/bio.dic        usr/@USR/bio.h        1 1 0 - - 0
setdic gerodic/g-jinmei.dic     usr/@USR/g-jinmei.h     1 1 0 - - 0
setdic usr/@USR/ud        -            5 0 0 - - 0


and setup for the detailed parameter setting of conversion algorithm.


;;       N nsho hindo len jiri flag jisho sbn dbn_len sbn_cnt suuji kana
eisuu kigou toji_kakko fuzokogo kaikakko
;setparam 2 10   2     40  100  200  20    1   40      -40     40    -100
40    80    40         100      40
; New Parameter
setparam 2 10   2     45  100  200  5     1   40      -100    200   -100
200   80    200        200      200


So maybe the client needs to call a different API to set up dictionary other
than jl_add_dict.

Actually, I have found out that
kinput2-wnn-V3.1 has this call after reading the above environment file.
./lib/wnnlib.c:    (void)jl_set_env_wnnrc(wnnenv, rcfile, confirm, errmsg);

jcOpen2() calls this part and jcOpen2() is there to talk to either v4 or v6
Wnn server. (Wnn4 or Wnn6).
The protocol is different and so client needs to figure out which version
should be used when it talks to the server.

So maybe the handling of the dictionary is better done by jl_set_env_wnnrc().

I think reading kinput2-wnn file might be a better resource than reading umm
source file since at least kinput2-wnn has been in wide use until about a
dozen years ago and there are still some diehard users like me.
(However, I use jserver by means of Japanese input mode of GNU emacs much
more often (a mode called egg exists. Unfortunately there is now a different
package with the same name. Also, I don't hack kinput2-wnn-v3.1 code unless
there is a portability/compilation issue between OS upgrades, 32bit-64bit
migration, etc. So my knowledge of the source file is rather scarce.
Probably you know more about uum code than I do at all.)

Welcome to freewnn and its clients, Alex.

At the same time, I am curious why you want to build a new client rather
than using existing clients such as kinput2-wnn.  You are going to use this
for Japanese input, correct?

Best Regards,
Chiaki Ishikawa


Question to Japanese readers.
日本語読者への質問:
kinput2-wnn は 直接 jl_add_dict
を呼んでないみたいなのですが、ひょっとするとこれはサーバー側だけで実行されるものなのでしょうかね?

  
On 2018年04月04日 22:51, Alex Taylor wrote:
> 皆さん、こんにちは。
>
> (まず、私が書いている不成功な日本語、申し訳ございません。それで、English  
> follows below.)
>
> 私は FreeWnn (jserver) につながる IME  
> プログラムを作成したいです。しかし、少し迷っています...
>
> 私が書いていたテストプログラムは jl_open()  
> でサーバーにつながることができますが、それから環境に辞書を設定することでどうするか分かりません。
>
> 他のセションから uum でつながている場合、作動します  
> (辞書がすべてちゃんと設定したからです)。でも、uum  
> がつながっていない時は、私が書いていたテストプログラムは辞書を何も使えません。はっきりに何かすることが必要なんですが、何か分かりません。
>
> このコードに対して
>      dics = jl_dic_list( bdata, &pdics );
> uum が他のセションからつながっている時、 dics == 12  
> (そして変更のファンクションが当たります)。
>
> しかし uum とかがつながっていない時、その結果は dics == 0。
>
> この形:
>      jl_dic_add( bdata, "pubdic/kihon.dic", "usr/alex/kihon.h", 0, 5, 0, 1,  
> NULL, NULL, WNN_CREATE, hnd_msg );
> を使ってみましたが、NG です。:(
>
> jserver のログに:
> Apr/03/2018:17:00:08 client=root: JS_ENV_EXIST(7): cur_clp = 0
> Apr/03/2018:17:00:08 client=root: JS_CONNECT(5): cur_clp = 0
> Apr/03/2018:17:00:08 client=root: new_env: Created , alex env_id=0
> Apr/03/2018:17:00:08 client=root: JS_DIC_LIST(36): cur_clp = 0
> Apr/03/2018:17:00:08 client=root: JS_ACCESS(82): cur_clp = 0
> Apr/03/2018:17:00:08 client=root: JS_FILE_READ(97): cur_clp = 0
> Apr/03/2018:17:00:08 client=root: JS_ACCESS(82): cur_clp = 0
> Apr/03/2018:17:00:08 client=root: JS_FILE_READ(97): cur_clp = 0
> Apr/03/2018:17:00:08 client=root: JS_DIC_ADD(33): cur_clp = 0
> Apr/03/2018:17:00:08 client=root: dic_add: eid=0,fid=1,hfid=13
> Apr/03/2018:17:00:08 client=root: Error パスワードが間違っています。(94):  
> cur_clp = 0
>
> 上紀のエラーは、頻度ファイルもう存在の時です。ファイルが無い場合、メッセージ200または203がクライアントセションに出ますが、ファイルは作成されません。
>
> ...ともかくに、これは学習用ないで難しいと思います。FreeWnn  
> のクライアントを作成する方法の説明が、どこか書いてありますか?  
> サンプルプログラムとかもありますか? (実は uum  
> が勉強するために複雑すぎます...)
>
> 参照目的で:
> Main C file:  http://altsan.org/programming/testwnn.c
> Full source:  http://altsan.org/programming/testwnn1.zip
> (Tested on both Linux Mint x86 (Cinnamon) and OS/2 v4.5.)
>
>
> I'll repeat in English because my Japanese ability is poor... 
>
> Hello everyone,
>
> I'm hoping to write an IME program using FreeWnn (jserver).  Unfortunately,  
> I find myself a bit lost.
>
> I've written a test program which can connect to the server using  
> jl_open().  However, I'm not sure what to do next with regard to setting up  
> dictionaries for the environment.
>
> Now, if I connect to the same server with uum in another session, my test  
> program works fine (because all the dictionaries are set up already).  
> However, when uum is not running, my test program has no dictionaries  
> available.  Obviously, there is something I need to do in order to set up  
> the dictionaries in the environment, but I don't know what.
>
> With this code:
>      dics = jl_dic_list( bdata, &pdics );
> when uum is running simultaneously, 'dics' is 12 (and doing a conversion  
> subsequently works fine).
>
> However, if uum is not also running, the result is that 'dics' equals 0.
>
> Trying to use code like:
>      jl_dic_add( bdata, "pubdic/kihon.dic", "usr/alex/kihon.h", 0, 5, 0, 1,  
> NULL, NULL, WNN_CREATE, hnd_msg );
> is also no good.  :(  I get error messages about passwords or other things  
> if the frequency files exist (see the jserver log excerpt I posted above);  
> if the files don't yet exist, nothing happens except a lot of messages 200  
> and 203.
>
> Overall, I think that this project is going to be very difficult without  
> any tutorial. Is there some kind of guide or explanation about writing a  
> FreeWnn client?  Are there any good sample programs for learning from?  (To  
> be honest, uum is much too complicated and difficult to follow for  
> practical learning material.) 
>
> I have the function reference man pages from 2.libwnn (although my Japanese  
> reading ability is not great), but they don't provide context or  
> explanations about how things fit together...
>
> よろしくお願いします。
> Thanks,
>




freewnn-users メーリングリストの案内
Back to archive index