では、ひらがな文字列から入力候補を作ってみよう!
具体的には「あかい」という文字列から「akai」という入力候補を作るあたり。
とりあえず、入力文字列が少なくてすむものを優先的に変換元の候補とするようにする。で、多分ローマ字をひらがなに変換するのと逆のことをすればよいかと。
- 入力文字列が少ないものに優先的に変換される -> テーブル並びを変更して対処
- ローマ字ひらがな変換と逆のこと -> 要はパターンの置換
くらいの方針かな?
とりあえず、テストを作ってしまいましょう。以下、抜粋。
void RomanCreatorTest::convertTest(void) {
RomanCreator roman_creator(&RomanTable[0][0][0],
ROMAN_CONVERT_SIZE_MAX);
Uint16 converted[16] = { 0x3042, 0x0 };
const char* input_example = roman_creator.convert(converted);
CPPUNIT_ASSERT_EQUAL('a', input_example[0]);
CPPUNIT_ASSERT_EQUAL('\0', input_example[1]);
converted[0] = 0x3042;
converted[1] = 0x304b;
converted[2] = 0x0;
input_example = roman_creator.convert(converted);
CPPUNIT_ASSERT_EQUAL('a', input_example[0]);
CPPUNIT_ASSERT_EQUAL('k', input_example[1]);
CPPUNIT_ASSERT_EQUAL('a', input_example[2]);
CPPUNIT_ASSERT_EQUAL('\0', input_example[3]);
}
これの実装は、また今度だな。