/usr/include/presage.h is in libpresage-dev 0.9.1-1.1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | /******************************************************
* Presage, an extensible predictive text entry system
* ---------------------------------------------------
*
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
**********(*)*/
#ifndef PRESAGE
#define PRESAGE
#include "presageException.h"
#include "presageCallback.h"
/** \mainpage
\section intro_section Introduction
Presage is an intelligent predictive text entry
platform. Presage exploits <a
href="http://en.wikipedia.org/wiki/Redundancy_%28information_theory%29">redundant
information</a> embedded in natural languages to generate
predictions. Presage's modular and pluggable <a
href="?q=node/14">architecture</a> allows its <a
href="http://en.wikipedia.org/wiki/Language_modeling">language
model</a> to be extended and customized to utilize statistical,
syntactic, and semantic information sources.
A predictive text entry system attempts to improve ease and speed of
textual input. Word prediction consists in computing which word tokens
or word completions are most likely to be entered next. The system
analyses the text already entered and combines the information thus
extracted with other information sources to calculate a set of most
probable tokens.
A typical presage-based application would display the set of most
probable tokens (i.e. a list of suggestions) to the user and
automatically enter the desired token after the user selects it. If
the list of suggestions does not contain the desired word, the user
continues entering text until the correct suggestion is offered or
until the user is done entering text.
Presage is fundamentally different from predictive <a
href="http://en.wikipedia.org/wiki/T9_%28predictive_text%29">input
technologies commonly found on mobile phones</a>, which might more
accurately be described as 'disambiguating text entry' rather than
'predictive text entry' systems. Such systems do not try to guess
what the user intends to write in the future, only to determine what
they most-likely intend to write in the present, given their past
input. Presage, on the other hand, actively predicts the what the
user intends to write, and only reverts to <a
href="http://en.wikipedia.org/wiki/Word_completion">word
completion</a> mode if the prediction did not contain the desired
token.
Presage is <a
href="http://www.gnu.org/philosophy/free-sw.html">free
software</a>. It is distributed under the term of the <a
href="http://www.gnu.org/copyleft/gpl.html">General Public
License</a>.
\author Matteo Vescovi
\section getting_started_section Getting started
\include getting_started.txt
*/
/********************************
* Presage C++ API starts here
*/
#ifdef __cplusplus
#ifndef _MSC_VER
#include <string>
#include <vector>
#include <map>
/* Forward declarations, not part of presage C++ API */
class Configuration;
class ProfileManager;
class Profile;
class ContextTracker;
class PredictorRegistry;
class PredictorActivator;
class Selector;
/** \brief Presage, the intelligent predictive text entry platform.
*/
class Presage {
public:
/** Creates and initializes presage.
*
* \param callback is a user-supplied implementation of PresageCallback interface
*
* Presage does not take ownership of the callback object.
*/
Presage(PresageCallback* callback) throw (PresageException);
/** Creates and initializes presage with supplied configuration.
*
* \param callback is a user-supplied implementation of PresageCallback interface
* \param config path to configuration file
*
* Presage does not take ownership of the callback object.
*/
Presage(PresageCallback* callback, const std::string config) throw (PresageException);
/** Destroys presage.
*/
~Presage();
/** \brief Obtain a prediction.
*
* This method requests that presage generates a prediction based
* on the current context.
*
* \return prediction (vector of strings) based on the current
* context.
*
*/
std::vector<std::string> predict() throw (PresageException);
/** \brief Obtain a prediction that matches the supplied token
* filter.
*
* \param 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.
*
* \return prediction containing only tokens that begin with one
* of the filter tokens.
*
*/
std::multimap<double, std::string> predict(std::vector<std::string> filter) throw (PresageException);
/** \brief Learn from text offline.
*
* Requests presage to offline learn from \param 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.
*
* \param text a text string to learn from.
*
*/
void learn(const std::string text) const throw (PresageException);
/** \brief Callback getter/setter.
*
* \param callback to be used by presage (pass a null pointer to
* obtain callback to current callback without modifying it)
*
* \return pointer to previously used callback
*/
PresageCallback* callback(PresageCallback* callback) throw (PresageException);
/** \brief 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.
*
* \param str successful prediction, for which a completion string
* is requested
*
* \return completion string
*/
std::string completion(std::string str) throw (PresageException);
/** \brief Returns the text entered so far.
*
* \return context, text entered so far.
*/
std::string context() const throw (PresageException);
/** \brief Returns true if a context change occured.
*
* \return true if a context change occured after the last update
* or predict calls, or false otherwise.
*/
bool context_change() const throw (PresageException);
/** \brief Returns the current prefix.
*
* \return prefix
*/
std::string prefix() const throw (PresageException);
/** \brief Gets the value of specified configuration variable.
*
* Programmatically get the value currently assigned to the
* specified configuration \param variable
*
* \return value assigned to configuration variable.
*/
std::string config(const std::string variable) const throw (PresageException);
/** \brief Sets the value of specified configuration variable.
*
* Programmatically set the specified configuration \param
* variable to \param value . This will override the setting read
* from the configuration file in use.
*
*/
void config(const std::string variable, const std::string value) const throw (PresageException);
/** \brief 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.
*
*/
void save_config() const throw (PresageException);
/*
* Presage public API ends here
*/
private:
ProfileManager* profileManager;
Configuration* configuration;
PredictorRegistry* predictorRegistry;
ContextTracker* contextTracker;
PredictorActivator* predictorActivator;
Selector* selector;
};
#endif /* _MSC_VER */
#endif /* __cplusplus */
/*
* Presage C++ API ends here
*******************************/
/*******************************
* Presage C API starts here
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _presage* presage_t;
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);
presage_error_code_t presage_new_with_config (_presage_callback_get_past_stream past,
void* past_stream_cb_arg,
_presage_callback_get_future_stream future_stream_cb,
void* future_stream_cb_arg,
const char* config,
presage_t* result);
void presage_free (presage_t prsg);
void presage_free_string (char* str);
void presage_free_string_array (char** str);
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_completion (presage_t prsg,
const char* token,
char** result);
presage_error_code_t presage_context (presage_t prsg,
char** result);
presage_error_code_t presage_context_change (presage_t prsg,
int* result);
presage_error_code_t presage_prefix (presage_t prsg,
char** result);
presage_error_code_t presage_config (presage_t prsg,
const char* variable,
char** result);
presage_error_code_t presage_config_set (presage_t prsg,
const char* variable,
const char* value);
presage_error_code_t presage_save_config (presage_t prsg);
#ifdef __cplusplus
}
#endif
/*
* Presage C API ends here
****************************/
#endif /* PRESAGE */
|