presage
0.9.2~beta
presage
src
lib
predictors
dummyPredictor.cpp
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
#include "
dummyPredictor.h
"
26
27
28
DummyPredictor::DummyPredictor
(
Configuration
*
config
,
ContextTracker
* ct,
const
char
* name)
29
:
Predictor
(
config
,
30
ct,
31
name,
32
"DummyPredictor, a fake predictor"
,
33
"DummyPredictor is a fake predictor.\n"
34
"It does not perform any actual computation nor implement any prediction mechanism.\n"
35
"It always returns the same sample prediction.\n"
)
36
{}
37
38
DummyPredictor::~DummyPredictor
()
39
{}
40
41
Prediction
DummyPredictor::predict
(
const
size_t
max_partial_predictions_size,
const
char
** filter)
const
42
{
43
// A real predictor would query its resources to retrieve the most
44
// probable completion of the prefix based on the current history,
45
// but this is just a dummy predictor that returns random suggestions.
46
//
47
Prediction
result;
48
49
result.
addSuggestion
(
Suggestion
(
"foo1"
, 0.99));
50
result.
addSuggestion
(
Suggestion
(
"foo2"
, 0.98));
51
result.
addSuggestion
(
Suggestion
(
"foo3"
, 0.97));
52
result.
addSuggestion
(
Suggestion
(
"foo4"
, 0.96));
53
result.
addSuggestion
(
Suggestion
(
"foo5"
, 0.95));
54
result.
addSuggestion
(
Suggestion
(
"foo6"
, 0.94));
55
56
result.
addSuggestion
(
Suggestion
(
"bar1"
, 0.89));
57
result.
addSuggestion
(
Suggestion
(
"bar2"
, 0.88));
58
result.
addSuggestion
(
Suggestion
(
"bar3"
, 0.87));
59
result.
addSuggestion
(
Suggestion
(
"bar4"
, 0.86));
60
result.
addSuggestion
(
Suggestion
(
"bar5"
, 0.85));
61
result.
addSuggestion
(
Suggestion
(
"bar6"
, 0.84));
62
63
result.
addSuggestion
(
Suggestion
(
"foobar1"
, 0.79));
64
result.
addSuggestion
(
Suggestion
(
"foobar2"
, 0.78));
65
result.
addSuggestion
(
Suggestion
(
"foobar3"
, 0.77));
66
result.
addSuggestion
(
Suggestion
(
"foobar4"
, 0.76));
67
result.
addSuggestion
(
Suggestion
(
"foobar5"
, 0.75));
68
result.
addSuggestion
(
Suggestion
(
"foobar6"
, 0.74));
69
70
return
result;
71
}
72
73
void
DummyPredictor::learn
(
const
std::vector<std::string>& change)
74
{
75
std::cout <<
"DummyPredictor::learn() method called"
<<
std::endl
;
76
std::cout <<
"DummyPredictor::learn() method exited"
<<
std::endl
;
77
}
Prediction
Definition:
prediction.h:47
Predictor
Definition:
predictor.h:46
DummyPredictor::~DummyPredictor
~DummyPredictor()
Definition:
dummyPredictor.cpp:38
config
std::string config
Definition:
presageDemo.cpp:70
DummyPredictor::learn
virtual void learn(const std::vector< std::string > &change)
Definition:
dummyPredictor.cpp:73
Configuration
Definition:
configuration.h:36
DummyPredictor::DummyPredictor
DummyPredictor(Configuration *, ContextTracker *, const char *)
Definition:
dummyPredictor.cpp:28
DummyPredictor::predict
virtual Prediction predict(const size_t size, const char **filter) const
Generate prediction.
Definition:
dummyPredictor.cpp:41
Prediction::addSuggestion
void addSuggestion(Suggestion)
Definition:
prediction.cpp:90
Suggestion
Definition:
suggestion.h:50
ContextTracker
Tracks user interaction and context.
Definition:
contextTracker.h:155
dummyPredictor.h
endl
const Logger< _charT, _Traits > & endl(const Logger< _charT, _Traits > &lgr)
Definition:
logger.h:278
Generated on Wed Nov 28 2018 12:12:14 for presage by
1.8.14