Better trim

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

View file

@ -83,14 +83,16 @@ 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) ||
suggestions.end()); s.length() < (l - 1);
}),
suggestions.end());
} }
int Dictionary::spit(path p) { int Dictionary::spit(path p) {