//------------------------------------------------------------ // 分割語(DividedWord)にならないならtrue public static bool NotDividedWord(DocumentData doc) { // 動詞,形容詞,形容動詞は部分語の訳語とはしない if (doc.IsVerb() || doc.IsAdjective() || doc.IsAdjectivalverb()) { // ただし長さ3以上は採用する。 string key; if (KJ_dict.inputIsHangul) { key = doc.GetData("key1"); } else { key = doc.GetData("key2"); } if (key.Length > 2) { return(false); } // ただし動詞で例外あり string root = doc.GetData("root1"); if (root == "하다" || root == "되다" || root == "시키다") // よくないけど、あとで考え直す // nop (*2) { } else { return(true); } } return(false); }
//------------------------------------------------------------ // 表示用詳細情報の作成 private String MakeDetailString(DocumentData sd) { // string pos; string detail = ""; string detailTagData; if (this.inputIsHangul) { detailTagData = sd.GetData("detail2"); } else { detailTagData = sd.GetData("detail1"); } if (detailTagData != "") { if (detail != "") { detail = detail + " " + detailTagData; } else { detail = detailTagData; } } return(detail); }
//------------------------------------------------------------ // 表示用品詞情報作成 private String MakePosString(DocumentData sd) { string pos = ""; // posタグの調査 if (this.inputIsHangul) { pos = sd.GetData("pos1"); } else { pos = sd.GetData("pos2"); } if (pos == "") { // pos1 or pos2がないなら posで探す pos = sd.GetPos(); } if (pos != "") { // posタグを詳細表示にする string posName = Pos.Name(pos); if (posName != "") { string conjugation = ""; if (inputIsHangul) { conjugation = sd.GetData("conju1"); } else { conjugation = sd.GetData("conju2"); } if (conjugation != "") { posName = posName + " " + conjugation; } return(posName); } } return(pos); }
//------------------------------------------------------------------------- // "*"正規表現用のフィルタ (前方一致、後方一致を使う簡易型) // static private bool asterRegexFilter(DocumentData doc){ // // string [] checkTags = { "key1", "word1", "pronun1", // "key2", "word2", "pronun2" }; // // foreach ( String tag in checkTags ) { // string key = doc.GetData(tag); // if(key.StartsWith(KJ_dict.filterHeadword) && // key.EndsWith(KJ_dict.filterTailword) ){ // return true; // } // } // return false; // } //-------------------------------------------------------------------- // 正規表現用のフィルタ (いろいろできるけど遅い) static private bool RegexFilter(DocumentData doc) { string [] checkTags = { "key1", "word1", "pronun1", "key2", "word2", "pronun2" }; Regex regex = new Regex("^" + KJ_dict.filterRegexword + "$"); foreach (String tag in checkTags) { string key = doc.GetData(tag); if (regex.IsMatch(key)) { return(true); } } return(false); }
//------------------------------------------------------------------ // 1つの語のデータを,表示用のstringに整形する。(edict用) // private string DisplayResult(string searchword, DocumentData sd) { StringBuilder rtn_str = new StringBuilder(); rtn_str.Length = 0; string key_from = ""; // 検索語 string key_to = ""; string word_from = ""; string word_to = ""; // string pos=""; // 品詞情報、格変化 (暫定) // String indent = ""; // 入力がアルファベットならfromがkey1(英語) // 入力が漢字・ひらがな・カタカナならfromがkey2(日本語) // // 入力が数字・英語の場合は,OSに依存。 // ・OSが"ja-JP"ならfromがkey1(英語) // ・OSが"ja-JP"以外ならfromがkey2(日本語) if (this.inputIsHangul) { key_from = sd.GetData("key1"); key_to = sd.GetData("key2"); word_from = sd.GetData("word1"); word_to = sd.GetData("word2"); } else { key_from = sd.GetData("key2"); // Jp key_to = sd.GetData("key1"); // Kr word_from = sd.GetData("word2"); word_to = sd.GetData("word1"); } // 表示の見た目を整える。インデントつけたり、括弧をつけたり。 if (prev_keyword != key_from && prev_keyword != "") { rtn_str.Append("\n\n"); } // 入力語の表示 if (prev_keyword != key_from) { rtn_str.Append(key_from); rtn_str.Append("\n"); } else { // 見出し語が一緒なら結果を ","で繋いで束ねる。 if (key_to != prev_answer) { rtn_str.Append(","); } } // 結果の表示 if (prev_keyword == key_from && key_to == prev_answer) { // NOP 重複する結果は表示しない } else { rtn_str.Append(key_to); } // もしあれば品詞情報 [2011/01/15 19:18:52] //edictの品詞情報は日本語についているので, //表示してもあまり意味がない。そのため表示しない。 // pos = MakePosString(sd); // if(pos != null && pos != ""){ // rtn_str.Append(indent + "【 " + pos + " 】\n"); // } // ~2011.01.15(old type) // // もしあれば品詞情報 // string pos = sd.GetData("pos"); // if(pos != null && pos != ""){ // rtn_str.Append("\n" + pos); // } // もしあれば補足情報 string detail1 = sd.GetData("detail1"); if (detail1 != null && detail1 != "") { rtn_str.Append("\n" + detail1); } prev_keyword = key_from; // 記憶 prev_answer = key_to; return(rtn_str.ToString()); } // end of DisplayResult_edict
//---------------------------------------------------------------------- // 1つの語のデータの表示 (通常のKJ_dict用) // private string DisplayResult(string searchword, DocumentData sd) { StringBuilder rtn_str = new StringBuilder(); rtn_str.Length = 0; string key_from = ""; // 検索語 string key_to = ""; string word_from = ""; string word_to = ""; string detail = ""; string ex = ""; string cost = ""; string src = ""; string pos = ""; // 品詞情報、格変化 (暫定) String indent = ""; // 入力がハングルならfromがkey1(ハングル) // 入力が漢字・ひらがな・カタカナならfromがkey2(日本語) // // 入力が数字・英語の場合は,OSに依存。 // ・OSが"ja-JP"ならfromがkey1(ハングル) // ・OSが"ja-JP"以外ならfromがkey2(日本語) if (this.inputIsHangul) { key_from = sd.GetData("key1"); key_to = sd.GetData("key2"); word_from = sd.GetData("word1"); word_to = sd.GetData("word2"); ex = sd.GetData("ex1"); cost = sd.GetData("cost2"); } else { key_from = sd.GetData("key2"); // Jp key_to = sd.GetData("key1"); // Kr word_from = sd.GetData("word2"); word_to = sd.GetData("word1"); ex = sd.GetData("ex2"); cost = sd.GetData("cost1"); } // 表示の見た目を整える。インデントつけたり、括弧をつけたり。 // 入力語の表示 rtn_str.Append(key_from); if (word_from != "") { // 詳細情報は以下の場合だけ // ・韓国OSのとき // または // ・デバッグ情報表示時 if (this.cultureName == "ko-KR" || CodeCheck.IsKanji(word_from) || Setting.debugInfo) { // 詳細情報。ハングルの旧漢字、日本語の読み rtn_str.Append(" 〔 " + word_from + " 〕"); } } rtn_str.Append("\n"); // K-->Jの時の入力ハングルのカナ表記の表示 if (this.Setting.withPronunciation) { if (this.inputIsHangul) { if (this.Setting.PronunciationType == 1) { string kana = Hangul.Hangul2Kana(key_from); rtn_str.Append(" (" + kana + ")\n"); } else { rtn_str.Append(indent + " (" + sd.GetData("pronun1") + ")\n"); } } } // もしあれば品詞情報 pos = MakePosString(sd); if (pos != null && pos != "") { rtn_str.Append(indent + "【 " + pos + " 】\n"); } // もしあれば原形表示 string root = ""; if (inputIsHangul) { root = sd.GetData("root1"); } else { root = sd.GetData("root2"); } if (root != "") { string rootname = Pos.conjugationName("conjugation_root"); rtn_str.Append(indent + "〔(" + rootname + ") " + root + "〕\n"); } // 結果の表示 rtn_str.Append(indent + key_to); // 詳細情報は以下の場合だけ // ・韓国OSのとき // または // ・デバッグ情報表示時 if (word_to != "") { if (this.cultureName == "ko-KR" || CodeCheck.IsKanji(word_to) || Setting.debugInfo) { rtn_str.Append(" 〔 " + word_to + " 〕"); // 詳細情報。ハングルの旧漢字、日本語の読み } } rtn_str.Append("\n"); // J-->Kの時の結果ハングルのカナ表記の表示 if (this.Setting.withPronunciation) { // 表示の設定がされているときだけ if (!this.inputIsHangul) { if (this.Setting.PronunciationType == 1) { string kana = Hangul.Hangul2Kana(key_to); rtn_str.Append(indent + " (" + kana + ")\n"); } else { rtn_str.Append(indent + " (" + sd.GetData("pronun1") + ")\n"); } } } // その他付加情報 detail = MakeDetailString(sd); if (detail != null && detail != "") { rtn_str.Append(indent + "( " + detail + " )\n"); } if (ex != "") { rtn_str.Append(indent + "Ex. " + ex + "\n"); } // 「デバッグ情報表示」 を選んだ場合 if (Setting.debugInfo) { src = sd.GetData("src"); if (src != "") { rtn_str.Append(indent + "src:" + src + "\n"); } if (cost != "") { rtn_str.Append(indent + "cost:" + cost + "\n"); } string pos2 = sd.GetPos(); // posの生データ if (pos2 != "") { rtn_str.Append(indent + "pos:" + pos2 + "\n"); } } rtn_str.Append("\n"); prev_keyword = key_from; // 記憶 return(rtn_str.ToString()); }