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.

150 lines
4.6 KiB

  1. #ifndef __CLASSBIGRAM__
  2. #define __CLASSBIGRAM__
  3. /******************************************************************************\
  4. * FILE: clbigram.h
  5. *
  6. * Public structures and functions library that are used to access the
  7. * class bigram information.
  8. *
  9. * Note that the code to create the binary file is in clbigram, not in the
  10. * common library.
  11. \******************************************************************************/
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /************************************************************************************************\
  16. * Public interface to class bigram data.
  17. \************************************************************************************************/
  18. //
  19. // Structures and types
  20. //
  21. // Structure giving access to a loaded copy of the class bigram tables.
  22. typedef struct tagCLASS_BIGRAM_INFO {
  23. WORD cNumClasses; // Number of classes
  24. BYTE *pProbTable; // Probability table
  25. void *pLoadInfo1; // Handles needed to unload the data
  26. void *pLoadInfo2;
  27. void *pLoadInfo3;
  28. } CLASS_BIGRAM_INFO;
  29. //
  30. // Functions.
  31. //
  32. // Load class bigram information from a file.
  33. BOOL ClassBigramLoadFile(LOCRUN_INFO *pLocRunInfo, CLASS_BIGRAM_INFO *pBigramInfo, wchar_t *pPath);
  34. // Unload runtime localization information that was loaded from a file.
  35. BOOL ClassBigramUnloadFile(CLASS_BIGRAM_INFO *pBigramInfo);
  36. // Load class bigram information from a resource.
  37. // Note, don't need to unload resources.
  38. BOOL ClassBigramLoadRes(
  39. LOCRUN_INFO *pLocRunInfo,
  40. CLASS_BIGRAM_INFO *pBigramInfo,
  41. HINSTANCE hInst,
  42. int nResID,
  43. int nType
  44. );
  45. // Load runtime localization information from an image already loaded into
  46. // memory.
  47. BOOL ClassBigramLoadPointer(LOCRUN_INFO *pLocRunInfo, CLASS_BIGRAM_INFO *pBigramInfo, void *pData);
  48. // Get class bigram probability for selected characters. Characters must be passed in as
  49. // dense coded values.
  50. FLOAT ClassBigramTransitionCost(
  51. LOCRUN_INFO *pLocRunInfo,
  52. CLASS_BIGRAM_INFO *pBigramInfo,
  53. wchar_t dchPrev,
  54. wchar_t dchCur
  55. );
  56. /************************************************************************************************\
  57. * Stuff to access binary class bigram file, only used by common and clbigram.
  58. \************************************************************************************************/
  59. // The format for the class bigram file is:
  60. // Header:
  61. // DWORD File type indicator.
  62. // DWORD Size of header.
  63. // BYTE Lowest version this code that can read this file.
  64. // BYTE Version of this code that wrote this file.
  65. // wchar_t[4] Locale ID (3 characters plus null).
  66. // DWORD * 3 Locale signature
  67. // WORD Number of classes.
  68. // DWORD[3] reserved
  69. // Prop table 0:
  70. // BYTE Prob of Trans between class 0 and to class 0.
  71. // BYTE Prob of Trans between class 0 and to class 1.
  72. // .
  73. // .
  74. // .
  75. // BYTE Prob of Trans between class 0 and to class N-1.
  76. // Prop table 1:
  77. // BYTE Prob of Trans between class 1 and to class 0.
  78. // BYTE Prob of Trans between class 1 and to class 1.
  79. // .
  80. // .
  81. // .
  82. // BYTE Prob of Trans between class 1 and to class N-1.// WORD Index to second table for first class code.
  83. // .
  84. // .
  85. // .
  86. // Prop table N-1:
  87. // BYTE Prob of Trans between class N-1 and to class 0.
  88. // BYTE Prob of Trans between class N-1 and to class 1.
  89. // .
  90. // .
  91. // .
  92. // BYTE Prob of Trans between class N-1 and to class N-1.// WORD Index to second table for first class code.
  93. // .
  94. // .
  95. // .
  96. //
  97. // Constants
  98. //
  99. // Magic key the identifies the Local Runtime files
  100. #define CLASS_BIGRAM_FILE_TYPE 0x7A30C362
  101. // Version information for file.
  102. #define CLASS_BIGRAM_MIN_FILE_VERSION 1 // First version of code that can read this file
  103. #define CLASS_BIGRAM_CUR_FILE_VERSION 1 // Current version of code.
  104. #define CLASS_BIGRAM_OLD_FILE_VERSION 0 // Oldest file version this code can read.
  105. // Probability to use if no bigram entry found.
  106. #define CLASS_BIGRAM_DEFAULT_PROB 255 // JRB: Figure a good value for this ???
  107. //
  108. // Structures and types
  109. //
  110. // Structure to hold file header.
  111. typedef struct tagCLASS_BIGRAM_HEADER {
  112. DWORD fileType; // This should always be set to BIGRAM_FILE_TYPE.
  113. DWORD headerSize; // Size of the header.
  114. BYTE minFileVer; // Earliest version of code that can read this file
  115. BYTE curFileVer; // Current version of code that wrote the file.
  116. wchar_t locale[4]; // Locale ID string.
  117. DWORD adwSignature [3]; // Locale signature
  118. WORD cNumClasses; // Number of classes
  119. DWORD reserved [3]; // reserved
  120. } CLASS_BIGRAM_HEADER;
  121. //
  122. // Functions
  123. //
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127. #endif //__CLASSBIGRAM__