Uim を使って日本語を入力

提供: ArchWiki
2010年8月14日 (土) 14:14時点におけるimported>Tettsyunによる版 (→‎インストール)
ナビゲーションに移動 検索に移動

テンプレート:I18n

この記事あるいはセクションは翻訳の途中です。
ノート: please use the first argument of the template to provide more detailed indications. (議論: トーク:Uim を使って日本語を入力#)

このページは uim を使った日本語入力の方法について説明します。
もしあなたがSCIMを使っているなら、Smart Common Input Method platform を参照して下さい。

インストール

日本語入力を行うためには、次のパッケージが必要です。

  • 日本語フォント
  • 日本語入力システム (かな漢字変換エンジン): このページでは AnthyMozc について説明します。
  • 入力メソッドフレームワーク: uim

日本語フォント

詳細については Fonts を参照して下さい。

推奨される日本語フォントは以下の通りです。

高品質で無償で利用できるアウトラインフォント。ゴシック体 (サンセリフ体) や明朝体 (セリフ体) グリフを含む。openSUSE の日本語ロケールの標準フォント。
IPAフォントの派生フォント。IPAフォントの問題を修正している。Ubuntu 日本語ローカライズ版 の日本語標準フォント。
Debian、Fedora、Vine Linux などの日本語環境で採用されている標準フォント。
Mandriva Linux 日本語環境の標準フォント。

2ちゃんねるの Shift JIS アート を適切に表示したい場合、次のいずれかのフォントを使うと良いでしょう:

uim

pacman を使う

Pull down the necessary things with a :

# pacman -S uim

PKGBUILD を使ってソースから uim をコンパイル

For instance, in the case of the followings, you should compile from source:

  • Arch repo's package is out-of-date: It's frequently sometimes out-of-date :P
  • You want to use Anthy(UTF-8): As of uim 1.5.7, Anthy(UTF-8) support is disabled by default (default text encoding is EUC-JP).
  • You use KDE and want to use uim-qt-tools: All tools for Qt are disabled by default.

The one of the easy way to build from source is using ABS.
First, install ABS:

# pacman -S abs

Update ABS:

# abs

Then, copy uim's directory to under your $HOME. For example:

$ cp -R /var/abs/extra/uim ~/sources/

Next, edit テンプレート:Filename. Typical build options are as follows:

Enable Anthy(UTF-8) support
Do not build gnome-applet. You can drop gnome-panel from makedepends (also optdepends).
Build uim-tools for Qt (needs Qt)
Build UimQt (Qt immodule support) for Qt4 (needs Qt)

Here is a sample of custom PKGBUILD for enable anthy-utf8 support, disable gnome-applet and supports to invert the color of mode icons (see below) based on uim 1.5.7 in extra.

## You can invert the color of mode icons by uncommenting below line. This is useful for darker theme.
#_icon4darker=yes

pkgname=uim-custom
_pkgname=uim
pkgver=1.5.7
pkgrel=1
pkgdesc="Multilingual input method library"
arch=('i686' 'x86_64')
url="http://code.google.com/p/uim/"
license=('custom')
depends=('m17n-lib' 'ncurses' 'gtk2')
#makedepends=('gnome-panel' 'pkgconfig' 'gettext' 'intltool')
makedepends=('pkgconfig' 'gettext' 'intltool')
#optdepends=('gnome-panel: for using the GNOME applet')
options=('!libtool')
provides=('uim')
conflicts=('uim')
install=uim.install
source=(http://uim.googlecode.com/files/${_pkgname}-${pkgver}.tar.bz2)
md5sums=('b84a43fb92d7ceb4bd801a76120c2a71')

if [[ "$_icon4darker" = "yes" ]]; then
  makedepends=(${makedepends[@]} imagemagick)
  _modify_icons=(
          direct_input.png
          ja_direct.png
          ja_fullwidth_alnum.png
          ja_halfkana.png
          ja_halfwidth_alnum.png
          ja_hiragana.png
          ja_katakana.png
          unknown.png
  )
fi

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}"

  # invert the color of mode icons for darker theme
  if [[ "$_icon4darker" = "yes" ]]; then
    cd pixmaps
    for _icon in ${_modify_icons[@]}
    do
      convert -negate $_icon tmp.${_icon} || return 1
      mv -f tmp.${_icon} $_icon
    done
    cd -
  fi

  ./configure --prefix=/usr --libexecdir=/usr/lib/uim \
              --with-anthy-utf8 \
              --disable-gnome-applet \
              || return 1
  make || return 1
}

package() {
  cd "${srcdir}/${_pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install || return 1
  install -D -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}

Finally, run makepkg under uim directory to make and install package:

$ makepkg -s -i

日本語入力システム

Anthy

