blog

Source files for chris.bracken.jp
git clone https://git.bracken.jp/blog.git
Log | Files | Refs | Submodules | README | LICENSE

2011-04-22-installing-mozc-on-ubuntu.md (5678B)


      1 +++
      2 title = "Installing Mozc on Ubuntu"
      3 date = "2011-04-22T00:00:00Z"
      4 slug = "installing-mozc-on-ubuntu"
      5 tags = ["Howto", "Japanese", "Linux", "Software"]
      6 +++
      7 
      8 If you're a Japanese speaker, one of the first things you do when you install a
      9 fresh Linux distribution is to install a decent [Japanese IME][wiki_ime].
     10 Ubuntu defaults to [Anthy][anthy], but I personally prefer [Mozc][mozc], and
     11 that's what I'm going to show you how to install here.
     12 
     13 *Update (2011-05-01):* Found an older [video tutorial][yt_tutorial] on YouTube
     14 which provides an alternative (and potentially more comprehensive) solution for
     15 Japanese support on 10.10 using ibus instead of uim, which is the better choice
     16 for newer releases.
     17 
     18 *Update (2011-10-25):* The software installation part of this process got a
     19 whole lot easier in Ubuntu releases after Natty, and as noted above, I'd
     20 recommend sticking with ibus over uim.
     21 
     22 ### Japanese Input Basics
     23 
     24 Before we get going, let's understand a bit about how Japanese input works on
     25 computers. Japanese comprises three main character sets: the two phonetic
     26 character sets, hiragana and katakana at 50 characters each, plus many
     27 thousands of Kanji, each with multiple readings. Clearly a full keyboard is
     28 impractical, so a mapping is required.
     29 
     30 Input happens in two steps. First, you input the text phonetically, then you
     31 convert it to a mix of kanji and kana.
     32 
     33 {{< figure src="/post/2011-04-22-henkan.png"
     34     alt="Japanese IME completion menu" >}}
     35 
     36 Over the years, two main mechanisms evolved to input kana. The first was common
     37 on old *wapuro*, and assigns a kana to each key on the keyboard—e.g. where
     38 the *A* key appears on a QWERTY keyboard, you'll find a ち. This is how our
     39 grandparents hacked out articles for the local *shinbun*, but I suspect only a
     40 few die-hard traditionalists still do this. The second and more common method
     41 is literal [transliteration of roman characters into kana][wiki_wapuro]. You
     42 type *fujisan* and out comes ふじさん.
     43 
     44 Once the phonetic kana have been input, you execute a conversion step wherein
     45 the input is transformed into the appropriate mix of kanji and kana. Given the
     46 large number of homonyms in Japanese, this step often involves disambiguating
     47 your input by selecting the intended kanji. For example, the *mita* in *eiga wo
     48 mita* (I watched a movie) is properly rendered as 観た whereas the *mita* in
     49 *kuruma wo mita* (I saw a car) should be 見た, and in neither case is it *mita*
     50 as in the place name *Mita-bashi* (Mita bridge) which is written 三田.
     51 
     52 
     53 ### Some Implementation Details
     54 
     55 Let's look at implementation. There are two main components used in inputting
     56 Japanese text:
     57 
     58 The GUI system (e.g. ibus, uim) is responsible for:
     59 
     60 1. Maintaining and switching the current input mode:
     61    ローマ字、ひらがな、カタカナ、半額カタカナ.
     62 1. Transliteration of character input into kana: *ku* into く,
     63    *nekko* into ねっこ, *xtu* into っ.
     64 1. Managing the text under edit (the underlined stuff) and the
     65    drop-down list of transliterations.
     66 1. Ancillary functions such as supplying a GUI for custom dictionary
     67    management, kanji lookup by radical, etc.
     68 
     69 The transliteration engine (e.g. Anthy, Mozc) is responsible for transforming a
     70 piece of input text, usually in kana form, into kanji: for example みる into
     71 one of: 見る、観る、診る、視る. This involves:
     72 
     73 1. Breaking the input phrase into components.
     74 1. Transforming each component into the appropriate best guess based on context
     75    and historical input.
     76 1. Supplying alternative transformations in case the best guess was incorrect.
     77 
     78 
     79 ### Why Mozc?
     80 
     81 TL;DR: because it's better. Have a look at the conversion list up at the top of
     82 this post. The input is *kinou*, for which there are two main conversion
     83 candidates: 機能 (feature) and 昨日 (yesterday). Notice however, that it also
     84 supplies several conversions for yesterday's date in various formats, including
     85 「平成23年4月21日」 using [Japanese Era Name][wiki_jp_era] rather than the
     86 Western notation 2011. This is just one small improvement among dozens of
     87 clever tricks it performs. If you're thinking this bears an uncanny resemblance
     88 to tricks that [Google's Japanese IME][google_ime] supports, you're right: Mozc
     89 originated from the same codebase.
     90 
     91 
     92 ### Switching to Mozc
     93 
     94 So let's assume you're now convinced to abandon Anthy and switch to Mozc.
     95 You'll need to make some changes. Here are the steps:
     96 
     97 If you haven't yet done so, install some Japanese fonts from either Software
     98 Centre or Synaptic. I'd recommend grabbing the *ttf-takao* package.
     99 
    100 Next up, we'll install and configure Mozc.
    101 
    102 1. **Install ibus-mozc:** `sudo apt-get install ibus-mozc`
    103 1. **Restart the ibus daemon:** `/usr/bin/ibus-daemon --xim -r -d`
    104 1. **Set your input method to mozc:**
    105    1. Open *Keyboard Input Methods* settings.
    106    1. Select the *Input Method* tab.
    107    1. From the *Select an input method* drop-down, select Japanese, then mozc from
    108       the sub-menu.
    109    1. Select *Japanese - Anthy* from the list, if it appears there, and click
    110       *Remove*.
    111 1. **Optionally, remove Anthy from your system:** `sudo apt-get autoremove anthy`
    112 
    113 Log out, and back in. You should see an input method menu in the menu
    114 bar at the top of the screen.
    115 
    116 That's it, Mozcを楽しんでください!
    117 
    118 [anthy]: https://sourceforge.jp/projects/anthy/news/
    119 [google_ime]: https://www.google.com/intl/ja/ime/
    120 [mozc]: https://code.google.com/p/mozc/
    121 [wiki_ime]: https://en.wikipedia.org/wiki/Japanese_IME
    122 [wiki_jp_era]: https://en.wikipedia.org/wiki/Japanese_era_name
    123 [wiki_wapuro]: https://en.wikipedia.org/wiki/Wapuro
    124 [yt_tutorial]: https://www.youtube.com/watch?v=MfgjTCXZ2-s