34 "DictionaryPredictor, dictionary lookup",
35 "DictionaryPredictor, a dictionary based predictor that generates a prediction by extracting tokens that start with the current prefix from a given dictionary" 57 logger << INFO <<
"DICTIONARY: " << value <<
endl;
64 logger << INFO <<
"PROBABILITY: " << value <<
endl;
71 std::string candidate;
74 std::ifstream dictionary_file;
78 assert(dictionary_file);
81 unsigned int count = 0;
82 while(dictionary_file >> candidate && count < max_partial_predictions_size) {
83 if(candidate.find(prefix) == 0) {
84 logger << NOTICE <<
"Found valid token: " << candidate <<
endl;
86 logger << NOTICE <<
"Filter check satisfied by token: " << candidate <<
endl;
90 logger << NOTICE <<
"Filter check failed, discarding token: " << candidate <<
endl;
93 logger << INFO <<
"Discarding invalid token: " << candidate <<
endl;
97 dictionary_file.close();
104 std::cout <<
"DictionaryPredictor::learn() method called" <<
std::endl;
105 std::cout <<
"DictionaryPredictor::learn() method exited" <<
std::endl;
DictionaryPredictor(Configuration *, ContextTracker *, const char *)
virtual void learn(const std::vector< std::string > &change)
void dispatch(const Observable *var)
virtual Prediction predict(const size_t size, const char **filter) const
Generate prediction.
virtual void set_logger(const std::string &level)
std::string dictionary_path
const std::string PREDICTORS
void set_dictionary(const std::string &value)
static double toDouble(const std::string)
virtual void update(const Observable *variable)
virtual std::string get_name() const =0
void map(Observable *var, const mbr_func_ptr_t &ptr)
ContextTracker * contextTracker
void set_probability(const std::string &value)
void addSuggestion(Suggestion)
Tracks user interaction and context.
virtual std::string get_value() const =0
std::string getPrefix() const
Dispatcher< DictionaryPredictor > dispatcher
virtual bool token_satisfies_filter(const std::string &token, const std::string &prefix, const char **filter) const
const Logger< _charT, _Traits > & endl(const Logger< _charT, _Traits > &lgr)