2006/03/29

SCIM上設定嘸蝦米

依據下列的文章才順利把嘸蝦米設定成功:
http://www.suse.idv.tw/viewtopic.php?t=379
首先把嘸蝦米的big5 table 砍頭砍尾成:
a 對
aa 寸
aaa 鑫
...
]]v ︼
]]v ︾
然後把原有的嘸蝦米的big5 table 轉成utf8:
piconv -f big5 -t utf8 < liu5.big5 > liu5.utf8

給 scim 的table 依該文的範本製作,
但到了嘸蝦米的 table 需像:
a 對 100
aa 寸 100
aaa 鑫 100
aaa 龘 99
aab 鎯 100

用以下很簡陋的perl程式就順利轉成:

%index = ();
open(F,'liu5.utf8');
while() {
chomp;
my($code,$word) = split (' ',$_);
$index{$code}++;
my $tmp = 101 - $index{$code};
print "$code $word $tmp\n";
}
close(F);

然後依其指示完成。
倒是其中的liu.png不知何處有現成的?
用gimp自製的圖總是會超過1K,
搞不定小小圖的問題。

-------------------
我弄過這個,過程有放在我的網頁裡,不過我的網站目前不一定都有上線。
網頁在 www.starjou.idv.tw/ 裡 SuSE筆記 的 中文輸入 那部份。
內容我把它剪過來,斷章取義可能有的地方不太通,參考參考吧:
(不過我現在都用 gcin 了,很久沒試 SCIM 了說)

要加入嘸蝦米到 SCIM 中,需要有嘸蝦米的對照表格,另外再下載 SCIM table file 的 source file scim-tables-0.4.0.tar.gz,取一個裡面的輸入法對照表 (例如 scim-tables-0.4.0/zh/Jyutping.txt.in) 然後拿它的檔頭跟嘸蝦米的字根對照內容,做成嘸蝦米的對照表。
我修改過的檔頭如下:
### File header must not be modified
### This file must be encoded into UTF-8.
### This file comes from xcin module.
SCIM_Generic_Table_Phrase_Library_TEXT
VERSION_1_0

### Begin Table definition.
BEGIN_DEFINITION

### An unique id to distinguish this table among others.
### Use uuidgen to generate this kind of id.
UUID = 3d872a7a-760e-400c-8b23-688d38390e81

### A unique number indicates the version of this file.
### For example the last modified date of this file.
### This number must be less than 2^32.
SERIAL_NUMBER = 20040922

ICON = /usr/share/scim/icons/liu5.png

### The default name of this table
NAME = Liu5

### The local names of this table
NAME.zh_CN = 嘸蝦米
NAME.zh_TW = 嘸蝦米
NAME.zh_HK = 嘸蝦米

### Supported languages of this table
LANGUAGES = zh_TW,zh_HK,zh_CN,zh_SG

### Prompt string to be displayed in the status area.
STATUS_PROMPT = 中

### If true then the first candidate phrase
### will be selected automatically during inputing.
AUTO_SELECT = FALSE

### If true then a multi wildcard will be appended
### at the end of inputing string automatically.
AUTO_WILDCARD = TRUE

### If true then the result string will be committed to client automatically.
### This should be used with AUTO_SELECT = TRUE.
AUTO_COMMIT = FALSE

### If true then the inputed string will be automatically splitted during inputing.
AUTO_SPLIT = TRUE

### If true then the phrases' frequencies will be adjusted dynamically.
DYNAMIC_ADJUST = TRUE

### If true then the preedit area will be filled up by the current candidate phrase automatically.
AUTO_FILL = FALSE

### If true then the lookup table will always be shown if there is any candidate phrase.
### Otherwise the lookup table won't be shown unless the user requires it by moving the preedit caret left.
ALWAYS_SHOW_LOOKUP = TRUE

### Use full width punctuation by default
DEF_FULL_WIDTH_PUNCT = TRUE

### Use full width letter by default
DEF_FULL_WIDTH_LETTER = FALSE

### The maxmium length of a key.
MAX_KEY_LENGTH = 4

### Valid input chars.
VALID_INPUT_CHARS = ,.'abcdefghijklmnopqrstuvwxyz[]

