Presage Class Reference

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

`#include <presage.h>`

Collaboration diagram for Presage:

## Public Member Functions

| Presage (PresageCallback *callback) noexcept(false)
| Presage (PresageCallback *callback, const std::string config) noexcept(false)
| ~Presage ()
std::vector< std::string > | predict () noexcept(false)
| Obtain a prediction.
std::multimap< double, std::string > | predict (std::vector< std::string > filter) noexcept(false)
| Obtain a prediction that matches the supplied token filter.
void | learn (const std::string text) const noexcept(false)
| Learn from text offline.
PresageCallback * | callback (PresageCallback *callback) noexcept(false)
| Callback getter/setter.
std::string | completion (std::string str) noexcept(false)
| Request presage to return the completion string for the given predicted token.
std::string | context () const noexcept(false)
| Returns the text entered so far.
bool | context_change () const noexcept(false)
| Returns true if a context change occured.
std::string | prefix () const noexcept(false)
| Returns the current prefix.
std::string | config (const std::string variable) const noexcept(false)
| Gets the value of specified configuration variable.
void | config (const std::string variable, const std::string value) const noexcept(false)
| Sets the value of specified configuration variable.
void | save_config () const noexcept(false)
| Save current configuration to file.

## Private Attributes

ProfileManager * | profileManager
Configuration * | configuration
PredictorRegistry * | predictorRegistry
ContextTracker * | contextTracker
PredictorActivator * | predictorActivator
Selector * | selector

## Detailed Description

Presage, the intelligent predictive text entry platform.

Definition at line 107 of file presage.h.

## Constructor & Destructor Documentation

## Presage() [1/2]

Presage::Presage | ( | PresageCallback * | callback | ) |

Creates and initializes presage.

Parameters

  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.

References callback(), configuration, contextTracker, predictorActivator, predictorRegistry, profileManager, and selector.

Here is the call graph for this function:

## Presage() [2/2]

Presage::Presage | ( | PresageCallback * | callback,
|  | const std::string | config )

Creates and initializes presage with supplied configuration.

Parameters

  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.

References callback(), configuration, contextTracker, predictorActivator, predictorRegistry, profileManager, and selector.

Here is the call graph for this function:

## ~Presage()

Presage::~Presage | ( |  | ) |

Destroys presage.

Definition at line 55 of file presage.cpp.

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

## Member Function Documentation

## callback()

PresageCallback * Presage::callback | ( | PresageCallback * | callback | ) |

Callback getter/setter.

Parameters

  callback | to 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 146 of file presage.cpp.

References callback(), and contextTracker.

Referenced by callback(), Presage(), and Presage().

Here is the call graph for this function:
Here is the caller graph for this function:

## completion()

std::string Presage::completion | ( | std::string | str | ) |

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

  str | successful prediction, for which a completion string is requested

Returns
  completion string

Definition at line 152 of file presage.cpp.

References contextTracker, prefix(), and PRESAGE_TOKEN_PREFIX_MISMATCH_ERROR.

Referenced by main(), and presage_completion().

Here is the call graph for this function:
Here is the caller graph for this function:

## config() [1/2]

std::string Presage::config | ( | const std::string | variable | ) | const

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

References configuration.

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

Here is the caller graph for this function:

## config() [2/2]

void Presage::config | ( | const std::string | variable,
|  | const std::string | value ) const

Sets the value of specified configuration variable.

Programmatically set the specified configuration

Parameters

  variable | to
  value | . This will override the setting read from the configuration file in use.

Definition at line 224 of file presage.cpp.

References configuration.

## context()

std::string Presage::context | ( |  | ) | const

Returns the text entered so far.

Returns
  context, text entered so far.

Definition at line 200 of file presage.cpp.

References contextTracker.

Referenced by main(), and presage_context().

Here is the caller graph for this function:

## context_change()

bool Presage::context_change | ( |  | ) | const

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

References contextTracker.

Referenced by main(), and presage_context_change().

Here is the caller graph for this function:

## learn()

void Presage::learn | ( | const std::string | text | ) | const

Learn from text offline.

Requests presage to offline learn from

Parameters

  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.

References contextTracker.

Referenced by presage_learn().

Here is the caller graph for this function:

## predict() [1/2]

std::vector< std::string > Presage::predict | ( |  | ) |

Obtain a prediction.

This method requests that presage generates a prediction based on the current context.

Returns
  prediction (vector of strings) based on the current context.

Definition at line 64 of file presage.cpp.

References contextTracker, predictorActivator, selector, and Prediction::size().

Referenced by main(), and presage_predict().

Here is the call graph for this function:
Here is the caller graph for this function:

## predict() [2/2]

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

Obtain a prediction that matches the supplied token filter.

Parameters

  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.

Returns
  prediction containing only tokens that begin with one of the filter tokens.

Definition at line 90 of file presage.cpp.

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

Here is the call graph for this function:

## prefix()

std::string Presage::prefix | ( |  | ) | const

Returns the current prefix.

Returns
  prefix

Definition at line 212 of file presage.cpp.

References contextTracker.

Referenced by completion(), and presage_prefix().

Here is the caller graph for this function:

## save_config()

void Presage::save_config | ( |  | ) | const

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.

Referenced by presage_save_config().

Here is the caller graph for this function:

## Member Data Documentation

## configuration

Configuration* Presage::configuration

private

Definition at line 247 of file presage.h.

Referenced by config(), config(), Presage(), and Presage().

## contextTracker

ContextTracker* Presage::contextTracker

private

Definition at line 249 of file presage.h.

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

## predictorActivator

PredictorActivator* Presage::predictorActivator

private

Definition at line 250 of file presage.h.

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

## predictorRegistry

PredictorRegistry* Presage::predictorRegistry

private

Definition at line 248 of file presage.h.

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

## profileManager

ProfileManager* Presage::profileManager

private

Definition at line 246 of file presage.h.

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

## selector

Selector* Presage::selector

private

Definition at line 251 of file presage.h.

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

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

- /build/presage-XwIsB9/presage-0.9.1/src/lib/presage.h
- /build/presage-XwIsB9/presage-0.9.1/src/lib/presage.cpp