presage  0.9.2~beta
predictor.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_PREDICTOR
26 #define PRESAGE_PREDICTOR
27 
28 #include "../core/prediction.h"
29 #include "../core/context_tracker/contextTracker.h"
30 #include "../core/configuration.h"
31 #include "../core/utility.h"
32 
33 #include <string>
34 #include <vector>
35 
46 class Predictor {
47 public:
50  const char* predictorName = "Predictor",
51  const char* shortDescription = "",
52  const char* longDescription = "");
53  virtual ~Predictor();
54 
61  virtual Prediction predict(const size_t size, const char** filter) const = 0;
62 
63  virtual void learn(const std::vector<std::string>& change) = 0;
64 
65  const std::string getName() const;
66  const std::string getShortDescription() const;
67  const std::string getLongDescription() const;
68 
69 
70 protected:
71  virtual bool token_satisfies_filter (const std::string& token,
72  const std::string& prefix,
73  const char** filter) const;
74 
75  virtual void set_logger (const std::string& level);
76 
77  const std::string name;
78  const std::string shortDescription; // predictor's descriptive name
79  const std::string longDescription; // predictor's exhaustive description
80 
81  const std::string PREDICTORS;
82 
84 
86 
88 
89 private:
90 
91 };
92 
93 
94 #endif // PRESAGE_PREDICTOR
Logger< char > logger
Definition: predictor.h:87
Configuration * configuration
Definition: predictor.h:85
const std::string getName() const
Definition: predictor.cpp:66
virtual Prediction predict(const size_t size, const char **filter) const =0
Generate prediction.
virtual void set_logger(const std::string &level)
Definition: predictor.cpp:88
virtual void learn(const std::vector< std::string > &change)=0
const std::string PREDICTORS
Definition: predictor.h:81
const std::string longDescription
Definition: predictor.h:79
const std::string name
Definition: predictor.h:77
Predictor(Configuration *configuration, ContextTracker *contextTracker, const char *predictorName="Predictor", const char *shortDescription="", const char *longDescription="")
Definition: predictor.cpp:39
ContextTracker * contextTracker
Definition: predictor.h:83
const std::string shortDescription
Definition: predictor.h:78
Tracks user interaction and context.
virtual ~Predictor()
Definition: predictor.cpp:60
const std::string getShortDescription() const
Definition: predictor.cpp:74
virtual bool token_satisfies_filter(const std::string &token, const std::string &prefix, const char **filter) const
Definition: predictor.cpp:95
const std::string getLongDescription() const
Definition: predictor.cpp:82