#include <paragraphs_internal.h>
Definition at line 95 of file paragraphs_internal.h.
◆ AddBodyLine()
void tesseract::RowScratchRegisters::AddBodyLine |
( |
const ParagraphModel * |
model | ) |
|
Definition at line 637 of file paragraphs.cpp.
637 {
639 auto found = std::find(hypotheses_.begin(), hypotheses_.end(), LineHypothesis(
LT_BODY,
nullptr));
640 if (found != hypotheses_.end()) {
641 hypotheses_.erase(found);
642 }
643}
void push_back_new(std::vector< T > &vector, const T &data)
◆ AddStartLine()
void tesseract::RowScratchRegisters::AddStartLine |
( |
const ParagraphModel * |
model | ) |
|
Definition at line 629 of file paragraphs.cpp.
629 {
631 auto found = std::find(hypotheses_.begin(), hypotheses_.end(), LineHypothesis(
LT_START,
nullptr));
632 if (found != hypotheses_.end()) {
633 hypotheses_.erase(found);
634 }
635}
◆ AlignsideIndent()
◆ AppendDebugHeaderFields()
void tesseract::RowScratchRegisters::AppendDebugHeaderFields |
( |
std::vector< std::string > & |
header | ) |
|
|
static |
Definition at line 510 of file paragraphs.cpp.
510 {
511 header.emplace_back("[lmarg,lind;rind,rmarg]");
512 header.emplace_back("model");
513}
◆ AppendDebugInfo()
void tesseract::RowScratchRegisters::AppendDebugInfo |
( |
const ParagraphTheory & |
theory, |
|
|
std::vector< std::string > & |
dbg |
|
) |
| const |
Definition at line 515 of file paragraphs.cpp.
516 {
517 char s[30];
519 dbg.emplace_back(s);
520 std::string model_string;
522 model_string += ":";
523
524 int model_numbers = 0;
525 for (const auto &hypothese : hypotheses_) {
526 if (hypothese.model == nullptr) {
527 continue;
528 }
529 if (model_numbers > 0) {
530 model_string += ",";
531 }
533 model_string += std::to_string(1 + theory.IndexOf(hypothese.model));
535 model_string += "CrL";
537 model_string += "CrR";
538 }
539 model_numbers++;
540 }
541 if (model_numbers == 0) {
542 model_string += "0";
543 }
544
545 dbg.push_back(model_string);
546}
bool StrongModel(const ParagraphModel *model)
const ParagraphModel * kCrownLeft
const ParagraphModel * kCrownRight
LineType GetLineType() const
◆ DiscardNonMatchingHypotheses()
void tesseract::RowScratchRegisters::DiscardNonMatchingHypotheses |
( |
const SetOfModels & |
models | ) |
|
Definition at line 684 of file paragraphs.cpp.
684 {
685 if (models.empty()) {
686 return;
687 }
688 for (int h = hypotheses_.size() - 1; h >= 0; h--) {
689 if (!
contains(models, hypotheses_[h].model)) {
690 hypotheses_.erase(hypotheses_.begin() + h);
691 }
692 }
693}
bool contains(const std::vector< T > &data, const T &value)
◆ GetLineType() [1/2]
LineType tesseract::RowScratchRegisters::GetLineType |
( |
| ) |
const |
Definition at line 556 of file paragraphs.cpp.
556 {
557 if (hypotheses_.empty()) {
559 }
560 bool has_start = false;
561 bool has_body = false;
562 for (const auto &hypothese : hypotheses_) {
563 switch (hypothese.ty) {
565 has_start = true;
566 break;
568 has_body = true;
569 break;
570 default:
571 tprintf(
"Encountered bad value in hypothesis list: %c\n", hypothese.ty);
572 break;
573 }
574 }
575 if (has_start && has_body) {
577 }
579}
void tprintf(const char *format,...)
◆ GetLineType() [2/2]
Definition at line 581 of file paragraphs.cpp.
581 {
582 if (hypotheses_.empty()) {
584 }
585 bool has_start = false;
586 bool has_body = false;
587 for (const auto &hypothese : hypotheses_) {
588 if (hypothese.model != model) {
589 continue;
590 }
591 switch (hypothese.ty) {
593 has_start = true;
594 break;
596 has_body = true;
597 break;
598 default:
599 tprintf(
"Encountered bad value in hypothesis list: %c\n", hypothese.ty);
600 break;
601 }
602 }
603 if (has_start && has_body) {
605 }
607}
◆ Init()
void tesseract::RowScratchRegisters::Init |
( |
const RowInfo & |
row | ) |
|
◆ NonNullHypotheses()
void tesseract::RowScratchRegisters::NonNullHypotheses |
( |
SetOfModels * |
models | ) |
const |
Definition at line 661 of file paragraphs.cpp.
661 {
662 for (const auto &hypothese : hypotheses_) {
663 if (hypothese.model != nullptr) {
665 }
666 }
667}
◆ OffsideIndent()
◆ SetBodyLine()
void tesseract::RowScratchRegisters::SetBodyLine |
( |
| ) |
|
Definition at line 619 of file paragraphs.cpp.
619 {
622 tprintf(
"Trying to set a line to be BODY when it's already START.\n");
623 }
626 }
627}
◆ SetStartLine()
void tesseract::RowScratchRegisters::SetStartLine |
( |
| ) |
|
Definition at line 609 of file paragraphs.cpp.
609 {
612 tprintf(
"Trying to set a line to be START when it's already BODY.\n");
613 }
616 }
617}
◆ SetUnknown()
void tesseract::RowScratchRegisters::SetUnknown |
( |
| ) |
|
|
inline |
◆ StartHypotheses()
void tesseract::RowScratchRegisters::StartHypotheses |
( |
SetOfModels * |
models | ) |
const |
Definition at line 645 of file paragraphs.cpp.
645 {
646 for (const auto &hypothese : hypotheses_) {
649 }
650 }
651}
◆ StrongHypotheses()
void tesseract::RowScratchRegisters::StrongHypotheses |
( |
SetOfModels * |
models | ) |
const |
Definition at line 653 of file paragraphs.cpp.
653 {
654 for (const auto &hypothese : hypotheses_) {
657 }
658 }
659}
◆ UniqueBodyHypothesis()
const ParagraphModel * tesseract::RowScratchRegisters::UniqueBodyHypothesis |
( |
| ) |
const |
Definition at line 676 of file paragraphs.cpp.
676 {
677 if (hypotheses_.size() != 1 || hypotheses_[0].ty !=
LT_BODY) {
678 return nullptr;
679 }
680 return hypotheses_[0].model;
681}
◆ UniqueStartHypothesis()
const ParagraphModel * tesseract::RowScratchRegisters::UniqueStartHypothesis |
( |
| ) |
const |
Definition at line 669 of file paragraphs.cpp.
669 {
670 if (hypotheses_.size() != 1 || hypotheses_[0].ty !=
LT_START) {
671 return nullptr;
672 }
673 return hypotheses_[0].model;
674}
◆ lindent_
int tesseract::RowScratchRegisters::lindent_ |
◆ lmargin_
int tesseract::RowScratchRegisters::lmargin_ |
◆ ri_
const RowInfo* tesseract::RowScratchRegisters::ri_ |
◆ rindent_
int tesseract::RowScratchRegisters::rindent_ |
◆ rmargin_
int tesseract::RowScratchRegisters::rmargin_ |
The documentation for this class was generated from the following files: