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.

245 lines
9.5 KiB

  1. /* *************************************************************** */
  2. /* * Word segmentation algorithm dafinitions & prototypes * */
  3. /* *************************************************************** */
  4. /* -------------------------------------------------------------- */
  5. /* ---- Private - Word segmentation definitions ------------------------- */
  6. /* -------------------------------------------------------------- */
  7. #ifndef PWS_H_INCLUDED
  8. #define PWS_H_INCLUDED
  9. #include "ws.h"
  10. #define CUT_LINE_POS 3 /* Position of decision line on hist */
  11. #define FL_DIV 8 /* Constant of points filter dist (relative to w.step */
  12. #define PIK_UP 3 /* Constant of hist pik sensing */
  13. #define PIK_DN 3 /* Constant of hist pik sensing */
  14. #define MIN_LINE_EXTR 3 /* Min number of extr for decision about w.step */
  15. #define MIN_FL 2 /* Min len of filtering distance */
  16. #define MAX_FL 100 /* Max len of filtering distance */
  17. #define V_LIMIT 128 /* Max value of hist (not to overflow uchar) */
  18. #define PIK_STEP_CONST 16 /* Relation between line_h_size and pik step */
  19. #define DEF_SEP_LET_LEVEL 30 /* Average sepletovost' v procentax */
  20. #define HORZ_REDUCT 16 /* Compression ratio of HORZ array */
  21. #define HIST_REDUCT 4 /* Compression ratio of HIST arrays */
  22. #define MIN_H_BORD 20 /* Min H of line */
  23. //#define DEF_WORD_DIST (TABLET_DPI/5) /* Default word distance */
  24. //#define DEF_H_STROKE (TABLET_DPI/5) /* Default height of line letters */
  25. //#define MIN_H_STROKE (DEF_H_STROKE/6) /* Min height of valuable stroke */
  26. //#define PIK_STEP (DEF_H_STROKE/6) /* Min distance between steps */
  27. #define MAX_LINES WS_MAX_LINES+1 /* Defaults for memory allocation */
  28. #define MAX_WORDS WS_MAX_WORDS+1 /* Defaults for memory allocation */
  29. #define MAX_STROKES WS_MAX_STROKES+1 /* Defaults for memory allocation */
  30. #define TABLET_XS (WS_TABLET_XS+32) /* Defaults for memory allocation */
  31. #define HORZ_SIZE (TABLET_XS/HORZ_REDUCT) /* Defaults for memory allocation */
  32. #define HIST_SIZE (TABLET_XS/HIST_REDUCT) /* Defaults for memory allocation */
  33. #define WS_NEWLINE 1 /* Cur stroke started new line */
  34. #define WS_ALLSENT 2 /* Cur stroke was last stroke at all */
  35. #define HIST_FIELD 0x3F /* Part of hist byte for value */
  36. #define FL_BODY 0x80 /* Bit flag of body of stroke */
  37. #define ST_FL_JUNK 0x80 /* Stroke flag showing no-pik stroke */
  38. #define ST_FL_NL_GESTURE 0x10 /* Line has leading word split gesture */
  39. #define LN_FL_NL_GESTURE 0x01 /* Line has leading word split gesture */
  40. #define WS_GP_LPUNCT 0x0001 /* Gap flag -- was postprocessed for leading punct */
  41. #define WS_GP_EPUNCT 0x0002 /* Gap flag -- was postprocessed for ending punct */
  42. #define WS_GP_LCAP 0x0004 /* Gap flag -- was postprocessed for capital letter */
  43. //#define WS_GP_UNSURE 0x0008 /* Gap flag -- segm code was unsure about segmenting on this gap */
  44. #define WS_SPNUMEXTRENOUGH 8 /* Line size and pos will be stable after this nuber of extr */
  45. /* -------------------------------------------------------------- */
  46. /* ------------------ Internal structures ----------------------- */
  47. /* -------------------------------------------------------------- */
  48. typedef struct {
  49. _SHORT st;
  50. _SHORT end;
  51. _SHORT top;
  52. _SHORT a_end;
  53. } ws_xstrokes_type;
  54. typedef struct {
  55. _UCHAR st_gap;
  56. _UCHAR en_gap;
  57. } ws_xwords_type;
  58. typedef struct {
  59. _SHORT loc;
  60. _SHORT lst;
  61. _SHORT bst;
  62. _SHORT size;
  63. _SHORT psize;
  64. _SHORT blank;
  65. _SHORT low;
  66. _UCHAR flags;
  67. _SCHAR k_sure;
  68. } ws_gaps_type, _PTR p_ws_gaps_type;
  69. typedef ws_gaps_type (_PTR ws_gaps_a_type)[XRINP_SIZE];
  70. typedef unsigned char (_PTR s_hist_a_type)[HIST_SIZE];
  71. typedef struct {
  72. _SHORT h_bord_history;
  73. _SHORT inword_dist_history;
  74. _SHORT inline_dist_history;
  75. _SHORT slope_history;
  76. _UCHAR sep_let_history;
  77. } ws_lrn_type, _PTR p_ws_lrn_type;
  78. typedef struct {
  79. PS_point_type _PTR stroke;
  80. _INT in_x_delay;
  81. _INT in_word_dist;
  82. _INT in_line_dist;
  83. _INT in_flags;
  84. _INT sure_level;
  85. _INT def_h_bord;
  86. _INT def_sep_let_level;
  87. _INT stroke_flags;
  88. _INT stroke_num_points;
  89. _INT stroke_min_x;
  90. _INT stroke_max_x;
  91. _INT stroke_min_y;
  92. _INT stroke_max_y;
  93. _INT stroke_dx;
  94. _INT stroke_dy;
  95. _INT stroke_wx_pos;
  96. _INT stroke_wy_pos;
  97. _INT stroke_filt_len;
  98. _INT stroke_active_st;
  99. _INT stroke_active_end;
  100. _INT prev_stroke_dx;
  101. _INT prev_stroke_dy;
  102. _INT line_flags;
  103. _INT line_word_dist;
  104. _INT line_inword_dist;
  105. _INT line_inline_dist;
  106. _INT line_h_bord;
  107. _INT line_st_stroke;
  108. _INT line_st_word;
  109. _INT line_start;
  110. _INT line_end;
  111. _INT line_active_start;
  112. _INT line_active_end;
  113. _INT line_extr;
  114. _INT line_cur_stroke;
  115. _INT line_word_len;
  116. _INT line_sw_sp;
  117. _INT line_bw_sp;
  118. _INT line_sep_let_level;
  119. _INT line_last_ws_try;
  120. _INT line_pik_step;
  121. _INT line_ngaps;
  122. _INT line_finished;
  123. _INT global_num_words;
  124. _INT global_cur_stroke;
  125. _INT global_cur_line;
  126. _INT global_word_dist;
  127. _INT global_inword_dist;
  128. _INT global_inline_dist;
  129. _INT global_sep_let_level;
  130. _INT global_num_extr;
  131. _INT global_word_len;
  132. _INT global_h_bord;
  133. _INT global_dy_sum;
  134. _INT global_num_dy_strokes;
  135. _INT global_line_ave_y_size;
  136. _INT global_bw_sp;
  137. _INT global_sw_sp;
  138. _INT global_slope;
  139. _LONG global_slope_dx;
  140. _LONG global_slope_dy;
  141. _INT s_hist_base;
  142. _UCHAR hist[HIST_SIZE];
  143. s_hist_a_type s_hist;
  144. _SHORT horz[HORZ_SIZE];
  145. ws_xstrokes_type xstrokes[MAX_STROKES];
  146. ws_xwords_type xwords[MAX_WORDS];
  147. ws_gaps_a_type gaps;
  148. _ULONG gaps_handle;
  149. // --- debug ---
  150. _INT ws_ssp;
  151. _INT ws_bsp;
  152. _INT ws_inline_dist;
  153. _INT ws_word_dist;
  154. _INT ws_action;
  155. // -- NN data --
  156. _INT nn_ssp;
  157. _INT nn_n_ssp;
  158. _INT nn_bsp;
  159. _INT nn_n_bsp;
  160. _INT nn_sl;
  161. _INT nn_inw_dist;
  162. _INT nn_npiks;
  163. _INT nn_cmp_min;
  164. _INT nn_cmp_max;
  165. _UCHAR (_PTR cmp)[WS_MAX_WORDS];
  166. } ws_data_type, _PTR p_ws_data_type;
  167. typedef struct {
  168. _ULONG hwsd;
  169. p_ws_data_type pwsd;
  170. ws_lrn_type lrn;
  171. ws_lrn_type lrn_buf[WS_LRN_SIZE];
  172. } ws_memory_header_type, _PTR p_ws_memory_header_type;
  173. /* ------------------ Internal function prototypes -------------- */
  174. _INT InitWSData(p_ws_control_type pwsc, p_ws_memory_header_type _PTR ppwmh);
  175. _INT ReleaseWSData(p_ws_control_type pwsc, p_ws_memory_header_type _PTR ppwmh);
  176. _INT UnlockWSData(p_ws_control_type pwsc, p_ws_memory_header_type _PTR ppwmh);
  177. _INT InitForNewLine(p_ws_data_type pwsd);
  178. _INT WS_GetStrokeBoxAndSlope(p_ws_data_type pws_data);
  179. _INT WS_HistTheStroke(p_ws_data_type pws_data);
  180. _INT WS_NewLine(p_ws_data_type pws_data);
  181. _INT CheckForSpaceGesture(p_ws_data_type pws_data);
  182. _INT WS_WriteStrokeHorzValues(p_ws_data_type pws_data);
  183. _INT WS_AddStrokeToHist(p_ws_data_type pws_data);
  184. _INT WS_SetLineVars(p_ws_data_type pws_data);
  185. _INT WS_CalcLineHeight(p_ws_data_type pws_data);
  186. _INT WS_GetWordDist(p_ws_data_type pws_data);
  187. _INT WS_CalcGaps(p_ws_data_type pws_data);
  188. _INT WS_CountPiks(p_ws_data_type pws_data);
  189. _INT WS_FlyLearn(p_ws_control_type pwsc, p_ws_memory_header_type pwmh, p_ws_data_type pws_data);
  190. _INT WS_PostprocessGaps(p_ws_data_type pwsd);
  191. #endif // PWS_H_INCLUDED
  192. /* *************************************************************** */
  193. /* * Word segmentation prototypes END * */
  194. /* *************************************************************** */