分享

Linux系统常用输入法框架

 算法与编程之美 2020-08-08

1 前言

之前使用的一直都是ibus-sunpinyin中文输入法,但在使用的过程中发现很多的词组都找不到,比较麻烦,所以打算换一下ibus-googlepinyin输入法,还没用,也不知道具体的效果怎么样?不过之前windows系统中用的都是google-pinyin,一直以来都还是比较相信google的服务。本文将从一次安装ibus-googlepinyin拼音输入法的实践入手,探讨常用的输入法框架有哪些,并做一简单的介绍。

2 ibus-googlepinyin安装

由于google官方未提供直接的rpm或其他的直接安装方式,所以只能自己编译源码然后安装。由于源码使用的是cmake进行项目管理的,所以我们需要先确定系统是否已经安装cmake。

(1) 安装编译工具cmake

[gschen@gschen ~]$ cmake -version cmake version 2.8.10.2

如果未安装cmake,可通过下述命令进行安装:

[gschen@gschen ~]$ sudo yum install -y cmake

cmake的编译工具安装完成以后,接下来就可以源码编译google拼音输入法了。

(2) 安装libgooglepinyin

先获得libgooglepinyin源码,https://code.google.com/p/libgooglepinyin/downloads/list从下载列表中,下载libgooglepinyin-0.1.*.tar.bz2,接着依次执行下面命令:

tar -jxvf libgooglepinyin-0.1.*.tar.bz2 mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=/usr make sudo make install

(3) 安装ibus-googlepinyin

同样也是从步骤1中的下载列表中下载ibus-googlepinyin-0.1.*.tar.bz2,接着

tar -jxvf ibus-googlepinyin-0.1.*.tar.bz2 mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=/usr make sudo make install

(4) 重启ibus

在ibus preferences中添加google拼音,至此安装完成,接下来就可以使用googlepinyin了。

3 输入法框架

首先我们来了解一下常用的输入法框架有哪些?

3.1 scim

scim全称是Smart Common Input Method

wikipedia对它的解释是:

The Smart Common Input Method platform (SCIM) is an input method (IM) platform containing support for more than thirty languages (CJK and many European languages) for POSIX-style operating systems including Linux and BSD. It uses a clear architecture and provides a simple and powerful programming interface, which is meant to reduce the time required for developing individual IMs.

scmi是一个输入法平台,在类posix的操作系统如linux和bsd中,它支持至少30种语言。它有一个非常清晰的架构,使用了一个简单但非常强大的编程接口,该接口为我们开发自己的输入法大大的节省了时间。

3.2 fcitx

首先我们来看一下官方是如何描述fcitx的:

Fcitx [ˈfaɪtɪks] is an input method framework with extension support. Currently it supports Linux and Unix systems like freebsd. It has three built-in Input Method Engine, Pinyin, QuWei and Table-based input methods.

fcitx一个支持扩展的输入法框架。目前它支持linux和unix系统如freebsd。它有三个内置的输入法引擎,分别是拼音输入法, 区位输入法和table-based输入法。

3.3 ibus 

ibus的全称是intelligent input bus

同样我们也首先来看一下wikipedia是如何描述的:

The Intelligent Input Bus (IBus, pronounced as I-Bus) is an input method (IM) framework for multilingual input in Unix-like operating systems. It's called "Bus" because it has a bus-like architecture.

ibus是在类unix操作系统中是一个为了多语言输入的输入法框架,之所以叫做"bus”原因在于它是一个总线型的架构。


ibus架构

 

 <上图引用自http://2008./static/upload/event_file/ibus-GNOME.pdf>

ibus是基于c/s的架构:

  • 他有一个ibus-daemon的后台进程,管理所有的客户端;

  • 所有的engines,panel,config modules和IM(Input Method) clients都是ibus-daemon的客户端;

  • ibus是基于dbus ipc协议的。


 <上图引用自http://2008./static/upload/event_file/ibus-GNOME.pdf>

ibus的优势在于:

  • ibus使用dbus rpc进行通信,客户端可以使用任何一种语言去呵ibus交互;

  • ibus-daemon, engines, clients&UI这些所有的都运行在独立的进程中。

4 结论

本文主要介绍了在linux系统中如何安装ibus-googlepinyin中文输入法,在成功安装google拼音输入法之后,并对目前常用的输入法框架做了简单的介绍。

5 参考文献

[1] http://en./wiki/Smart_Common_Input_Method

[2] https://wiki./index.php/IBus

[3] http://2008./static/upload/event_file/ibus-GNOME.pdf

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多