presage  0.9.1
defaultProfile.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 "defaultProfile.h"
26 
27 #include "dirs.h"
28 
29 #include <sstream>
30 
31 const char* DefaultProfile::DEFAULT_PROFILE_FILENAME = "presage.xml";
32 
33 DefaultProfile::DefaultProfile (const std::string& filename)
34  : Profile (filename)
35 {
36  build_xml_document (filename);
37 }
38 
40 {
41  // complete
42 }
43 
44 void DefaultProfile::build_xml_document (const std::string& filename)
45 {
46  const char* xml =
47 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>"
48 "<Presage>"
49 " <PredictorRegistry>"
50 " <LOGGER>ERROR</LOGGER>"
51 " <!-- PREDICTORS"
52 " Space separated list of predictors to use to generate predictions"
53 " -->"
54 " <PREDICTORS>DefaultAbbreviationExpansionPredictor DefaultSmoothedNgramPredictor UserSmoothedNgramPredictor DefaultRecencyPredictor</PREDICTORS>"
55 " </PredictorRegistry>"
56 " <ContextTracker>"
57 " <LOGGER>ERROR</LOGGER>"
58 " <!-- SLIDING_WINDOW_SIZE"
59 " Size of buffer used by context tracker to detect context changes"
60 " -->"
61 " <SLIDING_WINDOW_SIZE>80</SLIDING_WINDOW_SIZE>"
62 " <!-- LOWERCASE_MODE"
63 " Instruct context tracker to track text as lowercase"
64 " -->"
65 " <LOWERCASE_MODE>yes</LOWERCASE_MODE>"
66 " <!-- ONLINE_LEARNING"
67 " Controls presage online machine learning feature."
68 " Presage is context-aware and capable of dynamic online learning."
69 " Setting this to yes/true will enable online learning mode."
70 " Setting this to no/false will disable online learning mode."
71 " When online learning mode is disabled, it is still"
72 " possible to instruct presage to learn through its API."
73 " -->"
74 " <ONLINE_LEARNING>yes</ONLINE_LEARNING>"
75 " </ContextTracker>"
76 " <Selector>"
77 " <LOGGER>ERROR</LOGGER>"
78 " <!-- SUGGESTIONS"
79 " Controls how many suggestions are returned in each prediction."
80 " -->"
81 " <SUGGESTIONS>6</SUGGESTIONS>"
82 " <!-- REPEAT_SUGGESTIONS"
83 " Allow the same suggestion to be offered in subsequent"
84 " predictions, even if no context change has been detected."
85 " -->"
86 " <REPEAT_SUGGESTIONS>no</REPEAT_SUGGESTIONS>"
87 " <!-- GREEDY_SUGGESTION_THRESHOLD"
88 " Select only tokens whose completion length is greater than"
89 " the specified greedy suggestion threshold."
90 " i.e. If this option is set to 2 and the current prefix is"
91 " \"cu\", then the word \"cub\" will not offered as a"
92 " suggestion, because the completion's length is only one"
93 " character long. Tokens \"curb\" or \"cube\" or \"cubicle\" or"
94 " \"cucumber\" will however be offered, because these"
95 " words' completions are at least 2 characters long."
96 " -->"
97 " <GREEDY_SUGGESTION_THRESHOLD>0</GREEDY_SUGGESTION_THRESHOLD>"
98 " </Selector>"
99 " <PredictorActivator>"
100 " <LOGGER>ERROR</LOGGER>"
101 " <!-- PREDICT_TIME"
102 " Maximum time allowed for predictors to return their prediction."
103 " -->"
104 " <PREDICT_TIME>1000</PREDICT_TIME>"
105 " <!-- MAX_PARTIAL_PREDICTION_SIZE"
106 " Desired size of each prediction prior to combination phase."
107 " -->"
108 " <MAX_PARTIAL_PREDICTION_SIZE>60</MAX_PARTIAL_PREDICTION_SIZE>"
109 " <!-- COMBINATION_POLICY"
110 " policy used by predictor to combine predictions returned"
111 " by the active predictors into one prediction."
112 " -->"
113 " <COMBINATION_POLICY>Meritocracy</COMBINATION_POLICY>"
114 " </PredictorActivator>"
115 " <ProfileManager>"
116 " <LOGGER>ERROR</LOGGER>"
117 " <!-- AUTOPERSIST"
118 " Automatically saves configuration to active profile."
119 " -->"
120 " <AUTOPERSIST>false</AUTOPERSIST>"
121 " </ProfileManager>"
122 " <Predictors>"
123 " <DefaultSmoothedNgramPredictor>"
124 " <PREDICTOR>SmoothedNgramPredictor</PREDICTOR>"
125 " <LOGGER>ERROR</LOGGER>"
126 " <DBFILENAME>" pkgdatadir "/database_en.db</DBFILENAME>"
127 " <!-- $delta_0, $delta_1, ..., $delta_{n-1} -->"
128 " <DELTAS>0.01 0.1 0.89</DELTAS>"
129 " <LEARN>false</LEARN>"
130 " <DatabaseConnector>"
131 " <LOGGER>ERROR</LOGGER>"
132 " </DatabaseConnector>"
133 " </DefaultSmoothedNgramPredictor>"
134 " <UserSmoothedNgramPredictor>"
135 " <PREDICTOR>SmoothedNgramPredictor</PREDICTOR>"
136 " <LOGGER>ERROR</LOGGER>"
137 " <!-- ${HOME} is special. It expands to:"
138 " - $HOME on Unix"
139 " - %USERPROFILE% on Windows"
140 " -->"
141 " <DBFILENAME>${HOME}/.presage/lm.db</DBFILENAME>"
142 " <!-- delta_0, delta_1, ..., delta_{n-1} -->"
143 " <DELTAS>0.01 0.1 0.89</DELTAS>"
144 " <LEARN>true</LEARN>"
145 " <DatabaseConnector>"
146 " <LOGGER>ERROR</LOGGER>"
147 " </DatabaseConnector>"
148 " </UserSmoothedNgramPredictor>"
149 " <DefaultRecencyPredictor>"
150 " <PREDICTOR>RecencyPredictor</PREDICTOR>"
151 " <LOGGER>ERROR</LOGGER>"
152 " <LAMBDA>1</LAMBDA>"
153 " <N_0>1</N_0>"
154 " <CUTOFF_THRESHOLD>20</CUTOFF_THRESHOLD>"
155 " </DefaultRecencyPredictor>"
156 " <DefaultDictionaryPredictor>"
157 " <PREDICTOR>DictionaryPredictor</PREDICTOR>"
158 " <DICTIONARY>/usr/share/dict/words</DICTIONARY>"
159 " <!-- fixed probability assigned to prediction -->"
160 " <PROBABILITY>0.000001</PROBABILITY>"
161 " </DefaultDictionaryPredictor>"
162 " <DefaultAbbreviationExpansionPredictor>"
163 " <PREDICTOR>AbbreviationExpansionPredictor</PREDICTOR>"
164 " <LOGGER>ERROR</LOGGER>"
165 " <ABBREVIATIONS>" pkgdatadir "/abbreviations_en.txt</ABBREVIATIONS>"
166 " </DefaultAbbreviationExpansionPredictor>"
167 " <DefaultDejavuPredictor>"
168 " <PREDICTOR>DejavuPredictor</PREDICTOR>"
169 " <LOGGER>ERROR</LOGGER>"
170 " <MEMORY>" pkgdatadir "/dejavu_memory_en.txt</MEMORY>"
171 " <TRIGGER>3</TRIGGER>"
172 " </DefaultDejavuPredictor>"
173 " <DefaultARPAPredictor>"
174 " <PREDICTOR>ARPAPredictor</PREDICTOR>"
175 " <LOGGER>ERROR</LOGGER>"
176 " <ARPAFILENAME>" pkgdatadir "/arpa_en.arpa</ARPAFILENAME>"
177 " <VOCABFILENAME>" pkgdatadir "/arpa_en.vocab</VOCABFILENAME>"
178 " <TIMEOUT>100</TIMEOUT>"
179 " </DefaultARPAPredictor>"
180 " </Predictors>"
181 "</Presage>";
182 
183  xmlProfileDoc->Parse (xml);
184 
185 }
void build_xml_document(const std::string &)
DefaultProfile(const std::string &filename)
static const char * DEFAULT_PROFILE_FILENAME
TiXmlDocument * xmlProfileDoc
Definition: profile.h:99