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;
virtual void update(const Observable *variable)
std::map< std::string, std::string > cache
AbbreviationExpansionPredictor(Configuration *, ContextTracker *, const char *)
std::string abbreviations
void set_abbreviations(const std::string &filename)
Dispatcher< AbbreviationExpansionPredictor > dispatcher
virtual Prediction predict(const size_t size, const char **filter) const
Generate prediction.
std::string ABBREVIATIONS
virtual void learn(const std::vector< std::string > &change)
~AbbreviationExpansionPredictor()
void cacheAbbreviationsExpansions()
Tracks user interaction and context.
std::string getPrefix() const
void dispatch(const Observable *var)
void map(Observable *var, const mbr_func_ptr_t &ptr)
virtual std::string get_name() const =0
virtual std::string get_value() const =0
void addSuggestion(Suggestion)
ContextTracker * contextTracker
const std::string PREDICTORS
virtual void set_logger(const std::string &level)
const Logger< _charT, _Traits > & endl(const Logger< _charT, _Traits > &lgr)