@@ -1255,14 +1255,26 @@ float Tesseract::ClassifyBlobAsWord(int pass_n, PAGE_RES_IT* pr_it,
1255
1255
SetupWordPassN (1 , &wd);
1256
1256
classify_word_and_language (pass_n, &it, &wd);
1257
1257
if (debug_noise_removal) {
1258
- tprintf (" word xheight=%g, row=%g, range=[%g,%g]\n " , word_res->x_height ,
1259
- wd.row ->x_height (), wd.word ->raw_choice ->min_x_height (),
1260
- wd.word ->raw_choice ->max_x_height ());
1261
- }
1262
- float cert = wd.word ->raw_choice ->certainty ();
1263
- float rat = wd.word ->raw_choice ->rating ();
1264
- *c2 = rat > 0 .0f ? cert * cert / rat : 0 .0f ;
1265
- *best_str = wd.word ->raw_choice ->unichar_string ();
1258
+ if (wd.word ->raw_choice != NULL ) {
1259
+ tprintf (" word xheight=%g, row=%g, range=[%g,%g]\n " , word_res->x_height ,
1260
+ wd.row ->x_height (), wd.word ->raw_choice ->min_x_height (),
1261
+ wd.word ->raw_choice ->max_x_height ());
1262
+ } else {
1263
+ tprintf (" Got word with null raw choice xheight=%g, row=%g\n " , word_res->x_height ,
1264
+ wd.row ->x_height ());
1265
+ }
1266
+ }
1267
+ float cert = 0 .0f ;
1268
+ if (wd.word ->raw_choice != NULL ) { // This probably shouldn't happen, but...
1269
+ cert = wd.word ->raw_choice ->certainty ();
1270
+ float rat = wd.word ->raw_choice ->rating ();
1271
+ *c2 = rat > 0 .0f ? cert * cert / rat : 0 .0f ;
1272
+ *best_str = wd.word ->raw_choice ->unichar_string ();
1273
+ } else {
1274
+ *c2 = 0 .0f ;
1275
+ *best_str = " " ;
1276
+ }
1277
+
1266
1278
it.DeleteCurrentWord ();
1267
1279
pr_it->ResetWordIterator ();
1268
1280
return cert;
0 commit comments