From 651b6c612db4e809c506973996f2580c4158ac3a Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sat, 27 Sep 2003 11:29:26 +0000 Subject: merge dasher which has been introduced in BRANCH first (wtf?) into HEAD --- (limited to 'inputmethods/dasher/LanguageModel.cpp') diff --git a/inputmethods/dasher/LanguageModel.cpp b/inputmethods/dasher/LanguageModel.cpp new file mode 100644 index 0000000..9635273 --- a/dev/null +++ b/inputmethods/dasher/LanguageModel.cpp @@ -0,0 +1,77 @@ +// LanguageModel.cpp +// +///////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2001-2002 David Ward +// +///////////////////////////////////////////////////////////////////////////// + +#include "LanguageModel.h" + +using namespace Dasher; +using namespace std; + +// I have removed the following as it doesn't seem to compile in gcc: + +// using CLanguageModel::CNodeContext; + +/////////////////////////////////////////////////////////////////// + +CLanguageModel::CLanguageModel(CAlphabet* Alphabet, int Normalization) + : m_Alphabet(Alphabet), m_iNorm(Normalization) +{ + m_iModelChars = m_Alphabet->GetNumberSymbols(); +} + + +/////////////////////////////////////////////////////////////////// + +void CLanguageModel::EnterText(CNodeContext* NodeContext, string TheText) +{ + vector Symbols; + m_Alphabet->GetSymbols(&Symbols, &TheText, false); + for (unsigned int i=0; i Symbols; + + m_Alphabet->GetSymbols(&Symbols, TheText, IsMore); + + for (unsigned int i=0; i &NewSymbols, + vector &Groups, vector &Probs, double AddProb) +{ + // make sure it is a valid context + if (Context) { + int s = m_Alphabet->GetNumberSymbols(); + NewSymbols.resize(s); + Groups.resize(s); + for (int i=0;iget_group(i); + } + GetProbs((CContext*) Context,Probs,AddProb); + return true; + } + return false; +} + +int CLanguageModel::GetColour(int character) +{ + std::string colour=m_Alphabet->GetColour(character); + if (colour!="") { + return atoi(colour.c_str()); + } else { + return 0; + } +} -- cgit v0.9.0.2