presage
0.9.2~beta
|
Presage, the intelligent predictive text entry platform. More...
#include <presage.h>
Public Member Functions | |
Presage (PresageCallback *callback) throw (PresageException) | |
Presage (PresageCallback *callback, const std::string config) throw (PresageException) | |
~Presage () | |
std::vector< std::string > | predict () throw (PresageException) |
Obtain a prediction. More... | |
std::multimap< double, std::string > | predict (std::vector< std::string > filter) throw (PresageException) |
Obtain a prediction that matches the supplied token filter. More... | |
void | learn (const std::string text) const throw (PresageException) |
Learn from text offline. More... | |
PresageCallback * | callback (PresageCallback *callback) throw (PresageException) |
Callback getter/setter. More... | |
std::string | completion (std::string str) throw (PresageException) |
Request presage to return the completion string for the given predicted token. More... | |
std::string | context () const throw (PresageException) |
Returns the text entered so far. More... | |
bool | context_change () const throw (PresageException) |
Returns true if a context change occured. More... | |
std::string | prefix () const throw (PresageException) |
Returns the current prefix. More... | |
std::string | config (const std::string variable) const throw (PresageException) |
Gets the value of specified configuration variable. More... | |
void | config (const std::string variable, const std::string value) const throw (PresageException) |
Sets the value of specified configuration variable. More... | |
void | save_config () const throw (PresageException) |
Save current configuration to file. More... | |
std::string | version () const throw (PresageException) |
Returns presage release version. More... | |
Private Attributes | |
ProfileManager * | profileManager |
Configuration * | configuration |
PredictorRegistry * | predictorRegistry |
ContextTracker * | contextTracker |
PredictorActivator * | predictorActivator |
Selector * | selector |
Presage::Presage | ( | PresageCallback * | callback | ) | |
throw | ( | PresageException | |||
) |
Creates and initializes presage.
callback | is a user-supplied implementation of PresageCallback interface |
Presage does not take ownership of the callback object.
Definition at line 33 of file presage.cpp.
Presage::Presage | ( | PresageCallback * | callback, |
const std::string | config | ||
) | |||
throw | ( | PresageException | |
) |
Creates and initializes presage with supplied configuration.
callback | is a user-supplied implementation of PresageCallback interface |
config | path to configuration file |
Presage does not take ownership of the callback object.
Definition at line 44 of file presage.cpp.
Presage::~Presage | ( | ) |
Destroys presage.
Definition at line 55 of file presage.cpp.
References contextTracker, predictorActivator, predictorRegistry, profileManager, and selector.
PresageCallback * Presage::callback | ( | PresageCallback * | callback | ) | |
throw | ( | PresageException | |||
) |
Callback getter/setter.
callback | to be used by presage (pass a null pointer to obtain callback to current callback without modifying it) |
Definition at line 146 of file presage.cpp.
std::string Presage::completion | ( | std::string | str | ) | |
throw | ( | PresageException | |||
) |
Request presage to return the completion string for the given predicted token.
Requests presage to return the completion string. The completion string is defined as the string which, when appended to the current prefix, forms the token passed as the str argument.
str | successful prediction, for which a completion string is requested |
Definition at line 152 of file presage.cpp.
References PRESAGE_TOKEN_PREFIX_MISMATCH_ERROR.
Referenced by main(), and presage_completion().
std::string Presage::config | ( | const std::string | variable | ) | const |
throw | ( | PresageException | |||
) |
Gets the value of specified configuration variable.
Programmatically get the value currently assigned to the specified configuration
variable |
Definition at line 218 of file presage.cpp.
Referenced by main(), presage_config(), and presage_config_set().
void Presage::config | ( | const std::string | variable, |
const std::string | value | ||
) | const | ||
throw | ( | PresageException | |
) |
Sets the value of specified configuration variable.
Programmatically set the specified configuration
variable | to |
value | . This will override the setting read from the configuration file in use. |
Definition at line 224 of file presage.cpp.
std::string Presage::context | ( | ) | const | |
throw | ( | PresageException | ||
) |
Returns the text entered so far.
Definition at line 200 of file presage.cpp.
References contextTracker, and ContextTracker::getPastStream().
Referenced by main(), and presage_context().
bool Presage::context_change | ( | ) | const | |
throw | ( | PresageException | ||
) |
Returns true if a context change occured.
Definition at line 206 of file presage.cpp.
References ContextTracker::contextChange(), and contextTracker.
Referenced by main(), and presage_context_change().
void Presage::learn | ( | const std::string | text | ) | const |
throw | ( | PresageException | |||
) |
Learn from text offline.
Requests presage to offline learn from
text. | Active predictors in presage are capable of online learning (dynamic learning triggered by context changes - context-awareness enables presage to train predictors on changes in context dynamically). This method provides a way to instruct presage to learn from a specific body of text, separate from the context. |
text | a text string to learn from. |
Definition at line 139 of file presage.cpp.
Referenced by presage_learn().
std::vector< std::string > Presage::predict | ( | ) | ||
throw | ( | PresageException | ||
) |
Obtain a prediction.
This method requests that presage generates a prediction based on the current context.
Definition at line 64 of file presage.cpp.
References contextTracker, Selector::get_suggestions(), PredictorActivator::predict(), predictorActivator, Selector::select(), selector, Prediction::size(), and ContextTracker::update().
Referenced by main(), presage_predict(), presage_predict_with_filter(), and Simulator::simulate().
std::multimap< double, std::string > Presage::predict | ( | std::vector< std::string > | filter | ) | |
throw | ( | PresageException | |||
) |
Obtain a prediction that matches the supplied token filter.
filter | a vector of strings to use to filter the prediction for desired tokens. I.e. If the current prefix is "gr" and the filter is ["ea", "an"], then only words starting with "grea" or "gran" such as "great" or "grand" will be returned in the prediction. |
Definition at line 90 of file presage.cpp.
References Suggestion::getProbability(), Prediction::getSuggestion(), and Prediction::size().
std::string Presage::prefix | ( | ) | const | |
throw | ( | PresageException | ||
) |
Returns the current prefix.
Definition at line 212 of file presage.cpp.
References contextTracker, and ContextTracker::getPrefix().
Referenced by Simulator::find(), and presage_prefix().
void Presage::save_config | ( | ) | const | |
throw | ( | PresageException | ||
) |
Save current configuration to file.
Call this method to persist current presage configuration to file. The configuration data will be saved to the currently active XML profile.
Definition at line 230 of file presage.cpp.
References profileManager, and ProfileManager::save_profile().
Referenced by presage_save_config().
std::string Presage::version | ( | ) | const | |
throw | ( | PresageException | ||
) |
Returns presage release version.
Programmatically retrieve the presage release version string.
Definition at line 236 of file presage.cpp.
Referenced by presage_version().
|
private |
|
private |
Definition at line 256 of file presage.h.
Referenced by context(), context_change(), predict(), prefix(), and ~Presage().
|
private |
Definition at line 257 of file presage.h.
Referenced by predict(), and ~Presage().
|
private |
Definition at line 255 of file presage.h.
Referenced by ~Presage().
|
private |
Definition at line 253 of file presage.h.
Referenced by save_config(), and ~Presage().
|
private |
Definition at line 258 of file presage.h.
Referenced by predict(), and ~Presage().