tesseract  5.0.0-alpha-619-ge9db
tesseract::RowScratchRegisters Class Reference

#include <paragraphs_internal.h>

Public Member Functions

void Init (const RowInfo &row)
 
LineType GetLineType () const
 
LineType GetLineType (const ParagraphModel *model) const
 
void SetStartLine ()
 
void SetBodyLine ()
 
void AddStartLine (const ParagraphModel *model)
 
void AddBodyLine (const ParagraphModel *model)
 
void SetUnknown ()
 
void StartHypotheses (SetOfModels *models) const
 
void StrongHypotheses (SetOfModels *models) const
 
void NonNullHypotheses (SetOfModels *models) const
 
void DiscardNonMatchingHypotheses (const SetOfModels &models)
 
const ParagraphModelUniqueStartHypothesis () const
 
const ParagraphModelUniqueBodyHypothesis () const
 
int OffsideIndent (tesseract::ParagraphJustification just) const
 
int AlignsideIndent (tesseract::ParagraphJustification just) const
 
void AppendDebugInfo (const ParagraphTheory &theory, GenericVector< STRING > *dbg) const
 

Static Public Member Functions

static void AppendDebugHeaderFields (GenericVector< STRING > *header)
 

Public Attributes

const RowInfori_
 
int lmargin_
 
int lindent_
 
int rindent_
 
int rmargin_
 

Detailed Description

Definition at line 102 of file paragraphs_internal.h.

Member Function Documentation

◆ AddBodyLine()

void tesseract::RowScratchRegisters::AddBodyLine ( const ParagraphModel model)

Definition at line 618 of file paragraphs.cpp.

618  {
619  if (StrongModel(hypotheses_[h].model))
620  models->push_back_new(hypotheses_[h].model);
621  }
622 }
623 

◆ AddStartLine()

void tesseract::RowScratchRegisters::AddStartLine ( const ParagraphModel model)

Definition at line 611 of file paragraphs.cpp.

611  {
612  if (hypotheses_[h].ty == LT_START && StrongModel(hypotheses_[h].model))
613  models->push_back_new(hypotheses_[h].model);
614  }
615 }
616 

◆ AlignsideIndent()

int tesseract::RowScratchRegisters::AlignsideIndent ( tesseract::ParagraphJustification  just) const
inline

Definition at line 157 of file paragraphs_internal.h.

158  {
159  switch (just) {
162  default: return lindent_ > rindent_ ? lindent_ : rindent_;
163  }

◆ AppendDebugHeaderFields()

void tesseract::RowScratchRegisters::AppendDebugHeaderFields ( GenericVector< STRING > *  header)
static

Definition at line 504 of file paragraphs.cpp.

506  {
507  if (hypotheses_[h].model == nullptr)
508  continue;

◆ AppendDebugInfo()

void tesseract::RowScratchRegisters::AppendDebugInfo ( const ParagraphTheory theory,
GenericVector< STRING > *  dbg 
) const

Definition at line 510 of file paragraphs.cpp.

511  {
512  model_string += StrOf(1 + theory.IndexOf(hypotheses_[h].model));
513  } else if (hypotheses_[h].model == kCrownLeft) {
514  model_string += "CrL";
515  } else if (hypotheses_[h].model == kCrownRight) {
516  model_string += "CrR";
517  }
518  model_numbers++;
519  }
520  if (model_numbers == 0)
521  model_string += "0";
522 
523  dbg->push_back(model_string);
524 }
525 
526 void RowScratchRegisters::Init(const RowInfo &row) {
527  ri_ = &row;
528  lmargin_ = 0;
529  lindent_ = row.pix_ldistance;
530  rmargin_ = 0;
531  rindent_ = row.pix_rdistance;
532 }
533 
535  if (hypotheses_.empty())
536  return LT_UNKNOWN;
537  bool has_start = false;
538  bool has_body = false;
539  for (int i = 0; i < hypotheses_.size(); i++) {

◆ DiscardNonMatchingHypotheses()

void tesseract::RowScratchRegisters::DiscardNonMatchingHypotheses ( const SetOfModels models)

Definition at line 659 of file paragraphs.cpp.

659  : center(cen), count(num) {}
660 
661  int center; // The center of the cluster.
662  int count; // The number of entries within the cluster.
663 };
664 
665 class SimpleClusterer {
666  public:
667  explicit SimpleClusterer(int max_cluster_width)
668  : max_cluster_width_(max_cluster_width) {}

◆ GetLineType() [1/2]

LineType tesseract::RowScratchRegisters::GetLineType ( ) const

Definition at line 549 of file paragraphs.cpp.

551  : LT_BODY;
552 }
553 
555  if (hypotheses_.empty())
556  return LT_UNKNOWN;
557  bool has_start = false;
558  bool has_body = false;
559  for (int i = 0; i < hypotheses_.size(); i++) {
560  if (hypotheses_[i].model != model)
561  continue;
562  switch (hypotheses_[i].ty) {
563  case LT_START: has_start = true; break;
564  case LT_BODY: has_body = true; break;
565  default:
566  tprintf("Encountered bad value in hypothesis list: %c\n",
567  hypotheses_[i].ty);

◆ GetLineType() [2/2]

LineType tesseract::RowScratchRegisters::GetLineType ( const ParagraphModel model) const

Definition at line 569 of file paragraphs.cpp.

573  : LT_BODY;
574 }
575 
577  LineType current_lt = GetLineType();
578  if (current_lt != LT_UNKNOWN && current_lt != LT_START) {
579  tprintf("Trying to set a line to be START when it's already BODY.\n");
580  }
581  if (current_lt == LT_UNKNOWN || current_lt == LT_BODY) {
582  hypotheses_.push_back_new(LineHypothesis(LT_START, nullptr));
583  }
584 }
585 
587  LineType current_lt = GetLineType();
588  if (current_lt != LT_UNKNOWN && current_lt != LT_BODY) {
589  tprintf("Trying to set a line to be BODY when it's already START.\n");

◆ Init()

void tesseract::RowScratchRegisters::Init ( const RowInfo row)

Definition at line 541 of file paragraphs.cpp.

541  : has_start = true; break;
542  case LT_BODY: has_body = true; break;
543  default:
544  tprintf("Encountered bad value in hypothesis list: %c\n",
545  hypotheses_[i].ty);
546  break;
547  }

◆ NonNullHypotheses()

void tesseract::RowScratchRegisters::NonNullHypotheses ( SetOfModels models) const

Definition at line 639 of file paragraphs.cpp.

645  {

◆ OffsideIndent()

int tesseract::RowScratchRegisters::OffsideIndent ( tesseract::ParagraphJustification  just) const
inline

Definition at line 148 of file paragraphs_internal.h.

149  {
150  switch (just) {
153  default: return lindent_ > rindent_ ? lindent_ : rindent_;
154  }

◆ SetBodyLine()

void tesseract::RowScratchRegisters::SetBodyLine ( )

Definition at line 601 of file paragraphs.cpp.

603  {
604  hypotheses_.push_back_new(LineHypothesis(LT_BODY, model));
605  int old_idx = hypotheses_.get_index(LineHypothesis(LT_BODY, nullptr));
606  if (old_idx >= 0)
607  hypotheses_.remove(old_idx);
608 }
609 

◆ SetStartLine()

void tesseract::RowScratchRegisters::SetStartLine ( )

Definition at line 591 of file paragraphs.cpp.

591  {
592  hypotheses_.push_back_new(LineHypothesis(LT_BODY, nullptr));
593  }
594 }
595 
597  hypotheses_.push_back_new(LineHypothesis(LT_START, model));
598  int old_idx = hypotheses_.get_index(LineHypothesis(LT_START, nullptr));
599  if (old_idx >= 0)

◆ SetUnknown()

void tesseract::RowScratchRegisters::SetUnknown ( )
inline

Definition at line 125 of file paragraphs_internal.h.

126 { hypotheses_.truncate(0); }

◆ StartHypotheses()

void tesseract::RowScratchRegisters::StartHypotheses ( SetOfModels models) const

Definition at line 625 of file paragraphs.cpp.

625  {
626  if (hypotheses_[h].model != nullptr)
627  models->push_back_new(hypotheses_[h].model);
628  }
629 }
630 

◆ StrongHypotheses()

void tesseract::RowScratchRegisters::StrongHypotheses ( SetOfModels models) const

Definition at line 632 of file paragraphs.cpp.

637  {

◆ UniqueBodyHypothesis()

const ParagraphModel * tesseract::RowScratchRegisters::UniqueBodyHypothesis ( ) const

Definition at line 652 of file paragraphs.cpp.

657  {

◆ UniqueStartHypothesis()

const ParagraphModel * tesseract::RowScratchRegisters::UniqueStartHypothesis ( ) const

Definition at line 646 of file paragraphs.cpp.

648  {
649  if (!models.contains(hypotheses_[h].model)) {
650  hypotheses_.remove(h);

Member Data Documentation

◆ lindent_

int tesseract::RowScratchRegisters::lindent_

Definition at line 180 of file paragraphs_internal.h.

◆ lmargin_

int tesseract::RowScratchRegisters::lmargin_

Definition at line 179 of file paragraphs_internal.h.

◆ ri_

const RowInfo* tesseract::RowScratchRegisters::ri_

Definition at line 172 of file paragraphs_internal.h.

◆ rindent_

int tesseract::RowScratchRegisters::rindent_

Definition at line 181 of file paragraphs_internal.h.

◆ rmargin_

int tesseract::RowScratchRegisters::rmargin_

Definition at line 182 of file paragraphs_internal.h.


The documentation for this class was generated from the following files:
tesseract::RowScratchRegisters::lindent_
int lindent_
Definition: paragraphs_internal.h:180
tesseract::RowScratchRegisters::ri_
const RowInfo * ri_
Definition: paragraphs_internal.h:172
tesseract::JUSTIFICATION_RIGHT
Definition: publictypes.h:252
tesseract::RowScratchRegisters::rmargin_
int rmargin_
Definition: paragraphs_internal.h:182
tesseract::RowScratchRegisters::SetBodyLine
void SetBodyLine()
Definition: paragraphs.cpp:601
ParagraphModel
Definition: ocrpara.h:114
tesseract::RowScratchRegisters::lmargin_
int lmargin_
Definition: paragraphs_internal.h:179
tesseract::JUSTIFICATION_LEFT
Definition: publictypes.h:250
GenericVector::push_back
int push_back(T object)
Definition: genericvector.h:799
tesseract::RowScratchRegisters::rindent_
int rindent_
Definition: paragraphs_internal.h:181
tesseract::RowScratchRegisters::Init
void Init(const RowInfo &row)
Definition: paragraphs.cpp:541
tesseract::kCrownLeft
const ParagraphModel * kCrownLeft
Definition: paragraphs.cpp:69
tesseract::LT_UNKNOWN
Definition: paragraphs_internal.h:52
count
int count(LIST var_list)
Definition: oldlist.cpp:79
tesseract::RowScratchRegisters::SetStartLine
void SetStartLine()
Definition: paragraphs.cpp:591
tesseract::LT_BODY
Definition: paragraphs_internal.h:51
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:34
tesseract::RowScratchRegisters::GetLineType
LineType GetLineType() const
Definition: paragraphs.cpp:549
tesseract::LT_START
Definition: paragraphs_internal.h:50
tesseract::RowScratchRegisters::AddStartLine
void AddStartLine(const ParagraphModel *model)
Definition: paragraphs.cpp:611
tesseract::LineType
LineType
Definition: paragraphs_internal.h:49
tesseract::kCrownRight
const ParagraphModel * kCrownRight
Definition: paragraphs.cpp:71
tesseract::StrongModel
bool StrongModel(const ParagraphModel *model)
Definition: paragraphs_internal.h:70