Linux 常用工具之 Rime

Rime 中州韵输入法引擎,是一个跨平台的输入法算法框架。

Ubuntu 安装 ibus-rime

安装 ibus-rime

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
huzhifeng@Ubuntu16041:~$ sudo apt-get install -y ibus-rime
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libboost-chrono1.58.0 libboost-regex1.58.0 libboost-thread1.58.0 libgflags2v5 libgoogle-glog0v5 libkyotocabinet16v5 libmarisa0 libopencc1 librime-bin librime-data librime-data-cangjie5
librime-data-luna-pinyin librime1 libyaml-cpp0.5v5
Suggested packages:
librime-data-bopomofo librime-data-combo-pinyin librime-data-double-pinyin librime-data-ipa-xsampa librime-data-jyutping librime-data-pinyin-simp librime-data-quick5 librime-data-scj6
librime-data-stenotype librime-data-stroke librime-data-terra-pinyin librime-data-sampheng librime-data-wubi librime-data-wugniu librime-data-zyenpheng
The following NEW packages will be installed:
ibus-rime libboost-chrono1.58.0 libboost-regex1.58.0 libboost-thread1.58.0 libgflags2v5 libgoogle-glog0v5 libkyotocabinet16v5 libmarisa0 libopencc1 librime-bin librime-data librime-data-cangjie5
librime-data-luna-pinyin librime1 libyaml-cpp0.5v5
0 upgraded, 15 newly installed, 0 to remove and 182 not upgraded.
Need to get 12.9 MB of archives.
huzhifeng@Ubuntu16041:~$ dpkg-query --listfiles ibus-rime
/.
/usr
/usr/share
/usr/share/ibus
/usr/share/ibus/component
/usr/share/ibus/component/rime.xml
/usr/share/ibus-rime
/usr/share/ibus-rime/icons
/usr/share/ibus-rime/icons/disabled.png
/usr/share/ibus-rime/icons/abc.png
/usr/share/ibus-rime/icons/zh.png
/usr/share/ibus-rime/icons/sync.png
/usr/share/ibus-rime/icons/reload.png
/usr/share/ibus-rime/icons/keyboard.png
/usr/share/ibus-rime/icons/rime.png
/usr/share/ibus-rime/icons/pen.png
/usr/share/doc
/usr/share/doc/ibus-rime
/usr/share/doc/ibus-rime/README
/usr/share/doc/ibus-rime/copyright
/usr/share/doc/ibus-rime/changelog.Debian.gz
/usr/lib
/usr/lib/ibus-rime
/usr/lib/ibus-rime/ibus-engine-rime
huzhifeng@Ubuntu16041:~$

重启 ibus 服务

添加输入法之前需要重启ibus服务

1
huzhifeng@Ubuntu16041:~$ ibus restart

添加rime输入法

打开系统设置进入System Settings->Keyboard->Typing->Text Entry,点击加号+,添加输入法Chinese (Rime) (IBus)
然后记得勾选左下方的Show current input source in the menu bar,这样就能在桌面右上角看到输入法图标了,可以选择进行输入法切换。

配置文件 ~/.config/ibus/rime/

有兴趣的可以参考
Ubuntu 16.04 安装 Rime 输入法

1
2
3
4
5
huzhifeng@Ubuntu16041:~$ ls ~/.config/ibus/rime/
cangjie5_express.prism.bin cangjie5.schema.yaml installation.yaml luna_pinyin.prism.bin luna_pinyin_simp.prism.bin luna_pinyin_tw.prism.bin luna_pinyin.userdb.kct.wal
cangjie5.prism.bin cangjie5.table.bin luna_pinyin_fluency.prism.bin luna_pinyin.reverse.bin luna_pinyin_simp.schema.yaml luna_pinyin_tw.schema.yaml symbols.yaml
cangjie5.reverse.bin default.yaml luna_pinyin_fluency.schema.yaml luna_pinyin.schema.yaml luna_pinyin.table.bin luna_pinyin.userdb.kct user.yaml
huzhifeng@Ubuntu16041:~$

CentOS 安装 ibus-rime

参考 Manual Installation

下载源代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[huzhifeng@CentOS72 ~]$ mkdir rime
[huzhifeng@CentOS72 ~]$ cd rime/
[huzhifeng@CentOS72 rime]$ wget http://dl.bintray.com/lotem/rime/ibus-rime-1.2.tar.gz
[huzhifeng@CentOS72 rime]$ wget http://dl.bintray.com/lotem/rime/librime-1.2.tar.gz
[huzhifeng@CentOS72 rime]$ wget http://dl.bintray.com/lotem/rime/brise-0.35.tar.gz
[huzhifeng@CentOS72 rime]$ ls -lh *.gz
-rw-rw-r--. 1 huzhifeng huzhifeng 6.4M Jul 20 2014 brise-0.35.tar.gz
-rw-rw-r--. 1 huzhifeng huzhifeng 33K Jul 20 2014 ibus-rime-1.2.tar.gz
-rw-rw-r--. 1 huzhifeng huzhifeng 5.0M Jul 20 2014 librime-1.2.tar.gz
[huzhifeng@CentOS72 rime]$ md5sum *.gz
d0c7844796474b7a5f99a0d789213215 brise-0.35.tar.gz
88a9c79d5f2ad88ee6718c577e558e62 ibus-rime-1.2.tar.gz
b2900d3595058a4014cd8184e9f3f3fc librime-1.2.tar.gz
[huzhifeng@CentOS72 rime]$ tar -xzf librime-1.2.tar.gz
[huzhifeng@CentOS72 rime]$ tar -xzf brise-0.35.tar.gz
[huzhifeng@CentOS72 rime]$ tar -xzf ibus-rime-1.2.tar.gz

安装依赖包

官方Wiki上的依赖并不全,导致编译经常遇到各种错误,
Prerequisites

1
2
3
4
5
6
7
8
9
10
11
12
13
To build la rime, you need these tools and libraries:
cmake
boost >= 1.46
glog (for librime>=0.9.3)
gtest (optional, recommended for developers)
libibus-1.0
libnotify (for ibus-rime>=0.9.2)
kyotocabinet (for librime<=1.2)
leveldb (for librime>=1.3, replacing kyotocabinet)
libmarisa (for librime>=1.2)
opencc 0.x
yaml-cpp >= 0.5

以下是经过整理后编译OK的依赖包,有些必须通过 EPEL 安装,分别是:”cmake boost boost-devel glog glog-devel gtest ibus-libs ibus-devel libnotify libnotify-devel kyotocabinet kyotocabinet-devel leveldb marisa marisa-devel opencc opencc-devel yaml-cpp yaml-cpp-devel gflags-devel”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[huzhifeng@CentOS72 rime]$ sudo yum groupinstall "Development Tools"
[huzhifeng@CentOS72 rime]$ sudo yum install cmake boost boost-devel glog glog-devel gtest ibus-libs ibus-devel libnotify libnotify-devel kyotocabinet kyotocabinet-devel leveldb marisa marisa-devel opencc opencc-devel yaml-cpp yaml-cpp-devel gflags-devel
[huzhifeng@CentOS72 ibus-rime]$ rpm -q cmake boost boost-devel glog glog-devel gtest ibus-libs ibus-devel libnotify libnotify-devel kyotocabinet kyotocabinet-devel leveldb marisa marisa-devel opencc opencc-devel yaml-cpp yaml-cpp-devel gflags-devel | grep not
package glog is not installed
package glog-devel is not installed
package gtest is not installed
libnotify-0.7.5-8.el7.x86_64
libnotify-devel-0.7.5-8.el7.x86_64
package kyotocabinet is not installed
package kyotocabinet-devel is not installed
package leveldb is not installed
package yaml-cpp is not installed
package yaml-cpp-devel is not installed
package gflags-devel is not installed
[huzhifeng@CentOS72 ibus-rime]$ sudo yum install epel-release
[huzhifeng@CentOS72 rime]$ sudo yum install cmake boost boost-devel glog glog-devel gtest ibus-libs ibus-devel libnotify libnotify-devel kyotocabinet kyotocabinet-devel leveldb marisa marisa-devel opencc opencc-devel yaml-cpp yaml-cpp-devel gflags-devel

编译安装

编译过程中运行”rime_deployer –build /home/huzhifeng/rime/brise/data”时会提示找不到动态库”librime.so.1”,实际已存在,执行”sudo ldconfig”后解决。
为了防止该问题,可以提前修改 Makefile,改动如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[huzhifeng@CentOS72 rime]$ cp brise/Makefile /tmp/Makefile.orig
[huzhifeng@CentOS72 rime]$ vim brise/Makefile
[huzhifeng@CentOS72 rime]$ diff -Nurp /tmp/Makefile.orig brise/Makefile
--- /tmp/Makefile.orig 2017-02-12 17:20:18.589166216 +0800
+++ brise/Makefile 2017-02-12 17:20:46.343483106 +0800
@@ -18,6 +18,7 @@ all:
@cp symbols.yaml ${DATA}
@cp preset/*.yaml ${DATA}
@cp supplement/*.yaml ${DATA}
+ sudo ldconfig
rime_deployer --build ${DATA}
# deprecated
[huzhifeng@CentOS72 rime]$

然后进入目录 ibus-rime 执行 install.sh 开始编译

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[huzhifeng@CentOS72 rime]$ cd ibus-rime/
[huzhifeng@CentOS72 ibus-rime]$ cat install.sh
#!/bin/bash
if [ ! -e librime -a -e ../librime ]; then ln -s ../librime; fi
if [ ! -e brise -a -e ../brise ]; then ln -s ../brise; fi
(cd librime; make && sudo make install) || exit 1
(cd brise; make && sudo make install) || exit 1
make clean && make && sudo make install || exit 1
if [ "$1" == '--restart' ]; then
ibus-daemon -drx
fi
[huzhifeng@CentOS72 ibus-rime]$ ./install.sh
install -m 755 -d /usr/share/ibus/component
install -m 644 -t /usr/share/ibus/component/ rime.xml
install -m 755 -d /usr/lib/ibus-rime
install -m 755 -t /usr/lib/ibus-rime/ build/ibus-engine-rime
install -m 755 -d /usr/share/ibus-rime
install -m 755 -d /usr/share/ibus-rime/icons
install -m 644 -t /usr/share/ibus-rime/icons/ icons/*.png
[huzhifeng@CentOS72 ibus-rime]$

测试

在添加rime输入法之前,需要重启ibus,否则rime输入法不会出现在添加列表里。

1
[huzhifeng@CentOS72 ibus-rime]$ ibus restart

进入”All Settings->Region & Language->Input Sources”,点击”+”号,选择”Chinese (China)”,再选择”Chinese (Rime)”即可。

其它系统安装 Rime

Windows

小狼毫 0.9.30

Mac OS X

鼠须管 0.9.26.2

Android

同文安卓输入法平台

参考

Rime
RimeWithIBus#ubuntu
如何在 Ubuntu 16.04 上使用預設的 ibus 中文輸入法
下载及安装
推荐一个神级输入法——Rime

EOF