presage
0.9.2~beta
|
#include <dejavuPredictor.h>
Public Member Functions | |
DejavuPredictor (Configuration *, ContextTracker *, const char *) | |
~DejavuPredictor () | |
virtual Prediction | predict (const size_t size, const char **filter) const |
Generate prediction. More... | |
virtual void | learn (const std::vector< std::string > &change) |
virtual void | update (const Observable *variable) |
Public Member Functions inherited from Predictor | |
Predictor (Configuration *configuration, ContextTracker *contextTracker, const char *predictorName="Predictor", const char *shortDescription="", const char *longDescription="") | |
virtual | ~Predictor () |
const std::string | getName () const |
const std::string | getShortDescription () const |
const std::string | getLongDescription () const |
Public Member Functions inherited from Observer | |
virtual | ~Observer () |
Private Types | |
typedef void(DejavuPredictor::* | mbr_func_ptr_t) (const std::string &value) |
Private Member Functions | |
bool | init_memory_trigger (std::list< std::string > &) const |
bool | match (const std::list< std::string > &, const std::list< std::string > &) const |
bool | init_rolling_window (std::list< std::string > &, std::ifstream &) const |
void | update_rolling_window (std::list< std::string > &, const std::string &) const |
void | set_memory (const std::string &filename) |
void | set_trigger (const std::string &number) |
Private Attributes | |
std::map< std::string, mbr_func_ptr_t > | dispatch_map |
std::string | LOGGER |
std::string | MEMORY |
std::string | TRIGGER |
std::string | memory |
int | trigger |
Dispatcher< DejavuPredictor > | dispatcher |
Additional Inherited Members | |
Protected Member Functions inherited from Predictor | |
virtual bool | token_satisfies_filter (const std::string &token, const std::string &prefix, const char **filter) const |
virtual void | set_logger (const std::string &level) |
Protected Member Functions inherited from Observer | |
Observer () | |
Protected Attributes inherited from Predictor | |
const std::string | name |
const std::string | shortDescription |
const std::string | longDescription |
const std::string | PREDICTORS |
ContextTracker * | contextTracker |
Configuration * | configuration |
Logger< char > | logger |
Dejavu predictor learns and reproduces previously seen text tokens, once its memory is triggered by a known token sequence.
Dejavu predictor is able to learn and then later reproduce previously seen text sequences. The goal of dejavu predictor is to write a simple predictor that demonstrates how learning can be implemented in the presage system and exposes what functionality is required for learning predictors to work within the presage framework.
Definition at line 44 of file dejavuPredictor.h.
|
private |
Definition at line 56 of file dejavuPredictor.h.
DejavuPredictor::DejavuPredictor | ( | Configuration * | config, |
ContextTracker * | ct, | ||
const char * | name | ||
) |
Definition at line 37 of file dejavuPredictor.cpp.
References config, dispatcher, LOGGER, Dispatcher< class_t >::map(), MEMORY, Predictor::name, Predictor::PREDICTORS, Predictor::set_logger(), set_memory(), set_trigger(), and TRIGGER.
DejavuPredictor::~DejavuPredictor | ( | ) |
Definition at line 56 of file dejavuPredictor.cpp.
|
private |
Initialize memory trigger.
memory_trigger | contains tokens that will trigger a memory recollection |
Definition at line 154 of file dejavuPredictor.cpp.
References Predictor::contextTracker, endl(), ContextTracker::getToken(), Predictor::logger, and trigger.
Referenced by predict().
|
private |
Initialize rolling window.
Definition at line 182 of file dejavuPredictor.cpp.
References endl(), Predictor::logger, and trigger.
Referenced by predict().
|
virtual |
Implements Predictor.
Definition at line 116 of file dejavuPredictor.cpp.
References endl(), Predictor::logger, and memory.
|
private |
Tests two list arguments match.
Definition at line 140 of file dejavuPredictor.cpp.
Referenced by predict().
|
virtual |
Generate prediction.
size | desired prediction size |
filter | filter |
Implements Predictor.
Definition at line 71 of file dejavuPredictor.cpp.
References Prediction::addSuggestion(), Predictor::contextTracker, endl(), ContextTracker::getPrefix(), init_memory_trigger(), init_rolling_window(), Predictor::logger, match(), memory, Predictor::token_satisfies_filter(), and update_rolling_window().
|
private |
Definition at line 59 of file dejavuPredictor.cpp.
References endl(), Predictor::logger, and memory.
Referenced by DejavuPredictor().
|
private |
Definition at line 65 of file dejavuPredictor.cpp.
References endl(), Predictor::logger, Utility::toInt(), and trigger.
Referenced by DejavuPredictor().
|
virtual |
Implements Observer.
Definition at line 210 of file dejavuPredictor.cpp.
References Dispatcher< class_t >::dispatch(), dispatcher, endl(), Observable::get_name(), Observable::get_value(), and Predictor::logger.
|
private |
Update rolling window.
Pop front token and push back new token to list.
Definition at line 203 of file dejavuPredictor.cpp.
References endl(), and Predictor::logger.
Referenced by predict().
|
private |
Definition at line 57 of file dejavuPredictor.h.
|
private |
Definition at line 74 of file dejavuPredictor.h.
Referenced by DejavuPredictor(), and update().
|
private |
Definition at line 67 of file dejavuPredictor.h.
Referenced by DejavuPredictor().
|
private |
Definition at line 68 of file dejavuPredictor.h.
Referenced by DejavuPredictor().
|
private |
Definition at line 71 of file dejavuPredictor.h.
Referenced by learn(), predict(), and set_memory().
|
private |
Definition at line 69 of file dejavuPredictor.h.
Referenced by DejavuPredictor().
|
private |
Definition at line 72 of file dejavuPredictor.h.
Referenced by init_memory_trigger(), init_rolling_window(), and set_trigger().