20#ifndef TESSERACT_CCUTIL_AMBIGS_H_
21#define TESSERACT_CCUTIL_AMBIGS_H_
24# include "config_auto.h"
27#if !defined(DISABLED_LEGACY_ENGINE)
34# define MAX_AMBIG_SIZE 10
63 if (val1 == INVALID_UNICHAR_ID) {
66 if (val2 == INVALID_UNICHAR_ID) {
74 if (val1 == INVALID_UNICHAR_ID) {
87 }
while (dst[
i++] != INVALID_UNICHAR_ID);
95 if (*ptr == INVALID_UNICHAR_ID) {
98 while (*ptr != INVALID_UNICHAR_ID) {
103 while (*ptr != INVALID_UNICHAR_ID) {
146 for (
auto data : replace_ambigs_) {
149 for (
auto data : dang_ambigs_) {
152 for (
auto data : one_to_one_definite_ambigs_) {
161 return replace_ambigs_;
165 void InitUnicharAmbigs(
const UNICHARSET &unicharset,
bool use_ambigs_for_adaption);
182 void LoadUnicharAmbigs(
const UNICHARSET &encoder_set,
TFile *ambigs_file,
int debug_level,
183 bool use_ambigs_for_adaption,
UNICHARSET *unicharset);
187 if (one_to_one_definite_ambigs_.empty()) {
190 return one_to_one_definite_ambigs_[unichar_id];
199 if (ambigs_for_adaption_.empty()) {
202 return ambigs_for_adaption_[unichar_id];
209 if (reverse_ambigs_for_adaption_.empty()) {
212 return reverse_ambigs_for_adaption_[unichar_id];
216 bool ParseAmbiguityLine(
int line_num,
int version,
int debug_level,
const UNICHARSET &unicharset,
217 char *buffer,
int *test_ambig_part_size,
UNICHAR_ID *test_unichar_ids,
218 int *replacement_ambig_part_size,
char *replacement_string,
int *
type);
220 UNICHAR_ID *test_unichar_ids,
int replacement_ambig_part_size,
221 const char *replacement_string,
int type,
AmbigSpec *ambig_spec,
226 std::vector<UnicharIdVector *> one_to_one_definite_ambigs_;
227 std::vector<UnicharIdVector *> ambigs_for_adaption_;
228 std::vector<UnicharIdVector *> reverse_ambigs_for_adaption_;
#define ELISTIZEH(CLASSNAME)
std::vector< AmbigSpec_LIST * > UnicharAmbigsVector
void tprintf(const char *format,...)
std::vector< UNICHAR_ID > UnicharIdVector
static void print(const UNICHAR_ID array[], const UNICHARSET &unicharset)
static int compare(const UNICHAR_ID *ptr1, const UNICHAR_ID *ptr2)
static int copy(const UNICHAR_ID src[], UNICHAR_ID dst[])
UNICHAR_ID correct_ngram_id
UNICHAR_ID wrong_ngram[MAX_AMBIG_SIZE+1]
static int compare_ambig_specs(const void *spec1, const void *spec2)
UNICHAR_ID correct_fragments[MAX_AMBIG_SIZE+1]
const UnicharAmbigsVector & replace_ambigs() const
const UnicharAmbigsVector & dang_ambigs() const
const UnicharIdVector * AmbigsForAdaption(UNICHAR_ID unichar_id) const
const UnicharIdVector * OneToOneDefiniteAmbigs(UNICHAR_ID unichar_id) const
const UnicharIdVector * ReverseAmbigsForAdaption(UNICHAR_ID unichar_id) const
const char * id_to_unichar(UNICHAR_ID id) const