slightly tune glide typing garbage word detection

This commit is contained in:
Helium314 2023-12-05 08:14:11 +01:00
parent 43987ad037
commit 100da1beae

View file

@ -898,10 +898,16 @@ public class DictionaryFacilitatorImpl implements DictionaryFacilitator {
// (if the main dict contains shortcuts to non-words, this will break) // (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)); final boolean checkForGarbage = composedData.mIsBatchMode && (dictType.equals(Dictionary.TYPE_USER_HISTORY) || dictType.equals(Dictionary.TYPE_MAIN));
for (SuggestedWordInfo info : dictionarySuggestions) { for (SuggestedWordInfo info : dictionarySuggestions) {
if (!isBlacklisted(info.getWord())) { // don't add blacklisted words final String word = info.getWord();
if (!isBlacklisted(word)) { // don't add blacklisted words
if (checkForGarbage if (checkForGarbage
&& info.mSourceDict.mDictType.equals(dictType) // to only check history and "main main dictionary", and not addons like emoji // only check history and "main main dictionary"
&& !dictionary.isInDictionary(info.getWord())) // consider the user might use custom main dictionary containing shortcuts
// assume this is unlikely to happen, and take care about common shortcuts that are not actual words (emoji, symbols)
&& word.length() > 2 // should exclude most symbol shortcuts
&& info.mSourceDict.mDictType.equals(dictType) // dictType is always main, but info.mSourceDict.mDictType contains the actual dict (main dict is a dictionary group)
&& !StringUtils.mightBeEmoji(word) // emojis often have more than 2 chars; simplified check for performance reasons
&& !dictionary.isInDictionary(word))
continue; continue;
suggestions.add(info); suggestions.add(info);
} }