/// <summary> /// 指定した歌詞から、発音記号列を引き当てます /// </summary> /// <param name="phrase"></param> /// <returns></returns> public static SymbolTableEntry attatch(string phrase) { int size = mTable.Count; for (int i = 0; i < size; i++) { SymbolTable table = mTable[i]; if (table.isEnabled()) { SymbolTableEntry ret = table.attatchImp(phrase); if (ret != null) { return(ret); } } } return(null); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="path">読み込む辞書ファイルのパス</param> /// <param name="is_udc_mode">VOCALOID2仕様の辞書ファイルかどうか</param> /// <param name="enabled">辞書ファイルを有効とするかどうか</param> /// <param name="encoding">辞書ファイルのテキストエンコーディング</param> public SymbolTable(string path, bool is_udc_mode, bool enabled, string encoding) { mDict = new SortedDictionary <string, SymbolTableEntry>(); mEnabled = enabled; if (!System.IO.File.Exists(path)) { return; } mName = PortUtil.getFileName(path); StreamReader sr = null; try { sr = new StreamReader(path, Encoding.GetEncoding(encoding)); if (sr == null) { return; } string line; while ((line = sr.ReadLine()) != null) { if (line.StartsWith("//")) { continue; } string key = ""; string word = ""; string symbol = ""; if (is_udc_mode) { string[] spl = PortUtil.splitString(line, new string[] { "\t" }, 2, true); if (spl.Length >= 2) { key = spl[0].ToLower(); word = key; symbol = spl[1]; } } else { string[] spl = PortUtil.splitString(line, new string[] { "\t\t" }, 2, true); if (spl.Length >= 2) { string[] spl_word = PortUtil.splitString(spl[0], '\t'); mMaxDivisions = Math.Max(spl_word.Length, mMaxDivisions); key = spl[0].Replace("-\t", ""); word = spl[0]; symbol = spl[1]; } } if (!key.Equals("")) { if (!mDict.ContainsKey(key)) { mDict[key] = new SymbolTableEntry(word, symbol); } } } } catch (Exception ex) { serr.println("SymbolTable#.ctor; ex=" + ex); } finally { if (sr != null) { try { sr.Close(); } catch (Exception ex2) { serr.println("SymbolTable#.ctor; ex=" + ex2); } } } }