presage  0.8.7
Public Member Functions | Private Attributes
Presage Class Reference

Presage, the intelligent predictive text entry platform. More...

#include <presage.h>

Collaboration diagram for Presage:
Collaboration graph
[legend]

List of all members.

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, and notify presage of newly entered text (if any, else empty string).
std::multimap< double,
std::string > 
predict (std::vector< std::string > filter) throw (PresageException)
 Obtains a prediction that matches the supplied token filter.
PresageCallbackcallback (PresageCallback *callback) throw (PresageException)
 Callback getter/setter.
std::string completion (std::string str) throw (PresageException)
 Request presage to return the completion string for the given predicted token.
std::string context () const throw (PresageException)
 Returns the text entered so far.
bool context_change () const throw (PresageException)
 Returns true if a context change occured.
std::string prefix () const throw (PresageException)
 Returns the current prefix.
std::string config (const std::string variable) const throw (PresageException)
 Gets the value of specified configuration variable.
void config (const std::string variable, const std::string value) const throw (PresageException)
 Sets the value of specified configuration variable.
void save_config () const throw (PresageException)
 Save current configuration to file.

Private Attributes

ProfileManagerprofileManager
Configurationconfiguration
PredictorRegistrypredictorRegistry
ContextTrackercontextTracker
PredictorActivatorpredictorActivator
Selectorselector

Detailed Description

Presage, the intelligent predictive text entry platform.

Definition at line 116 of file presage.h.


Constructor & Destructor Documentation

Creates and initializes presage.

Parameters:
callbackis 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.

Parameters:
callbackis a user-supplied implementation of PresageCallback interface
configpath to configuration file

Presage does not take ownership of the callback object.

Definition at line 49 of file presage.cpp.

Destroys presage.

Definition at line 61 of file presage.cpp.

References contextTracker, predictorActivator, predictorRegistry, profileManager, and selector.


Member Function Documentation

Callback getter/setter.

Parameters:
callbackto be used by presage (pass a null pointer to obtain callback to current callback without modifying it)
Returns:
pointer to previously used callback

Definition at line 145 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.

Parameters:
strsuccessful prediction, for which a completion string is requested
Returns:
completion string

Definition at line 151 of file presage.cpp.

References PRESAGE_TOKEN_PREFIX_MISMATCH_ERROR.

Referenced by main(), and presage_completion().

Here is the caller graph for this function:

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

Parameters:
variable
Returns:
value assigned to configuration variable.

Definition at line 217 of file presage.cpp.

Referenced by main(), presage_config(), and presage_config_set().

Here is the caller graph for this function:

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

Parameters:
variableto
value. This will override the setting read from the configuration file in use.

Definition at line 223 of file presage.cpp.

std::string Presage::context ( ) const throw (PresageException)

Returns the text entered so far.

Returns:
context, text entered so far.

Definition at line 199 of file presage.cpp.

References contextTracker, and ContextTracker::getPastStream().

Referenced by main(), and presage_context().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Presage::context_change ( ) const throw (PresageException)

Returns true if a context change occured.

Returns:
true if a context change occured after the last update or predict calls, or false otherwise.

Definition at line 205 of file presage.cpp.

References ContextTracker::contextChange(), and contextTracker.

Referenced by main(), and presage_context_change().

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< std::string > Presage::predict ( ) throw (PresageException)

Obtain a prediction, and notify presage of newly entered text (if any, else empty string).

This method notifies presage that new text was entered by the user and requests that presage generates a prediction based on the newly updated context.

It is possible to invoke this method passing an empty string as argument, in cases where no text was entered by the user since the previous invocation.

This method returns a prediction based on the current context. The prediction is a std::vector of std::string's.

Returns:
prediction

Definition at line 70 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(), and Simulator::simulate().

Here is the call graph for this function:

Here is the caller graph for this function:

std::multimap< double, std::string > Presage::predict ( std::vector< std::string >  filter) throw (PresageException)

Obtains a prediction that matches the supplied token filter.

Parameters:
filtera 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"
Returns:
prediction containing only tokens that begin with one of the filter tokens.

Definition at line 96 of file presage.cpp.

References Suggestion::getProbability(), Prediction::getSuggestion(), and Prediction::size().

Here is the call graph for this function:

std::string Presage::prefix ( ) const throw (PresageException)

Returns the current prefix.

Returns:
prefix

Definition at line 211 of file presage.cpp.

References contextTracker, and ContextTracker::getPrefix().

Referenced by Simulator::find(), and presage_prefix().

Here is the call graph for this function:

Here is the caller graph for this function:

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 229 of file presage.cpp.

References profileManager, and ProfileManager::save_profile().

Referenced by presage_save_config().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 249 of file presage.h.

Definition at line 251 of file presage.h.

Referenced by context(), context_change(), predict(), prefix(), and ~Presage().

Definition at line 252 of file presage.h.

Referenced by predict(), and ~Presage().

Definition at line 250 of file presage.h.

Referenced by ~Presage().

Definition at line 248 of file presage.h.

Referenced by save_config(), and ~Presage().

Definition at line 253 of file presage.h.

Referenced by predict(), and ~Presage().


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