382 {
383 float blob_o_score[4] = {0.0f, 0.0f, 0.0f, 0.0f};
384 float total_blob_o_score = 0.0f;
385
386 for (int i = 0; i < 4; ++i) {
387 BLOB_CHOICE_IT choice_it(scores + i);
388 if (!choice_it.empty()) {
390 if (allowed_scripts_ !=
nullptr && !allowed_scripts_->
empty()) {
391
392 for (choice_it.mark_cycle_pt(); !choice_it.cycled_list() &&
393 choice == nullptr; choice_it.forward()) {
394 int choice_script = choice_it.data()->
script_id();
395 int s = 0;
396 for (s = 0; s < allowed_scripts_->
size(); ++s) {
397 if ((*allowed_scripts_)[s] == choice_script) {
398 choice = choice_it.data();
399 break;
400 }
401 }
402 }
403 } else {
404 choice = choice_it.data();
405 }
406 if (choice != nullptr) {
407
408
409 blob_o_score[i] = 1 + 0.05 * choice->
certainty();
410 total_blob_o_score += blob_o_score[i];
411 }
412 }
413 }
414 if (total_blob_o_score == 0.0) return false;
415
416
417 float worst_score = 0.0f;
418 int num_good_scores = 0;
419 for (float f : blob_o_score) {
420 if (f > 0.0f) {
421 ++num_good_scores;
422 if (worst_score == 0.0f || f < worst_score)
423 worst_score = f;
424 }
425 }
426 if (num_good_scores == 1) {
427
428 worst_score /= 2.0f;
429 }
430 for (float& f : blob_o_score) {
431 if (f == 0.0f) {
432 f = worst_score;
433 total_blob_o_score += worst_score;
434 }
435 }
436
437
438 for (int i = 0; total_blob_o_score != 0 && i < 4; ++i) {
440 }
441
442
443
444 return false;
445}