46 logger(
"PredictorRegistry", std::cerr),
84 std::set<std::string> active_predictors;
85 for (std::vector<Predictor*>::const_iterator it =
predictors.begin();
89 active_predictors.insert((*it)->getName());
93 std::set<std::string> desired_predictors;
95 std::string predictor;
96 while (ss >> predictor)
98 desired_predictors.insert(predictor);
102 std::set<std::string> predictors_to_remove;
103 std::set_difference(active_predictors.begin(), active_predictors.end(),
104 desired_predictors.begin(), desired_predictors.end(),
105 std::inserter(predictors_to_remove, predictors_to_remove.begin()));
108 std::set<std::string> predictors_to_add;
109 std::set_difference(desired_predictors.begin(), desired_predictors.end(),
110 active_predictors.begin(), active_predictors.end(),
111 std::inserter(predictors_to_add, predictors_to_add.begin()));
114 for (std::set<std::string>::const_iterator it = predictors_to_remove.begin();
115 it != predictors_to_remove.end();
122 for (std::set<std::string>::const_iterator it = predictors_to_add.begin();
123 it != predictors_to_add.end();
134 const char* name = predictorName.c_str();
135 std::string predictor_class_variable_key =
"Presage.Predictors." + predictorName +
".PREDICTOR";
136 Variable* predictor_class_variable = 0;
146 predictor_class_variable =
config->
find (predictor_class_variable_key);
148 std::string predictor_class = predictor_class_variable->
get_value();
150 if (predictor_class ==
"AbbreviationExpansionPredictor")
154 else if (predictor_class ==
"DummyPredictor")
158 else if (predictor_class ==
"DictionaryPredictor" )
163 else if (predictor_class ==
"SmoothedNgramPredictor")
168 else if (predictor_class ==
"RecencyPredictor")
172 else if (predictor_class ==
"DejavuPredictor")
176 else if (predictor_class ==
"ARPAPredictor")
182 logger << ERROR << predictor_class_variable_key <<
" class \"" 183 << predictor_class <<
"\" is unknown." <<
endl;
189 << ERROR <<
"Predictor " + predictorName +
" failed to initialize." <<
endl;
195 logger << INFO <<
"Activated predictor: " << predictorName <<
endl;
199 logger << FATAL <<
"Unable to initialize predictor: " << predictorName <<
endl;
206 logger << DEBUG <<
"Removing predictor: " << predictor_name <<
endl;
207 std::vector<Predictor*>::iterator it =
predictors.begin();
210 if ((*it)->getName() == predictor_name)
214 logger << DEBUG <<
"Removed predictor: " << predictor_name <<
endl;
225 for (
size_t i = 0; i <
predictors.size(); i++) {
241 : iter_end(cont.end()),
242 iter_curr(cont.begin())
250 bool result = (iter_end != iter_curr);
static const char * PREDICTORS
void dispatch(const Observable *var)
void removePredictor(const std::string &predictor_name)
Iterator(std::vector< Predictor *> &)
virtual void update(const Observable *variable)
PredictorRegistry(Configuration *config)
virtual const char * what() const
std::vector< Predictor * > predictors
_SetLevel setlevel(std::string __l)
Manipulator for level.
Dispatcher< PredictorRegistry > dispatcher
void addPredictor(const std::string &predictor_name)
Variable * find(const std::string &variable) const
static const char * LOGGER
std::string predictors_list
std::string get_value() const
void setContextTracker(ContextTracker *ct)
virtual std::string get_name() const =0
void setLogger(const std::string &level)
void map(Observable *var, const mbr_func_ptr_t &ptr)
Tracks user interaction and context.
virtual std::string get_value() const =0
void setPredictors(const std::string &predictor_list)
ContextTracker * contextTracker
const Logger< _charT, _Traits > & endl(const Logger< _charT, _Traits > &lgr)