public static List <JmdictEntity> SearchTokenWord(WordInformation selectedWord, int selectedIndex, List <WordInformation> words, Database japEngDictionary) { List <JmdictEntity> results = TrySearchCompoundVerbs(selectedWord, selectedIndex, words, japEngDictionary); if (results == null || results.Count == 0) { results = TrylongestWordSearch(selectedWord, selectedIndex, words, japEngDictionary); } if (results == null || results.Count == 0) { results = FindTokenPerfectMatchInDictionary(selectedWord, japEngDictionary); } else { results = results.Union(FindTokenPerfectMatchInDictionary(selectedWord, japEngDictionary), JmdictEntity.EqualComparer).ToList(); } var possibleWord = WordInformation.TryRemoveGodanPotential(selectedWord, japEngDictionary); if (possibleWord != null) { var newResults = FindTokenPerfectMatchInDictionary(possibleWord, japEngDictionary); results = results.Union(newResults, JmdictEntity.EqualComparer).ToList(); } if (StringHelper.IsKatakanaOnly(selectedWord.Surface)) { results = TrySearchByConvertToHira(selectedWord, japEngDictionary, results); } if (results.Count == 0) { return(FindTokenPartialMatchInDictionary(selectedWord, japEngDictionary)); } else { return(results); } }
private static List <JmdictEntity> TrySearchCompoundVerbs(WordInformation currentSelectedWord, int selectedIndex, List <WordInformation> words, Database japEngDictionary) { if (currentSelectedWord.IsVerb() && currentSelectedWord.IsMasuConjugation() && (selectedIndex < (words.Count - 1)) && words[selectedIndex + 1].IsVerb()) { var nextWord = words[selectedIndex + 1]; //Remove potential conjugation if has to make sure word is in its most baseform var nextWordBase = WordInformation.TryRemoveGodanPotential(nextWord, japEngDictionary); if (nextWordBase != null) { nextWord = nextWordBase; } string baseForm = currentSelectedWord.Surface + nextWord.BaseForm; var compoundWord = new WordInformation(nextWord.FirstConjugationType, nextWord.FirstConjugationForm, baseForm, nextWord.PartOfSpeech, false, nextWord.Conjugation); compoundWord.AddWordPart(currentSelectedWord.Surface + nextWord.Surface, currentSelectedWord.Reading + nextWord.Reading, currentSelectedWord.Pronunciation + nextWord.Pronunciation); return(FindTokenPerfectMatchInDictionary(compoundWord, japEngDictionary)); } return(null); }