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.

105 lines
2.9 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 1997, Microsoft Corporation. All Rights Reserved.
  4. //
  5. /////////////////////////////////////////////////////////////////////////////
  6. //#include "stdafx.h"
  7. #include "pch.cxx"
  8. #include <winnls.h>
  9. #include "ReadHeosaDict.h"
  10. // Ssi-Ggut, Tossi, AuxVerb, AuxAdj dictionary
  11. static CFSADict *heosaDicts[NUM_OF_HEOSA_DICT];
  12. static CFSAIrrDict *irrDicts[NUM_OF_IRR_DICT];
  13. BOOL OpenHeosaDict(HANDLE hDict, DWORD offset)
  14. {
  15. DWORD readBytes;
  16. //HANDLE hDict;
  17. int i;
  18. _HeosaDictHeader dictHeader;
  19. //hDict = CreateFile(lpFileName, GENERIC_READ, 0, 0,
  20. // OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
  21. //if (hDict==INVALID_HANDLE_VALUE) return FALSE;
  22. // Read Header
  23. SetFilePointer(hDict, offset, 0, FILE_BEGIN);
  24. ReadFile(hDict, &dictHeader, sizeof(_HeosaDictHeader), &readBytes, 0);
  25. //if (strcmp(COPYRIGHT_STR, dictHeader.COPYRIGHT_HEADER)!=0) return FALSE;
  26. SetFilePointer(hDict, offset + dictHeader.iStart, 0, FILE_BEGIN);
  27. // Open 4 Heosa dicts
  28. for (i=0; i<NUM_OF_HEOSA_DICT; i++)
  29. heosaDicts[i] = new CFSADict(hDict, dictHeader.heosaDictSparseMatSize[i],
  30. dictHeader.heosaDictActionSize[i]);
  31. // oOpen 36 irrgular dicts
  32. for (i=0; i<NUM_OF_IRR_DICT; i++)
  33. irrDicts[i] = new CFSAIrrDict(hDict, dictHeader.irrDictSize[i]);
  34. //CloseHandle(hDict);
  35. return TRUE;
  36. }
  37. void CloseHeosaDict()
  38. {
  39. int i;
  40. for (i=0; i<NUM_OF_HEOSA_DICT; i++)
  41. delete heosaDicts[i];
  42. for (i=0; i<NUM_OF_IRR_DICT; i++)
  43. delete irrDicts[i];
  44. }
  45. /////////////////////////////////////////////////////////////////////////////
  46. // Find word from Heosa dict.
  47. int FindHeosaWord(LPCSTR lpWord, BYTE heosaPumsa, BYTE *actCode)
  48. {
  49. return(heosaDicts[heosaPumsa]->Find(lpWord, actCode));
  50. }
  51. int FindIrrWord(LPCSTR lpWord, int irrCode)
  52. {
  53. return irrDicts[irrCode]->Find(lpWord);
  54. }
  55. /*
  56. int FindHeosaWord(LPCSTR lpWord, BYTE heosaPumsa, BYTE *actCode)
  57. {
  58. char invInternal[256];
  59. int ret;
  60. #ifdef _MBCS
  61. WCHAR uni[256];
  62. MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCTSTR)lpWord, -1, uni, 256);
  63. UniToInvInternal(uni, invInternal, wcslen(uni));
  64. #elif _UNICODE
  65. UniToInvInternal(lpWord, invInternal, wcslen(uni));
  66. #endif
  67. ret = heosaDicts[heosaPumsa]->Find(invInternal, actCode);
  68. //*actCode = BYTE((ret & 0xFF00)>>8);
  69. return ret;
  70. }
  71. /////////////////////////////////////////////////////////////////////////////
  72. // Find word from Irregular dict.
  73. int FindIrrWord(LPCSTR lpWord, int irrCode)
  74. {
  75. char internal[256];
  76. #ifdef _MBCS
  77. WCHAR uni[256];
  78. MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (LPCTSTR)lpWord, -1, uni, 256);
  79. UniToInternal(uni, internal, wcslen(uni));
  80. #elif _UNICODE
  81. UniToInternal(lpWord, internal, wcslen(uni));
  82. #endif
  83. return irrDicts[irrCode]->Find(internal);
  84. }
  85. */