You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.2 KiB
70 lines
2.2 KiB
//+---------------------------------------------------------------------------
|
|
//
|
|
//
|
|
// CThaiTrieIter - class CThaiTrieIter use for traversing trie.
|
|
//
|
|
// History:
|
|
// created 7/99 aarayas
|
|
//
|
|
// ©1999 Microsoft Corporation
|
|
//----------------------------------------------------------------------------
|
|
#ifndef _CTHAITRIEITER_H_
|
|
#define _CTHAITRIEITER_H_
|
|
|
|
#include "ctrie.hpp"
|
|
#include "thwbdef.hpp"
|
|
#include "WB_Asserts.h"
|
|
#include "lextable.hpp"
|
|
#include "wzmanip.h"
|
|
BOOL IsThaiUpperAndLowerClusterCharacter(WCHAR wc);
|
|
BOOL IsThaiBeginClusterCharacter(WCHAR wc);
|
|
BOOL IsThaiEndingClusterCharacter(WCHAR wc);
|
|
BOOL IsThaiConsonant(WCHAR wc);
|
|
bool IsThaiMostlyBeginCharacter(WCHAR wc);
|
|
bool IsThaiMostlyLastCharacter(WCHAR wc);
|
|
bool IsContain(const WCHAR* pwcWord, unsigned int iWordLen, WCHAR wc);
|
|
bool IsThaiEndingSign(WCHAR wc);
|
|
//unsigned int GetCluster(WCHAR* pszIndex);
|
|
DWORD POSCompress(const WCHAR* szTag);
|
|
WCHAR* POSDecompress(DWORD dwTag);
|
|
|
|
|
|
|
|
enum SOUNDEXSTATE {
|
|
UNABLE_TO_MOVE,
|
|
NOSUBSTITUTE,
|
|
SUBSTITUTE_DIACRITIC,
|
|
SUBSTITUTE_SOUNDLIKECHAR,
|
|
STOP_MOVE
|
|
};
|
|
|
|
class CThaiTrieIter : public CTrieIter {
|
|
public:
|
|
CThaiTrieIter();
|
|
~CThaiTrieIter();
|
|
void Init(CTrie* ctrie);
|
|
BOOL MoveCluster(const WCHAR* szCluster, unsigned int iNumCluster);
|
|
bool MoveCluster(WCHAR* szCluster, unsigned int iNumCluster, bool fBeginNewWord);
|
|
SOUNDEXSTATE MoveSoundexByCluster(WCHAR* szCluster, unsigned int iNumCluster, unsigned int iNumNextCluster);
|
|
int Soundex(WCHAR* word);
|
|
bool m_fThaiNumber;
|
|
protected:
|
|
unsigned int GetScore(WCHAR* idealWord, WCHAR* soundLikeWord);
|
|
bool Traverse(unsigned int iCharPos, unsigned int scoring);
|
|
inline void CopyScan();
|
|
|
|
// Trie Iterator - extra iterator for use as
|
|
TRIESCAN trieScan1;
|
|
|
|
WCHAR* soundexWord;
|
|
WCHAR* resultWord;
|
|
WCHAR* tempWord;
|
|
unsigned int iResultScore;
|
|
|
|
// For optimization quick look up table.
|
|
TRIESCAN* pTrieScanArray;
|
|
private:
|
|
bool CheckNextCluster(const WCHAR* szCluster, unsigned int iNumCluster);
|
|
bool GetScanFirstChar(WCHAR wc, TRIESCAN* pTrieScan);
|
|
};
|
|
#endif
|