predictorActivator.h
Go to the documentation of this file.
/******************************************************
* Presage, an extensible predictive text entry system
* ---------------------------------------------------
*
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
**********(*)*/
#ifndef PRESAGE_PREDICTORACTIVATOR
#define PRESAGE_PREDICTORACTIVATOR
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "configuration.h"
#include "predictorRegistry.h"
#include "context_tracker/contextTracker.h"
#include "prediction.h"
#include "logger.h"
#include "dispatcher.h"
#include "combiner.h"
#include "meritocracyCombiner.h"
#include "predictors/predictor.h"
#ifdef STDC_HEADERS
# include <stdlib.h> // needed for abort function
#endif
class PredictorActivator : public Observer {
public:
//PLUMP PredictorActivator(HistoryTracker&,
//PLUMP plump::Plump&);
PredictorActivator(Configuration* config, PredictorRegistry* registry, ContextTracker* contextTracker);
~PredictorActivator();
Prediction predict(unsigned int multiplier, const char** filter);
void setPredictors(const std::string& predictorList);
void addPredictor(const std::string& predictorName);
void removePredictors();
int getPredictTime() const;
void setPredictTime(const std::string& predictTime);
std::string getCombinationPolicy() const;
void setCombinationPolicy(const std::string& policy);
void setMaxPartialPredictionSize (const std::string& size);
void setLogger (const std::string& level);
void parse_internal_commands (Prediction& pred);
virtual void update (const Observable* variable);
static const char* LOGGER;
static const char* PREDICT_TIME;
static const char* MAX_PARTIAL_PREDICTION_SIZE;
static const char* COMBINATION_POLICY;
private:
// execute predictor function (invoked in thread)
void *execute(void *);
Configuration* config;
PredictorRegistry* predictorRegistry;
ContextTracker* contextTracker;
Logger<char> logger;
Combiner* combiner;
std::string combinationPolicy;
int max_partial_prediction_size;
std::vector<Prediction> predictions; // predictions computed by each predictor are returned here
int predict_time;
Dispatcher<PredictorActivator> dispatcher;
};
#endif // PRESAGE_PREDICTORACTIVATOR
Logger< char >
predictor.h
PredictorActivator::predict
Prediction predict(unsigned int multiplier, const char **filter)
Definition: predictorActivator.cpp:57
PredictorActivator::LOGGER
static const char * LOGGER
Definition: predictorActivator.h:166
PredictorActivator::getPredictTime
int getPredictTime() const
Definition: predictorActivator.cpp:117
Prediction
Definition: prediction.h:47
Combiner
Definition: combiner.h:40
Dispatcher< PredictorActivator >
PredictorActivator::config
Configuration * config
Definition: predictorActivator.h:176
PredictorActivator::combiner
Combiner * combiner
Definition: predictorActivator.h:182
PredictorActivator::setMaxPartialPredictionSize
void setMaxPartialPredictionSize(const std::string &size)
Definition: predictorActivator.cpp:146
PredictorActivator::PREDICT_TIME
static const char * PREDICT_TIME
Definition: predictorActivator.h:167
PredictorActivator::setPredictors
void setPredictors(const std::string &predictorList)
PredictorActivator::removePredictors
void removePredictors()
contextTracker.h
PredictorActivator::parse_internal_commands
void parse_internal_commands(Prediction &pred)
Definition: predictorActivator.cpp:160
PredictorActivator::MAX_PARTIAL_PREDICTION_SIZE
static const char * MAX_PARTIAL_PREDICTION_SIZE
Definition: predictorActivator.h:168
PredictorActivator::predict_time
int predict_time
Definition: predictorActivator.h:189
PredictorRegistry
Definition: predictorRegistry.h:46
PredictorActivator::setPredictTime
void setPredictTime(const std::string &predictTime)
Definition: predictorActivator.cpp:101
PredictorActivator::max_partial_prediction_size
int max_partial_prediction_size
Definition: predictorActivator.h:185
PredictorActivator::setCombinationPolicy
void setCombinationPolicy(const std::string &policy)
Definition: predictorActivator.cpp:123
PredictorActivator::getCombinationPolicy
std::string getCombinationPolicy() const
Definition: predictorActivator.cpp:140
configuration.h
combiner.h
PredictorActivator::update
virtual void update(const Observable *variable)
Definition: predictorActivator.cpp:153
PredictorActivator
Definition: predictorActivator.h:62
Observer
Definition: observer.h:34
dispatcher.h
prediction.h
PredictorActivator::PredictorActivator
PredictorActivator(Configuration *config, PredictorRegistry *registry, ContextTracker *contextTracker)
Definition: predictorActivator.cpp:33
predictorRegistry.h
Configuration
Definition: configuration.h:36
PredictorActivator::logger
Logger< char > logger
Definition: predictorActivator.h:180
PredictorActivator::setLogger
void setLogger(const std::string &level)
Definition: predictorActivator.cpp:94
PredictorActivator::COMBINATION_POLICY
static const char * COMBINATION_POLICY
Definition: predictorActivator.h:169
PredictorActivator::addPredictor
void addPredictor(const std::string &predictorName)
logger.h
PredictorActivator::combinationPolicy
std::string combinationPolicy
Definition: predictorActivator.h:183
meritocracyCombiner.h
PredictorActivator::contextTracker
ContextTracker * contextTracker
Definition: predictorActivator.h:178
ContextTracker
Tracks user interaction and context.
Definition: contextTracker.h:155
PredictorActivator::dispatcher
Dispatcher< PredictorActivator > dispatcher
Definition: predictorActivator.h:191
PredictorActivator::predictorRegistry
PredictorRegistry * predictorRegistry
Definition: predictorActivator.h:177
PredictorActivator::~PredictorActivator
~PredictorActivator()
Definition: predictorActivator.cpp:52
PredictorActivator::predictions
std::vector< Prediction > predictions
Definition: predictorActivator.h:187
Observable
Definition: observable.h:37
PredictorActivator::execute
void * execute(void *)