22 #include "allheaders.h" 30 int scale,
int scaled_yres,
int rect_left,
31 int rect_top,
int rect_width,
34 rect_width, rect_height),
35 line_separator_(
"\n"),
36 paragraph_separator_(
"\n") {}
46 if (
it_->
word() ==
nullptr)
return nullptr;
76 int length = text.
length() + 1;
77 char* result =
new char[length];
78 strncpy(result, text.
string(), length);
95 if (
it_->
word() ==
nullptr)
return 0.0f;
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();
138 if (certainty_count > 0) {
139 mean_certainty /= certainty_count;
140 float confidence = 100 + 5 * mean_certainty;
141 if (confidence < 0.0f) confidence = 0.0f;
142 if (confidence > 100.0f) confidence = 100.0f;
157 bool* is_bold,
bool* is_italic,
bool* is_underlined,
bool* is_monospace,
158 bool* is_serif,
bool* is_smallcaps,
int* pointsize,
int* font_id)
const {
159 const char* result =
nullptr;
174 #ifndef DISABLED_LEGACY_ENGINE 179 *is_bold = font_info->
is_bold();
181 *is_underlined =
false;
184 result = font_info->
name;
186 #endif // ndef DISABLED_LEGACY_ENGINE 194 *is_underlined =
false;
195 *is_monospace =
false;
197 *is_smallcaps =
false;
224 if (
it_->
word() ==
nullptr)
return false;
232 if (
it_->
word() ==
nullptr)
return 1;
238 if (
it_->
word() ==
nullptr)
return false;
249 #ifndef DISABLED_LEGACY_ENGINE 257 #endif // ndef DISABLED_LEGACY_ENGINE 273 if (
it_->
word() ==
nullptr)
return false;
295 int length = truth_text.
length() + 1;
296 char* result =
new char[length];
297 strncpy(result, truth_text.
string(), length);
304 if (
it_->
word() ==
nullptr)
return nullptr;
309 for (
int i = 0; i < best_choice->
length(); ++i) {
312 int length = ocr_text.
length() + 1;
313 char* result =
new char[length];
314 strncpy(result, ocr_text.
string(), length);
321 if (
it_->
word() ==
nullptr)
return nullptr;
357 word_res_ = result_it.
it_->
word();
358 BLOB_CHOICE_LIST* choices =
nullptr;
359 if (word_res_->ratings !=
nullptr)
361 if (choices !=
nullptr && !choices->empty()) {
362 choice_it_ =
new BLOB_CHOICE_IT(choices);
363 choice_it_->mark_cycle_pt();
365 choice_it_ =
nullptr;
373 if (choice_it_ ==
nullptr)
return false;
374 choice_it_->forward();
375 return !choice_it_->cycled_list();
381 if (choice_it_ ==
nullptr)
return nullptr;
382 UNICHAR_ID id = choice_it_->data()->unichar_id();
393 if (choice_it_ ==
nullptr)
return 0.0f;
394 float confidence = 100 + 5 * choice_it_->data()->certainty();
395 if (confidence < 0.0f) confidence = 0.0f;
396 if (confidence > 100.0f) confidence = 100.0f;
BLOCK_RES * prev_block() const
const FontInfo * fontinfo
bool HasBlamerInfo() const
const char * BestUTF8(int blob_index, bool in_rtl_context) const
bool is_fixed_pitch() const
ChoiceIterator(const LTRResultIterator &result_it)
void SetParagraphSeparator(const char *new_para)
int BlanksBeforeWord() const
StrongScriptDirection WordDirection() const
const char * WordLattice(int *lattice_size) const
bool WordIsFromDictionary() const
bool SymbolIsDropcap() const
const char * lattice_data() const
BlamerBundle * blamer_bundle
BLOB_CHOICE_LIST * GetBlobChoices(int index) const
bool SymbolIsSubscript() const
const char * GetBlamerDebug() const
tesseract::ScriptPos BlobPosition(int index) const
const char * string() const
tesseract::Tesseract * tesseract
const char * GetUTF8Text() const
LTRResultIterator(PAGE_RES *page_res, Tesseract *tesseract, int scale, int scaled_yres, int rect_left, int rect_top, int rect_width, int rect_height)
BLOCK_RES * block() const
const char * WordRecognitionLanguage() const
void SetLineSeparator(const char *new_line)
float Confidence(PageIteratorLevel level) const
bool SymbolIsSuperscript() const
bool ChoiceIsCorrect(const WERD_CHOICE *word_choice) const
char * WordTruthUTF8Text() const
const char * id_to_unichar_ext(UNICHAR_ID id) const
void truncate_at(int32_t index)
bool HasTruthString() const
const char * WordFontAttributes(bool *is_bold, bool *is_italic, bool *is_underlined, bool *is_monospace, bool *is_serif, bool *is_smallcaps, int *pointsize, int *font_id) const
const char * GetBlamerMisadaptionDebug() const
char * WordNormedUTF8Text() const
bool HasDebugInfo() const
UNICHAR_ID unichar_id(int index) const
const STRING & unichar_string() const
bool AnyRtlCharsInWord() const
ROW_RES * prev_row() const
~LTRResultIterator() override
constexpr int kPointsPerInch
char * GetUTF8Text(PageIteratorLevel level) const
bool AnyLtrCharsInWord() const
const tesseract::ParamsTrainingBundle & params_training_bundle() const
const void * GetParamsTrainingBundle() const
const UNICHARSET * uch_set
WERD_CHOICE * best_choice
bool WordIsNumeric() const
const char * paragraph_separator_
STRING TruthString() const
const char * line_separator_
const STRING & misadaption_debug() const
const char * get_normed_unichar(UNICHAR_ID unichar_id) const
const STRING & debug() const
bool EquivalentToTruth(const char *str) const