mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-25 18:40:53 +00:00
fix minor issues with suggestions debug string
This commit is contained in:
parent
c43e3efbc1
commit
50b38d7687
1 changed files with 16 additions and 20 deletions
|
@ -236,6 +236,8 @@ public final class Suggest {
|
||||||
// and SuggestionStripView (shouldOmitTypedWord, getStyledSuggestedWord)
|
// and SuggestionStripView (shouldOmitTypedWord, getStyledSuggestedWord)
|
||||||
// but this could become more complicated than simply adding a duplicate word in a case
|
// but this could become more complicated than simply adding a duplicate word in a case
|
||||||
// where the first occurrence of that word is ignored
|
// where the first occurrence of that word is ignored
|
||||||
|
if (SuggestionStripView.DEBUG_SUGGESTIONS)
|
||||||
|
addDebugInfo(typedWordFirstOccurrenceWordInfo, typedWordString);
|
||||||
suggestionsList.add(2, typedWordFirstOccurrenceWordInfo);
|
suggestionsList.add(2, typedWordFirstOccurrenceWordInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,33 +480,27 @@ public final class Suggest {
|
||||||
|
|
||||||
private static ArrayList<SuggestedWordInfo> getSuggestionsInfoListWithDebugInfo(
|
private static ArrayList<SuggestedWordInfo> getSuggestionsInfoListWithDebugInfo(
|
||||||
final String typedWord, final ArrayList<SuggestedWordInfo> suggestions) {
|
final String typedWord, final ArrayList<SuggestedWordInfo> suggestions) {
|
||||||
final SuggestedWordInfo typedWordInfo = suggestions.get(0);
|
|
||||||
typedWordInfo.setDebugString("+");
|
|
||||||
final int suggestionsSize = suggestions.size();
|
final int suggestionsSize = suggestions.size();
|
||||||
final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>(suggestionsSize);
|
final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>(suggestionsSize);
|
||||||
suggestionsList.add(typedWordInfo);
|
for (final SuggestedWordInfo cur : suggestions) {
|
||||||
// Note: i here is the index in mScores[], but the index in mSuggestions is one more
|
addDebugInfo(cur, typedWord);
|
||||||
// than i because we added the typed word to mSuggestions without touching mScores.
|
|
||||||
for (int i = 0; i < suggestionsSize - 1; ++i) {
|
|
||||||
final SuggestedWordInfo cur = suggestions.get(i + 1);
|
|
||||||
final float normalizedScore = BinaryDictionaryUtils.calcNormalizedScore(
|
|
||||||
typedWord, cur.toString(), cur.mScore);
|
|
||||||
final String scoreInfoString;
|
|
||||||
if (normalizedScore > 0) {
|
|
||||||
scoreInfoString = String.format(
|
|
||||||
Locale.ROOT, "%d (%4.2f), %s", cur.mScore, normalizedScore,
|
|
||||||
cur.mSourceDict.mDictType + ":" + cur.mSourceDict.mLocale);
|
|
||||||
} else {
|
|
||||||
scoreInfoString = String.format(
|
|
||||||
Locale.ROOT, "%d, %s", cur.mScore,
|
|
||||||
cur.mSourceDict.mDictType + ":" + cur.mSourceDict.mLocale);
|
|
||||||
}
|
|
||||||
cur.setDebugString(scoreInfoString);
|
|
||||||
suggestionsList.add(cur);
|
suggestionsList.add(cur);
|
||||||
}
|
}
|
||||||
return suggestionsList;
|
return suggestionsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addDebugInfo(final SuggestedWordInfo wordInfo, final String typedWord) {
|
||||||
|
final float normalizedScore = BinaryDictionaryUtils.calcNormalizedScore(typedWord, wordInfo.toString(), wordInfo.mScore);
|
||||||
|
final String scoreInfoString;
|
||||||
|
String dict = wordInfo.mSourceDict.mDictType + ":" + wordInfo.mSourceDict.mLocale;
|
||||||
|
if (normalizedScore > 0) {
|
||||||
|
scoreInfoString = String.format(Locale.ROOT, "%d (%4.2f), %s", wordInfo.mScore, normalizedScore, dict);
|
||||||
|
} else {
|
||||||
|
scoreInfoString = String.format(Locale.ROOT, "%d, %s", wordInfo.mScore, dict);
|
||||||
|
}
|
||||||
|
wordInfo.setDebugString(scoreInfoString);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes whether this suggestion should be blocked or not in this language
|
* Computes whether this suggestion should be blocked or not in this language
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue