Creates a fake best_choice entry in each WERD_RES with the correct text.*/
| 770 | |
| 771 | /** Creates a fake best_choice entry in each WERD_RES with the correct text.*/ |
| 772 | void Tesseract::CorrectClassifyWords(PAGE_RES* page_res) { |
| 773 | PAGE_RES_IT pr_it(page_res); |
| 774 | for (WERD_RES *word_res = pr_it.word(); word_res != NULL; |
| 775 | word_res = pr_it.forward()) { |
| 776 | WERD_CHOICE* choice = new WERD_CHOICE(word_res->uch_set, |
| 777 | word_res->correct_text.size()); |
| 778 | for (int i = 0; i < word_res->correct_text.size(); ++i) { |
| 779 | // The part before the first space is the real ground truth, and the |
| 780 | // rest is the bounding box location and page number. |
| 781 | GenericVector<STRING> tokens; |
| 782 | word_res->correct_text[i].split(' ', &tokens); |
| 783 | UNICHAR_ID char_id = unicharset.unichar_to_id(tokens[0].string()); |
| 784 | choice->append_unichar_id_space_allocated(char_id, |
| 785 | word_res->best_state[i], |
| 786 | 0.0f, 0.0f); |
| 787 | } |
| 788 | word_res->ClearWordChoices(); |
| 789 | word_res->LogNewRawChoice(choice); |
| 790 | word_res->LogNewCookedChoice(1, false, choice); |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | /// Calls #LearnWord to extract features for labelled blobs within each word. |
| 795 | /// Features are stored in an internal buffer. |
no test coverage detected