21 #ifndef TESSERACT_CCUTIL_AMBIGS_H_    22 #define TESSERACT_CCUTIL_AMBIGS_H_    30 #define MAX_AMBIG_SIZE    10    36 static const int kUnigramAmbigsBufferSize = 1000;
    37 static const char kAmbigNgramSeparator[] = { 
' ', 
'\0' };
    38 static const char kAmbigDelimiters[] = 
"\t ";
    39 static const char kIllegalMsg[] =
    40   "Illegal ambiguity specification on line %d\n";
    41 static const char kIllegalUnicharMsg[] =
    42   "Illegal unichar %s in ambiguity specification\n";
    67         if (val1 == INVALID_UNICHAR_ID) 
return -1;
    68         if (val2 == INVALID_UNICHAR_ID) 
return 1;
    69         if (val1 < val2) 
return -1;
    72       if (val1 == INVALID_UNICHAR_ID) 
return 0;
    78   static inline int find_in(
const UnicharIdVector& uid_vec,
    80     for (
int i = 0; i < uid_vec.
size(); ++i)
    81       if (uid_vec[i] == uid) 
return i;
    92     } 
while (dst[i++] != INVALID_UNICHAR_ID);
   101     if (*ptr == INVALID_UNICHAR_ID) 
tprintf(
"[Empty]");
   102     while (*ptr != INVALID_UNICHAR_ID) {
   107     while (*ptr != INVALID_UNICHAR_ID) 
tprintf(
"%d ", *ptr++);
   124       *
static_cast<const AmbigSpec * 
const *
>(spec1);
   126       *
static_cast<const AmbigSpec * 
const *
>(spec2);
   128     if (result != 0) 
return result;
   149     replace_ambigs_.delete_data_pointers();
   150     dang_ambigs_.delete_data_pointers();
   151     one_to_one_definite_ambigs_.delete_data_pointers();
   154   const UnicharAmbigsVector &
dang_ambigs()
 const { 
return dang_ambigs_; }
   158   void InitUnicharAmbigs(
const UNICHARSET& unicharset,
   159                          bool use_ambigs_for_adaption);
   176   void LoadUnicharAmbigs(
const UNICHARSET& encoder_set,
   177                          TFile *ambigs_file, 
int debug_level,
   178                          bool use_ambigs_for_adaption, 
UNICHARSET *unicharset);
   183     if (one_to_one_definite_ambigs_.empty()) 
return NULL;
   184     return one_to_one_definite_ambigs_[unichar_id];
   194     if (ambigs_for_adaption_.empty()) 
return NULL;
   195     return ambigs_for_adaption_[unichar_id];
   203     if (reverse_ambigs_for_adaption_.empty()) 
return NULL;
   204     return reverse_ambigs_for_adaption_[unichar_id];
   208   bool ParseAmbiguityLine(
int line_num, 
int version, 
int debug_level,
   210                           int *test_ambig_part_size,
   212                           int *replacement_ambig_part_size,
   213                           char *replacement_string, 
int *type);
   214   bool InsertIntoTable(UnicharAmbigsVector &table,
   215                        int test_ambig_part_size, 
UNICHAR_ID *test_unichar_ids,
   216                        int replacement_ambig_part_size,
   217                        const char *replacement_string, 
int type,
   220   UnicharAmbigsVector dang_ambigs_;
   221   UnicharAmbigsVector replace_ambigs_;
   229 #endif  // TESSERACT_CCUTIL_AMBIGS_H_ 
static int compare_ambig_specs(const void *spec1, const void *spec2)
 
const UnicharAmbigsVector & replace_ambigs() const
 
const UnicharIdVector * OneToOneDefiniteAmbigs(UNICHAR_ID unichar_id) const
 
UNICHAR_ID correct_fragments[MAX_AMBIG_SIZE+1]
 
const char * id_to_unichar(UNICHAR_ID id) const
 
const UnicharAmbigsVector & dang_ambigs() const
 
const UnicharIdVector * AmbigsForAdaption(UNICHAR_ID unichar_id) const
 
const UnicharIdVector * ReverseAmbigsForAdaption(UNICHAR_ID unichar_id) const
 
static int find_in(const UnicharIdVector &uid_vec, const UNICHAR_ID uid)
 
UNICHAR_ID wrong_ngram[MAX_AMBIG_SIZE+1]
 
static int copy(const UNICHAR_ID src[], UNICHAR_ID dst[])
 
static int compare(const UNICHAR_ID *ptr1, const UNICHAR_ID *ptr2)
 
GenericVector< AmbigSpec_LIST * > UnicharAmbigsVector
 
UNICHAR_ID correct_ngram_id
 
GenericVector< UNICHAR_ID > UnicharIdVector
 
static void print(const UNICHAR_ID array[], const UNICHARSET &unicharset)