34 "AbbreviationExpansionPredictor, maps abbreviations to the corresponding fully expanded token.",
35 "AbbreviationExpansionPredictor maps abbreviations to the corresponding fully expanded token (i.e. word or phrase).\n\nThe mapping between abbreviations and expansions is stored in the file specified by the predictor configuration section.\n\nThe format for the abbreviation-expansion database is a simple tab separated text file format, with each abbreviation-expansion pair per line." 68 std::map< std::string, std::string >::const_iterator it =
cache.find(prefix);
70 if (it !=
cache.end()) {
73 std::string expansion(prefix.size(),
'\b');
76 expansion += it->second;
81 logger << NOTICE <<
"Could not find expansion for abbreviation: " << prefix <<
endl;
106 std::string abbreviation;
107 std::string expansion;
108 std::string::size_type tab_pos;
109 while (getline(abbr_file,
buffer)) {
110 tab_pos =
buffer.find_first_of(
'\t');
111 if (tab_pos == std::string::npos) {
114 abbreviation =
buffer.substr(0, tab_pos);
115 expansion =
buffer.substr(tab_pos + 1, std::string::npos);
117 logger << INFO <<
"Caching abbreviation: " << abbreviation <<
" - expansion: " << expansion <<
endl;
118 cache[abbreviation] = expansion;
Dispatcher< AbbreviationExpansionPredictor > dispatcher
AbbreviationExpansionPredictor(Configuration *, ContextTracker *, const char *)
void dispatch(const Observable *var)
~AbbreviationExpansionPredictor()
virtual void set_logger(const std::string &level)
const std::string PREDICTORS
std::map< std::string, std::string > cache
void cacheAbbreviationsExpansions()
std::string abbreviations
virtual void learn(const std::vector< std::string > &change)
virtual std::string get_name() const =0
void map(Observable *var, const mbr_func_ptr_t &ptr)
ContextTracker * contextTracker
std::string ABBREVIATIONS
void addSuggestion(Suggestion)
virtual void update(const Observable *variable)
virtual Prediction predict(const size_t size, const char **filter) const
Generate prediction.
Tracks user interaction and context.
virtual std::string get_value() const =0
void set_abbreviations(const std::string &filename)
std::string getPrefix() const
const Logger< _charT, _Traits > & endl(const Logger< _charT, _Traits > &lgr)