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.

229 lines
11 KiB

  1. /* ************************************************************************* */
  2. /* Word corrector module for handwriting recognition program */
  3. /* Xrlv header. Created 3/00/96. AVP. */
  4. /* ************************************************************************* */
  5. #ifndef XRLV_HEADER_INCLUDED
  6. #define XRLV_HEADER_INCLUDED
  7. #include "snn.h"
  8. #include "peg_util.h"
  9. // ----------------- Defines ---------------------------------------------------
  10. #define XRLV_ALL_MULTIWORD 0 // Enable multiwording on any location
  11. #define XRLV_LNK_MULTIWORD 0 // Enable multiwording on link location
  12. #define XRLV_SEG_MULTIWORD 1 // Enable multiwording only on designated segmentation locs
  13. #define XRLV_ST_PUNCT_PENL 2
  14. #define XRLV_EN_PUNCT_PENL 2
  15. #define XRLV_NEWWORD_ST_PENL 2 /* Penalty for starting a new word */
  16. #define XRLV_NEWWORD_COEFF 0 /* Runnining penalty for new word coeff */
  17. #define XRLV_NOTFINISHED_PENL 24
  18. /* Alll penaties per XR el, mul by 4*/
  19. #define XRLV_VOC_PENL 0 /* Vocabulary symbol penalty */
  20. #define XRLV_PSX_ST_PENL 3 /* Prefix/Suffix starting symbol penalty */
  21. #define XRLV_PSX_PENL 1 /* Prefix/Suffix symbol penalty */
  22. #define XRLV_LDB_PENL 2 /* Lexical data base symbol penalty */
  23. #define XRLV_TRD_PENL 2 /* Triads symbol penalty */
  24. #define XRLV_CSA_PENL 4 /* Charset Alpha symbol penalty */
  25. #define XRLV_CSN_PENL 3 /* Charset Numbers symbol penalty */
  26. #define XRLV_CSM_PENL 4 /* Charset MATH symbol penalty */
  27. #define XRLV_CSO_PENL 4 /* Charset Other symbol penalty */
  28. #define XRLV_CSP_PENL 4 /* Charset Punctuation symbol penalty */
  29. #define XRLV_MWDP_COEFF 3 /* Penalty for startin a new word */
  30. #define XRLV_MWSP_COEFF 2 /* Multiplier of segm multiword penalty */
  31. #define XRLV_CSA_ID 1 /* Charset Alpha symbol Id */
  32. #define XRLV_CSN_ID 2 /* Charset Numbers symbol Id */
  33. #define XRLV_CSM_ID 3 /* Charset MATH symbol Id */
  34. #define XRLV_CSO_ID 4 /* Charset Other symbol Id */
  35. #define XRLV_CSP_ID 5 /* Charset Punctuation symbol Id */
  36. #define XRLV_VARNUM 256 /* Max number of cells to allocate per position */
  37. #define XRLV_CS_LOC_SHARE 8 /* One eight of all loactions will be devoted to CS */
  38. #define XRLV_ANS_SIZE (XRLV_VARNUM)
  39. #define XRLV_VOC_SIZE 512
  40. #define XRLV_CS_SIZE 256
  41. #define XRLV_PT_SIZE 16
  42. #define XRLV_ANSW_MAX_LEN (w_lim)
  43. #define XRLV_PP_INFO_SIZE (DTI_XR_SIZE+2)
  44. #define XRLV_MIN_BUFFERS 2 /* Number of symbol sources in XRLV */
  45. #define XRLV_FLOOR -50
  46. #define XRLV_INITIAL_WEIGHT 100
  47. #define XRLV_SEP_PENL_V 1
  48. #define XRLV_SEP_PENL_O 4
  49. #define XRLV_F_NCAP_PENL 5
  50. #define XRLV_S_LET_PENL 2
  51. #define XRLV_DICT_STREWARD (XRLV_CSA_PENL) /* Reward for dict words to overcome first letter competition */
  52. #define XRLV_VFL_CAP_PENL 2 /* Penalize capitalization of the first letter of dict */
  53. #define XRLV_CACHE_LEN (DTI_XR_SIZE+4)
  54. #define XRLV_SYMCORR_CACHE_SIZE (DTI_NUMSYMBOLS)
  55. #define XRLV_CACHE_EL_SET 0x01
  56. #define XRLV_CACHE_EL_VBAD 0x02
  57. #define XRLV_CACHE_EL_CBAD 0x04
  58. #define XRLV_DICT_FL_CAP 0x80 /* VocSymSet buf flags / xlv cell flag*/
  59. #define XRLV_SORT_USED 0x40 /* VocSymSet buf flags / xlv cell flag*/
  60. #define XRLV_DICT_PREFIXED 0x01 /* Word had prefix!, xlv cell flag*/
  61. #define XRLV_DICT_STREWARDED 0x02 /* This word has received initial reword, need to subtract, xlv cell flag */
  62. #define XRLV_YIELD_BREAK 2 /* Marker that xrlv data was saved after break by yield */
  63. #define MAX_LANDING_POS 32
  64. // ----------------- Structures ------------------------------------------------
  65. typedef struct {
  66. _UCHAR nvar;
  67. _UCHAR st;
  68. _UCHAR end;
  69. _UCHAR flags;
  70. _UCHAR mbuf[XRLV_CACHE_LEN];
  71. _UCHAR nvars[XRLV_CACHE_LEN];
  72. }xrlv_cache_type, _PTR p_xrlv_cache_type;
  73. typedef struct {
  74. _UCHAR sym;
  75. _UCHAR st; // Pos of parent
  76. _UCHAR np; // Num of parent
  77. _UCHAR sym_type; // Type of symbol (for trnp)
  78. _SHORT ppw; // PostProc penalty
  79. _SHORT boxp; // Boxes penalty
  80. _SHORT lexp; // Lex penalty
  81. _SHORT othp; // Other penalties
  82. _UCHAR nvar; // Number of sym variant in DTI
  83. _UCHAR nwords; // Num of voc words in this chain
  84. _SHORT w; // Sym weight
  85. _SHORT sw; // Sequence weight (word weight)
  86. _UCHAR source; // Lexical Source of the symbol
  87. _USHORT iXRScore; // XR NNet score
  88. _UCHAR len; // Length of current word
  89. _UCHAR wlen; // Length of last voc/ld word
  90. _UCHAR flags; // Flags of symbol
  91. _SHORT BoxPenalty;
  92. fw_buf_type sd; // Legacy stuff about symbol, to be updated !!
  93. _UCHAR word[XRLV_ANSW_MAX_LEN];// Answer symbols
  94. _SCHAR symw[XRLV_ANSW_MAX_LEN];// Symbols' weight
  95. _UCHAR nvps[XRLV_ANSW_MAX_LEN];// NumVar (4hbit)/ Len (in positions)(4lbit)
  96. }xrlv_var_data_type, _PTR p_xrlv_var_data_type;
  97. typedef struct {
  98. _INT gw;
  99. _INT min_w_v;
  100. _INT min_w_loc_v;
  101. _INT min_w_c;
  102. _INT min_w_loc_c;
  103. _INT nsym;
  104. _INT nsym_v;
  105. _INT nsym_c;
  106. _INT n_put;
  107. // _INT flags;
  108. _UCHAR nn_weights[256]; // 256 - Weights provided by the net
  109. xrlv_var_data_type buf[XRLV_VARNUM];
  110. }xrlv_var_data_type_array, _PTR p_xrlv_var_data_type_array;
  111. typedef struct {
  112. _SHORT percent; // Answer percent
  113. _UCHAR num; // Answer num in last pos buf
  114. _UCHAR vp ; // Answer voc penalty
  115. } xrlv_ans_type, _PTR p_xrlv_ans_type;
  116. typedef struct {
  117. _INT pos; // Current position in development
  118. _INT npos; // Overall Number of positions
  119. _INT n_real_pos; // Number of really allocated positions
  120. _INT size_pos; // Allocated memory for the position
  121. _INT nloc; // Real Number of cells allocated for the position
  122. _INT nloc_c; // Real Number of CS cells allocated for the position
  123. _INT nloc_v; // Real Number of VOC/LD cells allocated for the position
  124. _INT bad_dist; // Parameters From RC
  125. _INT xrwm; // RC xrw mode
  126. _INT xrw_cs; // RC charset select
  127. _INT caps_mode;
  128. _INT self_weight; // Max weight of Xrdata
  129. _INT init_weight; // Starting reward value
  130. _INT cs_fbuf_num; // Number of elements in CS buffer
  131. _INT lp_fbuf_num; // Number of elements in LP buffer
  132. _INT ep_fbuf_num; // Number of elements in EP buffer
  133. p_xrcm_type xrcm;
  134. p_rc_type rc;
  135. p_xrdata_type xrdata;
  136. p_SHORT xTrace;
  137. p_SHORT yTrace;
  138. p_xrlv_var_data_type_array pxrlvs[XRINP_SIZE];
  139. lex_data_type vs;
  140. _UCHAR link_index[XRINP_SIZE];
  141. _UCHAR unlink_index[XRINP_SIZE];
  142. xrlv_ans_type ans[XRLV_ANS_SIZE];
  143. _UCHAR order[XRLV_VARNUM];
  144. fw_buf_type (_PTR fbuf)[XRWD_MAX_LETBUF];
  145. fw_buf_type v_fbuf[XRLV_VOC_SIZE];
  146. fw_buf_type c_fbuf[XRLV_CS_SIZE];
  147. fw_buf_type lp_fbuf[XRLV_PT_SIZE];
  148. fw_buf_type ep_fbuf[XRLV_PT_SIZE];
  149. xrlv_cache_type cache[XRLV_SYMCORR_CACHE_SIZE];
  150. mlp_data_type mlpd;
  151. _UCHAR aXRNetScore[MAX_LANDING_POS][256];
  152. }xrlv_data_type, _PTR p_xrlv_data_type;
  153. // ----------------- Functions -------------------------------------------------
  154. _INT xrlv(p_rec_inst_type pri);
  155. _INT XrlvDevelopPos(_INT pos, p_xrlv_data_type xd);
  156. _INT XrlvDevelopCell(_INT pos, _INT caps_cnt, _INT penl, p_xrlv_var_data_type pxl, p_xrlv_data_type xd);
  157. #ifdef __cplusplus
  158. extern "C"
  159. {
  160. #endif
  161. _INT XrlvSortXrlvPos(_INT pos, p_xrlv_data_type xd);
  162. #ifdef __cplusplus
  163. }
  164. #endif
  165. _INT XrlvGetNextSymbols(p_xrlv_var_data_type pbp, _INT cap_dupl, p_xrlv_data_type xd);
  166. _INT XrlvAlloc(p_xrlv_data_type _PTR xdd, p_xrdata_type xrdata, p_rc_type rc);
  167. _INT XrlvDealloc(p_xrlv_data_type _PTR xd);
  168. _INT XrlvFreeSomePos(p_xrlv_data_type xd);
  169. _INT XrlvCreateRWG(p_RWG_type rwg, p_xrlv_data_type xd);
  170. _INT XrlvSetLocations(p_xrlv_data_type xd, _INT fl);
  171. //_INT XrlvCreateAnswers(_INT iw, p_xrlv_data_type xd);
  172. _INT XrlvSortAns(p_rec_inst_type pri, p_xrlv_data_type xd);
  173. _INT XrlvCleanAns(p_xrlv_data_type xd);
  174. _INT XrlvCHLXrlvPos(_INT pos, p_xrlv_data_type xd);
  175. _INT XrlvTrimXrlvPos(_INT pos, p_xrlv_data_type xd);
  176. _INT XrlvGuessFutureGws(_INT pos, p_xrlv_data_type xd);
  177. //_INT XrlvAliasXrlvPos(_INT pos, p_xrlv_data_type xd);
  178. _INT XrlvGetSymAliases(_UCHAR sym, _INT nvar, _INT st, _INT end, p_UCHAR buf, p_xrcm_type xrcm);
  179. _INT XrlvPPDXrlvSym(_UCHAR sym, _UCHAR nvar, p_UCHAR buf, p_SHORT x, p_SHORT y, p_rc_type rc);
  180. _INT XrlvGetCharset(p_xrlv_data_type xd);
  181. _INT XrlvGetRwgSymAliases(_INT rwsi, p_RWG_type rwg, p_xrlv_data_type xd);
  182. //_INT XrlvGetRwgSrcIds(p_RWG_type rwg, p_xrlv_data_type xd);
  183. _INT XrlvCheckDictCap(p_xrlv_var_data_type xv, p_xrlv_data_type xd);
  184. _INT XrlvApplyWordEndInfo(_INT pos, p_xrlv_var_data_type xv, p_xrlv_data_type xd);
  185. _INT XrlvNNXrlvPos(_INT pos, p_xrlv_data_type xd);
  186. #endif /* XRLV_HEADER_INCLUDED */
  187. /* ************************************************************************* */
  188. /* End of header */
  189. /* ************************************************************************* */
  190. //