* Sets up the internal data for iterating the blobs of a new word, then * moves the iterator to the given offset. */
| 574 | * moves the iterator to the given offset. |
| 575 | */ |
| 576 | void PageIterator::BeginWord(int offset) { |
| 577 | WERD_RES* word_res = it_->word(); |
| 578 | if (word_res == NULL) { |
| 579 | // This is a non-text block, so there is no word. |
| 580 | word_length_ = 0; |
| 581 | blob_index_ = 0; |
| 582 | word_ = NULL; |
| 583 | return; |
| 584 | } |
| 585 | if (word_res->best_choice != NULL) { |
| 586 | // Recognition has been done, so we are using the box_word, which |
| 587 | // is already baseline denormalized. |
| 588 | word_length_ = word_res->best_choice->length(); |
| 589 | if (word_res->box_word != NULL) { |
| 590 | if (word_res->box_word->length() != word_length_) { |
| 591 | tprintf("Corrupted word! best_choice[len=%d] = %s, box_word[len=%d]: ", |
| 592 | word_length_, word_res->best_choice->unichar_string().string(), |
| 593 | word_res->box_word->length()); |
| 594 | word_res->box_word->bounding_box().print(); |
| 595 | } |
| 596 | ASSERT_HOST(word_res->box_word->length() == word_length_); |
| 597 | } |
| 598 | word_ = NULL; |
| 599 | // We will be iterating the box_word. |
| 600 | delete cblob_it_; |
| 601 | cblob_it_ = NULL; |
| 602 | } else { |
| 603 | // No recognition yet, so a "symbol" is a cblob. |
| 604 | word_ = word_res->word; |
| 605 | ASSERT_HOST(word_->cblob_list() != NULL); |
| 606 | word_length_ = word_->cblob_list()->length(); |
| 607 | if (cblob_it_ == NULL) cblob_it_ = new C_BLOB_IT; |
| 608 | cblob_it_->set_to_list(word_->cblob_list()); |
| 609 | } |
| 610 | for (blob_index_ = 0; blob_index_ < offset; ++blob_index_) { |
| 611 | if (cblob_it_ != NULL) |
| 612 | cblob_it_->forward(); |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | bool PageIterator::SetWordBlamerBundle(BlamerBundle *blamer_bundle) { |
| 617 | if (it_->word() != NULL) { |
nothing calls this directly
no test coverage detected