2009-06-25 07:16:22 -07:00
|
|
|
|
/*
|
|
|
|
|
* SymbolTable.cs
|
|
|
|
|
* Copyright (c) 2008-2009 kbinani
|
|
|
|
|
*
|
|
|
|
|
* This file is part of Boare.Lib.Vsq.
|
|
|
|
|
*
|
|
|
|
|
* Boare.Lib.Vsq is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the BSD License.
|
|
|
|
|
*
|
|
|
|
|
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*/
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if JAVA
|
|
|
|
|
package org.kbinani.vsq;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import org.kbinani.*;
|
|
|
|
|
#else
|
2009-06-25 07:16:22 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using bocoree;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
using bocoree.java.util;
|
|
|
|
|
using bocoree.java.io;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
|
|
|
|
|
namespace Boare.Lib.Vsq {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
using boolean = System.Boolean;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
using Integer = System.Int32;
|
|
|
|
|
#endif
|
2009-09-07 03:44:18 -07:00
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if JAVA
|
|
|
|
|
public class SymbolTable implements Cloneable {
|
|
|
|
|
#else
|
2009-06-25 07:16:22 -07:00
|
|
|
|
public class SymbolTable : ICloneable {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|
2009-09-07 03:44:18 -07:00
|
|
|
|
private TreeMap<String, String> m_dict;
|
|
|
|
|
private String m_name;
|
|
|
|
|
private boolean m_enabled;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
|
|
|
|
|
#region Static Field
|
2010-03-16 20:14:08 -07:00
|
|
|
|
private static TreeMap<Integer, SymbolTable> s_table = new TreeMap<Integer, SymbolTable>();
|
2009-06-25 07:16:22 -07:00
|
|
|
|
private static SymbolTable s_default_jp = null;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
private static boolean s_initialized = false;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if JAVA
|
|
|
|
|
public static final String[][] _KEY_JP = {
|
|
|
|
|
#else
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public static readonly String[,] _KEY_JP = {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|
2009-06-25 07:16:22 -07:00
|
|
|
|
{"あ", "a"},
|
|
|
|
|
{"い", "i"},
|
|
|
|
|
{"う", "M"},
|
|
|
|
|
{"え", "e"},
|
|
|
|
|
{"お", "o"},
|
|
|
|
|
{"か", "k a"},
|
|
|
|
|
{"き", "k' i"},
|
|
|
|
|
{"く", "k M"},
|
|
|
|
|
{"け", "k e"},
|
|
|
|
|
{"こ", "k o"},
|
|
|
|
|
{"さ", "s a"},
|
|
|
|
|
{"し", "S i"},
|
|
|
|
|
{"す", "s M"},
|
|
|
|
|
{"せ", "s e"},
|
|
|
|
|
{"そ", "s o"},
|
|
|
|
|
{"た", "t a"},
|
|
|
|
|
{"ち", "tS i"},
|
|
|
|
|
{"つ", "ts M"},
|
|
|
|
|
{"て", "t e"},
|
|
|
|
|
{"と", "t o"},
|
|
|
|
|
{"な", "n a"},
|
|
|
|
|
{"に", "J i"},
|
|
|
|
|
{"ぬ", "n M"},
|
|
|
|
|
{"ね", "n e"},
|
|
|
|
|
{"の", "n o"},
|
|
|
|
|
{"は", "h a"},
|
|
|
|
|
{"ひ", "C i"},
|
2010-03-16 20:14:08 -07:00
|
|
|
|
{"ふ", "p\\ M"},
|
2009-06-25 07:16:22 -07:00
|
|
|
|
{"へ", "h e"},
|
|
|
|
|
{"ほ", "h o"},
|
|
|
|
|
{"ま", "m a"},
|
|
|
|
|
{"み", "m' i"},
|
|
|
|
|
{"む", "m M"},
|
|
|
|
|
{"め", "m e"},
|
|
|
|
|
{"も", "m o"},
|
|
|
|
|
{"や", "j a"},
|
|
|
|
|
{"ゆ", "j M"},
|
|
|
|
|
{"よ", "j o"},
|
|
|
|
|
{"ら", "4 a"},
|
|
|
|
|
{"り", "4' i"},
|
|
|
|
|
{"る", "4 M"},
|
|
|
|
|
{"れ", "4 e "},
|
|
|
|
|
{"ろ", "4 o"},
|
|
|
|
|
{"わ", "w a"},
|
|
|
|
|
{"ゐ", "w i"},
|
|
|
|
|
{"ゑ", "w e"},
|
|
|
|
|
{"を", "o"},
|
|
|
|
|
{"ぁ", "a"},
|
|
|
|
|
{"ぃ", "i"},
|
|
|
|
|
{"ぅ", "M"},
|
|
|
|
|
{"ぇ", "e"},
|
|
|
|
|
{"ぉ", "o"},
|
|
|
|
|
{"が", "g a"},
|
|
|
|
|
{"ぎ", "g' i"},
|
|
|
|
|
{"ぐ", "g M"},
|
|
|
|
|
{"げ", "g e"},
|
|
|
|
|
{"ご", "g o"},
|
|
|
|
|
{"ざ", "dz a"},
|
|
|
|
|
{"じ", "dZ i"},
|
|
|
|
|
{"ず", "dz M"},
|
|
|
|
|
{"ぜ", "dz e"},
|
|
|
|
|
{"ぞ", "dz o"},
|
|
|
|
|
{"だ", "d a"},
|
|
|
|
|
{"ぢ", "dZ i"},
|
|
|
|
|
{"づ", "dz M"},
|
|
|
|
|
{"で", "d e"},
|
|
|
|
|
{"ど", "d o"},
|
|
|
|
|
{"ば", "b a"},
|
|
|
|
|
{"び", "b' i"},
|
|
|
|
|
{"ぶ", "b M"},
|
|
|
|
|
{"べ", "b e"},
|
|
|
|
|
{"ぼ", "b o"},
|
|
|
|
|
{"ぱ", "p a"},
|
|
|
|
|
{"ぴ", "p' i"},
|
|
|
|
|
{"ぷ", "p M"},
|
|
|
|
|
{"ぺ", "p e"},
|
|
|
|
|
{"ぽ", "p o"},
|
|
|
|
|
{"いぇ", "j e"},
|
|
|
|
|
{"うぃ", "w i"},
|
|
|
|
|
{"うぇ", "w e"},
|
|
|
|
|
{"うぉ", "w o"},
|
|
|
|
|
{"きゃ", "k' a"},
|
|
|
|
|
{"きゅ", "k' M"},
|
|
|
|
|
{"きぇ", "k' e"},
|
|
|
|
|
{"きょ", "k' o"},
|
|
|
|
|
{"しゃ", "S a"},
|
|
|
|
|
{"しゅ", "S M"},
|
|
|
|
|
{"しぇ", "S e"},
|
|
|
|
|
{"しょ", "S o"},
|
|
|
|
|
{"ちゃ", "tS a"},
|
|
|
|
|
{"ちゅ", "tS M"},
|
|
|
|
|
{"ちぇ", "tS e"},
|
|
|
|
|
{"ちょ", "tS o"},
|
|
|
|
|
{"にゃ", "J a"},
|
|
|
|
|
{"にゅ", "J M"},
|
|
|
|
|
{"にぇ", "J e"},
|
|
|
|
|
{"にょ", "J o"},
|
|
|
|
|
{"ひゃ", "C a"},
|
|
|
|
|
{"ひゅ", "C M"},
|
|
|
|
|
{"ひぇ", "C e"},
|
|
|
|
|
{"ひょ", "C o"},
|
2010-03-16 20:14:08 -07:00
|
|
|
|
{"ふゃ", "p\\' a"},
|
|
|
|
|
{"ふぃ", "p\\' i"},
|
|
|
|
|
{"ふゅ", "p\\' M"},
|
|
|
|
|
{"ふぇ", "p\\ e"},
|
2009-06-25 07:16:22 -07:00
|
|
|
|
{"みゃ", "m' a"},
|
|
|
|
|
{"みゅ", "m' M"},
|
|
|
|
|
{"みぇ", "m' e"},
|
|
|
|
|
{"みょ", "m' o"},
|
|
|
|
|
{"りゃ", "4' a"},
|
|
|
|
|
{"りゅ", "4' M"},
|
|
|
|
|
{"りぇ", "4' e"},
|
|
|
|
|
{"りょ", "4' o"},
|
|
|
|
|
{"ぎゃ", "g' a"},
|
|
|
|
|
{"ぎゅ", "g' M"},
|
|
|
|
|
{"ぎぇ", "g' e"},
|
|
|
|
|
{"ぎょ", "g' o"},
|
|
|
|
|
{"じゃ", "dZ a"},
|
|
|
|
|
{"じゅ", "dZ M"},
|
|
|
|
|
{"じぇ", "dZ e"},
|
|
|
|
|
{"じょ", "dZ o"},
|
|
|
|
|
{"びゃ", "b' a"},
|
|
|
|
|
{"びゅ", "b' M"},
|
|
|
|
|
{"びぇ", "b' e"},
|
|
|
|
|
{"びょ", "b' o"},
|
|
|
|
|
{"ぴゃ", "p' a"},
|
|
|
|
|
{"ぴゅ", "p' M"},
|
|
|
|
|
{"ぴぇ", "p' e"},
|
|
|
|
|
{"ぴょ", "p' o"},
|
2010-03-16 20:14:08 -07:00
|
|
|
|
{"ふぁ", "p\\ a"},
|
|
|
|
|
{"ふぉ", "p\\ o"},
|
2009-06-25 07:16:22 -07:00
|
|
|
|
{"てゃ", "t' a"},
|
|
|
|
|
{"てぃ", "t' i"},
|
|
|
|
|
{"てゅ", "t' M"},
|
|
|
|
|
{"てぇ", "t' e"},
|
|
|
|
|
{"てょ", "t' o"},
|
|
|
|
|
{"でゃ", "d' a"},
|
|
|
|
|
{"でぃ", "d' i"},
|
|
|
|
|
{"でゅ", "d' M"},
|
|
|
|
|
{"でぇ", "d' e"},
|
|
|
|
|
{"でょ", "d' o"},
|
|
|
|
|
{"すぃ", "s i"},
|
|
|
|
|
{"ずぃ", "dz i"},
|
|
|
|
|
{"とぅ", "t M"},
|
|
|
|
|
{"どぅ", "d M"},
|
|
|
|
|
{"ゃ", "j a"},
|
|
|
|
|
{"ゅ", "j M"},
|
|
|
|
|
{"ょ", "j o"},
|
|
|
|
|
{"ん", "n"},
|
|
|
|
|
{"ア", "a"},
|
|
|
|
|
{"イ", "i"},
|
|
|
|
|
{"ウ", "M"},
|
|
|
|
|
{"エ", "e"},
|
|
|
|
|
{"オ", "o"},
|
|
|
|
|
{"カ", "k a"},
|
|
|
|
|
{"キ", "k' i"},
|
|
|
|
|
{"ク", "k M"},
|
|
|
|
|
{"ケ", "k e"},
|
|
|
|
|
{"コ", "k o"},
|
|
|
|
|
{"サ", "s a"},
|
|
|
|
|
{"シ", "S i"},
|
|
|
|
|
{"ス", "s M"},
|
|
|
|
|
{"セ", "s e"},
|
|
|
|
|
{"ソ", "s o"},
|
|
|
|
|
{"タ", "t a"},
|
|
|
|
|
{"チ", "tS i"},
|
|
|
|
|
{"ツ", "ts M"},
|
|
|
|
|
{"テ", "t e"},
|
|
|
|
|
{"ト", "t o"},
|
|
|
|
|
{"ナ", "n a"},
|
|
|
|
|
{"ニ", "J i"},
|
|
|
|
|
{"ヌ", "n M"},
|
|
|
|
|
{"ネ", "n e"},
|
|
|
|
|
{"ノ", "n o"},
|
|
|
|
|
{"ハ", "h a"},
|
|
|
|
|
{"ヒ", "C i"},
|
2010-03-16 20:14:08 -07:00
|
|
|
|
{"フ", "p\\ M"},
|
2009-06-25 07:16:22 -07:00
|
|
|
|
{"ヘ", "h e"},
|
|
|
|
|
{"ホ", "h o"},
|
|
|
|
|
{"マ", "m a"},
|
|
|
|
|
{"ミ", "m' i"},
|
|
|
|
|
{"ム", "m M"},
|
|
|
|
|
{"メ", "m e"},
|
|
|
|
|
{"モ", "m o"},
|
|
|
|
|
{"ヤ", "j a"},
|
|
|
|
|
{"ユ", "j M"},
|
|
|
|
|
{"ヨ", "j o"},
|
|
|
|
|
{"ラ", "4 a"},
|
|
|
|
|
{"リ", "4' i"},
|
|
|
|
|
{"ル", "4 M"},
|
|
|
|
|
{"レ", "4 e "},
|
|
|
|
|
{"ロ", "4 o"},
|
|
|
|
|
{"ワ", "w a"},
|
|
|
|
|
{"ヰ", "w i"},
|
|
|
|
|
{"ヱ", "w e"},
|
|
|
|
|
{"ヲ", "o"},
|
|
|
|
|
{"ァ", "a"},
|
|
|
|
|
{"ィ", "i"},
|
|
|
|
|
{"ゥ", "M"},
|
|
|
|
|
{"ェ", "e"},
|
|
|
|
|
{"ォ", "o"},
|
|
|
|
|
{"ガ", "g a"},
|
|
|
|
|
{"ギ", "g' i"},
|
|
|
|
|
{"グ", "g M"},
|
|
|
|
|
{"ゲ", "g e"},
|
|
|
|
|
{"ゴ", "g o"},
|
|
|
|
|
{"ザ", "dz a"},
|
|
|
|
|
{"ジ", "dZ i"},
|
|
|
|
|
{"ズ", "dz M"},
|
|
|
|
|
{"ゼ", "dz e"},
|
|
|
|
|
{"ゾ", "dz o"},
|
|
|
|
|
{"ダ", "d a"},
|
|
|
|
|
{"ヂ", "dZ i"},
|
|
|
|
|
{"ヅ", "dz M"},
|
|
|
|
|
{"デ", "d e"},
|
|
|
|
|
{"ド", "d o"},
|
|
|
|
|
{"バ", "b a"},
|
|
|
|
|
{"ビ", "b' i"},
|
|
|
|
|
{"ブ", "b M"},
|
|
|
|
|
{"ベ", "b e"},
|
|
|
|
|
{"ボ", "b o"},
|
|
|
|
|
{"パ", "p a"},
|
|
|
|
|
{"ピ", "p' i"},
|
|
|
|
|
{"プ", "p M"},
|
|
|
|
|
{"ペ", "p e"},
|
|
|
|
|
{"ポ", "p o"},
|
|
|
|
|
{"イェ", "j e"},
|
|
|
|
|
{"ウィ", "w i"},
|
|
|
|
|
{"ウェ", "w e"},
|
|
|
|
|
{"ウォ", "w o"},
|
|
|
|
|
{"キャ", "k' a"},
|
|
|
|
|
{"キュ", "k' M"},
|
|
|
|
|
{"キェ", "k' e"},
|
|
|
|
|
{"キョ", "k' o"},
|
|
|
|
|
{"シャ", "S a"},
|
|
|
|
|
{"シュ", "S M"},
|
|
|
|
|
{"シェ", "S e"},
|
|
|
|
|
{"ショ", "S o"},
|
|
|
|
|
{"チャ", "tS a"},
|
|
|
|
|
{"チュ", "tS M"},
|
|
|
|
|
{"チェ", "tS e"},
|
|
|
|
|
{"チョ", "tS o"},
|
|
|
|
|
{"ニャ", "J a"},
|
|
|
|
|
{"ニュ", "J M"},
|
|
|
|
|
{"ニェ", "J e"},
|
|
|
|
|
{"ニョ", "J o"},
|
|
|
|
|
{"ヒャ", "C a"},
|
|
|
|
|
{"ヒュ", "C M"},
|
|
|
|
|
{"ヒェ", "C e"},
|
|
|
|
|
{"ヒョ", "C o"},
|
2010-03-16 20:14:08 -07:00
|
|
|
|
{"フャ", "p\\' a"},
|
|
|
|
|
{"フィ", "p\\' i"},
|
|
|
|
|
{"フュ", "p\\' M"},
|
|
|
|
|
{"フェ", "p\\ e"},
|
2009-06-25 07:16:22 -07:00
|
|
|
|
{"ミャ", "m' a"},
|
|
|
|
|
{"ミュ", "m' M"},
|
|
|
|
|
{"ミェ", "m' e"},
|
|
|
|
|
{"ミョ", "m' o"},
|
|
|
|
|
{"リャ", "4' a"},
|
|
|
|
|
{"リュ", "4' M"},
|
|
|
|
|
{"リェ", "4' e"},
|
|
|
|
|
{"リョ", "4' o"},
|
|
|
|
|
{"ギャ", "g' a"},
|
|
|
|
|
{"ギュ", "g' M"},
|
|
|
|
|
{"ギェ", "g' e"},
|
|
|
|
|
{"ギョ", "g' o"},
|
|
|
|
|
{"ジャ", "dZ a"},
|
|
|
|
|
{"ジュ", "dZ M"},
|
|
|
|
|
{"ジェ", "dZ e"},
|
|
|
|
|
{"ジョ", "dZ o"},
|
|
|
|
|
{"ビャ", "b' a"},
|
|
|
|
|
{"ビュ", "b' M"},
|
|
|
|
|
{"ビェ", "b' e"},
|
|
|
|
|
{"ビョ", "b' o"},
|
|
|
|
|
{"ピャ", "p' a"},
|
|
|
|
|
{"ピュ", "p' M"},
|
|
|
|
|
{"ピェ", "p' e"},
|
|
|
|
|
{"ピョ", "p' o"},
|
2010-03-16 20:14:08 -07:00
|
|
|
|
{"ファ", "p\\ a"},
|
|
|
|
|
{"フォ", "p\\ o"},
|
2009-06-25 07:16:22 -07:00
|
|
|
|
{"テャ", "t' a"},
|
|
|
|
|
{"ティ", "t' i"},
|
|
|
|
|
{"テュ", "t' M"},
|
|
|
|
|
{"テェ", "t' e"},
|
|
|
|
|
{"テョ", "t' o"},
|
|
|
|
|
{"デャ", "d' a"},
|
|
|
|
|
{"ディ", "d' i"},
|
|
|
|
|
{"デュ", "d' M"},
|
|
|
|
|
{"デェ", "d' e"},
|
|
|
|
|
{"デョ", "d' o"},
|
|
|
|
|
{"スィ", "s i"},
|
|
|
|
|
{"ズィ", "dz i"},
|
|
|
|
|
{"トゥ", "t M"},
|
|
|
|
|
{"ドゥ", "d M"},
|
|
|
|
|
{"ャ", "j a"},
|
|
|
|
|
{"ュ", "j M"},
|
|
|
|
|
{"ョ", "j o"},
|
|
|
|
|
{"ン", "n"},
|
|
|
|
|
{"ヴ", "b M"},
|
|
|
|
|
{"a", "a"},
|
|
|
|
|
{"e", "e"},
|
|
|
|
|
{"i", "i"},
|
|
|
|
|
{"m", "n"},
|
|
|
|
|
{"n", "n"},
|
|
|
|
|
{"o", "o"},
|
|
|
|
|
{"u", "M"},
|
|
|
|
|
{"A", "a"},
|
|
|
|
|
{"E", "e"},
|
|
|
|
|
{"I", "i"},
|
|
|
|
|
{"M", "n"},
|
|
|
|
|
{"N", "n"},
|
|
|
|
|
{"O", "o"},
|
|
|
|
|
{"U", "M"},
|
|
|
|
|
{"ka", "k a"},
|
|
|
|
|
{"ki", "k' i"},
|
|
|
|
|
{"ku", "k M"},
|
|
|
|
|
{"ke", "k e"},
|
|
|
|
|
{"ko", "k o"},
|
|
|
|
|
{"kya", "k' a"},
|
|
|
|
|
{"kyu", "k' M"},
|
|
|
|
|
{"kyo", "k' o"},
|
|
|
|
|
{"sa", "s a"},
|
|
|
|
|
{"si", "s i"},
|
|
|
|
|
{"su", "s M"},
|
|
|
|
|
{"se", "s e"},
|
|
|
|
|
{"so", "s o"},
|
|
|
|
|
{"ta", "t a"},
|
|
|
|
|
{"ti", "t' i"},
|
|
|
|
|
{"tu", "t M"},
|
|
|
|
|
{"te", "t e"},
|
|
|
|
|
{"to", "t o"},
|
|
|
|
|
{"tya", "t' a"},
|
|
|
|
|
{"tyu", "t' M"},
|
|
|
|
|
{"tyo", "t' o"},
|
|
|
|
|
{"na", "n a"},
|
|
|
|
|
{"ni", "J i"},
|
|
|
|
|
{"nu", "n M"},
|
|
|
|
|
{"ne", "n e"},
|
|
|
|
|
{"no", "n o"},
|
|
|
|
|
{"nya", "J a"},
|
|
|
|
|
{"nyu", "J M"},
|
|
|
|
|
{"nyo", "J o"},
|
|
|
|
|
{"ha", "h a"},
|
|
|
|
|
{"hi", "C i"},
|
|
|
|
|
{"he", "h e"},
|
|
|
|
|
{"ho", "h o"},
|
|
|
|
|
{"hya", "C a"},
|
|
|
|
|
{"hyu", "C M"},
|
|
|
|
|
{"hyo", "C o"},
|
|
|
|
|
{"ma", "m a"},
|
|
|
|
|
{"mi", "m' i"},
|
|
|
|
|
{"mu", "m M"},
|
|
|
|
|
{"me", "m e"},
|
|
|
|
|
{"mo", "m o"},
|
|
|
|
|
{"mya", "m' a"},
|
|
|
|
|
{"myu", "m' M"},
|
|
|
|
|
{"myo", "m' o"},
|
|
|
|
|
{"ya", "j a"},
|
|
|
|
|
{"yu", "j M"},
|
|
|
|
|
{"ye", "j e"},
|
|
|
|
|
{"yo", "j o"},
|
|
|
|
|
{"ra", "4 a"},
|
|
|
|
|
{"ri", "4' i"},
|
|
|
|
|
{"ru", "4 M"},
|
|
|
|
|
{"re", "4 e"},
|
|
|
|
|
{"ro", "4 o"},
|
|
|
|
|
{"rya", "4' a"},
|
|
|
|
|
{"ryu", "4' M"},
|
|
|
|
|
{"ryo", "4' o"},
|
|
|
|
|
{"wa", "w a"},
|
|
|
|
|
{"wi", "w i"},
|
|
|
|
|
{"we", "w e"},
|
|
|
|
|
{"wo", "w o"},
|
|
|
|
|
{"ga", "g a"},
|
|
|
|
|
{"gi", "g' i"},
|
|
|
|
|
{"gu", "g M"},
|
|
|
|
|
{"ge", "g e"},
|
|
|
|
|
{"go", "g o"},
|
|
|
|
|
{"gya", "g' a"},
|
|
|
|
|
{"gyu", "g' M"},
|
|
|
|
|
{"gyo", "g' o"},
|
|
|
|
|
{"za", "dz a"},
|
|
|
|
|
{"zi", "dz i"},
|
|
|
|
|
{"zu", "dz M"},
|
|
|
|
|
{"ze", "dz e"},
|
|
|
|
|
{"zo", "dz o"},
|
|
|
|
|
{"da", "d a"},
|
|
|
|
|
{"di", "d' i"},
|
|
|
|
|
{"du", "d M"},
|
|
|
|
|
{"de", "d e"},
|
|
|
|
|
{"do", "d o"},
|
|
|
|
|
{"dya", "d' a"},
|
|
|
|
|
{"dyu", "d' M"},
|
|
|
|
|
{"dyo", "d' o"},
|
|
|
|
|
{"ba", "b a"},
|
|
|
|
|
{"bi", "b' i"},
|
|
|
|
|
{"bu", "b M"},
|
|
|
|
|
{"be", "b e"},
|
|
|
|
|
{"bo", "b o"},
|
|
|
|
|
{"bya", "b' a"},
|
|
|
|
|
{"byu", "b' M"},
|
|
|
|
|
{"byo", "b' o"},
|
|
|
|
|
{"pa", "p a"},
|
|
|
|
|
{"pi", "p' i"},
|
|
|
|
|
{"pu", "p M"},
|
|
|
|
|
{"pe", "p e"},
|
|
|
|
|
{"po", "p o"},
|
|
|
|
|
{"pya", "p' a"},
|
|
|
|
|
{"pyu", "p' M"},
|
|
|
|
|
{"pyo", "p' o"},
|
|
|
|
|
{"sha", "S a"},
|
|
|
|
|
{"shi", "S i"},
|
|
|
|
|
{"shu", "S M"},
|
|
|
|
|
{"sho", "S o"},
|
|
|
|
|
{"tsu", "ts M"},
|
|
|
|
|
{"cha", "tS a"},
|
|
|
|
|
{"chi", "tS i"},
|
|
|
|
|
{"chu", "tS M"},
|
|
|
|
|
{"cho", "tS o"},
|
2010-03-16 20:14:08 -07:00
|
|
|
|
{"fu", "p\\ M"},
|
2009-06-25 07:16:22 -07:00
|
|
|
|
{"ja", "dZ a"},
|
|
|
|
|
{"ji", "dZ i"},
|
|
|
|
|
{"ju", "dZ M"},
|
|
|
|
|
{"jo", "dZ o"},
|
|
|
|
|
};
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Static Method and Property
|
|
|
|
|
public static SymbolTable getSymbolTable( int index ) {
|
|
|
|
|
if ( !s_initialized ) {
|
|
|
|
|
loadDictionary();
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
if ( 0 <= index && index < s_table.size() ) {
|
|
|
|
|
return s_table.get( index );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
} else {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void loadDictionary() {
|
|
|
|
|
#if DEBUG
|
2010-03-16 20:14:08 -07:00
|
|
|
|
PortUtil.println( "SymbolTable.LoadDictionary()" );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#endif
|
|
|
|
|
s_default_jp = new SymbolTable( "DEFAULT_JP", _KEY_JP, true );
|
2010-03-16 20:14:08 -07:00
|
|
|
|
s_table.clear();
|
|
|
|
|
s_table.put( 0, s_default_jp );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
|
|
// 辞書フォルダからの読込み
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String editor_path = VocaloSysUtil.getEditorPath( SynthesizerType.VOCALOID2 );
|
2009-09-07 03:44:18 -07:00
|
|
|
|
if ( editor_path != "" ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String path = PortUtil.combinePath( PortUtil.getDirectoryName( editor_path ), "UDIC" );
|
|
|
|
|
if ( !PortUtil.isDirectoryExists( path ) ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String[] files = PortUtil.listFiles( path, "*.udc" );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
for ( int i = 0; i < files.Length; i++ ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
files[i] = PortUtil.getFileName( files[i] );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#if DEBUG
|
2010-03-16 20:14:08 -07:00
|
|
|
|
PortUtil.println( " files[i]=" + files[i] );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#endif
|
|
|
|
|
count++;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String dict = PortUtil.combinePath( path, files[i] );
|
|
|
|
|
s_table.put( count, new SymbolTable( dict, true, false ) );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 起動ディレクトリ
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String path2 = PortUtil.combinePath( PortUtil.getApplicationStartupPath(), "udic" );
|
|
|
|
|
if ( PortUtil.isDirectoryExists( path2 ) ) {
|
|
|
|
|
String[] files2 = PortUtil.listFiles( path2, "*.eudc" );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
for ( int i = 0; i < files2.Length; i++ ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
files2[i] = PortUtil.getFileName( files2[i] );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#if DEBUG
|
2010-03-16 20:14:08 -07:00
|
|
|
|
PortUtil.println( " files2[i]=" + files2[i] );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#endif
|
|
|
|
|
count++;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String dict = PortUtil.combinePath( path2, files2[i] );
|
|
|
|
|
s_table.put( count, new SymbolTable( dict, false, false ) );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
s_initialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
public static boolean attatch( String phrase, ByRef<String> result ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#if DEBUG
|
2010-03-16 20:14:08 -07:00
|
|
|
|
PortUtil.println( "SymbolTable.Attatch" );
|
|
|
|
|
PortUtil.println( " phrase=" + phrase );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#endif
|
2010-03-16 20:14:08 -07:00
|
|
|
|
for ( Iterator itr = s_table.keySet().iterator(); itr.hasNext(); ) {
|
|
|
|
|
int key = (Integer)itr.next();
|
|
|
|
|
SymbolTable table = s_table.get( key );
|
|
|
|
|
if ( table.isEnabled() ) {
|
|
|
|
|
if ( table.attatchImp( phrase, result ) ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
result.value = "a";
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int getCount() {
|
|
|
|
|
if ( !s_initialized ) {
|
|
|
|
|
loadDictionary();
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
return s_table.size();
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
public static void changeOrder( Vector<ValuePair<String, Boolean>> list ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#if DEBUG
|
2010-03-16 20:14:08 -07:00
|
|
|
|
PortUtil.println( "SymbolTable.Sort()" );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#endif
|
2010-03-16 20:14:08 -07:00
|
|
|
|
TreeMap<Integer, SymbolTable> buff = new TreeMap<Integer, SymbolTable>();
|
|
|
|
|
for ( Iterator itr = s_table.keySet().iterator(); itr.hasNext(); ) {
|
|
|
|
|
int key = (Integer)itr.next();
|
|
|
|
|
buff.put( key, (SymbolTable)s_table.get( key ).clone() );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
s_table.clear();
|
|
|
|
|
int count = list.size();
|
|
|
|
|
for ( int i = 0; i < count; i++ ) {
|
|
|
|
|
ValuePair<String, Boolean> itemi = list.get( i );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#if DEBUG
|
2010-03-16 20:14:08 -07:00
|
|
|
|
PortUtil.println( " list[i]=" + itemi.getKey() + "," + itemi.getValue() );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#endif
|
2010-03-16 20:14:08 -07:00
|
|
|
|
for ( Iterator itr = buff.keySet().iterator(); itr.hasNext(); ) {
|
|
|
|
|
int key = (Integer)itr.next();
|
|
|
|
|
SymbolTable table = buff.get( key );
|
|
|
|
|
if ( table.getName().Equals( itemi.getKey() ) ) {
|
|
|
|
|
table.setEnabled( itemi.getValue() );
|
|
|
|
|
s_table.put( i, table );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if !JAVA
|
2009-06-25 07:16:22 -07:00
|
|
|
|
public object Clone() {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
return clone();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
public Object clone() {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
SymbolTable ret = new SymbolTable();
|
2009-09-07 03:44:18 -07:00
|
|
|
|
ret.m_dict = new TreeMap<String, String>();
|
2010-03-16 20:14:08 -07:00
|
|
|
|
for ( Iterator itr = m_dict.keySet().iterator(); itr.hasNext(); ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String key = (String)itr.next();
|
|
|
|
|
ret.m_dict.put( key, m_dict.get( key ) );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
ret.m_name = m_name;
|
|
|
|
|
ret.m_enabled = m_enabled;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SymbolTable() {
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public String getName() {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return m_name;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public boolean isEnabled() {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return m_enabled;
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
|
|
|
|
|
public void setEnabled( boolean value ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
m_enabled = value;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public SymbolTable( String path, boolean is_udc_mode, boolean enabled ) {
|
|
|
|
|
m_dict = new TreeMap<String, String>();
|
2009-06-25 07:16:22 -07:00
|
|
|
|
m_enabled = enabled;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
if ( !PortUtil.isFileExists( path ) ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
m_name = PortUtil.getFileName( path );
|
|
|
|
|
BufferedReader sr = null;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
try {
|
|
|
|
|
if ( is_udc_mode ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
sr = new BufferedReader( new InputStreamReader( new FileInputStream( path ), "Shift_JIS" ) );
|
|
|
|
|
if ( sr == null ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
sr = new BufferedReader( new InputStreamReader( new FileInputStream( path ), "UTF8" ) );
|
|
|
|
|
if ( sr == null ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String line;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
while ( sr.ready() ) {
|
|
|
|
|
line = sr.readLine();
|
2009-06-25 07:16:22 -07:00
|
|
|
|
if ( !line.StartsWith( "//" ) ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String[] spl = PortUtil.splitString( line, new String[] { "\t" }, 2, true );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
if ( spl.Length >= 2 ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
if ( m_dict.containsKey( spl[0] ) ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
PortUtil.println( "SymbolTable..ctor" );
|
|
|
|
|
PortUtil.println( " dictionary already contains key: " + spl[0] );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
} else {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
m_dict.put( spl[0], spl[1] );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch ( Exception ex ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
PortUtil.println( "SymbolTable..ctor" );
|
|
|
|
|
PortUtil.println( " " + ex );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
} finally {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
if ( sr != null ) {
|
|
|
|
|
try {
|
|
|
|
|
sr.close();
|
|
|
|
|
} catch ( Exception ex2 ) {
|
|
|
|
|
}
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
private boolean attatchImp( String phrase, ByRef<String> result ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String s = phrase.ToLower();
|
|
|
|
|
if ( m_dict.containsKey( s ) ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
result.value = m_dict.get( s );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return true;
|
|
|
|
|
} else {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
result.value = "a";
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if JAVA
|
|
|
|
|
private SymbolTable( String name, String[][] key, boolean enabled ){
|
|
|
|
|
#else
|
2009-09-07 03:44:18 -07:00
|
|
|
|
private SymbolTable( String name, String[,] key, boolean enabled ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
#endif
|
|
|
|
|
m_enabled = enabled;
|
|
|
|
|
m_name = name;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
m_dict = new TreeMap<String, String>();
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if JAVA
|
|
|
|
|
for( int i = 0; i < key.length; i++ ){
|
|
|
|
|
if( m_dict.containsKey( key[i][0] ) ){
|
|
|
|
|
}else{
|
|
|
|
|
m_dict.put( key[i][0], key[i][1] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
2009-06-25 07:16:22 -07:00
|
|
|
|
for ( int i = 0; i < key.GetLength( 0 ); i++ ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
if ( m_dict.containsKey( key[i, 0] ) ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
} else {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
m_dict.put( key[i, 0], key[i, 1] );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if !JAVA
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|