presage  0.8.7
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
DejavuPredictor Class Reference

#include <dejavuPredictor.h>

Inheritance diagram for DejavuPredictor:
Inheritance graph
[legend]
Collaboration diagram for DejavuPredictor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DejavuPredictor (Configuration *, ContextTracker *)
 ~DejavuPredictor ()
virtual Prediction predict (const size_t size, const char **filter) const
 Generate prediction.
virtual void learn (const std::vector< std::string > &change)
virtual void update (const Observable *variable)

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 memory
int trigger
Dispatcher< DejavuPredictordispatcher

Static Private Attributes

static const char * LOGGER = "Presage.Predictors.DejavuPredictor.LOGGER"
static const char * MEMORY = "Presage.Predictors.DejavuPredictor.MEMORY"
static const char * TRIGGER = "Presage.Predictors.DejavuPredictor.TRIGGER"

Detailed Description

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.


Member Typedef Documentation

typedef void(DejavuPredictor::* DejavuPredictor::mbr_func_ptr_t)(const std::string &value) [private]

Definition at line 56 of file dejavuPredictor.h.


Constructor & Destructor Documentation

Definition at line 40 of file dejavuPredictor.cpp.

References dispatcher, Configuration::find(), LOGGER, Dispatcher< class_t >::map(), MEMORY, Predictor::set_logger(), set_memory(), set_trigger(), and TRIGGER.

Here is the call graph for this function:

Definition at line 55 of file dejavuPredictor.cpp.


Member Function Documentation

bool DejavuPredictor::init_memory_trigger ( std::list< std::string > &  memory_trigger) const [private]

Initialize memory trigger.

Parameters:
memory_triggercontains tokens that will trigger a memory recollection
Returns:
true if memory trigger has been populated with enough tokens to trigger a memory recollection, false otherwise

Definition at line 150 of file dejavuPredictor.cpp.

References Predictor::contextTracker, endl(), ContextTracker::getToken(), Predictor::logger, and trigger.

Referenced by predict().

Here is the call graph for this function:

Here is the caller graph for this function:

bool DejavuPredictor::init_rolling_window ( std::list< std::string > &  rolling_window,
std::ifstream &  memory_file 
) const [private]

Initialize rolling window.

Returns:
true if initialized rolling window has been populated with enough tokens to trigger a memory recollection, false otherwise

Definition at line 178 of file dejavuPredictor.cpp.

References endl(), Predictor::logger, and trigger.

Referenced by predict().

Here is the call graph for this function:

Here is the caller graph for this function:

void DejavuPredictor::learn ( const std::vector< std::string > &  change) [virtual]

Implements Predictor.

Definition at line 112 of file dejavuPredictor.cpp.

References endl(), Predictor::logger, and memory.

Here is the call graph for this function:

bool DejavuPredictor::match ( const std::list< std::string > &  l1,
const std::list< std::string > &  l2 
) const [private]

Tests two list arguments match.

Returns:
true if lists contain the same tokens in the same order, false otherwise

Definition at line 136 of file dejavuPredictor.cpp.

Referenced by predict().

Here is the caller graph for this function:

Prediction DejavuPredictor::predict ( const size_t  size,
const char **  filter 
) const [virtual]

Generate prediction.

Parameters:
sizedesired prediction size
filterfilter

Implements Predictor.

Definition at line 70 of file dejavuPredictor.cpp.

References Prediction::addSuggestion(), endl(), init_memory_trigger(), init_rolling_window(), Predictor::logger, match(), memory, and update_rolling_window().

Here is the call graph for this function:

void DejavuPredictor::set_memory ( const std::string &  filename) [private]

Definition at line 58 of file dejavuPredictor.cpp.

References endl(), Predictor::logger, and memory.

Referenced by DejavuPredictor().

Here is the call graph for this function:

Here is the caller graph for this function:

void DejavuPredictor::set_trigger ( const std::string &  number) [private]

Definition at line 64 of file dejavuPredictor.cpp.

References endl(), Predictor::logger, Utility::toInt(), and trigger.

Referenced by DejavuPredictor().

Here is the call graph for this function:

Here is the caller graph for this function:

void DejavuPredictor::update ( const Observable variable) [virtual]

Implements Observer.

Definition at line 206 of file dejavuPredictor.cpp.

References Dispatcher< class_t >::dispatch(), dispatcher, endl(), Observable::get_name(), Observable::get_value(), and Predictor::logger.

Here is the call graph for this function:

void DejavuPredictor::update_rolling_window ( std::list< std::string > &  rolling_window,
const std::string &  token 
) const [private]

Update rolling window.

Pop front token and push back new token to list.

Definition at line 199 of file dejavuPredictor.cpp.

References endl(), and Predictor::logger.

Referenced by predict().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

std::map<std::string, mbr_func_ptr_t> DejavuPredictor::dispatch_map [private]

Definition at line 57 of file dejavuPredictor.h.

Definition at line 74 of file dejavuPredictor.h.

Referenced by DejavuPredictor(), and update().

const char * DejavuPredictor::LOGGER = "Presage.Predictors.DejavuPredictor.LOGGER" [static, private]

Definition at line 67 of file dejavuPredictor.h.

Referenced by DejavuPredictor().

const char * DejavuPredictor::MEMORY = "Presage.Predictors.DejavuPredictor.MEMORY" [static, private]

Definition at line 68 of file dejavuPredictor.h.

Referenced by DejavuPredictor().

std::string DejavuPredictor::memory [private]

Definition at line 71 of file dejavuPredictor.h.

Referenced by learn(), predict(), and set_memory().

const char * DejavuPredictor::TRIGGER = "Presage.Predictors.DejavuPredictor.TRIGGER" [static, private]

Definition at line 69 of file dejavuPredictor.h.

Referenced by DejavuPredictor().

int DejavuPredictor::trigger [private]

Definition at line 72 of file dejavuPredictor.h.

Referenced by init_memory_trigger(), init_rolling_window(), and set_trigger().


The documentation for this class was generated from the following files: