Beispiel #1
0
        //----------------------------------------------------------------
        // 語分割ありの熟語チェック
        //     공부하지는 못할 것이라는==> 공부 + 하지는 못할 것이라는
        //     ~~~~~~~~~~                         ~~~~~~~~~~~~~~~~~~~~
        //      startwt                       ここのWordTableはdivided=Trail
        //
        static public WordTable  Search2(WordChain wc, WordTable startwt)
        {
            String str = startwt.word;

            if (!startwt.IsWord())
            {
                return(null);     // 空白などで始まる場合は、は処理しない
            }

            int target_len = 1;
            int str_len    = str.Length;

            // 前から1文字ずつ落としつつ,熟語検索。
            while (true)
            {
                if (target_len >= str_len)
                {
                    break;
                }

                // 文字列を分割する
                // str --> str2 + str3
                String str2 = str.Substring(0, target_len);
                String str3 = str.Remove(0, target_len);

                WordTable wt3 = new WordTable(str3);
                wt3.next = startwt.next;
                wt3.prev = startwt.prev;
                WordTable idiomTable = Idiom.Search(wc, wt3);

                if (idiomTable != null)
                {
                    // 熟語確定
                    WordTable wt2 = new WordTable(str2);
                    wc.InsertBefore(idiomTable, wt2);

                    WordChain wc2 = KJ_Analyzer.WordPartProc(wt2);
                    if (wc2 != null)
                    {
                        wc.Swap(wt2, wc2);
                    }
                    idiomTable.divided = Divided.Trail;
                    return(idiomTable);
                }

                target_len++;
            }

            return(null);
        }
Beispiel #2
0
        //-------------------------------------------------------
        // 語のchainを先頭から舐め、熟語を探す。
        static public WordTable Scan(WordChain wChain, WordTable wTable)
        {
            // 熟語は優先のため変換済みチェックなし
            //if(wTable.IsTranslated()){
            //    return wTable;  // 変換済みなら何もしない
            //}

            // wtで始まる熟語のチェック
            WordTable idiomwt = Idiom.Search(wChain, wTable);

            if (idiomwt != null)
            {
                // 熟語が解決できた
                return(idiomwt);
            }

            return(wTable);
        }
Beispiel #3
0
        //-------------------------------------------------------
        // 語のchainを先頭から舐め、助詞(Postpositional Particle)を分解する。
        static private WordTable ScanPPKr(WordChain wChain, WordTable wTable)
        {
            bool inputIsHangul = KJ_dict.inputIsHangul;

            // 語を舐め、助詞を分解する。

            if (wTable.charCategory != CharCategory.Hangul &&
                wTable.charCategory != CharCategory.LetterMix)
            {
                // ハングルでないなら、または英字+ハングルでないなら何もしない。
                return(wTable);
            }


            // 完全一致の助詞なら情報をセットし、終了
            string pp_trans = CheckHangulPP_Full(wTable);

            if (pp_trans != "")
            {
                wTable.transWord   = pp_trans;
                wTable.posCategory = PosCategory.PP;
                if (wTable.word.Length > 2)
                {
                    wTable.Cost = 0;
                }
                else if (wTable.word.Length == 2)
                {
                    wTable.Cost = 3;
                }
                else
                {
                    wTable.Cost = 5;
                }

                return(wTable);
            }

            // wordTableが辞書に完全一致で存在するか調べる。
            bool isExist = KJ_dict.CheckFull(wTable.word);

            if (isExist)
            {
                // 完全一致した語は判定せず、なにもしない。
                return(wTable);
            }


            // 助詞の分解を試みる
            WordChain resultChain = DivideHangulPP(wTable);

            if (resultChain == null)
            {
                // 助詞はついてなかった。なにもしない。
                return(wTable);
            }

            // resultChainは 語+助詞のチェーン。WordTと入れ替える
            wChain.Swap(wTable, resultChain);

            // 助詞で始まる熟語でないかチェック
            WordTable idiomwt = Idiom.Search(wChain, resultChain.Tail);

            // resultChainの先頭は未処理。
            // いったんcurrentをresultChainの先頭に戻す
            //     위원회를 --->    위원회          +   를
            //      wTable        resultChain.Head     [を]:翻訳済み
            wTable = resultChain.Head;


            return(wTable);
        }