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 *, const char *)
 ~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 LOGGER
std::string MEMORY
std::string TRIGGER
std::string memory
int trigger
Dispatcher< DejavuPredictordispatcher

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

DejavuPredictor::DejavuPredictor ( Configuration config,
ContextTracker ct,
const char *  name 
)
DejavuPredictor::~DejavuPredictor (  ) 

Definition at line 56 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_trigger contains 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 154 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 182 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 116 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 140 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:
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().

Here is the call graph for this function:

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

Definition at line 59 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 65 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 210 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 203 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().

std::string DejavuPredictor::LOGGER [private]

Definition at line 67 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().

std::string DejavuPredictor::MEMORY [private]

Definition at line 68 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().

std::string DejavuPredictor::TRIGGER [private]

Definition at line 69 of file dejavuPredictor.h.

Referenced by DejavuPredictor().


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

Generated on 9 Feb 2015 for presage by  doxygen 1.6.1