コード例 #1
0
 public void addMatch(EdictMatchWithType match, InflectionState inf, double score)
 {
     this.matches.Add(Tuple.Create(match, inf, score));
     this.matches.Sort(sortByDescendingScore);
 }
コード例 #2
0
        public string getStemReading()
        {
            string stem = match.match.stem;

            if (string.IsNullOrEmpty(stem))
            {
                return(null);
            }
            if (match.matchType == EdictMatchType.KANJI)
            {
                var entry = getSelectedEntry();
                if (entry == null)
                {
                    return(null);
                }
                // hack :(
                string suffix = null;
                if (entry.kanji.Count > 0)
                {
                    foreach (DictionaryKey k in entry.kanji)
                    {
                        if (k.text.StartsWith(stem))
                        {
                            string newSuffix = k.text.Substring(stem.Length);
                            if (suffix == null || newSuffix.Length < suffix.Length)
                            {
                                suffix = newSuffix;
                            }
                        }
                    }
                    if (suffix == null)
                    {
                        suffix = "";
                    }
                    suffix = InflectionState.getReading(suffix);
                    string kanaStem    = null;
                    var    userReading = (Settings.app.getSelectedReading(stem));
                    if (userReading != null && userReading.EndsWith(suffix))
                    {
                        kanaStem = userReading.Substring(0, userReading.Length - suffix.Length);
                    }
                    else
                    {
                        foreach (DictionaryKey k in entry.kana)
                        {
                            if (k.text.EndsWith(suffix))
                            {
                                kanaStem = k.text.Substring(0, k.text.Length - suffix.Length);
                                break;
                            }
                        }
                    }
                    if (kanaStem == null)
                    {
                        return(null);
                    }
                    return(kanaStem);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
 public WordParseResult(string originalText, EdictMatchWithType match, InflectionState inf, double score)
 {
     this.originalText = originalText;
     this.addMatch(match, inf, score);
 }