presage 0.9.1
presage.h
Go to the documentation of this file.
1
2/******************************************************
3 * Presage, an extensible predictive text entry system
4 * ---------------------------------------------------
5 *
6 * Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 **********(*)*/
23
24
25#ifndef PRESAGE
26#define PRESAGE
27
28#include "presageException.h"
29#include "presageCallback.h"
30
85/********************************
86 * Presage C++ API starts here
87 */
88
89#ifdef __cplusplus
90#ifndef _MSC_VER
91
92#include <string>
93#include <vector>
94#include <map>
95
96/* Forward declarations, not part of presage C++ API */
97class Configuration;
98class ProfileManager;
99class Profile;
100class ContextTracker;
103class Selector;
104
107class Presage {
108public:
116
117
125 Presage(PresageCallback* callback, const std::string config);
126
127
130 ~Presage();
131
141 std::vector<std::string> predict();
142
156 std::multimap<double, std::string> predict(std::vector<std::string> filter);
157
170 void learn(const std::string text);
171
180
193 std::string completion(std::string str);
194
199 std::string context();
200
206 bool context_change();
207
212 std::string prefix();
213
221 std::string config(const std::string variable);
222
230 void config(const std::string variable, const std::string value);
231
239 void save_config();
240
241 /*
242 * Presage public API ends here
243 */
244
245private:
252
253};
254
255#endif /* _MSC_VER */
256#endif /* __cplusplus */
257
258/*
259 * Presage C++ API ends here
260 *******************************/
261
262
263/*******************************
264 * Presage C API starts here
265 */
266
267#ifdef __cplusplus
268extern "C" {
269#endif
270
271 typedef struct _presage* presage_t;
272
274 void* past_stream_cb_arg,
276 void* future_stream_cb_arg,
277 presage_t* result);
278
280 void* past_stream_cb_arg,
282 void* future_stream_cb_arg,
283 const char* config,
284 presage_t* result);
285
286 void presage_free (presage_t prsg);
287
288 void presage_free_string (char* str);
289 void presage_free_string_array (char** str);
290
292 char*** result);
293
295 const char* text);
296
298 const char* token,
299 char** result);
300
302 char** result);
303
305 int* result);
306
308 char** result);
309
311 const char* variable,
312 char** result);
313
315 const char* variable,
316 const char* value);
317
319
320#ifdef __cplusplus
321}
322#endif
323
324/*
325 * Presage C API ends here
326 ****************************/
327
328
329#endif /* PRESAGE */
Tracks user interaction and context.
Presage, the intelligent predictive text entry platform.
Definition presage.h:107
bool context_change()
Returns true if a context change occured.
Definition presage.cpp:198
Configuration * configuration
Definition presage.h:247
std::string completion(std::string str)
Request presage to return the completion string for the given predicted token.
Definition presage.cpp:146
std::vector< std::string > predict()
Obtain a prediction.
Definition presage.cpp:62
PresageCallback * callback(PresageCallback *callback)
Callback getter/setter.
Definition presage.cpp:141
void learn(const std::string text)
Learn from text offline.
Definition presage.cpp:135
Selector * selector
Definition presage.h:251
ContextTracker * contextTracker
Definition presage.h:249
~Presage()
Definition presage.cpp:53
PredictorRegistry * predictorRegistry
Definition presage.h:248
void save_config()
Save current configuration to file.
Definition presage.cpp:218
std::string context()
Returns the text entered so far.
Definition presage.cpp:193
ProfileManager * profileManager
Definition presage.h:246
std::string prefix()
Returns the current prefix.
Definition presage.cpp:203
PredictorActivator * predictorActivator
Definition presage.h:250
const char *(* _presage_callback_get_past_stream)(void *)
const char *(* _presage_callback_get_future_stream)(void *)
std::string config
presage_error_code_t
presage_error_code_t presage_prefix(presage_t prsg, char **result)
Definition presage.cpp:418
presage_error_code_t presage_context(presage_t prsg, char **result)
Definition presage.cpp:402
presage_error_code_t presage_completion(presage_t prsg, const char *token, char **result)
Definition presage.cpp:394
struct _presage * presage_t
Definition presage.h:271
presage_error_code_t presage_predict(presage_t prsg, char ***result)
Definition presage.cpp:360
presage_error_code_t presage_learn(presage_t prsg, const char *text)
Definition presage.cpp:386
void presage_free_string_array(char **str)
Definition presage.cpp:350
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)
Definition presage.cpp:291
presage_error_code_t presage_config_set(presage_t prsg, const char *variable, const char *value)
Definition presage.cpp:434
presage_error_code_t presage_context_change(presage_t prsg, int *result)
Definition presage.cpp:410
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)
Definition presage.cpp:312
presage_error_code_t presage_config(presage_t prsg, const char *variable, char **result)
Definition presage.cpp:426
void presage_free(presage_t prsg)
Definition presage.cpp:334
void presage_free_string(char *str)
Definition presage.cpp:345
presage_error_code_t presage_save_config(presage_t prsg)
Definition presage.cpp:442