Anthy is one of the most popular Japanese input method in open source world. Though it is not maintained for a long time, Debian succeeds it from May 2010.

To install Anthy :

# pacman -S anthy

Modified Anthy

Modified Anthy is a set of patches and huge extended dictionaries which aims to improve the Kana-Kanji conversion quality of original Anthy.

警告: Modified Anthy applies to only Anthy (UTF-8). So you have to build uim with "テンプレート:Codeline".
警告: Modified Anthy does not have compatibility of the dictionaries and learning data with original Anthy.

PKGBUILD を使って Modified Anthy をコンパイル

Modified Anthy consists two different sources:

  • Patched source of Anthy by G-HAL
  • Huge extended dictionalies by UTSUMI

The G-HAL patches allows only hand-operated download so you have to get by yourself from here. As of 2010-07-05, latest stable version archive is:

anthy-9100h.patch13B-23-iconv-ucdict.2010629.alt-depgraph-100603d.alt-cannadic-100603-patch100628.zipdic-201005-patch100614.tar.lzma

Search and get it (or newer archive) from the page.

Here is a sample of the PKGBUILD:

ノート: The both upstreams do not retain older versions. Please check latest archives each by yourself.
pkgname=modified-anthy
_pkgname=anthy
pkgver=20100710
_pkgver=9100h
_ghalarc="anthy-9100h.patch13B-23-iconv-ucdict.2010629.alt-depgraph-100603d.alt-cannadic-100603-patch100628.zipdic-201005-patch100614.tar.lzma"
_utver=20100710
pkgrel=1
pkgdesc="Hiragana text to Kana Kanji mixed text Japanese input method"
arch=("i686" "x86_64")
url="http://sourceforge.jp/projects/anthy/"
license=('LGPL' 'GPL')
depends=('glibc')
options=('!libtool' 'force')
provides=("anthy=${_pkgver}")
conflicts=('anthy')
source=(${_ghalarc}
        "http://downloads.sourceforge.net/project/mdk-ut/30-source/source/anthy-ut-patches-${_utver}.tar.bz2")
md5sums=('6be18e8ef5fec087ead4b6ebf798219b'
        'd7321adeaed49dda8b06407c64c91973')

