コード例 #1
0
        public static List <WordInformation> ConvertTokensToWords <T>(List <T> tokens, Database dictionary) where T : class, IToken
        {
            List <WordInformation> words   = WordConjungateCombiner.Combine(tokens, dictionary);
            WordListReducer        reducer = new WordListReducer();

            words = reducer.ReduceAll(words, dictionary);
            return(words);
        }
コード例 #2
0
        private static List <JmdictEntity> TrylongestWordSearch(WordInformation currentSelectedWord, int selectedIndex, List <WordInformation> words, Database japEngDictionary)
        {
            WordListReducer reducer     = new WordListReducer();
            var             longestWord = reducer.ReduceOnce(selectedIndex, words, japEngDictionary, true);

            if (!longestWord.Surface.Equals(currentSelectedWord.Surface, StringComparison.OrdinalIgnoreCase))
            {
                var perfectMatches = FindTokenPerfectMatchInDictionary(longestWord, japEngDictionary, true);
                if (perfectMatches.Count <= VALID_LONGEST_MATCH_COUNT)
                {
                    return(perfectMatches);
                }

                if (StringHelper.IsHaveKanji(longestWord.Surface) && perfectMatches.Count <= MAX_VALID_LONGEST_MATCH_COUNT)
                {
                    return(perfectMatches);
                }

                return(null);
            }

            return(null);
        }