Better trim
This commit is contained in:
parent
1c88d49452
commit
57d5f34ee5
1 changed files with 10 additions and 8 deletions
|
@ -83,12 +83,14 @@ void Dictionary::trim_suggestions(std::vector<std::string> &suggestions,
|
||||||
suggestions.erase(std::remove(suggestions.begin(), suggestions.end(), word),
|
suggestions.erase(std::remove(suggestions.begin(), suggestions.end(), word),
|
||||||
suggestions.end());
|
suggestions.end());
|
||||||
|
|
||||||
// Example: Remove any suggestions that are too short
|
auto l = word.length();
|
||||||
suggestions.erase(
|
std::cout << "WTF" << l << std::endl;
|
||||||
std::remove_if(suggestions.begin(), suggestions.end(),
|
|
||||||
[](const std::string &s) {
|
// Example: Remove any suggestions that are not within 1 string length
|
||||||
return s.length() <
|
suggestions.erase(std::remove_if(suggestions.begin(), suggestions.end(),
|
||||||
3; // Remove words shorter than 3 characters
|
[l](const std::string &s) {
|
||||||
|
return s.length() > (l + 1) ||
|
||||||
|
s.length() < (l - 1);
|
||||||
}),
|
}),
|
||||||
suggestions.end());
|
suggestions.end());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue