@@ -33,7 +33,7 @@ class Image;
33
33
Dict::Dict (CCUtil *ccutil)
34
34
: letter_is_okay_(&tesseract::Dict::def_letter_is_okay),
35
35
probability_in_context_ (&tesseract::Dict::def_probability_in_context),
36
- params_model_classify_(NULL ),
36
+ params_model_classify_(nullptr ),
37
37
ccutil_(ccutil),
38
38
STRING_MEMBER(user_words_file, " " , " A filename of user-provided words." ,
39
39
getCCUtil ()->params()),
@@ -164,29 +164,29 @@ Dict::Dict(CCUtil *ccutil)
164
164
" are specified, since overly generic patterns can result in"
165
165
" dawg search exploring an overly large number of options." ,
166
166
getCCUtil ()->params()) {
167
- dang_ambigs_table_ = NULL ;
168
- replace_ambigs_table_ = NULL ;
167
+ dang_ambigs_table_ = nullptr ;
168
+ replace_ambigs_table_ = nullptr ;
169
169
reject_offset_ = 0.0 ;
170
- go_deeper_fxn_ = NULL ;
171
- hyphen_word_ = NULL ;
170
+ go_deeper_fxn_ = nullptr ;
171
+ hyphen_word_ = nullptr ;
172
172
last_word_on_line_ = false ;
173
173
hyphen_unichar_id_ = INVALID_UNICHAR_ID;
174
- document_words_ = NULL ;
175
- dawg_cache_ = NULL ;
174
+ document_words_ = nullptr ;
175
+ dawg_cache_ = nullptr ;
176
176
dawg_cache_is_ours_ = false ;
177
- pending_words_ = NULL ;
178
- bigram_dawg_ = NULL ;
179
- freq_dawg_ = NULL ;
180
- punc_dawg_ = NULL ;
181
- unambig_dawg_ = NULL ;
177
+ pending_words_ = nullptr ;
178
+ bigram_dawg_ = nullptr ;
179
+ freq_dawg_ = nullptr ;
180
+ punc_dawg_ = nullptr ;
181
+ unambig_dawg_ = nullptr ;
182
182
wordseg_rating_adjust_factor_ = -1 .0f ;
183
- output_ambig_words_file_ = NULL ;
183
+ output_ambig_words_file_ = nullptr ;
184
184
}
185
185
186
186
Dict::~Dict () {
187
187
End ();
188
188
delete hyphen_word_;
189
- if (output_ambig_words_file_ != NULL ) fclose (output_ambig_words_file_);
189
+ if (output_ambig_words_file_ != nullptr ) fclose (output_ambig_words_file_);
190
190
}
191
191
192
192
DawgCache *Dict::GlobalDawgCache () {
@@ -205,7 +205,7 @@ void Dict::SetupForLoad(DawgCache *dawg_cache) {
205
205
slash_unichar_id_ = getUnicharset ().unichar_to_id (kSlashSymbol );
206
206
hyphen_unichar_id_ = getUnicharset ().unichar_to_id (kHyphenSymbol );
207
207
208
- if (dawg_cache != NULL ) {
208
+ if (dawg_cache != nullptr ) {
209
209
dawg_cache_ = dawg_cache;
210
210
dawg_cache_is_ours_ = false ;
211
211
} else {
@@ -330,7 +330,7 @@ bool Dict::FinishLoad() {
330
330
SuccessorList *lst = new SuccessorList ();
331
331
for (int j = 0 ; j < dawgs_.length (); ++j) {
332
332
const Dawg *other = dawgs_[j];
333
- if (dawg != NULL && other != NULL &&
333
+ if (dawg != nullptr && other != nullptr &&
334
334
(dawg->lang () == other->lang ()) &&
335
335
kDawgSuccessors [dawg->type ()][other->type ()]) *lst += j;
336
336
}
@@ -350,14 +350,14 @@ void Dict::End() {
350
350
dawg_cache_->FreeDawg (bigram_dawg_);
351
351
if (dawg_cache_is_ours_) {
352
352
delete dawg_cache_;
353
- dawg_cache_ = NULL ;
353
+ dawg_cache_ = nullptr ;
354
354
}
355
355
successors_.delete_data_pointers ();
356
356
dawgs_.clear ();
357
357
successors_.clear ();
358
- document_words_ = NULL ;
358
+ document_words_ = nullptr ;
359
359
delete pending_words_;
360
- pending_words_ = NULL ;
360
+ pending_words_ = nullptr ;
361
361
}
362
362
363
363
// Returns true if in light of the current state unichar_id is allowed
@@ -394,8 +394,8 @@ int Dict::def_letter_is_okay(void* void_dawg_args,
394
394
// dawg_args->updated_pos.
395
395
for (int a = 0 ; a < dawg_args->active_dawgs ->length (); ++a) {
396
396
const DawgPosition &pos = (*dawg_args->active_dawgs )[a];
397
- const Dawg *punc_dawg = pos.punc_index >= 0 ? dawgs_[pos.punc_index ] : NULL ;
398
- const Dawg *dawg = pos.dawg_index >= 0 ? dawgs_[pos.dawg_index ] : NULL ;
397
+ const Dawg *punc_dawg = pos.punc_index >= 0 ? dawgs_[pos.punc_index ] : nullptr ;
398
+ const Dawg *dawg = pos.dawg_index >= 0 ? dawgs_[pos.dawg_index ] : nullptr ;
399
399
400
400
if (!dawg && !punc_dawg) {
401
401
// shouldn't happen.
@@ -499,7 +499,7 @@ int Dict::def_letter_is_okay(void* void_dawg_args,
499
499
}
500
500
if (dawg->permuter () > curr_perm) curr_perm = dawg->permuter ();
501
501
if (dawg->end_of_word (edge) &&
502
- (punc_dawg == NULL || punc_dawg->end_of_word (pos.punc_ref )))
502
+ (punc_dawg == nullptr || punc_dawg->end_of_word (pos.punc_ref )))
503
503
dawg_args->valid_end = true ;
504
504
dawg_args->updated_dawgs ->add_unique (
505
505
DawgPosition (pos.dawg_index , edge, pos.punc_index , pos.punc_ref ,
@@ -581,11 +581,11 @@ void Dict::init_active_dawgs(DawgPositionVector *active_dawgs,
581
581
void Dict::default_dawgs (DawgPositionVector *dawg_pos_vec,
582
582
bool suppress_patterns) const {
583
583
bool punc_dawg_available =
584
- (punc_dawg_ != NULL ) &&
584
+ (punc_dawg_ != nullptr ) &&
585
585
punc_dawg_->edge_char_of (0 , Dawg::kPatternUnicharID , true ) != NO_EDGE;
586
586
587
587
for (int i = 0 ; i < dawgs_.length (); i++) {
588
- if (dawgs_[i] != NULL &&
588
+ if (dawgs_[i] != nullptr &&
589
589
!(suppress_patterns && (dawgs_[i])->type () == DAWG_TYPE_PATTERN)) {
590
590
int dawg_ty = dawgs_[i]->type ();
591
591
bool subsumed_by_punc = kDawgSuccessors [DAWG_TYPE_PUNCTUATION][dawg_ty];
@@ -607,7 +607,7 @@ void Dict::default_dawgs(DawgPositionVector *dawg_pos_vec,
607
607
608
608
void Dict::add_document_word (const WERD_CHOICE &best_choice) {
609
609
// Do not add hyphenated word parts to the document dawg.
610
- // hyphen_word_ will be non-NULL after the set_hyphen_word() is
610
+ // hyphen_word_ will be non-nullptr after the set_hyphen_word() is
611
611
// called when the first part of the hyphenated word is
612
612
// discovered and while the second part of the word is recognized.
613
613
// hyphen_word_ is cleared in cc_recg() before the next word on
@@ -721,7 +721,7 @@ void Dict::adjust_word(WERD_CHOICE *word,
721
721
}
722
722
} else { // dictionary word
723
723
if (case_is_ok) {
724
- if (!is_han && freq_dawg_ != NULL && freq_dawg_->word_in_dawg (*word)) {
724
+ if (!is_han && freq_dawg_ != nullptr && freq_dawg_->word_in_dawg (*word)) {
725
725
word->set_permuter (FREQ_DAWG_PERM);
726
726
adjust_factor += segment_penalty_dict_frequent_word;
727
727
new_rating *= adjust_factor;
@@ -778,7 +778,7 @@ int Dict::valid_word(const WERD_CHOICE &word, bool numbers_ok) const {
778
778
779
779
bool Dict::valid_bigram (const WERD_CHOICE &word1,
780
780
const WERD_CHOICE &word2) const {
781
- if (bigram_dawg_ == NULL ) return false ;
781
+ if (bigram_dawg_ == nullptr ) return false ;
782
782
783
783
// Extract the core word from the middle of each word with any digits
784
784
// replaced with question marks.
@@ -838,7 +838,7 @@ bool Dict::valid_punctuation(const WERD_CHOICE &word) {
838
838
}
839
839
}
840
840
for (i = 0 ; i < dawgs_.size (); ++i) {
841
- if (dawgs_[i] != NULL &&
841
+ if (dawgs_[i] != nullptr &&
842
842
dawgs_[i]->type () == DAWG_TYPE_PUNCTUATION &&
843
843
dawgs_[i]->word_in_dawg (new_word)) return true ;
844
844
}
0 commit comments