64 std::vector<std::string> result;
66 unsigned int multiplier = 1;
79 previous_prediction = prediction;
89 std::multimap<double, std::string> result;
91 std::vector<std::string> selection;
92 const char** internal_filter = 0;
97 internal_filter =
new const char*[filter.size() + 1];
98 for (std::vector<std::string>::size_type i = 0; i < filter.size(); i++) {
99 internal_filter[i] = filter[i].c_str();
101 internal_filter[filter.size()] = 0;
104 unsigned int multiplier = 1;
117 previous_prediction = prediction;
120 delete[] internal_filter;
122 for (std::vector<std::string>::const_iterator it = selection.begin();
123 it != selection.end();
164 std::string::size_type offset = str.find_first_not_of(
'\b');
172 result = str.substr(
prefix.size());
174 std::string message =
"[Presage] Error: token '";
176 message +=
"' does not match prefix: ";
260#define presage_exception_handler(CODE) \
265 catch (PresageException& ex) \
271#define presage_exception_handler_with_result(CODE) \
276 catch (PresageException& ex) \
285 char* result_c_str = (
char*) malloc (str.size() + 1);
287 strcpy (result_c_str, str.c_str());
292 void* past_stream_cb_arg,
294 void* future_stream_cb_arg,
305 future_stream_cb_arg);
306 (*result)->presage_object =
new Presage ((*result)->presage_callback_object);
313 void* past_stream_cb_arg,
315 void* future_stream_cb_arg,
328 future_stream_cb_arg);
329 (*result)->presage_object =
new Presage ((*result)->presage_callback_object,
config);
353 for (
size_t t = 0; strs[t] != 0; t++) {
366 size_t prediction_c_str_size = prediction.size() + 1;
367 char** prediction_c_str = (
char**) malloc (prediction_c_str_size *
sizeof(
char*));
368 if (prediction_c_str != NULL)
370 memset (prediction_c_str, 0, prediction_c_str_size *
sizeof(
char*));
373 while (i < prediction_c_str_size - 1) {
374 prediction_c_str[i] = (
char*) malloc (prediction[i].size() + 1);
375 if (prediction_c_str[i] != NULL)
376 strcpy (prediction_c_str[i], prediction[i].c_str());
379 prediction_c_str[i] = 0;
382 *result = prediction_c_str;
virtual ~CPresageCallback()
CPresageCallback(_presage_callback_get_past_stream past, void *past_arg, _presage_callback_get_future_stream future, void *future_arg)
void * m_get_past_stream_cb_arg
void * m_get_future_stream_cb_arg
_presage_callback_get_past_stream m_get_past_stream_cb
_presage_callback_get_future_stream m_get_future_stream_cb
std::string get_past_stream() const
std::string get_future_stream() const
void insert(const std::string &variable, const std::string &value)
Variable * find(const std::string &variable) const
Tracks user interaction and context.
std::string getPastStream() const
bool isCompletionValid(const std::string &) const
const PresageCallback * callback(const PresageCallback *callback)
std::string getPrefix() const
void learn(const std::string &text) const
Learn from text.
Suggestion getSuggestion(int=0) const
Prediction predict(unsigned int multiplier, const char **filter)
Presage, the intelligent predictive text entry platform.
bool context_change()
Returns true if a context change occured.
Configuration * configuration
std::string completion(std::string str)
Request presage to return the completion string for the given predicted token.
std::string config(const std::string variable)
Gets the value of specified configuration variable.
std::vector< std::string > predict()
Obtain a prediction.
PresageCallback * callback(PresageCallback *callback)
Callback getter/setter.
void learn(const std::string text)
Learn from text offline.
ContextTracker * contextTracker
PredictorRegistry * predictorRegistry
void save_config()
Save current configuration to file.
Presage(PresageCallback *callback)
std::string context()
Returns the text entered so far.
ProfileManager * profileManager
std::string prefix()
Returns the current prefix.
PredictorActivator * predictorActivator
void save_profile() const
Configuration * get_configuration()
std::vector< std::string > select(Prediction)
size_t get_suggestions() const
double getProbability() const
std::string get_value() const
const char *(* _presage_callback_get_past_stream)(void *)
const char *(* _presage_callback_get_future_stream)(void *)
@ PRESAGE_TOKEN_PREFIX_MISMATCH_ERROR
presage_error_code_t presage_prefix(presage_t prsg, char **result)
void presage_free_string_array(char **strs)
presage_error_code_t presage_context(presage_t prsg, char **result)
presage_error_code_t presage_completion(presage_t prsg, const char *token, char **result)
presage_error_code_t presage_new_with_config(_presage_callback_get_past_stream past_stream_cb, void *past_stream_cb_arg, _presage_callback_get_future_stream future_stream_cb, void *future_stream_cb_arg, const char *config, presage_t *result)
presage_error_code_t presage_predict(presage_t prsg, char ***result)
presage_error_code_t presage_learn(presage_t prsg, const char *text)
presage_error_code_t presage_new(_presage_callback_get_past_stream past_stream_cb, void *past_stream_cb_arg, _presage_callback_get_future_stream future_stream_cb, void *future_stream_cb_arg, presage_t *result)
#define presage_exception_handler(CODE)
presage_error_code_t presage_config_set(presage_t prsg, const char *variable, const char *value)
presage_error_code_t presage_context_change(presage_t prsg, int *result)
#define presage_exception_handler_with_result(CODE)
static char * alloc_c_str(const std::string &str)
presage_error_code_t presage_config(presage_t prsg, const char *variable, char **result)
void presage_free(presage_t prsg)
void presage_free_string(char *str)
presage_error_code_t presage_save_config(presage_t prsg)
PresageCallback * presage_callback_object