00001
00002
00003
00004
00005
00006
00007 #ifndef TOSPACE_H
00008 #define TOSPACE_H
00009
00010 #include "blobbox.h"
00011 #include "gap_map.h"
00012 #include "statistc.h"
00013 #include "notdll.h"
00014
00015 extern BOOL_VAR_H(tosp_old_to_method, FALSE, "Space stats use prechopping?");
00016 extern BOOL_VAR_H(tosp_only_use_prop_rows, TRUE,
00017 "Block stats to use fixed pitch rows?");
00018 extern BOOL_VAR_H(tosp_use_pre_chopping, FALSE,
00019 "Space stats use prechopping?");
00020 extern BOOL_VAR_H(tosp_old_to_bug_fix, FALSE,
00021 "Fix suspected bug in old code");
00022 extern BOOL_VAR_H(tosp_block_use_cert_spaces, TRUE,
00023 "Only stat OBVIOUS spaces");
00024 extern BOOL_VAR_H(tosp_row_use_cert_spaces, TRUE,
00025 "Only stat OBVIOUS spaces");
00026 extern BOOL_VAR_H(tosp_narrow_blobs_not_cert, TRUE,
00027 "Only stat OBVIOUS spaces");
00028 extern BOOL_VAR_H(tosp_row_use_cert_spaces1, TRUE,
00029 "Only stat OBVIOUS spaces");
00030 extern BOOL_VAR_H(tosp_recovery_isolated_row_stats, TRUE,
00031 "Use row alone when inadequate cert spaces");
00032 extern BOOL_VAR_H(tosp_force_wordbreak_on_punct, FALSE,
00033 "Force word breaks on punct to break long lines in non-space delimited langs");
00034 extern BOOL_VAR_H(tosp_only_small_gaps_for_kern, FALSE, "Better guess");
00035 extern BOOL_VAR_H(tosp_all_flips_fuzzy, FALSE, "Pass ANY flip to context?");
00036 extern BOOL_VAR_H(tosp_fuzzy_limit_all, TRUE,
00037 "Dont restrict kn->sp fuzzy limit to tables");
00038 extern BOOL_VAR_H(tosp_stats_use_xht_gaps, TRUE,
00039 "Use within xht gap for wd breaks");
00040 extern BOOL_VAR_H(tosp_use_xht_gaps, TRUE,
00041 "Use within xht gap for wd breaks");
00042 extern BOOL_VAR_H(tosp_only_use_xht_gaps, FALSE,
00043 "Only use within xht gap for wd breaks");
00044 extern BOOL_VAR_H(tosp_rule_9_test_punct, FALSE,
00045 "Dont chng kn to space next to punct");
00046 extern BOOL_VAR_H(tosp_flip_fuzz_kn_to_sp, TRUE, "Default flip");
00047 extern BOOL_VAR_H(tosp_flip_fuzz_sp_to_kn, TRUE, "Default flip");
00048 extern BOOL_VAR_H(tosp_improve_thresh, FALSE,
00049 "Enable improvement heuristic");
00050 extern INT_VAR_H(tosp_debug_level, 0, "Debug data");
00051 extern INT_VAR_H(tosp_enough_space_samples_for_median, 3,
00052 "or should we use mean");
00053 extern INT_VAR_H(tosp_redo_kern_limit, 10,
00054 "No.samples reqd to reestimate for row");
00055 extern INT_VAR_H(tosp_few_samples, 40,
00056 "No.gaps reqd with 1 large gap to treat as a table");
00057 extern INT_VAR_H(tosp_short_row, 20,
00058 "No.gaps reqd with few cert spaces to use certs");
00059 extern INT_VAR_H(tosp_sanity_method, 1, "How to avoid being silly");
00060 extern double_VAR_H(tosp_threshold_bias1, 0,
00061 "how far between kern and space?");
00062 extern double_VAR_H(tosp_threshold_bias2, 0,
00063 "how far between kern and space?");
00064 extern double_VAR_H(tosp_narrow_fraction, 0.3,
00065 "Fract of xheight for narrow");
00066 extern double_VAR_H(tosp_narrow_aspect_ratio, 0.48,
00067 "narrow if w/h less than this");
00068 extern double_VAR_H(tosp_wide_fraction, 0.52, "Fract of xheight for wide");
00069 extern double_VAR_H(tosp_wide_aspect_ratio, 0.0,
00070 "wide if w/h less than this");
00071 extern double_VAR_H(tosp_fuzzy_space_factor, 0.6,
00072 "Fract of xheight for fuzz sp");
00073 extern double_VAR_H(tosp_fuzzy_space_factor1, 0.5,
00074 "Fract of xheight for fuzz sp");
00075 extern double_VAR_H(tosp_fuzzy_space_factor2, 0.72,
00076 "Fract of xheight for fuzz sp");
00077 extern double_VAR_H(tosp_gap_factor, 0.83, "gap ratio to flip sp->kern");
00078 extern double_VAR_H(tosp_kern_gap_factor1, 2.0,
00079 "gap ratio to flip kern->sp");
00080 extern double_VAR_H(tosp_kern_gap_factor2, 1.3,
00081 "gap ratio to flip kern->sp");
00082 extern double_VAR_H(tosp_kern_gap_factor3, 2.5,
00083 "gap ratio to flip kern->sp");
00084 extern double_VAR_H(tosp_ignore_big_gaps, -1, "xht multiplier");
00085 extern double_VAR_H(tosp_ignore_very_big_gaps, 3.5, "xht multiplier");
00086 extern double_VAR_H(tosp_rep_space, 1.6, "rep gap multiplier for space");
00087 extern double_VAR_H(tosp_enough_small_gaps, 0.65,
00088 "Fract of kerns reqd for isolated row stats");
00089 extern double_VAR_H(tosp_table_kn_sp_ratio, 2.25,
00090 "Min difference of kn & sp in table");
00091 extern double_VAR_H(tosp_table_xht_sp_ratio, 0.33,
00092 "Expect spaces bigger than this");
00093 extern double_VAR_H(tosp_table_fuzzy_kn_sp_ratio, 3.0,
00094 "Fuzzy if less than this");
00095 extern double_VAR_H(tosp_fuzzy_kn_fraction, 0.5, "New fuzzy kn alg");
00096 extern double_VAR_H(tosp_fuzzy_sp_fraction, 0.5, "New fuzzy sp alg");
00097 extern double_VAR_H(tosp_min_sane_kn_sp, 1.5,
00098 "Dont trust spaces less than this time kn");
00099 extern double_VAR_H(tosp_init_guess_kn_mult, 2.2,
00100 "Thresh guess - mult kn by this");
00101 extern double_VAR_H(tosp_init_guess_xht_mult, 0.28,
00102 "Thresh guess - mult xht by this");
00103 extern double_VAR_H(tosp_max_sane_kn_thresh, 5.0,
00104 "Multiplier on kn to limit thresh");
00105 extern double_VAR_H(tosp_flip_caution, 0.0,
00106 "Dont autoflip kn to sp when large separation");
00107 extern double_VAR_H(tosp_large_kerning, 0.19,
00108 "Limit use of xht gap with large kns");
00109 extern double_VAR_H(tosp_dont_fool_with_small_kerns, -1,
00110 "Limit use of xht gap with odd small kns");
00111 extern double_VAR_H(tosp_near_lh_edge, 0,
00112 "Dont reduce box if the top left is non blank");
00113 extern double_VAR_H(tosp_silly_kn_sp_gap, 0.2,
00114 "Dont let sp minus kn get too small");
00115 extern double_VAR_H(tosp_pass_wide_fuzz_sp_to_context, 0.75,
00116 "How wide fuzzies need context");
00117
00118 void to_spacing(
00119 ICOORD page_tr,
00120 TO_BLOCK_LIST *blocks
00121 );
00122
00123 void block_spacing_stats(TO_BLOCK *block,
00124 GAPMAP *gapmap,
00125 BOOL8 &old_text_ord_proportional,
00126 inT16 &block_space_gap_width,
00127 inT16 &block_non_space_gap_width
00128 );
00129
00130 void row_spacing_stats(TO_ROW *row,
00131 GAPMAP *gapmap,
00132 inT16 block_idx,
00133 inT16 row_idx,
00134 inT16 block_space_gap_width,
00135 inT16 block_non_space_gap_width
00136 );
00137
00138 void old_to_method(TO_ROW *row,
00139 STATS *all_gap_stats,
00140 STATS *space_gap_stats,
00141 STATS *small_gap_stats,
00142 inT16 block_space_gap_width,
00143 inT16 block_non_space_gap_width
00144 );
00145 BOOL8 isolated_row_stats(TO_ROW *row,
00146 GAPMAP *gapmap,
00147 STATS *all_gap_stats,
00148 BOOL8 suspected_table,
00149 inT16 block_idx,
00150 inT16 row_idx);
00151 inT16 stats_count_under(STATS *stats, inT16 threshold);
00152 void improve_row_threshold(TO_ROW *row, STATS *all_gap_stats);
00153 ROW *make_prop_words(
00154 TO_ROW *row,
00155 FCOORD rotation
00156 );
00157 ROW *make_blob_words(
00158 TO_ROW *row,
00159 FCOORD rotation
00160 );
00161 BOOL8 make_a_word_break(
00162 TO_ROW *row,
00163 TBOX blob_box,
00164 inT16 prev_gap,
00165 TBOX prev_blob_box,
00166 inT16 real_current_gap,
00167 inT16 within_xht_current_gap,
00168 TBOX next_blob_box,
00169 inT16 next_gap,
00170 uinT8 &blanks,
00171 BOOL8 &fuzzy_sp,
00172 BOOL8 &fuzzy_non);
00173 BOOL8 narrow_blob(TO_ROW *row, TBOX blob_box);
00174 BOOL8 wide_blob(TO_ROW *row, TBOX blob_box);
00175 BOOL8 suspected_punct_blob(TO_ROW *row, TBOX box);
00176
00177 void peek_at_next_gap(TO_ROW *row,
00178 BLOBNBOX_IT box_it,
00179 TBOX &next_blob_box,
00180 inT16 &next_gap,
00181 inT16 &next_within_xht_gap);
00182 void mark_gap(
00183 TBOX blob,
00184 inT16 rule,
00185 inT16 prev_gap,
00186 inT16 prev_blob_width,
00187 inT16 current_gap,
00188 inT16 next_blob_width,
00189 inT16 next_gap);
00190 float find_mean_blob_spacing(WERD *word);
00191 BOOL8 ignore_big_gap(TO_ROW *row,
00192 inT32 row_length,
00193 GAPMAP *gapmap,
00194 inT16 left,
00195 inT16 right);
00196 TBOX reduced_box_next(
00197 TO_ROW *row,
00198 BLOBNBOX_IT *it
00199 );
00200 TBOX reduced_box_for_blob(BLOBNBOX *blob, TO_ROW *row, inT16 *left_above_xht);
00201 #endif