presage  0.9.1
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
DejavuPredictor::DejavuPredictor
DejavuPredictor(Configuration *, ContextTracker *, const char *)
Definition: dejavuPredictor.cpp:37
predictor.h
Observer
Definition: observer.h:34
DejavuPredictor::mbr_func_ptr_t
void(DejavuPredictor::* mbr_func_ptr_t)(const std::string &value)
Definition: dejavuPredictor.h:56
DejavuPredictor::match
bool match(const std::list< std::string > &, const std::list< std::string > &) const
Definition: dejavuPredictor.cpp:140
DejavuPredictor::predict
virtual Prediction predict(const size_t size, const char **filter) const
Generate prediction.
Definition: dejavuPredictor.cpp:71
DejavuPredictor::TRIGGER
std::string TRIGGER
Definition: dejavuPredictor.h:69
DejavuPredictor::update_rolling_window
void update_rolling_window(std::list< std::string > &, const std::string &) const
Definition: dejavuPredictor.cpp:203
DejavuPredictor::LOGGER
std::string LOGGER
Definition: dejavuPredictor.h:67
DejavuPredictor::update
virtual void update(const Observable *variable)
Definition: dejavuPredictor.cpp:210
Prediction
Definition: prediction.h:47
DejavuPredictor::dispatch_map
std::map< std::string, mbr_func_ptr_t > dispatch_map
Definition: dejavuPredictor.h:57
Predictor
Definition: predictor.h:46
DejavuPredictor::dispatcher
Dispatcher< DejavuPredictor > dispatcher
Definition: dejavuPredictor.h:74
DejavuPredictor::set_memory
void set_memory(const std::string &filename)
Definition: dejavuPredictor.cpp:59
ContextTracker
Tracks user interaction and context.
Definition: contextTracker.h:155
DejavuPredictor::set_trigger
void set_trigger(const std::string &number)
Definition: dejavuPredictor.cpp:65
DejavuPredictor::memory
std::string memory
Definition: dejavuPredictor.h:71
DejavuPredictor::init_rolling_window
bool init_rolling_window(std::list< std::string > &, std::ifstream &) const
Definition: dejavuPredictor.cpp:182
DejavuPredictor::init_memory_trigger
bool init_memory_trigger(std::list< std::string > &) const
Definition: dejavuPredictor.cpp:154
DejavuPredictor::learn
virtual void learn(const std::vector< std::string > &change)
Definition: dejavuPredictor.cpp:116
Configuration
Definition: configuration.h:36
DejavuPredictor
Definition: dejavuPredictor.h:44
DejavuPredictor::MEMORY
std::string MEMORY
Definition: dejavuPredictor.h:68
DejavuPredictor::trigger
int trigger
Definition: dejavuPredictor.h:72
Observable
Definition: observable.h:37
DejavuPredictor::~DejavuPredictor
~DejavuPredictor()
Definition: dejavuPredictor.cpp:56
Dispatcher< DejavuPredictor >