### Single wildcard char, can have multiple chars.
SINGLE_WILDCARD_CHAR = ?

### Multi wildcard char.
MULTI_WILDCARD_CHAR = *

### The key strokes to split inputed string.
SPLIT_KEYS = space

### The key strokes to commit the convert result to client.
COMMIT_KEYS = space

### The key strokes to forward the inputed string to client.
FORWARD_KEYS = Return

### The key strokes to select candidiate phrases.
SELECT_KEYS = space,v,3,4,5,6,7,8,9,0

### The key strokes to page up the lookup table.
PAGE_UP_KEYS = Page_Up

### The key strokes to page down the lookup table.
PAGE_DOWN_KEYS = Page_Down,space
END_DEFINITION

### Begin Table data.
BEGIN_TABLE

底下接嘸蝦米的對照表,最後接檔尾
a 對 100
aa 寸 100
.
.
.
END_TABLE

大部份的設定等安裝完輸入法之後,到 SCIM 的設定視窗裡都還可以重新設定。在製作 table 時需要注意的只有幾個地方:

UUID = 3d872a7a-760e-400c-8b23-688d38390e81
NAME = Liu5
NAME.zh_CN = 嘸蝦米
NAME.zh_TW = 嘸蝦米
NAME.zh_HK = 嘸蝦米
VALID_INPUT_CHARS = ,.'abcdefghijklmnopqrstuvwxyz[]
SELECT_KEYS = space,v,3,4,5,6,7,8,9,0

UUID 是在 terminal 下執行 uuidgen 產生的一串字串。
VALID_INPUT_CHARS 是嘸蝦米的字根鍵。
SELECT_KEYS 可以設定選字的字根,設成 space,v 就可以保留嘸蝦米以 v 送次選字的習慣。
其它還有一些設定,可以等到安裝完之後,再到 SCIM 的設定視窗裡去更改,了解它的功能。
icon 的圖檔要自己生,如果沒有做的話,也可以到 /usr/share/scim/icons 底下借用其它輸入法的圖檔暫用一下。不然就留白了。
關於嘸蝦米字根對照的部份,它的格式跟製作 xcin 所使用 .tab 檔的 source .cin 檔格式稍有不同,.txt 中的字根跟對照字是用 tab 隔開的,.cin 中是用空白,再則 .cin 中可以在一行中以一個字根對應幾個字,如
deev 旦 曜
但是在 .txt 中則要分成兩行
deev 旦 100
deev 曜 99
而且 .txt 中每個字根後面都會有代表選字順序的數字。如果一個字根只對應一個字,該數字就是 100,如果有兩個,就分別是 100、99,依此類推。
所以如果沒有現成的嘸蝦米 for SCIM 的 .txt 檔的話,自行製作可能會花不少工夫,或是需要自己寫個處理的小程式轉換。
.txt 檔準備好之後,在 terminal 下執行 scim-make-table 將 .txt 轉成 .bin,命令格式如下:
$ scim-make-table liu.txt -b -o liu.bin
-b 指定輸出二進位檔,-o 指定輸出的檔名,執行 scim-make-table 不加任何參數就會顯示這些參數的說明。
產生 .bin 檔之後,再到 SCIM 的設定視窗中的 泛用對照表->管理對照表 安裝嘸蝦米,然後重新啟動 SCIM,就有嘸蝦米用了。
重新啟動 SCIM 需要手動 kill 掉蕉的 SCIM 執行緒,再重新執行 scim -d。
目前還有一些小問題就是如果拆錯碼 SCIM 不會自動清除拆字區的錯誤拆碼,另外雖然改變選字鍵,讓 v 可以上次選字,不過這跟嘸蝦米的 v 上次選字略有不同,傳統的嘸蝦米按了 v 之後還要再按 space 再上字,SCIM 則是按了 v 之後直接上字(因為其實它的 v 就等於在選字列按了 2),這些小地方比較不習慣,拆錯碼要自己 按 esc 取消,然後用 v 選字時常會在文件中多打一個空白。不知道 SCIM 中的設定是否有地方可以調整?
_________________
Linux 菜鳥周星星使用 SuSE 9.1 全紀錄
http://www.starjou.idv.tw/suse.php

0 Comments:

Post a Comment

<< Home