2010年5月5日 星期三

無蝦米之ibus安裝

轉自 http://reic.twbbs.org/post/1/431

Ubuntu 已於 10月29日釋出。Ubuntu 9.10 將輸入法由 scim 轉換為 IBus (Intelligent Input Bus) ,為了先習慣後來 ubuntu 的改變,還是決定怎了解怎麼在 IBus 中安裝 嘸蝦米。在網路上查詢了一下,只有看到 Vicamo Yang 的 Boshiamy for iBus 這一篇文章比較完整,但是因為我比較懶,不想重新打包 deb 檔,所遙還是透過 ibus-table-createdb 直接來完成。

這一次筆者手邊有 Liu7 和 Liu57b,當然最直接的方法還是說到說 Liu7 是否有提供相對應的下載,於是到官網去找了一下,竟然沒有看到 cin 可以下載,所以還是從 Liu57b 的 cin 檔開始好了。而我手邊剛好有已經整理好的 For scim使用的 scim檔(詳見此篇 、 或 此篇)。所以整理的 cin 檔的工作在此篇就不再詳述了。

本次在 IBus 安裝嘸蝦米的工作大概分成三個部分:

  1. 整理字碼表
  2. 建立符合 IBus 的轉換檔
  3. 產生 db 檔,安裝

整理字碼表
此步驟為建立符合 IBus 的字碼格式,所以取得 scim 中已建立好的 Liu.txt檔。一口氣取出字碼部分,並加上權重的設定。

awk '/BEGIN\_TABLE/{f=1;next}/END\_TABLE/{exit}f' Liu.txt |awk '{count[$1]++}{print $1"\t"$2"\t"101-count[$1]}' > liu_ibus.txt

如果你想要手動的看看 IBUS,利用文字編輯軟體移除檔案開始-->BEGIN_TABLE 中的所有內容 和 檔尾的 END_TABLE 。然後透過下述指令整理好內容:

cat Liu.txt | awk '{print $1"\t"$2"\t100"}' > liu_ibus.txt
cat Liu.txt | awk '{counter[$1]++} END {} {print $1"\t"$2"\t"101-counter[$1]}' > liu_ibus.txt
感謝 太魯閣被車載回來 的指點了這麼一個酷的用法,如果你已經做好了權重都是 100 的 liu_ibus_final.txt 也不用再重來一次
mv liu_ibus_final.txt liu_ibus_old.txt; cat liu_ibus_old.txt |awk '{if($3==100){count[$1]++;print $1"\t"$2"\t"$3+1-count[$1]}else{print $0}}' > liu_ibus_final.txt

建立符合 IBus 的轉換檔

我已經移除掉一些說明註解,如果想要看更清楚的說明,可以參考Vicamo Yang 的 Boshiamy for iBus 所提供的內容。如果懶的去一一修改,可以直接取用下述的內容。

### File header must not be modified
### This file must be encoded into UTF-8.
### This table under LGPL
### comments start with ### not single #
### Derive from the format of SCIM Table, so you can modify the table from
### scim-tables' table
SCIM_Generic_Table_Phrase_Library_TEXT
VERSION_1_0

### Begin Table definition.
BEGIN_DEFINITION
LICENSE = LGPL
UUID = 702d9641-a51b-4688-b4a2-8e8b8fe579cf
SERIAL_NUMBER = 20090709

ICON = liu5.png
NAME = liu5
NAME.zh_TW = 嘸蝦米
DESCRIPTION = Boshiamy Input Method
LANGUAGES = zh_TW
AUTHOR = Boshiamy Corp. Reic Wang
STATUS_PROMPT = TW
VALID_INPUT_CHARS = ,.'abcdefghijklmnopqrstuvwxyz[]
LAYOUT = us
MAX_KEY_LENGTH = 5
AUTO_COMMIT = FALSE

DEF_FULL_WIDTH_PUNCT = FALSE
DEF_FULL_WIDTH_LETTER = FALSE

USER_CAN_DEFINE_PHRASE = TRUE

PINYIN_MODE = TRUE

# 2009/11/26 更新,建議將此選項關閉,否則會動態調整 frequency ,會讓打字變的很不習慣
DYNAMIC_ADJUST = FALSE

END_DEFINITION

### Begin Table data.
### Format of every line whose formated in "input_keys\tphrase\tfreq\n" is an
### entry.
### From left to right, the 1st column are the input key combination that you
### entered via keyboard; the 2nd column are presented character or phrase of
### the key combination you want; the 3rd column are frequency of the character
### or phrase.

BEGIN_TABLE
END_TABLE

將在上一個部分已建好的 liu_ibus.txt的內容,貼至 BEGIN_TABLE 和 END_TABLE 間,並將之命名為 liu_ibus_final.txt。即完成此部分。

產生 db 檔,安裝

再來的步驟就比較容易了。產生db檔:

ibus-table-createdb -s liu_ibus_final.txt -n liu5.db
cp liu5.db /usr/share/ibus-table/tables/
cp liu5.png /usr/share/ibus-table/icons/

重新啟動 IBus 即可以在 漢語 中找到嘸蝦米輸入法了。

沒有留言: