Archive for the ‘Japanese’ Category

Japanese Input on Fedora 14 Linux

Sunday, February 20th, 2011

Fedora 14 is the quickest and easiest Linux distribution to get Japanese input working so you can type in Japanese. Fedora uses the IBus keyboard input method system and uses the Anthy Japanese input method for the Japanese keyboard input.

This short tutorial will show you step by step how to get Japanese IME setup on Fedora 14 in a few short minutes. There is noting to install—just a few menus to navigate and you are all set up to type in Japanese.

To start, select from the top panel SystemPreferencesInput Method


On the IM Chooser – Input Method configuration screen, click the check box to Enable input method feature.

Then click the Input Method Preferences… button.

On the IBus Preferences screen, select the Input Method tab.

Press the Select an input method drop down and scroll down to select JapaneseAnthy.

Press the Add button to add Anthy as the Japanese input method.

Press the Close button on the IBus Preferences screen.

Press the Log Out button on the IM Chooser – Input Method configuration screen.

Press Log Out on the Log Out popup window to log out of Fedora.

Log back in to have the new Japanese input method changes take effect.

You will now have the IBus input method framework button on the Gnome top panel. This is the button to change input modes. Open a text editor such as gedit or some other application with a text input window.

Press the IBus input method framework button and select Japanese – Anthy.

The keyboard icon has now changed to Aち, which shows the letter A and the hiragana character chi, which probably is trying to get something close the the pronunciation of Anthy while indicating Japanese/English input modes.

You should now be able to type in Japanese.

Use the Anthy Aち button to toggle between Japanese, English, and other Japanese IME modes.

That’s it. Now you can type in Japanese, as well as quickly toggle between English and Japanese on the fly in Fedora. As an added convenience, the IBus input method remembers individual preferences per application. So if you are typing Japanese in gedit, but writing an email in English in Firefox, you can switch between the applications and IBus will give you the correct input method that you last used in that application.

Sorting in Japanese — An Unsolved Problem

Sunday, February 13th, 2011

Sorting Japanese is not only difficult—it’s an unsolved problem. This seems hard to believe if you are not familiar with the complexities of processing Japanese digitally. But what is trivially easy in English is impossible in Japanese, even with the amount of computer power we have available today.

The problem comes from the complex nature of written Japanese. Contrast it with English, which only has 26 letters: a comes before b; b comes before c; and so on. On the other hand, Japanese not only has thousands of characters, it also has four different kinds of written characters. But this is only the beginning of the difficulty. The unique nature of kanji characters and their associated pronunciations is the language feature that makes Japanese unsortable.

Let’s work our way through the complexities to understand why Japanese cannot be sorted.

A Simple Sort

Let’s do a simple sort of a list of English words. Here I have a list of characters from the video game Street Fighter.

  • Ryu
  • Ken
  • Chun Li
  • Yun

Let’s put this list through a simple sort function using PHP.

<?php
   $names = array (“Ryu”, “Ken”, “Chun-Li”, “Yun”);
   sort ($names);

   foreach ($names as $name) {
      echo “$name<br/>”;
   }
?>

Here is the result:

  • Chun Li
  • Ken
  • Ryu
  • Yun

This is the result we expect—it’s in alphabetical order. A computer can easily sort English in alphabetical order because there are simple rules. C comes before K; K comes before R; and R comes before Y. You should have learned this in the first grade.

Now let’s start looking at the complexities of Japanese, and see why sorting does not work as easily.

Multiple Character Sets

Japanese has four different character sets in the written language. Don’t worry about why there are four different types of characters, just know that there are.

  • Hiragana alphabet — ひらがな
  • Katakana alphabet — カタカナ
  • Kanji characters — 漢字
  • ABC alphabet — abc

