31 #ifndef DATA_TOKENCORRECT_HPP_ 32 #define DATA_TOKENCORRECT_HPP_ 34 #include "../Wrapper/AspellChecker.hpp" 35 #include "../Wrapper/AspellConfig.hpp" 66 void correct(std::string& token);
109 this->config.
setOption(
"encoding",
"utf-8");
112 if(!language.empty()) {
113 this->config.
setOption(
"lang", language);
116 this->checker.
create(this->config);
130 std::vector<std::string> suggested;
132 if(this->checker.
check(token, suggested) || suggested.empty()) {
136 token = suggested.front();
virtual ~TokenCorrect()=default
Default destructor.
RAII wrapper for aspell configurations.
Definition: AspellConfig.hpp:58
TokenCorrect & operator=(TokenCorrect &)=delete
Deleted copy assignment operator.
RAII wrapper for aspell spell checkers.
Definition: AspellChecker.hpp:62
void correct(std::string &token)
Corrects a token, if aspell offers at least one correction proposal.
Definition: TokenCorrect.hpp:129
void setOption(const std::string &name, const std::string &value)
Sets an option in the configuration.
Definition: AspellConfig.hpp:186
void create(AspellConfig &configuration)
Creates the spell checker.
Definition: AspellChecker.hpp:197
bool check(const std::string &token, std::vector< std::string > &suggestionsTo)
Checks whether a token is correctly spelled.
Definition: AspellChecker.hpp:254
TokenCorrect(const std::string &language)
Constructor setting options for the token correction.
Definition: TokenCorrect.hpp:108
Corrects tokens using an aspell dictionary.
Definition: TokenCorrect.hpp:47
Namespace for different types of data.