Exemplo n.º 1
0
        private void addToIndex(EdictEntryBuilder entry)
        {
            foreach (DictionaryKeyBuilder key in entry.kanji)
            {
                if (key.text.Length == 1 && TextUtils.isAllKatakana(key.text))
                {
                    continue;
                }
                double rate       = entry.globalMultiplier * key.rate;
                string stem       = inflect.getStem(key.text, entry.POS);
                int    kanjiCount = stem.Count((c) => TextUtils.isKanji(c));
                if (kanjiCount > 1)
                {
                    rate = rate * 2.0; // kanji are good
                }
                addToIndex(mainIndex, stem, rate, entry);
            }
            if (entry.kanji.Count == 0 && entry.kana.Count > 0)
            {
                foreach (DictionaryKeyBuilder key in entry.kana)
                {
                    if (key.text == "です")       // DESU DESU DESU
                    {
                        entry.addPOS("copula"); // DESU DESU DESU
                    }
                    string stem = inflect.getStem(key.text, entry.POS);
                    double rate;
                    if (key.text == "は" || key.text == "が" || key.text == "の" || key.text == "に" || key.text == "し")
                    {
                        rate = 2.0; // these are good
                    }
                    else
                    {
                        rate = entry.globalMultiplier * Math.Max(key.rate, 1.3);

                        /*if (stem.Length == 1 && rate > 1.0) {
                         *  rate = 1.0;
                         * }*/
                    }
                    addToIndex(mainIndex, stem, rate, entry);
                }
            }
            else
            {
                foreach (DictionaryKeyBuilder key in entry.kana)
                {
                    if (key.text.Length > 1)
                    {
                        string stem = inflect.getStem(key.text, entry.POS);
                        double rate = entry.globalMultiplier * entry.globalKanaMultiplier * key.rate;
                        if (rate > 0)
                        {
                            addToIndex(kanaIndex, stem, rate, entry);
                        }
                    }
                }
            }
        }