Here is where the difficulty comes in: each character set has characters with the same pronunciations as characters in the other sets. On top of that, all four character sets are written together to form what is modern written Japanese. If you only had to deal with one character set at a time (ignoring kanji for the moment, we will get to that later), you could sort Japanese automatically just like English. Hiragana sorts just fine; katakana sorts just fine; and the ABC alphabet sorts just fine. But, in combination, it is not clear how you would sort these.

I should note that there are two different alphabetical sorting orders in Japanese. For this article I am going to use the a i u e o (あいうえお) sort order.

Sorting Settings

Now let’s look at an example of sorting mixed character sets. Again, using PHP.

<?php
   setlocale(LC_ALL, ‘jpn’);
   $settings = array (“システム”, “画面”, “Windows ファイウォール”,
      “インターネット オプション”,  “キーボード”, “メール”, “音声認識”, “管理ツール”,
      “自動更新”, “日付と時刻”, “タスク”, “プログラムの追加と削除”, “フォント”,
      “電源オプション”, “マウス”, “地域と言語オプション”, “電話とモデムのオプション”,
      “Java”, “NVIDIA”);
   sort ($settings);

   foreach ($settings as $setting) {
      echo “$setting<br/>”;
   }
?>

Here is the result.

  • Java
  • NVIDIA
  • Windows ファイアウォール
  • インターネット オプション
  • キーボード
  • システム
  • タスク
  • フォント
  • プログラムの追加と削除
  • マウス
  • メール
  • 地域と言語のオプション
  • 日付と時刻
  • 画面
  • 管理ツール
  • 自動更新
  • 電源オプション
  • 電話とモデムのオプション
  • 音声認識

Take a look at what happened with this sort. The first three strings start with characters of the alphabet, and were sorted as we expect. The next eight strings are in katakana, and they are sorted correctly according to the Japanese a i u e o sort order. The rest of the strings all start with kanji and are not sorted in any way that makes sense to a human.

So what is going on here? In this case, it seems that PHP is using the character code to determine the sort order. This works fine with alphabets like English, or even the Japanese katakana, because the character codes go in order with the sort order. But the character codes do not go in order when mixed with other character sets. In this example you can see ABC and katakana are separated. Kanji are then separated from katakana. There were no hiragana in this list but they would do the same. Sort order by character code works fine for alphabets when the alphabets are by themselves. But once you mix alphabets together, you cannot have any sensible sorting order by doing it that way.

An observant reader might have noticed what these items in our list are: Control Panel items in Windows XP. It’s clear that PHP’s sort function can’t sort this properly. But what about Windows XP Japanese edition?

Microsoft seems to have the same problem. They do alright with sorting each character set individually. But they don’t seem to be able to integrate the character sets together like a Japanese user would expect. It’s OK, I don’t expect Microsoft to be able to solve such a hard problem.

Sorting Names

Let’s look at another example to show what happens when you have all four character sets sorted together. Here we have two names, both written four different ways—using each character set: ABC alphabet, hiragana, katakana, and kanji.

Ayumi、 あゆみ、アユミ、歩美

Tanaka、たなか、タナカ、田中

It is very possible to have different people with the same name write their name in different character sets. The traditional way of writing the Japanese name of Ayumi would be written in kanji; a modern, stylish way would be to write it in hiragana, and a second generation Japanese-American might write their name in katakana or the alphabet.

Put these names into the same PHP sort function and look what happens.

<?php
   setlocale(LC_ALL, ‘jpn’);
   $names = array (“Ayumi”, “アユミ”, “あゆみ”,  “歩美”,  
   “Tanaka”, “タナカ”,  “たなか”, “田中”);
   sort ($names);

   foreach ($names as $name) {
      echo “$name<br/>”;
   }
?>

Here is the result:

  • Ayumi
  • Tanaka
  • あゆみ (Ayumi)
  • たなか (Takana)
  • アユミ (Ayumi)
  • タナカ (Tanaka)
  • 歩美 (Ayumi)
  • 田中 (Tanaka)

Within each character set Ayumi is sorted before Tanaka, which is correct for the ABC, hiragana, and katakana alphabets. The kanji pair had a 50/50 chance of being right. But as you can see, the different character sets are not integrated together. If these were all names in your phone’s contact list or your Facebook friends list, you would expect all of the Ayumis and Tanakas to be listed together.

The ABC, hiragana, and katakana alphabets can be sorted—although which character set of Ayumi gets sort preference is a whole other issue—once that preference is agreed upon, sorting can be done just as easily as English.

Kanji — The Real Problem

The real problem with sorting Japanese text is kanji. Kanji aren’t just difficult for students of Japanese to make sense of, they are literally impossible for computers to process with the same intelligence as a human. The reason for this is the following:

Kanji have multiple pronunciations, determined by the context in which it appears.

This fact keeps students up nights studying for years trying to remember how to pronounce kanji right. And it also makes our sorting problem extremely nontrivial. We sort things in language by the pronunciations. Up until now we were dealing with letters. ABC, hiragana, katakana—these are all letters which a single pronunciation. There is only one place they can go.

Kanji on the other hand all have multiple pronunciations. Some have over ten! Only from the context in which the kanji appears do you know how to pronounce it. Our simple sorting problem has now turned into a natural language processing problem.

Here is an example:

私は私立大学で勉強しています。

Here the kanji 私 is used in two different contexts. The first usage, is 私 (watashi). The second usage is part of the compound word 私立大学 (shiritsu daigaku). Using the Japanese sort order, these words should be sorted like this:

  • 私立大学 (しりつだいがく)
  • 私(わたし)

A second year Japanese student could figure this out. For a computer, this is a very difficult problem.

Here is another, more extreme example.

There are four Japanese women whose names you have to sort: Junko, Atsuko, Kiyoko, and Akiko. This does not seem difficult, until they each show you how they write their names in kanji:

  • 淳子 (Junko)
  • 淳子 (Atsuko)
  • 淳子 (Kiyoko)
  • 淳子 (Akiko)

As you can see, this is rather troublesome. This comes back to kanji having multiple pronunciations. If this was for an address book of your phone contacts for example, you would want Atsuko and Akiko listed with the A names like Ayumi and Akira. But you would not want Junko and Kiyoko listed there.

And this problem is not limited to names. Regular, everyday words also have multiple pronunciations. For example, 故郷 (ふるさと、こきょう), 上手 (じょうず、じょうて、うわて、かみて…) etc.

So how do we deal with this? They have phones and social networking Web sites in Japan with sorted contact lists, so how can we sort these words properly?

The Wrong Way – Using IME Input

First, let’s look at a good try, but failed attempt at Microsoft to try to solve this problem. What good would Excel be if you could not sort on columns and rows. Microsoft clearly understands the issue with sorting Japanese—they just didn’t think through the solution thoroughly.

What Microsoft does in Excel is to capture the input the user types to get the kanji character. For example, if you typed Junko to get 淳子, it will save that input string as meta data in the background. When it is time to sort, it sorts on the input pronunciation meta data rather than the kanji that are displayed. You can actually see what the meta data looks like in Excel 2003 if you save as XML.

You can see the kanji 淳子 is in two different rows, but the input used to get them was different, Atsuko and Junko, so those are saved as meta data to assist with sorting later on.

The problem with this approach is it doesn’t take into account of how people actually interact with computers using a Japanese IME system. Japanese input works with a dictionary of possible kanji conversions based on what has been input. But not every word or name is in that dictionary. Sometimes you have to type each kanji individually or use a totally different pronunciation to get the kanji you want to show up. This results in the wrong pronunciation being saved as meta data, and sorting will not work as expected.

This system also doesn’t work with cutting and pasting text from other sources, as well as any sort of CSV or database import, etc. This was a good try by Microsoft to solve this problem, but it just doesn’t work.

The Right Way – Ask the User

A computer simply cannot guess the correct pronunciation of kanji, even if it logs the users input, because that might not even be correct. The easiest way to solve this problem is just ask the user for the pronunciation! Most software developed in Japan uses this approach.

