presage  0.8.7
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
SmoothedNgramPredictor Class Reference

#include <smoothedNgramPredictor.h>

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

List of all members.

Public Member Functions

 SmoothedNgramPredictor (Configuration *, ContextTracker *)
 ~SmoothedNgramPredictor ()
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 Member Functions

unsigned int count (const std::vector< std::string > &tokens, int offset, int ngram_size) const
 Builds the required n-gram and returns its count.
void check_learn_consistency (const Ngram &name) const
void set_dbfilename (const std::string &filename)
void set_deltas (const std::string &deltas)
void set_database_logger_level (const std::string &value)
void set_learn (const std::string &deltas)

Private Attributes

DatabaseConnectordb
std::string dbfilename
std::string dbloglevel
std::vector< double > deltas
bool wanna_learn
Dispatcher
< SmoothedNgramPredictor
dispatcher

Static Private Attributes

static const char * LOGGER = "Presage.Predictors.SmoothedNgramPredictor.LOGGER"
static const char * DBFILENAME = "Presage.Predictors.SmoothedNgramPredictor.DBFILENAME"
static const char * DELTAS = "Presage.Predictors.SmoothedNgramPredictor.DELTAS"
static const char * LEARN = "Presage.Predictors.SmoothedNgramPredictor.LEARN"
static const char * DATABASE_LOGGER = "Presage.Predictors.SmoothedNgramPredictor.DatabaseConnector.LOGGER"

Detailed Description

Smoothed n-gram statistical predictor.

Definition at line 47 of file smoothedNgramPredictor.h.


Constructor & Destructor Documentation

Definition at line 55 of file smoothedNgramPredictor.cpp.

References db.


Member Function Documentation

void SmoothedNgramPredictor::check_learn_consistency ( const Ngram name) const [private]

Definition at line 370 of file smoothedNgramPredictor.cpp.

References count(), db, endl(), DatabaseConnector::incrementNgramCount(), Predictor::logger, and Logger< _charT, _Traits >::shouldLog().

Referenced by learn().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int SmoothedNgramPredictor::count ( const std::vector< std::string > &  tokens,
int  offset,
int  ngram_size 
) const [private]

Builds the required n-gram and returns its count.

Parameters:
tokenstokens[i] contains ContextTracker::getToken(i)
offsetentry point into tokens, must be a non-positive number
ngram_sizesize of the ngram whose count is returned, must not be greater than tokens size
Returns:
count of the ngram built based on tokens, offset and ngram_size
 Let tokens = [ "how", "are", "you", "today" ];

 count(tokens,  0, 3) returns the count associated with 3-gram [ "are", "you", "today" ].
 count(tokens, -1, 2) returns the count associated with 2-gram [ "are", "you" ];
 * 

Definition at line 119 of file smoothedNgramPredictor.cpp.

References db, endl(), DatabaseConnector::getNgramCount(), DatabaseConnector::getUnigramCountsSum(), and Predictor::logger.

Referenced by check_learn_consistency(), and predict().

Here is the call graph for this function:

Here is the caller graph for this function:

void SmoothedNgramPredictor::learn ( const std::vector< std::string > &  change) [virtual]
Prediction SmoothedNgramPredictor::predict ( const size_t  size,
const char **  filter 
) const [virtual]
void SmoothedNgramPredictor::set_database_logger_level ( const std::string &  value) [private]

Definition at line 79 of file smoothedNgramPredictor.cpp.

References dbloglevel.

Referenced by SmoothedNgramPredictor().

Here is the caller graph for this function:

void SmoothedNgramPredictor::set_dbfilename ( const std::string &  filename) [private]

Definition at line 61 of file smoothedNgramPredictor.cpp.

References db, dbfilename, dbloglevel, endl(), and Predictor::logger.

Referenced by SmoothedNgramPredictor().

Here is the call graph for this function:

Here is the caller graph for this function:

void SmoothedNgramPredictor::set_deltas ( const std::string &  deltas) [private]

Definition at line 85 of file smoothedNgramPredictor.cpp.

References deltas, endl(), Predictor::logger, and Utility::toDouble().

Referenced by SmoothedNgramPredictor().

Here is the call graph for this function:

Here is the caller graph for this function:

void SmoothedNgramPredictor::set_learn ( const std::string &  deltas) [private]

Definition at line 97 of file smoothedNgramPredictor.cpp.

References endl(), Utility::isTrue(), Predictor::logger, and wanna_learn.

Referenced by SmoothedNgramPredictor().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements Observer.

Definition at line 405 of file smoothedNgramPredictor.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:


Member Data Documentation

const char * SmoothedNgramPredictor::DATABASE_LOGGER = "Presage.Predictors.SmoothedNgramPredictor.DatabaseConnector.LOGGER" [static, private]

Definition at line 63 of file smoothedNgramPredictor.h.

Referenced by SmoothedNgramPredictor().

const char * SmoothedNgramPredictor::DBFILENAME = "Presage.Predictors.SmoothedNgramPredictor.DBFILENAME" [static, private]

Definition at line 60 of file smoothedNgramPredictor.h.

Referenced by SmoothedNgramPredictor().

std::string SmoothedNgramPredictor::dbfilename [private]

Definition at line 74 of file smoothedNgramPredictor.h.

Referenced by set_dbfilename().

std::string SmoothedNgramPredictor::dbloglevel [private]

Definition at line 75 of file smoothedNgramPredictor.h.

Referenced by set_database_logger_level(), and set_dbfilename().

const char * SmoothedNgramPredictor::DELTAS = "Presage.Predictors.SmoothedNgramPredictor.DELTAS" [static, private]

Definition at line 61 of file smoothedNgramPredictor.h.

Referenced by SmoothedNgramPredictor().

std::vector<double> SmoothedNgramPredictor::deltas [private]

Definition at line 76 of file smoothedNgramPredictor.h.

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

Definition at line 79 of file smoothedNgramPredictor.h.

Referenced by SmoothedNgramPredictor(), and update().

const char * SmoothedNgramPredictor::LEARN = "Presage.Predictors.SmoothedNgramPredictor.LEARN" [static, private]

Definition at line 62 of file smoothedNgramPredictor.h.

Referenced by SmoothedNgramPredictor().

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

Definition at line 59 of file smoothedNgramPredictor.h.

Referenced by SmoothedNgramPredictor().

Definition at line 77 of file smoothedNgramPredictor.h.

Referenced by learn(), and set_learn().


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