diff --git a/yuuna/lib/src/language/implementations/japanese_language.dart b/yuuna/lib/src/language/implementations/japanese_language.dart index e1b18fae8..0513ef5b8 100644 --- a/yuuna/lib/src/language/implementations/japanese_language.dart +++ b/yuuna/lib/src/language/implementations/japanese_language.dart @@ -399,9 +399,6 @@ Future prepareSearchResultsJapaneseLanguage( .map((entry) => MapEntry(entry.id, entry)), ...(readingExactResultsByLength[length] ?? []) .map((entry) => MapEntry(entry.id, entry)), - ...startsWithResults.map( - (entry) => MapEntry(entry.id, entry), - ), ]; List> deinflectedEntriesToAdd = [ @@ -413,6 +410,9 @@ Future prepareSearchResultsJapaneseLanguage( uniqueEntriesById.addEntries(exactEntriesToAdd); uniqueEntriesById.addEntries(deinflectedEntriesToAdd); + uniqueEntriesById.addEntries(startsWithResults.map( + (entry) => MapEntry(entry.id, entry), + )); } List entries = uniqueEntriesById.values.toList(); diff --git a/yuuna/lib/src/language/language_utils.dart b/yuuna/lib/src/language/language_utils.dart index eb3e2e547..61d706c08 100644 --- a/yuuna/lib/src/language/language_utils.dart +++ b/yuuna/lib/src/language/language_utils.dart @@ -124,14 +124,19 @@ class LanguageUtils { } String readingNormalized = _kanaKit.toHiragana(reading); - List? segments = segmentizeFurigana( - reading: reading, - readingNormalized: readingNormalized, - groups: groups, - groupsStart: 0, - ); - if (segments != null) { - return segments; + try { + List? segments = segmentizeFurigana( + reading: reading, + readingNormalized: readingNormalized, + groups: groups, + groupsStart: 0, + ); + if (segments != null) { + return segments; + } + } catch (e) { + /// This is the fallback upon failure. + return [RubyTextData(term, ruby: reading)]; } /// This is the fallback upon failure.