build() {

  cd ${srcdir}

  tar xvf $_ghalarc --lzma

  cd ${srcdir}/${_pkgname}-${_pkgver}

  # UTSUMI dictionalies and patches
  cat anthy-conf.in ${srcdir}/anthy-ut-patches-${_utver}/ghal-patch/conf > anthy-conf.in.new || return 1
  mv -f anthy-conf.in.new anthy-conf.in

  cp -f ${srcdir}/anthy-ut-patches-${_utver}/dictionaries/*         alt-cannadic/
  cp -f ${srcdir}/anthy-ut-patches-${_utver}/zipcode/zipcode.t      mkworddic/
  cp -f ${srcdir}/anthy-ut-patches-${_utver}/mkworddic/dict.args.in mkworddic/dict.args.in

  mkdir -p doc-ut
  cp -f ${srcdir}/anthy-ut-patches-${_utver}/AUTHORS \
        ${srcdir}/anthy-ut-patches-${_utver}/ChangeLog.* \
        ${srcdir}/anthy-ut-patches-${_utver}/README* \
        ${srcdir}/anthy-ut-patches-${_utver}/THANKS \
        doc-ut
  autoreconf -fiv || return 1

  ./configure --prefix=/usr --sysconfdir=/etc || return 1
  make EMACS=emacs sysconfdir=/etc || return 1
}

package() {
  cd ${srcdir}/${_pkgname}-${_pkgver}
  make EMACS=emacs DESTDIR=$pkgdir install || return 1
}

Finally, run makepkg to make and install package:

$ makepkg -s -i

If you have already used original Anthy, you have to convert the existing learning data format.

$ rm ~/.anthy/last-record1_*.bin
$ anthy-agent --update-base-record
$ rm ~/.anthy/last-record1_*.bin
$ anthy-agent --update-base-record

(Though this step repeats the same commands twice, it is not mistypes.)

Mozc

Mozc (on AUR) is a Japanese open source input method originates from Google Japanese Input. It is considered that it has better conversion quality than Anthy as for multi segments conversion (e.g. one sentence) in a lump but the dictionary is not so sufficient. Though Mozc adapts to only ibus and scim input method framework, macuim provides uim-mozc plugin and you can use it with テンプレート:Package AUR on AUR.

PKGBUILD を使って Mozc をコンパイル (uim から Mozc を使う)

First, you get mozc-svn tarball from AUR (or use AUR tools like yaourt) and edit the PKGBUILD to enable uim-mozc. That is, uncomment テンプレート:Codeline line and you can comment out テンプレート:Codeline line to disable ibus module if unnecessary:

## You can choose the input method framework to use either ibus, uim or both.
## If you will be not using ibus, comment out below.
#_ibus_mozc="yes"
## If you will be using uim, uncomment below.
_uim_mozc="yes"
## If you will be using scim, uncomment below.
#_scim_mozc="yes"

日本の郵便番号辞書の構築 (オプション)

mozc-svn can import Japanese zip code by Japan Post as dictionary seed.

To add zip code dictionary, edit the following lines in PKGBUILD:

## You can add Japanese zip code provided by Japan Post.
## If you want to use it, uncomment below.
_zipcode="yes"

ビルド、インストール

Next, build and install:

$ makepkg -s -i

Finally, register Mozc on uim.

# uim-module-manager --register mozc

When you have uninstalled Mozc, unregister it from uim.

# uim-module-manager --unregister mozc

設定

Add the followings to ~/.xprofile, ~/.xinitrc or ~/.xsession:

環境変数

export GTK_IM_MODULE='uim'
export QT_IM_MODULE='uim'
uim-xim &
export XMODIFIERS=@im='uim'

ツールバーユーティリティ

If you want to use UimToolbar utilities which shows and controls uim mode, add one of the followings too.

uim-toolbar-gtk/qt

Using toolbar appears as a window:

uim-toolbar-gtk &

or if you built テンプレート:Codeline, you can add:

uim-toolbar-qt &

uim-toolbar-gtk-systray

Using toolbar for system tray:

uim-toolbar-gtk-systray &

パネルアプレット

Or, if you use GNOME, KDE or Xfce, you can use uim-toolbar panel applet (Xfce requires xfce4-xfapplet-plugin to use uim-applet-gnome and KDE requires to buid uim with テンプレート:Codeline).

uim の外観

Configure uim preferences by running :

$ uim-pref-gtk

which brings forth a GUI.
Choose テンプレート:Codeline, テンプレート:Codeline or テンプレート:Codeline for 'Default input method'.

ノート: Mozc will be not listed in 'Default input method' at first time so you will need to add it into 'Enabled input methods' to use.


You can run テンプレート:Codeline or restart X to test your settings.
Provided everything went well you should be able to input Japanese in X.

Emacs で uim を使う

uim provides uim.el the bridge software between Emacs and uim.

マイナーモードで使うための設定

Here is a sample to use uim with utf-8 encoding. Add the following into your テンプレート:Filename or some other file for Emacs customizing.

;; read uim.el
(require 'uim)
;; uncomment next and comment out previous to load uim.el on-demand
;; (autoload 'uim-mode "uim" nil t)

;; key-binding for activate uim (ex. C-\)
(global-set-key "\C-\\" 'uim-mode)

;; Set UTF-8 as preferred character encoding (default is euc-jp).
(setq uim-lang-code-alist
      (cons '("Japanese" "Japanese" utf-8 "UTF-8")
           (delete (assoc "Japanese" uim-lang-code-alist) 
                   uim-lang-code-alist)))

;; Set Hiragana input mode at activating uim with anthy (utf-8).
;(setq uim-default-im-prop '("action_anthy_utf8_hiragana"))
;; Set Hiragana input mode at activating uim with mozc.
;(setq uim-default-im-prop '("action_mozc_hiragana"))

Please see Official wiki for more detail.

You may need to add the following to disable xim on Emacs into your テンプレート:Filenames or テンプレート:Filename.

Emacs.UseXIM: false

トラブルシューティング

Cannot input Japanese on Opera

Opera で日本語入力ができない

If you use Opera and cannot input Japanese with uim, try to edit environment variable as follows:

export QT_IM_MODULE='xim'

uim-toolbar-gtk-systray: トレイアイコンがクラッシュする

uim-toolbar-gtk-systray isn't compliant with freedesktop.org system tray specs so some icons are shown in one icon space by default. Choose just one of them to solve it. The steps to display only 'Input mode' icon for example as follows:

  1. Run テンプレート:Codeline.
  2. Click 'Toolbar' on 'Group' list.
  3. Take the all checkmarks off.
  4. Click 'Anthy', 'Anthy (UTF-8)' or 'Mozc' which you are using on 'Group' list.
  5. Click Edit button in 'Toolbar' box -> 'Enable toolbar buttons' line.
  6. Enable only 'Input mode' and click 'Close' button.
  7. Click 'OK' button to close uim-pref-gtk.

The tray icon will be displayed "あ" (Hiragana mode) or "ー" (Direct mode).

暗いテーマを使用しているので uim モードのアイコンが見えません

Modify icons in accordance with your theme (e.g. invert the colors). The icons which should be modified will be as follows:

There is a sample PKGBUILD to apply it. See above.

関連文献

uim
uim official document
uim on wikibooks
Fonts
Japanese fonts showcase
modified Japanese fonts