tesseract  4.00.00dev
dict.h
Go to the documentation of this file.
1 // File: dict.h
3 // Description: dict class.
4 // Author: Samuel Charron
5 //
6 // (C) Copyright 2006, Google Inc.
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
18 
19 #ifndef TESSERACT_DICT_DICT_H_
20 #define TESSERACT_DICT_DICT_H_
21 
22 #include "ambigs.h"
23 #include "dawg.h"
24 #include "dawg_cache.h"
25 #include "host.h"
26 #include "ratngs.h"
27 #include "stopper.h"
28 #include "trie.h"
29 #include "unicharset.h"
31 
32 class MATRIX;
33 class WERD_RES;
34 
35 #define MAX_WERD_LENGTH (inT64) 128
36 #define NO_RATING -1
37 
43  float rating;
44  float certainty;
45 };
46 
47 namespace tesseract {
48 
50 
51 //
52 // Constants
53 //
54 static const int kRatingPad = 4;
55 static const char kDictWildcard[] = "\u2606"; // WHITE STAR
56 static const int kDictMaxWildcards = 2; // max wildcards for a word
57 // TODO(daria): If hyphens are different in different languages and can be
58 // inferred from training data we should load their values dynamically.
59 static const char kHyphenSymbol[] = "-";
60 static const char kSlashSymbol[] = "/";
61 static const char kQuestionSymbol[] = "?";
62 static const char kApostropheSymbol[] = "'";
63 static const float kSimCertaintyScale = -10.0; // similarity matcher scaling
64 static const float kSimCertaintyOffset = -10.0; // similarity matcher offset
65 static const float kSimilarityFloor = 100.0; // worst E*L product to stop on
66 static const int kDocDictMaxRepChars = 4;
67 
68 // Enum for describing whether the x-height for the word is consistent:
69 // 0 - everything is good.
70 // 1 - there are one or two secondary (but consistent) baselines
71 // [think subscript and superscript], or there is an oversized
72 // first character.
73 // 2 - the word is inconsistent.
75 
76 struct DawgArgs {
78  : active_dawgs(d), updated_dawgs(up), permuter(p), valid_end(false) {}
79 
83  // True if the current position is a valid word end.
84  bool valid_end;
85 };
86 
87 class Dict {
88  public:
89  Dict(CCUtil* image_ptr);
90  ~Dict();
91  const CCUtil* getCCUtil() const {
92  return ccutil_;
93  }
95  return ccutil_;
96  }
97  const UNICHARSET& getUnicharset() const {
98  return getCCUtil()->unicharset;
99  }
101  return getCCUtil()->unicharset;
102  }
104  return getCCUtil()->unichar_ambigs;
105  }
106 
107  // Returns true if unichar_id is a word compounding character like - or /.
109  const GenericVector<UNICHAR_ID>& normed_ids =
110  getUnicharset().normed_ids(unichar_id);
111  return normed_ids.size() == 1 &&
112  (normed_ids[0] == hyphen_unichar_id_ ||
113  normed_ids[0] == slash_unichar_id_);
114  }
115  // Returns true if unichar_id is an apostrophe-like character that may
116  // separate prefix/suffix words from a main body word.
118  const GenericVector<UNICHAR_ID>& normed_ids =
119  getUnicharset().normed_ids(unichar_id);
120  return normed_ids.size() == 1 && normed_ids[0] == apostrophe_unichar_id_;
121  }
122 
123  /* hyphen.cpp ************************************************************/
124 
126  inline bool hyphenated() const { return
127  !last_word_on_line_ && hyphen_word_;
128  }
130  inline int hyphen_base_size() const {
131  return this->hyphenated() ? hyphen_word_->length() : 0;
132  }
136  inline void copy_hyphen_info(WERD_CHOICE *word) const {
137  if (this->hyphenated()) {
138  *word = *hyphen_word_;
139  if (hyphen_debug_level) word->print("copy_hyphen_info: ");
140  }
141  }
143  inline bool has_hyphen_end(UNICHAR_ID unichar_id, bool first_pos) const {
144  if (!last_word_on_line_ || first_pos)
145  return false;
146  const GenericVector<UNICHAR_ID>& normed_ids =
147  getUnicharset().normed_ids(unichar_id);
148  return normed_ids.size() == 1 && normed_ids[0] == hyphen_unichar_id_;
149  }
151  inline bool has_hyphen_end(const WERD_CHOICE &word) const {
152  int word_index = word.length() - 1;
153  return has_hyphen_end(word.unichar_id(word_index), word_index == 0);
154  }
158  void reset_hyphen_vars(bool last_word_on_line);
161  void set_hyphen_word(const WERD_CHOICE &word,
162  const DawgPositionVector &active_dawgs);
163 
164  /* permdawg.cpp ************************************************************/
165  // Note: Functions in permdawg.cpp are only used by NoDangerousAmbig().
166  // When this function is refactored, permdawg.cpp can be removed.
167 
170  inline void update_best_choice(const WERD_CHOICE &word,
171  WERD_CHOICE *best_choice) {
172  if (word.rating() < best_choice->rating()) {
173  *best_choice = word;
174  }
175  }
179  void init_active_dawgs(DawgPositionVector *active_dawgs,
180  bool ambigs_mode) const;
181  // Fill the given vector with the default collection of any-length dawgs
182  void default_dawgs(DawgPositionVector *anylength_dawgs,
183  bool suppress_patterns) const;
184 
185 
191  WERD_CHOICE *dawg_permute_and_select(
192  const BLOB_CHOICE_LIST_VECTOR &char_choices, float rating_limit);
196  void go_deeper_dawg_fxn(
197  const char *debug, const BLOB_CHOICE_LIST_VECTOR &char_choices,
198  int char_choice_index, const CHAR_FRAGMENT_INFO *prev_char_frag_info,
199  bool word_ending, WERD_CHOICE *word, float certainties[],
200  float *limit, WERD_CHOICE *best_choice, int *attempts_left,
201  void *void_more_args);
202 
204  void (Dict::*go_deeper_fxn_)(const char *debug,
205  const BLOB_CHOICE_LIST_VECTOR &char_choices,
206  int char_choice_index,
207  const CHAR_FRAGMENT_INFO *prev_char_frag_info,
208  bool word_ending, WERD_CHOICE *word,
209  float certainties[], float *limit,
210  WERD_CHOICE *best_choice, int *attempts_left,
211  void *void_more_args);
212  //
213  // Helper functions for dawg_permute_and_select().
214  //
215  void permute_choices(
216  const char *debug,
217  const BLOB_CHOICE_LIST_VECTOR &char_choices,
218  int char_choice_index,
219  const CHAR_FRAGMENT_INFO *prev_char_frag_info,
220  WERD_CHOICE *word,
221  float certainties[],
222  float *limit,
223  WERD_CHOICE *best_choice,
224  int *attempts_left,
225  void *more_args);
226 
227  void append_choices(
228  const char *debug,
229  const BLOB_CHOICE_LIST_VECTOR &char_choices,
230  const BLOB_CHOICE &blob_choice,
231  int char_choice_index,
232  const CHAR_FRAGMENT_INFO *prev_char_frag_info,
233  WERD_CHOICE *word,
234  float certainties[],
235  float *limit,
236  WERD_CHOICE *best_choice,
237  int *attempts_left,
238  void *more_args);
239 
240  bool fragment_state_okay(UNICHAR_ID curr_unichar_id,
241  float curr_rating, float curr_certainty,
242  const CHAR_FRAGMENT_INFO *prev_char_frag_info,
243  const char *debug, int word_ending,
244  CHAR_FRAGMENT_INFO *char_frag_info);
245 
246  /* stopper.cpp *************************************************************/
247  bool NoDangerousAmbig(WERD_CHOICE *BestChoice,
248  DANGERR *fixpt,
249  bool fix_replaceable,
250  MATRIX* ratings);
251  // Replaces the corresponding wrong ngram in werd_choice with the correct
252  // one. The whole correct n-gram is inserted into the ratings matrix and
253  // the werd_choice: no more fragments!. Rating and certainty of new entries
254  // in matrix and werd_choice are the sum and mean of the wrong ngram
255  // respectively.
256  // E.g. for werd_choice mystring'' and ambiguity ''->": werd_choice becomes
257  // mystring", with a new entry in the ratings matrix for ".
258  void ReplaceAmbig(int wrong_ngram_begin_index, int wrong_ngram_size,
259  UNICHAR_ID correct_ngram_id, WERD_CHOICE *werd_choice,
260  MATRIX *ratings);
261 
263  int LengthOfShortestAlphaRun(const WERD_CHOICE &WordChoice) const;
271  int UniformCertainties(const WERD_CHOICE& word);
273  bool AcceptableChoice(const WERD_CHOICE& best_choice,
274  XHeightConsistencyEnum xheight_consistency);
278  bool AcceptableResult(WERD_RES *word) const;
279  void EndDangerousAmbigs();
281  void DebugWordChoices();
283  void SettupStopperPass1();
285  void SettupStopperPass2();
286  /* context.cpp *************************************************************/
288  int case_ok(const WERD_CHOICE &word, const UNICHARSET &unicharset) const;
291  bool absolute_garbage(const WERD_CHOICE &word, const UNICHARSET &unicharset);
292 
293  /* dict.cpp ****************************************************************/
294 
297  static DawgCache *GlobalDawgCache();
298  // Sets up ready for a Load or LoadLSTM.
299  void SetupForLoad(DawgCache *dawg_cache);
300  // Loads the dawgs needed by Tesseract. Call FinishLoad() after.
301  void Load(const STRING &lang, TessdataManager *data_file);
302  // Loads the dawgs needed by the LSTM model. Call FinishLoad() after.
303  void LoadLSTM(const STRING &lang, TessdataManager *data_file);
304  // Completes the loading process after Load() and/or LoadLSTM().
305  // Returns false if no dictionaries were loaded.
306  bool FinishLoad();
307  void End();
308 
309  // Resets the document dictionary analogous to ResetAdaptiveClassifier.
311  if (pending_words_ != NULL)
312  pending_words_->clear();
313  if (document_words_ != NULL)
314  document_words_->clear();
315  }
316 
352  //
353  int def_letter_is_okay(void* void_dawg_args,
354  UNICHAR_ID unichar_id, bool word_end) const;
355 
356  int (Dict::*letter_is_okay_)(void* void_dawg_args,
357  UNICHAR_ID unichar_id, bool word_end) const;
359  int LetterIsOkay(void* void_dawg_args,
360  UNICHAR_ID unichar_id, bool word_end) const {
361  return (this->*letter_is_okay_)(void_dawg_args, unichar_id, word_end);
362  }
363 
364 
366  double (Dict::*probability_in_context_)(const char* lang,
367  const char* context,
368  int context_bytes,
369  const char* character,
370  int character_bytes);
372  double ProbabilityInContext(const char* context,
373  int context_bytes,
374  const char* character,
375  int character_bytes) {
376  return (this->*probability_in_context_)(
377  getCCUtil()->lang.string(),
378  context, context_bytes,
379  character, character_bytes);
380  }
381 
384  const char* lang, const char* context, int context_bytes,
385  const char* character, int character_bytes) {
386  (void)lang;
387  (void)context;
388  (void)context_bytes;
389  (void)character;
390  (void)character_bytes;
391  return 0.0;
392  }
393  double ngram_probability_in_context(const char* lang,
394  const char* context,
395  int context_bytes,
396  const char* character,
397  int character_bytes);
398 
399  // Interface with params model.
400  float (Dict::*params_model_classify_)(const char *lang, void *path);
401  float ParamsModelClassify(const char *lang, void *path);
402  // Call params_model_classify_ member function.
403  float CallParamsModelClassify(void *path) {
404  ASSERT_HOST(params_model_classify_ != NULL); // ASSERT_HOST -> assert
405  return (this->*params_model_classify_)(
406  getCCUtil()->lang.string(), path);
407  }
408 
409  inline void SetWildcardID(UNICHAR_ID id) { wildcard_unichar_id_ = id; }
410  inline UNICHAR_ID WildcardID() const { return wildcard_unichar_id_; }
412  inline int NumDawgs() const { return dawgs_.size(); }
414  inline const Dawg *GetDawg(int index) const { return dawgs_[index]; }
416  inline const Dawg *GetPuncDawg() const { return punc_dawg_; }
418  inline const Dawg *GetUnambigDawg() const { return unambig_dawg_; }
420  static inline NODE_REF GetStartingNode(const Dawg *dawg, EDGE_REF edge_ref) {
421  if (edge_ref == NO_EDGE) return 0; // beginning to explore the dawg
422  NODE_REF node = dawg->next_node(edge_ref);
423  if (node == 0) node = NO_EDGE; // end of word
424  return node;
425  }
426 
427  // Given a unichar from a string and a given dawg, return the unichar
428  // we should use to match in that dawg type. (for example, in the number
429  // dawg, all numbers are transformed to kPatternUnicharId).
430  inline UNICHAR_ID char_for_dawg(UNICHAR_ID ch, const Dawg *dawg) const {
431  if (!dawg) return ch;
432  switch (dawg->type()) {
433  case DAWG_TYPE_NUMBER:
434  return getUnicharset().get_isdigit(ch) ? Dawg::kPatternUnicharID : ch;
435  default:
436  return ch;
437  }
438  }
439 
445  void ProcessPatternEdges(const Dawg *dawg, const DawgPosition &info,
446  UNICHAR_ID unichar_id, bool word_end,
447  DawgArgs *dawg_args,
448  PermuterType *current_permuter) const;
449 
453 
455  inline static bool valid_word_permuter(uinT8 perm, bool numbers_ok) {
456  return (perm == SYSTEM_DAWG_PERM || perm == FREQ_DAWG_PERM ||
457  perm == DOC_DAWG_PERM || perm == USER_DAWG_PERM ||
458  perm == USER_PATTERN_PERM || perm == COMPOUND_PERM ||
459  (numbers_ok && perm == NUMBER_PERM));
460  }
461  int valid_word(const WERD_CHOICE &word, bool numbers_ok) const;
462  int valid_word(const WERD_CHOICE &word) const {
463  return valid_word(word, false); // return NO_PERM for words with digits
464  }
465  int valid_word_or_number(const WERD_CHOICE &word) const {
466  return valid_word(word, true); // return NUMBER_PERM for valid numbers
467  }
469  int valid_word(const char *string) const {
470  WERD_CHOICE word(string, getUnicharset());
471  return valid_word(word);
472  }
473  // Do the two WERD_CHOICEs form a meaningful bigram?
474  bool valid_bigram(const WERD_CHOICE &word1, const WERD_CHOICE &word2) const;
479  bool valid_punctuation(const WERD_CHOICE &word);
481  int good_choice(const WERD_CHOICE &choice);
483  void add_document_word(const WERD_CHOICE &best_choice);
485  void adjust_word(WERD_CHOICE *word,
486  bool nonword, XHeightConsistencyEnum xheight_consistency,
487  float additional_adjust,
488  bool modify_rating,
489  bool debug);
491  inline void SetWordsegRatingAdjustFactor(float f) {
492  wordseg_rating_adjust_factor_ = f;
493  }
495  bool IsSpaceDelimitedLang() const;
496 
497  private:
499  CCUtil* ccutil_;
506  UnicharAmbigs *dang_ambigs_table_;
508  UnicharAmbigs *replace_ambigs_table_;
510  FLOAT32 reject_offset_;
511  // Cached UNICHAR_IDs:
512  UNICHAR_ID wildcard_unichar_id_; // kDictWildcard.
513  UNICHAR_ID apostrophe_unichar_id_; // kApostropheSymbol.
514  UNICHAR_ID question_unichar_id_; // kQuestionSymbol.
515  UNICHAR_ID slash_unichar_id_; // kSlashSymbol.
516  UNICHAR_ID hyphen_unichar_id_; // kHyphenSymbol.
517  // Hyphen-related variables.
518  WERD_CHOICE *hyphen_word_;
519  DawgPositionVector hyphen_active_dawgs_;
520  bool last_word_on_line_;
521  // List of lists of "equivalent" UNICHAR_IDs for the purposes of dictionary
522  // matching. The first member of each list is taken as canonical. For
523  // example, the first list contains hyphens and dashes with the first symbol
524  // being the ASCII hyphen minus.
525  GenericVector<GenericVectorEqEq<UNICHAR_ID> > equivalent_symbols_;
526  // Dawg Cache reference - this is who we ask to allocate/deallocate dawgs.
527  DawgCache *dawg_cache_;
528  bool dawg_cache_is_ours_; // we should delete our own dawg_cache_
529  // Dawgs.
530  DawgVector dawgs_;
531  SuccessorListsVector successors_;
532  Trie *pending_words_;
533  // bigram_dawg_ points to a dawg of two-word bigrams which always supercede if
534  // any of them are present on the best choices list for a word pair.
535  // the bigrams are stored as space-separated words where:
536  // (1) leading and trailing punctuation has been removed from each word and
537  // (2) any digits have been replaced with '?' marks.
538  Dawg *bigram_dawg_;
541  // TODO(daria): need to support multiple languages in the future,
542  // so maybe will need to maintain a list of dawgs of each kind.
543  Dawg *freq_dawg_;
544  Dawg *unambig_dawg_;
545  Dawg *punc_dawg_;
546  Trie *document_words_;
549  float wordseg_rating_adjust_factor_;
550  // File for recording ambiguities discovered during dictionary search.
551  FILE *output_ambig_words_file_;
552 
553  public:
557  STRING_VAR_H(user_words_file, "", "A filename of user-provided words.");
558  STRING_VAR_H(user_words_suffix, "",
559  "A suffix of user-provided words located in tessdata.");
560  STRING_VAR_H(user_patterns_file, "",
561  "A filename of user-provided patterns.");
562  STRING_VAR_H(user_patterns_suffix, "",
563  "A suffix of user-provided patterns located in tessdata.");
564  BOOL_VAR_H(load_system_dawg, true, "Load system word dawg.");
565  BOOL_VAR_H(load_freq_dawg, true, "Load frequent word dawg.");
566  BOOL_VAR_H(load_unambig_dawg, true, "Load unambiguous word dawg.");
567  BOOL_VAR_H(load_punc_dawg, true,
568  "Load dawg with punctuation patterns.");
569  BOOL_VAR_H(load_number_dawg, true, "Load dawg with number patterns.");
570  BOOL_VAR_H(load_bigram_dawg, true,
571  "Load dawg with special word bigrams.");
572  double_VAR_H(xheight_penalty_subscripts, 0.125,
573  "Score penalty (0.1 = 10%) added if there are subscripts "
574  "or superscripts in a word, but it is otherwise OK.");
575  double_VAR_H(xheight_penalty_inconsistent, 0.25,
576  "Score penalty (0.1 = 10%) added if an xheight is "
577  "inconsistent.");
578  double_VAR_H(segment_penalty_dict_frequent_word, 1.0,
579  "Score multiplier for word matches which have good case and"
580  "are frequent in the given language (lower is better).");
581 
582  double_VAR_H(segment_penalty_dict_case_ok, 1.1,
583  "Score multiplier for word matches that have good case "
584  "(lower is better).");
585 
586  double_VAR_H(segment_penalty_dict_case_bad, 1.3125,
587  "Default score multiplier for word matches, which may have "
588  "case issues (lower is better).");
589 
590  // TODO(daria): remove this param when ngram permuter is deprecated.
591  double_VAR_H(segment_penalty_ngram_best_choice, 1.24,
592  "Multipler to for the best choice from the ngram model.");
593 
594  double_VAR_H(segment_penalty_dict_nonword, 1.25,
595  "Score multiplier for glyph fragment segmentations which "
596  "do not match a dictionary word (lower is better).");
597 
598  double_VAR_H(segment_penalty_garbage, 1.50,
599  "Score multiplier for poorly cased strings that are not in"
600  " the dictionary and generally look like garbage (lower is"
601  " better).");
602  STRING_VAR_H(output_ambig_words_file, "",
603  "Output file for ambiguities found in the dictionary");
604  INT_VAR_H(dawg_debug_level, 0, "Set to 1 for general debug info"
605  ", to 2 for more details, to 3 to see all the debug messages");
606  INT_VAR_H(hyphen_debug_level, 0, "Debug level for hyphenated words.");
607  INT_VAR_H(max_viterbi_list_size, 10, "Maximum size of viterbi list.");
608  BOOL_VAR_H(use_only_first_uft8_step, false,
609  "Use only the first UTF8 step of the given string"
610  " when computing log probabilities.");
611  double_VAR_H(certainty_scale, 20.0, "Certainty scaling factor");
612  double_VAR_H(stopper_nondict_certainty_base, -2.50,
613  "Certainty threshold for non-dict words");
614  double_VAR_H(stopper_phase2_certainty_rejection_offset, 1.0,
615  "Reject certainty offset");
616  INT_VAR_H(stopper_smallword_size, 2,
617  "Size of dict word to be treated as non-dict word");
618  double_VAR_H(stopper_certainty_per_char, -0.50,
619  "Certainty to add for each dict char above small word size.");
620  double_VAR_H(stopper_allowable_character_badness, 3.0,
621  "Max certaintly variation allowed in a word (in sigma)");
622  INT_VAR_H(stopper_debug_level, 0, "Stopper debug level");
623  BOOL_VAR_H(stopper_no_acceptable_choices, false,
624  "Make AcceptableChoice() always return false. Useful"
625  " when there is a need to explore all segmentations");
626  BOOL_VAR_H(save_raw_choices, false,
627  "Deprecated- backward compatibility only");
628  INT_VAR_H(tessedit_truncate_wordchoice_log, 10, "Max words to keep in list");
629  STRING_VAR_H(word_to_debug, "", "Word for which stopper debug information"
630  " should be printed to stdout");
631  STRING_VAR_H(word_to_debug_lengths, "",
632  "Lengths of unichars in word_to_debug");
633  INT_VAR_H(fragments_debug, 0, "Debug character fragments");
634  BOOL_VAR_H(segment_nonalphabetic_script, false,
635  "Don't use any alphabetic-specific tricks."
636  "Set to true in the traineddata config file for"
637  " scripts that are cursive or inherently fixed-pitch");
638  BOOL_VAR_H(save_doc_words, 0, "Save Document Words");
639  double_VAR_H(doc_dict_pending_threshold, 0.0,
640  "Worst certainty for using pending dictionary");
641  double_VAR_H(doc_dict_certainty_threshold, -2.25, "Worst certainty"
642  " for words that can be inserted into the document dictionary");
643  INT_VAR_H(max_permuter_attempts, 10000, "Maximum number of different"
644  " character choices to consider during permutation."
645  " This limit is especially useful when user patterns"
646  " are specified, since overly generic patterns can result in"
647  " dawg search exploring an overly large number of options.");
648 };
649 } // namespace tesseract
650 
651 #endif // THIRD_PARTY_TESSERACT_DICT_DICT_H_
void update_best_choice(const WERD_CHOICE &word, WERD_CHOICE *best_choice)
Definition: dict.h:170
double def_probability_in_context(const char *lang, const char *context, int context_bytes, const char *character, int character_bytes)
Default (no-op) implementation of probability in context function.
Definition: dict.h:383
double ProbabilityInContext(const char *context, int context_bytes, const char *character, int character_bytes)
Calls probability_in_context_ member function.
Definition: dict.h:372
static NODE_REF GetStartingNode(const Dawg *dawg, EDGE_REF edge_ref)
Returns the appropriate next node given the EDGE_REF.
Definition: dict.h:420
virtual NODE_REF next_node(EDGE_REF edge_ref) const =0
const UNICHARSET & getUnicharset() const
Definition: dict.h:97
bool has_hyphen_end(const WERD_CHOICE &word) const
Same as above, but check the unichar at the end of the word.
Definition: dict.h:151
UNICHAR_ID unichar_id(int index) const
Definition: ratngs.h:313
void print() const
Definition: ratngs.h:578
UNICHAR_ID char_for_dawg(UNICHAR_ID ch, const Dawg *dawg) const
Definition: dict.h:430
float certainty
Definition: dict.h:44
int UNICHAR_ID
Definition: unichar.h:33
int length() const
Definition: ratngs.h:301
DawgType type() const
Definition: dawg.h:127
static bool valid_word_permuter(uinT8 perm, bool numbers_ok)
Check all the DAWGs to see if this word is in any of them.
Definition: dict.h:455
bool valid_end
Definition: dict.h:84
const Dawg * GetUnambigDawg() const
Return the points to the unambiguous words dawg.
Definition: dict.h:418
int size() const
Definition: genericvector.h:72
const CHAR_FRAGMENT * fragment
Definition: dict.h:41
bool compound_marker(UNICHAR_ID unichar_id)
Definition: dict.h:108
UNICHARSET & getUnicharset()
Definition: dict.h:100
#define ASSERT_HOST(x)
Definition: errcode.h:84
int num_fragments
Definition: dict.h:42
int valid_word(const WERD_CHOICE &word) const
Definition: dict.h:462
int hyphen_base_size() const
Size of the base word (the part on the line before) of a hyphenated word.
Definition: dict.h:130
inT64 NODE_REF
Definition: dawg.h:55
float CallParamsModelClassify(void *path)
Definition: dict.h:403
const Dawg * GetPuncDawg() const
Return the points to the punctuation dawg.
Definition: dict.h:416
const CCUtil * getCCUtil() const
Definition: dict.h:91
const Dawg * GetDawg(int index) const
Return i-th dawg pointer recorded in the dawgs_ vector.
Definition: dict.h:414
void SetWildcardID(UNICHAR_ID id)
Definition: dict.h:409
int NumDawgs() const
Return the number of dawgs in the dawgs_ vector.
Definition: dict.h:412
float rating
Definition: dict.h:43
XHeightConsistencyEnum
Definition: dict.h:74
Definition: strngs.h:45
#define double_VAR_H(name, val, comment)
Definition: params.h:273
DawgPositionVector * updated_dawgs
Definition: dict.h:81
bool is_apostrophe(UNICHAR_ID unichar_id)
Definition: dict.h:117
const UnicharAmbigs & getUnicharAmbigs() const
Definition: dict.h:103
void copy_hyphen_info(WERD_CHOICE *word) const
Definition: dict.h:136
bool hyphenated() const
Returns true if we&#39;ve recorded the beginning of a hyphenated word.
Definition: dict.h:126
void SetWordsegRatingAdjustFactor(float f)
Set wordseg_rating_adjust_factor_ to the given value.
Definition: dict.h:491
void ResetDocumentDictionary()
Definition: dict.h:310
int LetterIsOkay(void *void_dawg_args, UNICHAR_ID unichar_id, bool word_end) const
Calls letter_is_okay_ member function.
Definition: dict.h:359
float FLOAT32
Definition: host.h:42
#define STRING_VAR_H(name, val, comment)
Definition: params.h:270
Definition: matrix.h:563
DawgPositionVector * active_dawgs
Definition: dict.h:80
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
uint8_t uinT8
Definition: host.h:35
PermuterType permuter
Definition: dict.h:82
GenericVector< Dawg * > DawgVector
Definition: dict.h:49
#define INT_VAR_H(name, val, comment)
Definition: params.h:264
int valid_word_or_number(const WERD_CHOICE &word) const
Definition: dict.h:465
#define BOOL_VAR_H(name, val, comment)
Definition: params.h:267
int valid_word(const char *string) const
This function is used by api/tesseract_cube_combiner.cpp.
Definition: dict.h:469
DawgArgs(DawgPositionVector *d, DawgPositionVector *up, PermuterType p)
Definition: dict.h:77
inT64 EDGE_REF
Definition: dawg.h:54
UNICHAR_ID WildcardID() const
Definition: dict.h:410
PermuterType
Definition: ratngs.h:240
UNICHAR_ID unichar_id
Definition: dict.h:40
float rating() const
Definition: ratngs.h:325
CCUtil * getCCUtil()
Definition: dict.h:94
bool has_hyphen_end(UNICHAR_ID unichar_id, bool first_pos) const
Check whether the word has a hyphen at the end.
Definition: dict.h:143