From 2af9348b8ca275db45cd9b5837f319931648a6d8 Mon Sep 17 00:00:00 2001 From: Phil Cowans Date: Sun, 23 Apr 2006 18:58:27 +0000 Subject: [PATCH] Fixing bugs in conversion mode * Fixing bugs in conversion mode --- Src/DasherCore/ConversionManager.cpp | 17 ++++++++--------- Src/DasherCore/ConversionManager.h | 4 +++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Src/DasherCore/ConversionManager.cpp b/Src/DasherCore/ConversionManager.cpp index 878187c9..8f853658 100644 --- a/Src/DasherCore/ConversionManager.cpp +++ b/Src/DasherCore/ConversionManager.cpp @@ -1,6 +1,5 @@ #include "ConversionManager.h" -#include #include #include @@ -29,20 +28,18 @@ CConversionManager::CConversionManager(CDasherModel *pModel, CLanguageModel *pLa for(std::vector::iterator it(vCandidateList.begin()); it != vCandidateList.end(); ++it) { CConversionManagerNode *pCurrentNode(m_pRoot); - std::cout << "Adding: " << *it << std::endl; - // TODO: Need to do unicode here! - for(std::string::iterator it2(it->begin()); it2 != it->end(); ++it2) { + + + for(int j(0); j < it->size(); ++j) { CConversionManagerNode *pNextNode; - std::cout << "Symbol: *" << *it2 << "*" << std::endl; + pNextNode = pCurrentNode->FindChild(it->substr(j,1)); - pNextNode = pCurrentNode->FindChild(std::string(1, *it2)); - if(!pNextNode) { pNextNode = new CConversionManagerNode; - pNextNode->m_strSymbol = std::string(1, *it2); + pNextNode->m_strSymbol = it->substr(j,1); pNextNode->m_pChild = 0; pNextNode->m_pNext = pCurrentNode->m_pChild; pNextNode->m_iNumChildren = 0; @@ -81,16 +78,18 @@ CDasherNode *CConversionManager::GetRoot(CDasherNode *pParent, int iLower, int i } void CConversionManager::PopulateChildren( CDasherNode *pNode ) { + CDasherNode *pNewNode; CConversionManagerNode *pCurrentCMNode(static_cast(pNode->m_pUserData)); CConversionManagerNode *pCurrentCMChild(pCurrentCMNode->m_pChild); + if(pCurrentCMChild) { int iIdx(0); while(pCurrentCMChild) { - int iLbnd( iIdx*(m_pModel->GetLongParameter(LP_NORMALIZATION)/pCurrentCMNode->m_iNumChildren)); + int iLbnd( iIdx*(m_pModel->GetLongParameter(LP_NORMALIZATION)/pCurrentCMNode->m_iNumChildren)); int iHbnd( (iIdx+1)*(m_pModel->GetLongParameter(LP_NORMALIZATION)/pCurrentCMNode->m_iNumChildren)); // TODO: Parameters here are placeholders - need to figure out what's right diff --git a/Src/DasherCore/ConversionManager.h b/Src/DasherCore/ConversionManager.h index 4ba6d1c1..9cf851cc 100644 --- a/Src/DasherCore/ConversionManager.h +++ b/Src/DasherCore/ConversionManager.h @@ -6,7 +6,6 @@ #include "LanguageModelling/LanguageModel.h" // Urgh - we really shouldn't need to know about language models here #include "DasherModel.h" - namespace Dasher { class CDasherNode; // Forward declaration @@ -75,11 +74,14 @@ namespace Dasher { CConversionManagerNode *pCurrentChild(m_pChild); while(pCurrentChild) { + if(pCurrentChild->m_strSymbol == strSymbol) return pCurrentChild; pCurrentChild = pCurrentChild->m_pNext; } + + return 0; } }; -- 2.11.4.GIT