Let’s look at this approach done correctly: Amazon.com. Let’s look at their new user registration First, notice the fields in the English version of this screen.

Now look at the Japanese version of this screen.

As you can see, the Japanese version has an extra field. This is for the user to enter the pronunciation of their name in katakana. This way, Amazon has their name in kanji, and the correct pronunciation to go with. They can now sort their user information correctly. This is the approach that most Japanese software takes. It is an extra step, but it solves the problem.

The big takeaway from this is that you cannot just translate software, or even a Web site, and expect it to work. Something as simple as registering a new user has to be completely reworked. In the case of a simple Web site, you will need to redo not only the Web interface, but also the database back end and the code to interface with the database and Web site generation. Localizing a site into Japanese is much more complicated than other languages because of the extra functionality that is required.

While Amazon.com does do the interface and programming localization correct, they do have something on their site that isn’t localized for the Japanese audience: Their logo.

In English, the logo goes with their saying: “Everything from A to Z.” This is indicated by the arrow. But in Japan, and any other country that doesn’t use English, A and Z aren’t always the first and last letters of the alphabet. The A to Z thing works in English because the name Amazon has A and Z in it. But in other countries, they might not have any idea why there is an arrow under the Amazon logo.

Final Thoughts

Sorting in Japanese is hard. Without user input, it is impossible in some contexts to know how to sort some Japanese words. People developing and localizing software need to understand these issues. But regarding the general problem of sorting Japanese when you don’t have user input to give the pronunciation, there may not be a way to automate this until computers can understand language as well as a native Japanese person. For a computer to understand Japanese is far more complex than most other languages. You can see this first hand by using machine translation software and comparing Japanese to something like French.

I think this is an interesting problem. This goes beyond just sorting. How can you expect a machine translation program to work if it doesn’t even know the pronunciation of a word—something that can be key to understanding what that word is. I can imagine even statistical machine translation being confused, especially with names.

Japanese is an interesting language, and processing it with computers is even more interesting.

Japanese Display Menus and Messages in Windows 7

Monday, January 31st, 2011

This tutorial will show you how to get Windows 7 to display menus, icons, and messages in Japanese. This is different from Japanese input. For Japanese input please refer to the Japanese Input on Windows 7 tutorial.

There are many steps involved, but you don’t need a Windows install CD like Windows XP required. There are three main steps:

  1. Install Japanese language pack
  2. Set the display language to Japanese
  3. Set additional menus to Japanese

Install Japanese Language Pack

To get Japanese menus, first we need to download the Japanese language pack using Windows Update.

To start, press the Windows button to open the Start menu.

On the Start menu, select Control Panel.

On the Control Panel screen, select System and Security. If you don’t see this option at first, change the View by: option at the top right of the screen to Category.

On the System and Security screen, press Windows Update.

On the Windows Update screen, press Check for updates.

After a few moments, Windows Update will display the updates available for your computer. Select optional updates are available. (If you have important updates, you should also come back and update those when you are finished).

On the Select the updates you want to install screen, you should see Windows 7 Languages Packs under the Optional updates, which appears under the Important updates. Scroll down and select the Japanese Language Pack – Windows 7 optional update and press OK.

On the Windows Update screen, press Install updates to begin installing the Japanese Language Pack.

Wait a few moments while the language pack update downloads.

After the download completes, wait a few moments while the language pack update installs.

A pop window, the Install or uninstall display languages screen, will show the installation progress. As it notes, display language installation may take a long time on some computers. It took approximately 10 minutes on my Core i5 laptop.

When installation is complete, the Windows Update screen will show a successfully installed message.

Set the Display Language to Japanese

To start, press the Windows button to open the Start menu.

On the Start menu, select Control Panel.

On the Control Panel screen, under Clock, Language, and Region, select Change display language. If you don’t see this option at first, change the View by: option at the top right of the screen to Category.

On the Keyboards and Languages tab, click on the Choose a display language drop down menu. You should now have the option for Japanese, displayed as 日本語.

Select 日本語 and press OK.

You will be prompted to log off for the display language changes to take effect. Press Log off now.

Windows will log you out. Log back in as you normally do.

Windows 7 will now display menus, icons, and messages in Japanese.

Some applications, such as Internet Explorer, will automatically change to Japanese display menus. However, some applications may still be in English. You may be able to get these to display in Japanese by changing the Windows region to Japan via the Control Panel, or by changing specific settings within the application itself.

Set Additional Menus to Japanese

As you may have noticed when you logged in, the Welcome screen and message were still in English. To change this to Japanese as well do the following:

On the Start menu, select コントロール パネル (Control Panel).

On the コントロール パネル (Control Panel) screen, under 時計、言語、および地域 (Clock, Language, and Region), select キーボードまたは入力方法の変更 (Change display language). If you don’t see this option at first, change the View by: option at the top right of the screen to カテゴリ (Category).

On the 管理 (Administrative) tab, under the ようこそ画面と新しいユーザー アカウント (Welcome screen and new user accounts) area, press 設定のコピー (Copy settings).

On the ようこそ画面と新しいユーザー アカウント (Welcome screen and new user accounts) dialog box, select ようこそ画面とシステム アカウント (Welcome screen and system accounts) and 新しいユーザーアカウント (New user accounts) and press OK.

You will be prompted to reboot for the changes to take effect. Press 今すぐ再起動 (Restart now).

Windows 7 will restart. When it boots up, the start up, user log in,  and welcome screens will now be in Japanese.

That’s it. Now you have all your Windows 7 menus and messages in Japanese.

Japanese Input on Windows 7

Thursday, January 20th, 2011

Setting up Japanese input mode on Windows 7 is quick and easy compared to XP. You no longer need a Windows install CD—all of the Japanese fonts are available in the default installation.

This tutorial will show you how to get Japanese input mode set up.

To start, press the Windows button to open the Start menu.

On the Start menu, select Control Panel.

On the Control Panel screen, under Clock, Language, and Region, select Change keyboards or other input methods. If you don’t see this option at first, change the View by: option at the top right of the screen to Category.

On the Keyboards and Languages tab, press Change keyboards….

On the Text Services and Input Languages screen, press the Add… button.

On the Add Input Language screen, scroll down to Japanese (Japan) and expand Keyboard.

Select Microsoft IME.

Press OK and OK on the input language screens and you will now have the Language Bar icon in the notification area of the task bar. EN stands for English

JP stands for Japanese. In Japanese mode you can type in English or Japanese. The A signifies that you are in English mode.

Press the A and select Hiragana to switch to Japanese input. The A changes to a Hiragana .

You can also choose an option to have the language bar display in full on top of the screen.

You should now be able to type in Japanese. Try it out. できましたか?

Windows 7 has the same short cut as XP to switch between English and Japanese input while in Japanese input mode: Alt-~ (Alt + tilde).

Japanese Input on Ubuntu Linux 10.04 LTS Lucid Lynx

Tuesday, June 15th, 2010

The latest release of Ubuntu, 10.04 LTS Lucid Lynx, makes a lot of things easy in Linux. And setting up Ubuntu with a Japanese IME to type in Japanese is as easy as ever. Whether you are a student of Japanese or a native Japanese speaker, you will need to set up Ubuntu to type in Japanese if you are not on a Japanese system.

This simple tutorial will get you set up with a Japanese input method in as few steps as possible.

To start, select from the top panel SystemAdministrationLanguage Support

System - Administration - Language Support

In the Language and Text screen, press the Install / Remove Languages… button.

Language and Text Screen

In the Installed Languages screen, scroll down to Japanese and check Input methods and Extra fonts, and press Apply Changes.

Installed Languages Screen

You will be prompted for your administration password.

Administration Password

The necessary packages will start downloading.

Downloading Packages

The downloaded packages will be installed automatically.

Installing Software

A dialog box confirming the Japanese language packages have been installed will be displayed.

Install Completed

After everything is installed, the next step is the set up the keyboard input method editor.

Select from the top panel SystemAdministrationLanguage Support

In the Language and Text screen, click on the Keyboard method input system dropdown and select ibus.

ibus

Next, set up ibus by selecting from the top panel SystemPreferences IBus Preferences

IBus Preferences

You may get the following dialog box saying IBus is not started. Press Yes to start it.

Start IBus

You may also get a dialog box with the following message. Just press OK.

IBus error

On the IBus Preferences screen, go to the Input Method tab.

IBus Preferences

Press the Select an input method dropdown and select JapaneseAnthy.

Japanese - Anthy

Press Add on the IBus Preferences screen to add the Anthy Japanese input method.

Add Anthy

You should now have a little keyboard icon displayed somewhere on the right side of the top panel.

Keyboard Icon

Open a text editor like gedit. While the cursor is in the text field, press the keyboard icon in the top panel and select Japanese – Anthy.

Select Anthy

The Anthy Japanese IME toolbar will appear on your screen.

Anthy toolbar

Use the toolbar to toggle the various Japanese input modes. Now you’re ready to type Japanese in Ubuntu!

gedit with Japanese

That wasn’t very difficult. In fact, after you do it on a few machines you can get it all set up in under a few minutes.

There you go. With these steps, you can begin typing Japanese on your Ubuntu Linux system, regardless of what language the OS menus display in.


Japanese Input on Android Phones

Monday, February 15th, 2010

With the release of the first Google Android phones in Japan from NTT Docomo, there are finally phones with Google’s native Japanese keyboard input. The keyboard has been in the SDK, but it has not appeared on any handsets in the U.S. yet. I have not been able to find any information about when non-Japanese Android phones will be able to use the Japanese keyboard input.

Until there is a native Japanese keyboard input, the only usable option is the Simeji Japanese keyboard input. Simeji is a Japanese input app that lets you switch input modes on the fly between English and Japanese. It includes multiple Japanese input modes, including the standard keitai-style mode. Under the phone settings you can configure the keyboard to your preferences. I prefer the vibrate on touch option to keep the Japanese input mode feel similar to the default English keyboard on the HTC Hero.

The biggest drawback to Simeji is that it is an app. Since it is not a native part of the OS, it takes time to load every time you toggle the keyboard. There is also some lag when typing at times. It is always running in the background ready to be toggled to, but it never feels like it is a natural part of the phone’s OS.

Another drawback to using Japanese input on Android is that it does not work with text messages. You can input Japanese and sent text messages; you just can’t read any messages you receive. I don’t know if this is a problem with Sprint’s network or American text messages in general, but it is a problem. I can understand an older phone having problems receiving Japanese text messages. But from Android to Android I expect better. Between Android phones you can always use Google Talk, but there is no guarantee that the person you are messaging has notifications turned on for Talk, whereas with text messages that is almost guaranteed.

Simeji works—for the most part—and has lots of configuration options. It is great that someone has created this app because there is a need for it. But the native Android Japanese input keyboard should be made available to all Android phones. The iPhone gets this right; Google should too.

Localization and the Japanese Language

Saturday, January 12th, 2008

This is a blog about localization, and some unique issues with the Japanese language when it comes to translation and localization.

My name is Mark. I work for a large Japanese semiconductor company as a localization engineer. I write documentation, translate documentation, and use software to increase translation efficiency. I also write software and create publishing systems to assist in the documentation and translation process. I have degrees in Computer Sciences and Japanese. I went to college in the U.S.A. and in Japan.

Documentation and localization has a number of interesting issue that come up that I want to talk about. Also, the Japanese language increases the complexity of our work and adds many unique considerations to the job that I want to cover.

Localizing Japanese is hard, but very interesting. As I work and discover new things, I want to share them on here.