Better trim

This commit is contained in:
Imbus 2024-11-21 09:33:20 +01:00
parent 1c88d49452
commit 57d5f34ee5

View file

@ -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());
}