presage  0.9.2~beta
dejavuPredictor.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 #ifndef PRESAGE_DEJAVUPREDICTOR
25 #define PRESAGE_DEJAVUPREDICTOR
26 
27 #include "predictor.h"
28 #include "../core/dispatcher.h"
29 
30 #include <list>
31 #include <string>
32 #include <fstream>
33 
34 
44 class DejavuPredictor : public Predictor, public Observer {
45 public:
48 
49  virtual Prediction predict(const size_t size, const char** filter) const;
50 
51  virtual void learn(const std::vector<std::string>& change);
52 
53  virtual void update (const Observable* variable);
54 
55 private:
56  typedef void (DejavuPredictor::* mbr_func_ptr_t) (const std::string& value);
57  std::map<std::string, mbr_func_ptr_t> dispatch_map;
58 
59  bool init_memory_trigger(std::list<std::string>&) const;
60  bool match(const std::list<std::string>&, const std::list<std::string>&) const;
61  bool init_rolling_window(std::list<std::string>&, std::ifstream&) const;
62  void update_rolling_window(std::list<std::string>&, const std::string&) const;
63 
64  void set_memory (const std::string& filename);
65  void set_trigger (const std::string& number);
66 
67  std::string LOGGER;
68  std::string MEMORY;
69  std::string TRIGGER;
70 
71  std::string memory;
72  int trigger;
73 
75 };
76 
77 #endif // SOOTH_DEJAVUPREDICTOR
void set_memory(const std::string &filename)
std::string LOGGER
DejavuPredictor(Configuration *, ContextTracker *, const char *)
void(DejavuPredictor::* mbr_func_ptr_t)(const std::string &value)
bool match(const std::list< std::string > &, const std::list< std::string > &) const
bool init_memory_trigger(std::list< std::string > &) const
virtual void update(const Observable *variable)
std::string memory
std::map< std::string, mbr_func_ptr_t > dispatch_map
std::string TRIGGER
Dispatcher< DejavuPredictor > dispatcher
virtual void learn(const std::vector< std::string > &change)
void set_trigger(const std::string &number)
virtual Prediction predict(const size_t size, const char **filter) const
Generate prediction.
Tracks user interaction and context.
void update_rolling_window(std::list< std::string > &, const std::string &) const
std::string MEMORY
bool init_rolling_window(std::list< std::string > &, std::ifstream &) const