dejavuPredictor.h
Go to the documentation of this file.
/******************************************************
* Presage, an extensible predictive text entry system
* ---------------------------------------------------
*
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
**********(*)*/
#ifndef PRESAGE_DEJAVUPREDICTOR
#define PRESAGE_DEJAVUPREDICTOR
#include "predictor.h"
#include "../core/dispatcher.h"
#include <list>
#include <string>
#include <fstream>
class DejavuPredictor : public Predictor, public Observer {
public:
DejavuPredictor(Configuration*, ContextTracker*, const char*);
~DejavuPredictor();
virtual Prediction predict(const size_t size, const char** filter) const;
virtual void learn(const std::vector<std::string>& change);
virtual void update (const Observable* variable);
private:
typedef void (DejavuPredictor::* mbr_func_ptr_t) (const std::string& value);
std::map<std::string, mbr_func_ptr_t> dispatch_map;
bool init_memory_trigger(std::list<std::string>&) const;
bool match(const std::list<std::string>&, const std::list<std::string>&) const;
bool init_rolling_window(std::list<std::string>&, std::ifstream&) const;
void update_rolling_window(std::list<std::string>&, const std::string&) const;
void set_memory (const std::string& filename);
void set_trigger (const std::string& number);
std::string LOGGER;
std::string MEMORY;
std::string TRIGGER;
std::string memory;
int trigger;
Dispatcher<DejavuPredictor> dispatcher;
};
#endif // SOOTH_DEJAVUPREDICTOR
Configuration
Definition configuration.h:36
ContextTracker
Tracks user interaction and context.
Definition contextTracker.h:155
DejavuPredictor::update_rolling_window
void update_rolling_window(std::list< std::string > &, const std::string &) const
Definition dejavuPredictor.cpp:203
DejavuPredictor::update
virtual void update(const Observable *variable)
Definition dejavuPredictor.cpp:210
DejavuPredictor::trigger
int trigger
Definition dejavuPredictor.h:72
DejavuPredictor::learn
virtual void learn(const std::vector< std::string > &change)
Definition dejavuPredictor.cpp:116
DejavuPredictor::set_trigger
void set_trigger(const std::string &number)
Definition dejavuPredictor.cpp:65
DejavuPredictor::dispatcher
Dispatcher< DejavuPredictor > dispatcher
Definition dejavuPredictor.h:74
DejavuPredictor::TRIGGER
std::string TRIGGER
Definition dejavuPredictor.h:69
DejavuPredictor::mbr_func_ptr_t
void(DejavuPredictor::* mbr_func_ptr_t)(const std::string &value)
Definition dejavuPredictor.h:56
DejavuPredictor::init_memory_trigger
bool init_memory_trigger(std::list< std::string > &) const
Definition dejavuPredictor.cpp:154
DejavuPredictor::memory
std::string memory
Definition dejavuPredictor.h:71
DejavuPredictor::dispatch_map
std::map< std::string, mbr_func_ptr_t > dispatch_map
Definition dejavuPredictor.h:57
DejavuPredictor::DejavuPredictor
DejavuPredictor(Configuration *, ContextTracker *, const char *)
Definition dejavuPredictor.cpp:37
DejavuPredictor::match
bool match(const std::list< std::string > &, const std::list< std::string > &) const
Definition dejavuPredictor.cpp:140
DejavuPredictor::~DejavuPredictor
~DejavuPredictor()
Definition dejavuPredictor.cpp:56
DejavuPredictor::MEMORY
std::string MEMORY
Definition dejavuPredictor.h:68
DejavuPredictor::set_memory
void set_memory(const std::string &filename)
Definition dejavuPredictor.cpp:59
DejavuPredictor::LOGGER
std::string LOGGER
Definition dejavuPredictor.h:67
DejavuPredictor::predict
virtual Prediction predict(const size_t size, const char **filter) const
Generate prediction.
Definition dejavuPredictor.cpp:71
DejavuPredictor::init_rolling_window
bool init_rolling_window(std::list< std::string > &, std::ifstream &) const
Definition dejavuPredictor.cpp:182
Dispatcher
Definition dispatcher.h:42
Observable
Definition observable.h:37
Observer::Observer
Observer()
Definition observer.h:40
Prediction
Definition prediction.h:47
Predictor::Predictor
Predictor(Configuration *configuration, ContextTracker *contextTracker, const char *predictorName="Predictor", const char *shortDescription="", const char *longDescription="")
Definition predictor.cpp:39
dispatcher.h
predictor.h