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.end());
|
||||
|
||||
// Example: Remove any suggestions that are too short
|
||||
suggestions.erase(
|
||||
std::remove_if(suggestions.begin(), suggestions.end(),
|
||||
[](const std::string &s) {
|
||||
return s.length() <
|
||||
3; // Remove words shorter than 3 characters
|
||||
auto l = word.length();
|
||||
std::cout << "WTF" << l << std::endl;
|
||||
|
||||
// Example: Remove any suggestions that are not within 1 string length
|
||||
suggestions.erase(std::remove_if(suggestions.begin(), suggestions.end(),
|
||||
[l](const std::string &s) {
|
||||
return s.length() > (l + 1) ||
|
||||
s.length() < (l - 1);
|
||||
}),
|
||||
suggestions.end());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue