#include <paragraphs_internal.h>
Definition at line 95 of file paragraphs_internal.h.
◆ AddBodyLine()
void tesseract::RowScratchRegisters::AddBodyLine |
( |
const ParagraphModel * |
model | ) |
|
Definition at line 641 of file paragraphs.cpp.
641 {
643 auto found = std::find(hypotheses_.begin(), hypotheses_.end(), LineHypothesis(
LT_BODY,
nullptr));
644 if (found != hypotheses_.end()) {
645 hypotheses_.erase(found);
646 }
647}
void push_back_new(std::vector< T > &vector, const T &data)
◆ AddStartLine()
void tesseract::RowScratchRegisters::AddStartLine |
( |
const ParagraphModel * |
model | ) |
|
Definition at line 633 of file paragraphs.cpp.
633 {
635 auto found = std::find(hypotheses_.begin(), hypotheses_.end(), LineHypothesis(
LT_START,
nullptr));
636 if (found != hypotheses_.end()) {
637 hypotheses_.erase(found);
638 }
639}
◆ 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[60];
518
519
520
521
523 dbg.emplace_back(s);
524 std::string model_string;
526 model_string += ":";
527
528 int model_numbers = 0;
529 for (const auto &hypothese : hypotheses_) {
530 if (hypothese.model == nullptr) {
531 continue;
532 }
533 if (model_numbers > 0) {
534 model_string += ",";
535 }
537 model_string += std::to_string(1 + theory.IndexOf(hypothese.model));
539 model_string += "CrL";
541 model_string += "CrR";
542 }
543 model_numbers++;
544 }
545 if (model_numbers == 0) {
546 model_string += "0";
547 }
548
549 dbg.push_back(model_string);
550}
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 688 of file paragraphs.cpp.
688 {
689 if (models.empty()) {
690 return;
691 }
692 for (int h = hypotheses_.size() - 1; h >= 0; h--) {
693 if (!
contains(models, hypotheses_[h].model)) {
694 hypotheses_.erase(hypotheses_.begin() + h);
695 }
696 }
697}
bool contains(const std::vector< T > &data, const T &value)
◆ GetLineType() [1/2]
LineType tesseract::RowScratchRegisters::GetLineType |
( |
| ) |
const |
Definition at line 560 of file paragraphs.cpp.
560 {
561 if (hypotheses_.empty()) {
563 }
564 bool has_start = false;
565 bool has_body = false;
566 for (const auto &hypothese : hypotheses_) {
567 switch (hypothese.ty) {
569 has_start = true;
570 break;
572 has_body = true;
573 break;
574 default:
575 tprintf(
"Encountered bad value in hypothesis list: %c\n", hypothese.ty);
576 break;
577 }
578 }
579 if (has_start && has_body) {
581 }
583}
void tprintf(const char *format,...)
◆ GetLineType() [2/2]
Definition at line 585 of file paragraphs.cpp.
585 {
586 if (hypotheses_.empty()) {
588 }
589 bool has_start = false;
590 bool has_body = false;
591 for (const auto &hypothese : hypotheses_) {
592 if (hypothese.model != model) {
593 continue;
594 }
595 switch (hypothese.ty) {
597 has_start = true;
598 break;
600 has_body = true;
601 break;
602 default:
603 tprintf(
"Encountered bad value in hypothesis list: %c\n", hypothese.ty);
604 break;
605 }
606 }
607 if (has_start && has_body) {
609 }
611}
◆ Init()
void tesseract::RowScratchRegisters::Init |
( |
const RowInfo & |
row | ) |
|
◆ NonNullHypotheses()
void tesseract::RowScratchRegisters::NonNullHypotheses |
( |
SetOfModels * |
models | ) |
const |
Definition at line 665 of file paragraphs.cpp.
665 {
666 for (const auto &hypothese : hypotheses_) {
667 if (hypothese.model != nullptr) {
669 }
670 }
671}
◆ OffsideIndent()
◆ SetBodyLine()
void tesseract::RowScratchRegisters::SetBodyLine |
( |
| ) |
|
Definition at line 623 of file paragraphs.cpp.
623 {
626 tprintf(
"Trying to set a line to be BODY when it's already START.\n");
627 }
630 }
631}
◆ SetStartLine()
void tesseract::RowScratchRegisters::SetStartLine |
( |
| ) |
|
Definition at line 613 of file paragraphs.cpp.
613 {
616 tprintf(
"Trying to set a line to be START when it's already BODY.\n");
617 }
620 }
621}
◆ SetUnknown()
void tesseract::RowScratchRegisters::SetUnknown |
( |
| ) |
|
|
inline |
◆ StartHypotheses()
void tesseract::RowScratchRegisters::StartHypotheses |
( |
SetOfModels * |
models | ) |
const |
Definition at line 649 of file paragraphs.cpp.
649 {
650 for (const auto &hypothese : hypotheses_) {
653 }
654 }
655}
◆ StrongHypotheses()
void tesseract::RowScratchRegisters::StrongHypotheses |
( |
SetOfModels * |
models | ) |
const |
Definition at line 657 of file paragraphs.cpp.
657 {
658 for (const auto &hypothese : hypotheses_) {
661 }
662 }
663}
◆ UniqueBodyHypothesis()
const ParagraphModel * tesseract::RowScratchRegisters::UniqueBodyHypothesis |
( |
| ) |
const |
Definition at line 680 of file paragraphs.cpp.
680 {
681 if (hypotheses_.size() != 1 || hypotheses_[0].ty !=
LT_BODY) {
682 return nullptr;
683 }
684 return hypotheses_[0].model;
685}
◆ UniqueStartHypothesis()
const ParagraphModel * tesseract::RowScratchRegisters::UniqueStartHypothesis |
( |
| ) |
const |
Definition at line 673 of file paragraphs.cpp.
673 {
674 if (hypotheses_.size() != 1 || hypotheses_[0].ty !=
LT_START) {
675 return nullptr;
676 }
677 return hypotheses_[0].model;
678}
◆ 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: