DejavuPredictor Class Reference

`#include <dejavuPredictor.h>`

Inheritance diagram for DejavuPredictor:
Collaboration diagram for DejavuPredictor:

## 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

## 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

## mbr_func_ptr_t

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

private

Definition at line 76 of file dejavuPredictor.h.

## Constructor & Destructor Documentation

## DejavuPredictor()

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.

Here is the call graph for this function:

## ~DejavuPredictor()

DejavuPredictor::~DejavuPredictor | ( |  | ) |

Definition at line 56 of file dejavuPredictor.cpp.

## Member Function Documentation

## init_memory_trigger()

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:

## init_rolling_window()

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:

## learn()

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:

## match()

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:

## predict()

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:

## set_memory()

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:

## set_trigger()

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:

## update()

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:

## update_rolling_window()

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

## dispatch_map

std::map<std::string, mbr_func_ptr_t> DejavuPredictor::dispatch_map

private

Definition at line 77 of file dejavuPredictor.h.

## dispatcher

Dispatcher<DejavuPredictor> DejavuPredictor::dispatcher

private

Definition at line 94 of file dejavuPredictor.h.

Referenced by DejavuPredictor(), and update().

## LOGGER

std::string DejavuPredictor::LOGGER

private

Definition at line 87 of file dejavuPredictor.h.

Referenced by DejavuPredictor().

## MEMORY

std::string DejavuPredictor::MEMORY

private

Definition at line 88 of file dejavuPredictor.h.

Referenced by DejavuPredictor().

## memory

std::string DejavuPredictor::memory

private

Definition at line 91 of file dejavuPredictor.h.

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

## TRIGGER

std::string DejavuPredictor::TRIGGER

private

Definition at line 89 of file dejavuPredictor.h.

Referenced by DejavuPredictor().

## trigger

int DejavuPredictor::trigger

private

Definition at line 92 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:

- /build/presage-F72hLE/presage-0.9.1/src/lib/predictors/dejavuPredictor.h
- /build/presage-F72hLE/presage-0.9.1/src/lib/predictors/dejavuPredictor.cpp