presage  0.9.2~beta
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 " </ContextTracker>"
67 " <Selector>"
68 " <LOGGER>ERROR</LOGGER>"
69 " <!-- SUGGESTIONS"
70 " Controls how many suggestions are returned in each prediction."
71 " -->"
72 " <SUGGESTIONS>6</SUGGESTIONS>"
73 " <!-- REPEAT_SUGGESTIONS"
74 " Allow the same suggestion to be offered in subsequent"
75 " predictions, even if no context change has been detected."
76 " -->"
77 " <REPEAT_SUGGESTIONS>no</REPEAT_SUGGESTIONS>"
78 " <!-- GREEDY_SUGGESTION_THRESHOLD"
79 " Select only tokens whose completion length is greater than"
80 " the specified greedy suggestion threshold."
81 " i.e. If this option is set to 2 and the current prefix is"
82 " \"cu\", then the word \"cub\" will not offered as a"
83 " suggestion, because the completion's length is only one"
84 " character long. Tokens \"curb\" or \"cube\" or \"cubicle\" or"
85 " \"cucumber\" will however be offered, because these"
86 " words' completions are at least 2 characters long."
87 " -->"
88 " <GREEDY_SUGGESTION_THRESHOLD>0</GREEDY_SUGGESTION_THRESHOLD>"
89 " </Selector>"
90 " <PredictorActivator>"
91 " <LOGGER>ERROR</LOGGER>"
92 " <!-- PREDICT_TIME"
93 " Maximum time allowed for predictors to return their prediction."
94 " -->"
95 " <PREDICT_TIME>1000</PREDICT_TIME>"
96 " <!-- MAX_PARTIAL_PREDICTION_SIZE"
97 " Desired size of each prediction prior to combination phase."
98 " -->"
99 " <MAX_PARTIAL_PREDICTION_SIZE>60</MAX_PARTIAL_PREDICTION_SIZE>"
100 " <!-- COMBINATION_POLICY"
101 " policy used by predictor to combine predictions returned"
102 " by the active predictors into one prediction."
103 " -->"
104 " <COMBINATION_POLICY>Meritocracy</COMBINATION_POLICY>"
105 " </PredictorActivator>"
106 " <ProfileManager>"
107 " <LOGGER>ERROR</LOGGER>"
108 " <!-- AUTOPERSIST"
109 " Automatically saves configuration to active profile."
110 " -->"
111 " <AUTOPERSIST>false</AUTOPERSIST>"
112 " </ProfileManager>"
113 " <Predictors>"
114 " <DefaultSmoothedNgramPredictor>"
115 " <PREDICTOR>SmoothedNgramPredictor</PREDICTOR>"
116 " <LOGGER>ERROR</LOGGER>"
117 " <DBFILENAME>" pkgdatadir "/database_en.db</DBFILENAME>"
118 " <!-- $delta_0, $delta_1, ..., $delta_{n-1} -->"
119 " <DELTAS>0.01 0.1 0.89</DELTAS>"
120 " <COUNT_THRESHOLD>0</COUNT_THRESHOLD>"
121 " <LEARN>false</LEARN>"
122 " <DatabaseConnector>"
123 " <LOGGER>ERROR</LOGGER>"
124 " </DatabaseConnector>"
125 " </DefaultSmoothedNgramPredictor>"
126 " <UserSmoothedNgramPredictor>"
127 " <PREDICTOR>SmoothedNgramPredictor</PREDICTOR>"
128 " <LOGGER>ERROR</LOGGER>"
129 " <!-- ${HOME} is special. It expands to:"
130 " - $HOME on Unix"
131 " - %USERPROFILE% on Windows"
132 " -->"
133 " <DBFILENAME>${HOME}/.presage/lm.db</DBFILENAME>"
134 " <!-- delta_0, delta_1, ..., delta_{n-1} -->"
135 " <DELTAS>0.01 0.1 0.89</DELTAS>"
136 " <COUNT_THRESHOLD>0</COUNT_THRESHOLD>"
137 " <LEARN>true</LEARN>"
138 " <DatabaseConnector>"
139 " <LOGGER>ERROR</LOGGER>"
140 " </DatabaseConnector>"
141 " </UserSmoothedNgramPredictor>"
142 " <DefaultRecencyPredictor>"
143 " <PREDICTOR>RecencyPredictor</PREDICTOR>"
144 " <LOGGER>ERROR</LOGGER>"
145 " <LAMBDA>1</LAMBDA>"
146 " <N_0>1</N_0>"
147 " <CUTOFF_THRESHOLD>20</CUTOFF_THRESHOLD>"
148 " </DefaultRecencyPredictor>"
149 " <DefaultDictionaryPredictor>"
150 " <PREDICTOR>DictionaryPredictor</PREDICTOR>"
151 " <DICTIONARY>/usr/share/dict/words</DICTIONARY>"
152 " <!-- fixed probability assigned to prediction -->"
153 " <PROBABILITY>0.000001</PROBABILITY>"
154 " </DefaultDictionaryPredictor>"
155 " <DefaultAbbreviationExpansionPredictor>"
156 " <PREDICTOR>AbbreviationExpansionPredictor</PREDICTOR>"
157 " <LOGGER>ERROR</LOGGER>"
158 " <ABBREVIATIONS>" pkgdatadir "/abbreviations_en.txt</ABBREVIATIONS>"
159 " </DefaultAbbreviationExpansionPredictor>"
160 " <DefaultDejavuPredictor>"
161 " <PREDICTOR>DejavuPredictor</PREDICTOR>"
162 " <LOGGER>ERROR</LOGGER>"
163 " <MEMORY>" pkgdatadir "/dejavu_memory_en.txt</MEMORY>"
164 " <TRIGGER>3</TRIGGER>"
165 " </DefaultDejavuPredictor>"
166 " <DefaultARPAPredictor>"
167 " <PREDICTOR>ARPAPredictor</PREDICTOR>"
168 " <LOGGER>ERROR</LOGGER>"
169 " <ARPAFILENAME>" pkgdatadir "/arpa_en.arpa</ARPAFILENAME>"
170 " <VOCABFILENAME>" pkgdatadir "/arpa_en.vocab</VOCABFILENAME>"
171 " <TIMEOUT>100</TIMEOUT>"
172 " </DefaultARPAPredictor>"
173 " </Predictors>"
174 "</Presage>";
175 
176  xmlProfileDoc->Parse (xml);
177 
178 }
static const char * DEFAULT_PROFILE_FILENAME
DefaultProfile(const std::string &filename)
TiXmlDocument * xmlProfileDoc
Definition: profile.h:99
void build_xml_document(const std::string &)