Source code of Windows XP (NT5)
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.

65 lines
2.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. //
  4. // CThaiTrieIter - class CThaiTrieIter use for traversing trie.
  5. //
  6. // History:
  7. // created 7/99 aarayas
  8. //
  9. // �1999 Microsoft Corporation
  10. //----------------------------------------------------------------------------
  11. #ifndef _CTHAITRIEITER_H_
  12. #define _CTHAITRIEITER_H_
  13. #include "ctrie.hpp"
  14. #include "thwbdef.hpp"
  15. #include "WB_Asserts.h"
  16. #include "lextable.hpp"
  17. BOOL IsThaiUpperAndLowerClusterCharacter(WCHAR wc);
  18. BOOL IsThaiBeginClusterCharacter(WCHAR wc);
  19. BOOL IsThaiEndingClusterCharacter(WCHAR wc);
  20. BOOL IsThaiConsonant(WCHAR wc);
  21. bool IsThaiMostlyBeginCharacter(WCHAR wc);
  22. bool IsThaiMostlyLastCharacter(WCHAR wc);
  23. //unsigned int GetCluster(WCHAR* pszIndex);
  24. DWORD POSCompress(WCHAR* szTag);
  25. WCHAR* POSDecompress(DWORD dwTag);
  26. enum SOUNDEXSTATE {
  27. UNABLE_TO_MOVE,
  28. NOSUBSTITUTE,
  29. SUBSTITUTE_DIACRITIC,
  30. SUBSTITUTE_SOUNDLIKECHAR
  31. };
  32. class CThaiTrieIter : public CTrieIter {
  33. public:
  34. CThaiTrieIter();
  35. ~CThaiTrieIter();
  36. void Init(CTrie* ctrie);
  37. BOOL MoveCluster(WCHAR* szCluster, unsigned int iNumCluster);
  38. bool MoveCluster(WCHAR* szCluster, unsigned int iNumCluster, bool fBeginNewWord);
  39. SOUNDEXSTATE MoveSoundexByCluster(WCHAR* szCluster, unsigned int iNumCluster, unsigned int iNumNextCluster);
  40. int Soundex(WCHAR* word);
  41. bool m_fThaiNumber;
  42. protected:
  43. unsigned int GetScore(WCHAR* idealWord, WCHAR* soundLikeWord);
  44. bool Traverse(unsigned int iCharPos, unsigned int scoring);
  45. inline void CopyScan();
  46. // Trie Iterator - extra iterator for use as
  47. TRIESCAN trieScan1;
  48. WCHAR* soundexWord;
  49. WCHAR* resultWord;
  50. WCHAR* tempWord;
  51. unsigned int iResultScore;
  52. // For optimization quick look up table.
  53. TRIESCAN* pTrieScanArray;
  54. private:
  55. bool CheckNextCluster(WCHAR* szCluster, unsigned int iNumCluster);
  56. bool GetScanFirstChar(WCHAR wc, TRIESCAN* pTrieScan);
  57. };
  58. #endif