@@ -1300,14 +1300,25 @@ float Tesseract::ClassifyBlobAsWord(int pass_n, PAGE_RES_IT* pr_it,
1300
1300
SetupWordPassN (1 , &wd);
1301
1301
classify_word_and_language (pass_n, &it, &wd);
1302
1302
if (debug_noise_removal) {
1303
- tprintf (" word xheight=%g, row=%g, range=[%g,%g]\n " , word_res->x_height ,
1304
- wd.row ->x_height (), wd.word ->raw_choice ->min_x_height (),
1305
- wd.word ->raw_choice ->max_x_height ());
1306
- }
1307
- const float cert = wd.word ->raw_choice ->certainty ();
1308
- const float rat = wd.word ->raw_choice ->rating ();
1309
- *c2 = rat > 0 .0f ? cert * cert / rat : 0 .0f ;
1310
- *best_str = wd.word ->raw_choice ->unichar_string ();
1303
+ if (wd.word ->raw_choice != NULL ) {
1304
+ tprintf (" word xheight=%g, row=%g, range=[%g,%g]\n " , word_res->x_height ,
1305
+ wd.row ->x_height (), wd.word ->raw_choice ->min_x_height (),
1306
+ wd.word ->raw_choice ->max_x_height ());
1307
+ } else {
1308
+ tprintf (" Got word with null raw choice xheight=%g, row=%g\n " , word_res->x_height ,
1309
+ wd.row ->x_height ());
1310
+ }
1311
+ }
1312
+ float cert = 0 .0f ;
1313
+ if (wd.word ->raw_choice != NULL ) { // This probably shouldn't happen, but...
1314
+ cert = wd.word ->raw_choice ->certainty ();
1315
+ float rat = wd.word ->raw_choice ->rating ();
1316
+ *c2 = rat > 0 .0f ? cert * cert / rat : 0 .0f ;
1317
+ *best_str = wd.word ->raw_choice ->unichar_string ();
1318
+ } else {
1319
+ *c2 = 0 .0f ;
1320
+ *best_str = " " ;
1321
+ }
1311
1322
it.DeleteCurrentWord ();
1312
1323
pr_it->ResetWordIterator ();
1313
1324
return cert;
0 commit comments