Skip flags and some other suggestions.

This commit is contained in:
John Preston 2019-04-01 14:19:36 +04:00
parent a12bc60ef5
commit 9ba65e9ca0
1 changed files with 22 additions and 1 deletions

View File

@ -46,6 +46,25 @@ struct LangPackData {
return (code == 0x2122U) || (code == 0xA9U) || (code == 0xAEU);
}
[[nodiscard]] bool SkipExactKeyword(
const QString &language,
const QString &word) {
if (language != qstr("en")) {
return false;
} else if ((word.size() == 1)
&& (word[0] != '$')
&& (word[0].unicode() != 8364)) { // Euro.
return true;
} else if ((word.size() == 2)
&& (word != qstr("us"))
&& (word != qstr("uk"))
&& (word != qstr("hi"))
&& (word != qstr("ok"))) {
return true;
}
return false;
}
void CreateCacheFilePath() {
QDir().mkpath(internal::CacheFileFolder() + qstr("/keywords"));
}
@ -416,7 +435,9 @@ void EmojiKeywords::LangPack::apiChanged() {
std::vector<Result> EmojiKeywords::LangPack::query(
const QString &normalized,
bool exact) const {
if (normalized.size() > _data.maxKeyLength || _data.emoji.empty()) {
if (normalized.size() > _data.maxKeyLength
|| _data.emoji.empty()
|| (exact && SkipExactKeyword(_id, normalized))) {
return {};
}