| presage.h | | presage.h | |
| | | | |
| skipping to change at line 27 | | skipping to change at line 27 | |
| | | | |
| You should have received a copy of the GNU General Public License along | | 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., | | with this program; if not, write to the Free Software Foundation, Inc., | |
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
|
* | |
* | |
| **********(
*)*/ | | **********(
*)*/ | |
| | | | |
| #ifndef PRESAGE | | #ifndef PRESAGE | |
| #define PRESAGE | | #define PRESAGE | |
| | | | |
|
| #ifdef HAVE_CONFIG_H | | | |
| #include "config.h" | | | |
| #endif | | | |
| | | | |
| #include <string> | | #include <string> | |
| #include <vector> | | #include <vector> | |
| #include <map> | | #include <map> | |
| | | | |
|
| #include "presageException.h" | | // Forward declarations, not part of presage API | |
| | | | |
| class Configuration; | | class Configuration; | |
| class ProfileManager; | | class ProfileManager; | |
| class Profile; | | class Profile; | |
| class ContextTracker; | | class ContextTracker; | |
| class PluginRegistry; | | class PluginRegistry; | |
| class PredictorActivator; | | class PredictorActivator; | |
| class Selector; | | class Selector; | |
| | | | |
|
| | | /* | |
| | | * Presage public API starts here | |
| | | */ | |
| | | #include "presageException.h" | |
| | | #include "presageCallback.h" | |
| | | | |
| /** \brief Presage, the intelligent predictive text entry platform. | | /** \brief Presage, the intelligent predictive text entry platform. | |
| */ | | */ | |
| class Presage { | | class Presage { | |
| public: | | public: | |
| /** Creates and initializes presage. | | /** Creates and initializes presage. | |
|
| | | * | |
| | | * \param callback is a user-supplied implementation of PresageCallback | |
| | | interface | |
| | | * | |
| | | * Presage does not take ownership of the callback object. | |
| */ | | */ | |
|
| Presage(); | | Presage(PresageCallback* callback); | |
| | | | |
| /** Creates and initializes presage with supplied configuration. | | /** Creates and initializes presage with supplied configuration. | |
|
| | | * | |
| | | * \param callback is a user-supplied implementation of PresageCallback | |
| | | interface | |
| * \param config path to configuration file | | * \param config path to configuration file | |
|
| | | * | |
| | | * Presage does not take ownership of the callback object. | |
| */ | | */ | |
|
| Presage(const std::string config); | | Presage(PresageCallback* callback, const std::string config); | |
| | | | |
| /** Destroys presage. | | /** Destroys presage. | |
| */ | | */ | |
| ~Presage(); | | ~Presage(); | |
| | | | |
| /** \brief Obtain a prediction, and notify presage of newly | | /** \brief Obtain a prediction, and notify presage of newly | |
| * entered text (if any, else empty string). | | * entered text (if any, else empty string). | |
| * | | * | |
| * This method notifies presage that new text was entered by | | * This method notifies presage that new text was entered by | |
| * the user and requests that presage generates a prediction | | * the user and requests that presage generates a prediction | |
| * based on the newly updated context. | | * based on the newly updated context. | |
| * | | * | |
| * It is possible to invoke this method passing an empty string as | | * It is possible to invoke this method passing an empty string as | |
| * argument, in cases where no text was entered by the user since | | * argument, in cases where no text was entered by the user since | |
| * the previous invocation. | | * the previous invocation. | |
| * | | * | |
| * This method returns a prediction based on the current | | * This method returns a prediction based on the current | |
| * context. The prediction is a std::vector of std::string's. | | * context. The prediction is a std::vector of std::string's. | |
| * | | * | |
|
| * \param str user entered text | | | |
| * \return prediction | | * \return prediction | |
| * | | * | |
| */ | | */ | |
|
| std::vector<std::string> predict(std::string str); | | std::vector<std::string> predict(); | |
| | | | |
| /** \brief Obtains a prediction that matches the supplied token | | /** \brief Obtains a prediction that matches the supplied token | |
| * filter. | | * filter. | |
| * | | * | |
| * \param filter a vector of strings to use to filter the | | * \param filter a vector of strings to use to filter the | |
| * prediction for desired tokens. I.e. If the current prefix is | | * prediction for desired tokens. I.e. If the current prefix is | |
| * "gr" and the filter is ["ea", "an"], then only words starting | | * "gr" and the filter is ["ea", "an"], then only words starting | |
| * with "grea" or "gran" such as "great" or "grand" | | * with "grea" or "gran" such as "great" or "grand" | |
| * | | * | |
| * \return prediction containing only tokens that begin with one | | * \return prediction containing only tokens that begin with one | |
| * of the filter tokens. | | * of the filter tokens. | |
| * | | * | |
| */ | | */ | |
| std::multimap<double, std::string> predict(std::vector<std::string> fil
ter); | | std::multimap<double, std::string> predict(std::vector<std::string> fil
ter); | |
| | | | |
|
| /** \brief Notifies presage that new text was entered. | | /** \brief Callback getter/setter. | |
| * | | * | |
|
| * Notifies presage that new text was entered, without | | * \param callback to be used by presage (pass a null pointer to | |
| * requesting a new prediction to be generated. | | * obtain callback to current callback without modifying it) | |
| * | | * | |
|
| * \param str user entered text | | * \return pointer to previously used callback | |
| */ | | */ | |
|
| void update(std::string str); | | PresageCallback* callback(PresageCallback* callback); | |
| | | | |
|
| /** \brief Informs presage that a prediction was successful. | | /** \brief Request presage to return the completion string for the give
n predicted token. | |
| * | | * | |
|
| * Informs presage that a prediction was successful. The | | * Requests presage to return the completion string. The | |
| * successful prediction is passed in as argument. Presage | | * completion string is defined as the string which, when appended | |
| * updates its internal tracker with the successful prediction. | | * to the current prefix, forms the token passed as the str | |
| | | * argument. | |
| * | | * | |
|
| * \param str successful prediction | | * \param str successful prediction, for which a completion string | |
| | | * is requested | |
| | | * | |
| | | * \return completion string | |
| */ | | */ | |
|
| void complete(std::string str); | | std::string completion(std::string str); | |
| | | | |
| /** \brief Returns the text entered so far. | | /** \brief Returns the text entered so far. | |
| * | | * | |
| * \return context, text entered so far. | | * \return context, text entered so far. | |
| */ | | */ | |
| std::string context() const; | | std::string context() const; | |
| | | | |
| /** \brief Returns true if a context change occured. | | /** \brief Returns true if a context change occured. | |
| * | | * | |
| * \return true if a context change occured after the last update | | * \return true if a context change occured after the last update | |
| | | | |
| skipping to change at line 150 | | skipping to change at line 162 | |
| */ | | */ | |
| std::string config(const std::string variable) const; | | std::string config(const std::string variable) const; | |
| | | | |
| /** \brief Sets the value of specified configuration variable. | | /** \brief Sets the value of specified configuration variable. | |
| * | | * | |
| * Programmatically set the specified configuration \param | | * Programmatically set the specified configuration \param | |
| * variable to \param value . This will override the setting read | | * variable to \param value . This will override the setting read | |
| * from the configuration file in use. | | * from the configuration file in use. | |
| * | | * | |
| */ | | */ | |
|
| void config(const std::string variable, const std::string value); | | void config(const std::string variable, const std::string value) const; | |
| | | | |
| | | /** \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; | |
| | | | |
| | | /* | |
| | | * Presage public API ends here | |
| | | */ | |
| | | | |
| private: | | private: | |
| ProfileManager* profileManager; | | ProfileManager* profileManager; | |
|
| Profile* profile; | | | |
| Configuration* configuration; | | Configuration* configuration; | |
| PluginRegistry* pluginRegistry; | | PluginRegistry* pluginRegistry; | |
| ContextTracker* contextTracker; | | ContextTracker* contextTracker; | |
| PredictorActivator* predictorActivator; | | PredictorActivator* predictorActivator; | |
| Selector* selector; | | Selector* selector; | |
| | | | |
| }; | | }; | |
| | | | |
| /** \mainpage | | /** \mainpage | |
| | | | |
| | | | |
End of changes. 20 change blocks. |
| 23 lines changed or deleted | | 49 lines changed or added | |
|