mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-18 16:03:12 +00:00
somewhat improve garbage word issue
This commit is contained in:
parent
4d015d0c83
commit
79b84a0b58
2 changed files with 14 additions and 7 deletions
|
@ -890,13 +890,18 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
|
|||
weightForLocale, weightOfLangModelVsSpatialModel);
|
||||
if (null == dictionarySuggestions) continue;
|
||||
|
||||
// don't add blacklisted words
|
||||
// this may not be the most efficient way, but getting suggestions is much slower anyway
|
||||
// for some reason, garbage words are produced when glide typing
|
||||
// for user history and main dictionary we can filter them out by checking whether the
|
||||
// dictionary actually contains the word
|
||||
// but personal dictionary and addon dictionaries may contain shortcuts, which do not
|
||||
// pass an isInDictionary check (e.g. emojis)
|
||||
// (if the main dict contains shortcuts to non-words, this will break)
|
||||
final boolean checkForGarbage = composedData.mIsBatchMode && (dictType.equals(Dictionary.TYPE_USER_HISTORY) || dictType.equals(Dictionary.TYPE_MAIN));
|
||||
for (SuggestedWordInfo info : dictionarySuggestions) {
|
||||
if (!isBlacklisted(info.getWord())) {
|
||||
// for some reason, user history produces garbage words in batch mode
|
||||
// this also happens for other dictionaries, but for those the score usually is much lower, so they are less visible
|
||||
if (composedData.mIsBatchMode && dictType.equals(Dictionary.TYPE_USER_HISTORY) && !dictionary.isInDictionary(info.getWord()))
|
||||
if (!isBlacklisted(info.getWord())) { // don't add blacklisted words
|
||||
if (checkForGarbage
|
||||
&& info.mSourceDict.mDictType.equals(dictType) // to only check history and "main main dictionary", and not addons like emoji
|
||||
&& !dictionary.isInDictionary(info.getWord()))
|
||||
continue;
|
||||
suggestions.add(info);
|
||||
}
|
||||
|
|
|
@ -495,7 +495,9 @@ public final class Suggest {
|
|||
Locale.ROOT, "%d (%4.2f), %s", cur.mScore, normalizedScore,
|
||||
cur.mSourceDict.mDictType + ":" + cur.mSourceDict.mLocale);
|
||||
} else {
|
||||
scoreInfoString = Integer.toString(cur.mScore);
|
||||
scoreInfoString = String.format(
|
||||
Locale.ROOT, "%d, %s", cur.mScore,
|
||||
cur.mSourceDict.mDictType + ":" + cur.mSourceDict.mLocale);
|
||||
}
|
||||
cur.setDebugString(scoreInfoString);
|
||||
suggestionsList.add(cur);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue