Skip to content

Commit

Permalink
Fix starts with entry ordering + Fix gray screen furigana when englis…
Browse files Browse the repository at this point in the history
…h result
  • Loading branch information
arianneorpilla committed Jan 19, 2023
1 parent f02e18a commit 0c447de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions yuuna/lib/src/language/implementations/japanese_language.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,6 @@ Future<DictionaryResult> prepareSearchResultsJapaneseLanguage(
.map((entry) => MapEntry(entry.id, entry)),
...(readingExactResultsByLength[length] ?? [])
.map((entry) => MapEntry(entry.id, entry)),
...startsWithResults.map(
(entry) => MapEntry(entry.id, entry),
),
];

List<MapEntry<int?, DictionaryEntry>> deinflectedEntriesToAdd = [
Expand All @@ -413,6 +410,9 @@ Future<DictionaryResult> prepareSearchResultsJapaneseLanguage(

uniqueEntriesById.addEntries(exactEntriesToAdd);
uniqueEntriesById.addEntries(deinflectedEntriesToAdd);
uniqueEntriesById.addEntries(startsWithResults.map(
(entry) => MapEntry(entry.id, entry),
));
}

List<DictionaryEntry> entries = uniqueEntriesById.values.toList();
Expand Down
21 changes: 13 additions & 8 deletions yuuna/lib/src/language/language_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,19 @@ class LanguageUtils {
}

String readingNormalized = _kanaKit.toHiragana(reading);
List<RubyTextData>? segments = segmentizeFurigana(
reading: reading,
readingNormalized: readingNormalized,
groups: groups,
groupsStart: 0,
);
if (segments != null) {
return segments;
try {
List<RubyTextData>? 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.
Expand Down

0 comments on commit 0c447de

Please sign in to comment.