@@ -1998,39 +1998,39 @@ bool TessBaseAPI::AdaptToWordStr(PageSegMode mode, const char* wordstr) {
1998
1998
WERD_RES* word_res = it.word ();
1999
1999
if (word_res != nullptr ) {
2000
2000
word_res->word ->set_text (wordstr);
2001
+ // Check to see if text matches wordstr.
2002
+ int w = 0 ;
2003
+ int t;
2004
+ for (t = 0 ; text[t] != ' \0 ' ; ++t) {
2005
+ if (text[t] == ' \n ' || text[t] == ' ' )
2006
+ continue ;
2007
+ while (wordstr[w] == ' ' ) ++w;
2008
+ if (text[t] != wordstr[w])
2009
+ break ;
2010
+ ++w;
2011
+ }
2012
+ if (text[t] != ' \0 ' || wordstr[w] != ' \0 ' ) {
2013
+ // No match.
2014
+ delete page_res_;
2015
+ GenericVector<TBOX> boxes;
2016
+ page_res_ = tesseract_->SetupApplyBoxes (boxes, block_list_);
2017
+ tesseract_->ReSegmentByClassification (page_res_);
2018
+ tesseract_->TidyUp (page_res_);
2019
+ PAGE_RES_IT pr_it (page_res_);
2020
+ if (pr_it.word () == nullptr )
2021
+ success = false ;
2022
+ else
2023
+ word_res = pr_it.word ();
2024
+ } else {
2025
+ word_res->BestChoiceToCorrectText ();
2026
+ }
2027
+ if (success) {
2028
+ tesseract_->EnableLearning = true ;
2029
+ tesseract_->LearnWord (nullptr , word_res);
2030
+ }
2001
2031
} else {
2002
2032
success = false ;
2003
2033
}
2004
- // Check to see if text matches wordstr.
2005
- int w = 0 ;
2006
- int t = 0 ;
2007
- for (t = 0 ; text[t] != ' \0 ' ; ++t) {
2008
- if (text[t] == ' \n ' || text[t] == ' ' )
2009
- continue ;
2010
- while (wordstr[w] == ' ' ) ++w;
2011
- if (text[t] != wordstr[w])
2012
- break ;
2013
- ++w;
2014
- }
2015
- if (text[t] != ' \0 ' || wordstr[w] != ' \0 ' ) {
2016
- // No match.
2017
- delete page_res_;
2018
- GenericVector<TBOX> boxes;
2019
- page_res_ = tesseract_->SetupApplyBoxes (boxes, block_list_);
2020
- tesseract_->ReSegmentByClassification (page_res_);
2021
- tesseract_->TidyUp (page_res_);
2022
- PAGE_RES_IT pr_it (page_res_);
2023
- if (pr_it.word () == nullptr )
2024
- success = false ;
2025
- else
2026
- word_res = pr_it.word ();
2027
- } else {
2028
- word_res->BestChoiceToCorrectText ();
2029
- }
2030
- if (success) {
2031
- tesseract_->EnableLearning = true ;
2032
- tesseract_->LearnWord (nullptr , word_res);
2033
- }
2034
2034
} else {
2035
2035
success = false ;
2036
2036
}
0 commit comments