Leaked source code of windows server 2003
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.

69 lines
2.2 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. #include "wzmanip.h"
  18. BOOL IsThaiUpperAndLowerClusterCharacter(WCHAR wc);
  19. BOOL IsThaiBeginClusterCharacter(WCHAR wc);
  20. BOOL IsThaiEndingClusterCharacter(WCHAR wc);
  21. BOOL IsThaiConsonant(WCHAR wc);
  22. bool IsThaiMostlyBeginCharacter(WCHAR wc);
  23. bool IsThaiMostlyLastCharacter(WCHAR wc);
  24. bool IsContain(const WCHAR* pwcWord, unsigned int iWordLen, WCHAR wc);
  25. bool IsThaiEndingSign(WCHAR wc);
  26. //unsigned int GetCluster(WCHAR* pszIndex);
  27. DWORD POSCompress(const WCHAR* szTag);
  28. WCHAR* POSDecompress(DWORD dwTag);
  29. enum SOUNDEXSTATE {
  30. UNABLE_TO_MOVE,
  31. NOSUBSTITUTE,
  32. SUBSTITUTE_DIACRITIC,
  33. SUBSTITUTE_SOUNDLIKECHAR,
  34. STOP_MOVE
  35. };
  36. class CThaiTrieIter : public CTrieIter {
  37. public:
  38. CThaiTrieIter();
  39. ~CThaiTrieIter();
  40. void Init(CTrie* ctrie);
  41. BOOL MoveCluster(const WCHAR* szCluster, unsigned int iNumCluster);
  42. bool MoveCluster(WCHAR* szCluster, unsigned int iNumCluster, bool fBeginNewWord);
  43. SOUNDEXSTATE MoveSoundexByCluster(WCHAR* szCluster, unsigned int iNumCluster, unsigned int iNumNextCluster);
  44. int Soundex(WCHAR* word);
  45. bool m_fThaiNumber;
  46. protected:
  47. unsigned int GetScore(WCHAR* idealWord, WCHAR* soundLikeWord);
  48. bool Traverse(unsigned int iCharPos, unsigned int scoring);
  49. inline void CopyScan();
  50. // Trie Iterator - extra iterator for use as
  51. TRIESCAN trieScan1;
  52. WCHAR* soundexWord;
  53. WCHAR* resultWord;
  54. WCHAR* tempWord;
  55. unsigned int iResultScore;
  56. // For optimization quick look up table.
  57. TRIESCAN* pTrieScanArray;
  58. private:
  59. bool CheckNextCluster(const WCHAR* szCluster, unsigned int iNumCluster);
  60. bool GetScanFirstChar(WCHAR wc, TRIESCAN* pTrieScan);
  61. };
  62. #endif