presage
0.9.2~beta
presage
src
lib
core
predictorActivator.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_PREDICTORACTIVATOR
26
#define PRESAGE_PREDICTORACTIVATOR
27
28
#ifdef HAVE_CONFIG_H
29
# include "config.h"
30
#endif
31
32
#include "
configuration.h
"
33
#include "
predictorRegistry.h
"
34
#include "
context_tracker/contextTracker.h
"
35
#include "
prediction.h
"
36
#include "
logger.h
"
37
#include "
dispatcher.h
"
38
39
#include "
combiner.h
"
40
#include "
meritocracyCombiner.h
"
41
42
#include "
predictors/predictor.h
"
43
44
45
#ifdef STDC_HEADERS
46
# include <stdlib.h>
// needed for abort function
47
#endif
48
49
62
class
PredictorActivator
:
public
Observer
{
63
public
:
64
//PLUMP PredictorActivator(HistoryTracker&,
65
//PLUMP plump::Plump&);
66
77
PredictorActivator
(
Configuration
*
config
,
PredictorRegistry
* registry,
ContextTracker
*
contextTracker
);
78
82
~PredictorActivator
();
83
92
Prediction
predict
(
unsigned
int
multiplier,
const
char
** filter);
93
101
int
getPredictTime
()
const
;
102
108
void
setPredictTime
(
const
std::string& predictTime);
109
118
std::string
getCombinationPolicy
()
const
;
119
131
void
setCombinationPolicy
(
const
std::string& policy);
132
137
void
setMaxPartialPredictionSize
(
const
std::string& size);
138
143
void
setLogger
(
const
std::string& level);
144
145
void
parse_internal_commands
(
Prediction
& pred);
146
147
virtual
void
update
(
const
Observable
* variable);
148
149
static
const
char
*
LOGGER
;
150
static
const
char
*
PREDICT_TIME
;
151
static
const
char
*
MAX_PARTIAL_PREDICTION_SIZE
;
152
static
const
char
*
COMBINATION_POLICY
;
153
154
private
:
155
// execute predictor function (invoked in thread)
156
void
*
execute
(
void
*);
157
158
159
Configuration
*
config
;
160
PredictorRegistry
*
predictorRegistry
;
161
ContextTracker
*
contextTracker
;
162
163
Logger<char>
logger
;
164
165
Combiner
*
combiner
;
166
std::string
combinationPolicy
;
167
168
int
max_partial_prediction_size
;
169
170
std::vector<Prediction>
predictions
;
// predictions computed by each predictor are returned here
171
172
int
predict_time
;
173
174
Dispatcher<PredictorActivator>
dispatcher
;
175
};
176
177
#endif // PRESAGE_PREDICTORACTIVATOR
Logger< char >
predictor.h
PredictorActivator::predict
Prediction predict(unsigned int multiplier, const char **filter)
Definition:
predictorActivator.cpp:57
PredictorActivator::LOGGER
static const char * LOGGER
Definition:
predictorActivator.h:149
Prediction
Definition:
prediction.h:47
Combiner
Definition:
combiner.h:40
Dispatcher< PredictorActivator >
PredictorActivator::config
Configuration * config
Definition:
predictorActivator.h:159
PredictorActivator::combiner
Combiner * combiner
Definition:
predictorActivator.h:165
PredictorActivator::setMaxPartialPredictionSize
void setMaxPartialPredictionSize(const std::string &size)
Definition:
predictorActivator.cpp:146
PredictorActivator::getPredictTime
int getPredictTime() const
Definition:
predictorActivator.cpp:117
PredictorActivator::PREDICT_TIME
static const char * PREDICT_TIME
Definition:
predictorActivator.h:150
contextTracker.h
PredictorActivator::parse_internal_commands
void parse_internal_commands(Prediction &pred)
Definition:
predictorActivator.cpp:160
PredictorActivator::MAX_PARTIAL_PREDICTION_SIZE
static const char * MAX_PARTIAL_PREDICTION_SIZE
Definition:
predictorActivator.h:151
PredictorActivator::predict_time
int predict_time
Definition:
predictorActivator.h:172
PredictorRegistry
Definition:
predictorRegistry.h:46
PredictorActivator::setPredictTime
void setPredictTime(const std::string &predictTime)
Definition:
predictorActivator.cpp:101
PredictorActivator::max_partial_prediction_size
int max_partial_prediction_size
Definition:
predictorActivator.h:168
PredictorActivator::setCombinationPolicy
void setCombinationPolicy(const std::string &policy)
Definition:
predictorActivator.cpp:123
configuration.h
combiner.h
PredictorActivator::update
virtual void update(const Observable *variable)
Definition:
predictorActivator.cpp:153
PredictorActivator
Definition:
predictorActivator.h:62
PredictorActivator::getCombinationPolicy
std::string getCombinationPolicy() const
Definition:
predictorActivator.cpp:140
Observer
Definition:
observer.h:34
dispatcher.h
prediction.h
PredictorActivator::PredictorActivator
PredictorActivator(Configuration *config, PredictorRegistry *registry, ContextTracker *contextTracker)
Definition:
predictorActivator.cpp:33
predictorRegistry.h
Configuration
Definition:
configuration.h:36
PredictorActivator::logger
Logger< char > logger
Definition:
predictorActivator.h:163
PredictorActivator::setLogger
void setLogger(const std::string &level)
Definition:
predictorActivator.cpp:94
PredictorActivator::COMBINATION_POLICY
static const char * COMBINATION_POLICY
Definition:
predictorActivator.h:152
logger.h
PredictorActivator::combinationPolicy
std::string combinationPolicy
Definition:
predictorActivator.h:166
meritocracyCombiner.h
PredictorActivator::contextTracker
ContextTracker * contextTracker
Definition:
predictorActivator.h:161
ContextTracker
Tracks user interaction and context.
Definition:
contextTracker.h:155
PredictorActivator::dispatcher
Dispatcher< PredictorActivator > dispatcher
Definition:
predictorActivator.h:174
PredictorActivator::predictorRegistry
PredictorRegistry * predictorRegistry
Definition:
predictorActivator.h:160
PredictorActivator::~PredictorActivator
~PredictorActivator()
Definition:
predictorActivator.cpp:52
PredictorActivator::predictions
std::vector< Prediction > predictions
Definition:
predictorActivator.h:170
Observable
Definition:
observable.h:37
PredictorActivator::execute
void * execute(void *)
Generated on Wed Nov 28 2018 12:12:13 for presage by
1.8.14