summaryrefslogtreecommitdiff
path: root/inputmethods/dasher/PPMLanguageModel.cpp
Unidiff
Diffstat (limited to 'inputmethods/dasher/PPMLanguageModel.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/dasher/PPMLanguageModel.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/inputmethods/dasher/PPMLanguageModel.cpp b/inputmethods/dasher/PPMLanguageModel.cpp
index b725a2b..137b07f 100644
--- a/inputmethods/dasher/PPMLanguageModel.cpp
+++ b/inputmethods/dasher/PPMLanguageModel.cpp
@@ -63,38 +63,38 @@ CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization)
63{ 63{
64 root=new CPPMnode(-1); 64 root=new CPPMnode(-1);
65 m_rootcontext=new CPPMContext(root,0); 65 m_rootcontext=new CPPMContext(root,0);
66} 66}
67 67
68 68
69CPPMLanguageModel::~CPPMLanguageModel() 69CPPMLanguageModel::~CPPMLanguageModel()
70{ 70{
71 delete root; 71 delete root;
72} 72}
73 73
74 74
75bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double addprob) 75bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double )
76 // get the probability distribution at the context 76 // get the probability distribution at the context
77{ 77{
78 // seems like we have to have this hack for VC++ 78 // seems like we have to have this hack for VC++
79 CPPMContext *ppmcontext=static_cast<CPPMContext *> (context); 79 CPPMContext *ppmcontext=static_cast<CPPMContext *> (context);
80 80
81 81
82 int modelchars=GetNumberModelChars(); 82 int modelchars=GetNumberModelChars();
83 int norm=CLanguageModel::normalization(); 83 int norm=CLanguageModel::normalization();
84 probs.resize(modelchars); 84 probs.resize(modelchars);
85 CPPMnode *temp,*s; 85 CPPMnode *temp,*s;
86 int loop,total; 86 int loop,total;
87 int sym; 87 int sym;
88 ulong spent=0; 88 // ulong spent=0;
89 ulong size_of_slice; 89 ulong size_of_slice;
90 bool *exclusions=new bool [modelchars]; 90 bool *exclusions=new bool [modelchars];
91 ulong uniform=modelchars; 91 ulong uniform=modelchars;
92 ulong tospend=norm-uniform; 92 ulong tospend=norm-uniform;
93 temp=ppmcontext->head; 93 temp=ppmcontext->head;
94 for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */ 94 for (loop=0; loop <modelchars; loop++) { /* set up the exclusions array */
95 probs[loop]=0; 95 probs[loop]=0;
96 exclusions[loop]=0; 96 exclusions[loop]=0;
97 } 97 }
98 while (temp!=0) { 98 while (temp!=0) {
99 //Usprintf(debug,TEXT("tospend %u\n"),tospend); 99 //Usprintf(debug,TEXT("tospend %u\n"),tospend);
100 //DebugOutput(TEXT("round\n")); 100 //DebugOutput(TEXT("round\n"));
@@ -183,25 +183,25 @@ void CPPMLanguageModel::AddSymbol(CPPMLanguageModel::CPPMContext &context,int sy
183 context.head=context.head->vine; 183 context.head=context.head->vine;
184 context.order--; 184 context.order--;
185 } 185 }
186} 186}
187 187
188 188
189// update context with symbol 'Symbol' 189// update context with symbol 'Symbol'
190void CPPMLanguageModel::EnterSymbol(CContext* Context, modelchar Symbol) 190void CPPMLanguageModel::EnterSymbol(CContext* Context, modelchar Symbol)
191{ 191{
192 CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context); 192 CPPMLanguageModel::CPPMContext& context = * static_cast<CPPMContext *> (Context);
193 193
194 CPPMnode *find; 194 CPPMnode *find;
195 CPPMnode *temp=context.head; 195 // CPPMnode *temp=context.head;
196 196
197 while (context.head) { 197 while (context.head) {
198 find =context.head->find_symbol(Symbol); 198 find =context.head->find_symbol(Symbol);
199 if (find) { 199 if (find) {
200 context.order++; 200 context.order++;
201 context.head=find; 201 context.head=find;
202 //Usprintf(debug,TEXT("found context %x order %d\n"),head,order); 202 //Usprintf(debug,TEXT("found context %x order %d\n"),head,order);
203 //DebugOutput(debug); 203 //DebugOutput(debug);
204 return; 204 return;
205 } 205 }
206 context.order--; 206 context.order--;
207 context.head=context.head->vine; 207 context.head=context.head->vine;
@@ -237,25 +237,25 @@ void CPPMLanguageModel::dumpString( char *str, int pos, int len )
237 char cc; 237 char cc;
238 int p; 238 int p;
239 for (p = pos; p<pos+len; p++) { 239 for (p = pos; p<pos+len; p++) {
240 cc = str [p]; 240 cc = str [p];
241 if ((cc <= 31) || (cc >= 127)) 241 if ((cc <= 31) || (cc >= 127))
242 printf( "<%d>", cc ); 242 printf( "<%d>", cc );
243 else 243 else
244 printf( "%c", cc ); 244 printf( "%c", cc );
245 } 245 }
246} 246}
247 247
248 248
249void CPPMLanguageModel::dumpTrie( CPPMLanguageModel::CPPMnode *t, int d ) 249void CPPMLanguageModel::dumpTrie( CPPMLanguageModel::CPPMnode *, int )
250 // diagnostic display of the PPM trie from node t and deeper 250 // diagnostic display of the PPM trie from node t and deeper
251{ 251{
252//TODO 252//TODO
253/* 253/*
254 dchar debug[256]; 254 dchar debug[256];
255 int sym; 255 int sym;
256 CPPMnode *s; 256 CPPMnode *s;
257 Usprintf( debug,TEXT("%5d %7x "), d, t ); 257 Usprintf( debug,TEXT("%5d %7x "), d, t );
258 //TODO: Uncomment this when headers sort out 258 //TODO: Uncomment this when headers sort out
259 //DebugOutput(debug); 259 //DebugOutput(debug);
260 if (t < 0) // pointer to input 260 if (t < 0) // pointer to input
261 printf( " <" ); 261 printf( " <" );