23 #include "allheaders.h"
31 int scale,
int scaled_yres,
32 int rect_left,
int rect_top,
33 int rect_width,
int rect_height)
35 rect_left, rect_top, rect_width, rect_height),
36 line_separator_(
"\n"),
37 paragraph_separator_(
"\n") {
76 int length = text.
length() + 1;
77 char* result =
new char[length];
78 strncpy(result, text.
string(), length);
96 float mean_certainty = 0.0f;
97 int certainty_count = 0;
106 mean_certainty += best_choice->
certainty();
115 mean_certainty += best_choice->
certainty();
125 mean_certainty += best_choice->
certainty();
131 mean_certainty += best_choice->
certainty();
135 BLOB_CHOICE_LIST_CLIST* choices = best_choice->
blob_choices();
136 if (choices !=
NULL) {
137 BLOB_CHOICE_LIST_C_IT blob_choices_it(choices);
139 blob_choices_it.forward();
140 BLOB_CHOICE_IT choice_it(blob_choices_it.data());
141 for (choice_it.mark_cycle_pt();
142 !choice_it.cycled_list();
143 choice_it.forward()) {
144 if (choice_it.data()->unichar_id() ==
148 mean_certainty += choice_it.data()->certainty();
150 mean_certainty += best_choice->
certainty();
154 if (certainty_count > 0) {
155 mean_certainty /= certainty_count;
156 float confidence = 100 + 5 * mean_certainty;
157 if (confidence < 0.0
f) confidence = 0.0f;
158 if (confidence > 100.0
f) confidence = 100.0f;
179 int* font_id)
const {
187 *is_bold = font_info.
is_bold();
189 *is_underlined =
false;
200 return font_info.
name;
214 if (has_rtl && !has_ltr)
216 if (has_ltr && !has_rtl)
218 if (!has_ltr && !has_rtl)
227 return permuter == SYSTEM_DAWG_PERM || permuter == FREQ_DAWG_PERM ||
228 permuter == USER_DAWG_PERM;
235 return permuter == NUMBER_PERM;
275 for (
int i = 0; i < truth_vec.
size(); ++i) truth_text += truth_vec[i];
276 int length = truth_text.
length() + 1;
277 char* result =
new char[length];
278 strncpy(result, truth_text.
string(), length);
320 word_res_ = result_it.
it_->
word();
323 BLOB_CHOICE_LIST_CLIST* choices = best_choice->
blob_choices();
324 if (choices !=
NULL) {
325 BLOB_CHOICE_LIST_C_IT blob_choices_it(choices);
326 for (
int blob = 0; blob < result_it.
blob_index_; ++blob)
327 blob_choices_it.forward();
328 choice_it_ =
new BLOB_CHOICE_IT(blob_choices_it.data());
329 choice_it_->mark_cycle_pt();
342 if (choice_it_ ==
NULL)
344 choice_it_->forward();
345 return !choice_it_->cycled_list();
351 if (choice_it_ ==
NULL)
353 UNICHAR_ID id = choice_it_->data()->unichar_id();
360 if (choice_it_ ==
NULL)
362 float confidence = 100 + 5 * choice_it_->data()->certainty();
363 if (confidence < 0.0
f) confidence = 0.0f;
364 if (confidence > 100.0
f) confidence = 100.0f;