MCPcopy Create free account
hub / github.com/creatale/node-dv / MarkRowsWithModel

Function MarkRowsWithModel

deps/tesseract/ccmain/paragraphs.cpp:807–844  ·  view source on GitHub ↗

Given a paragraph model mark rows[row_start, row_end) as said model start or body lines. Case 1: model->first_indent_ != model->body_indent_ Differentiating the paragraph start lines from the paragraph body lines in this case is easy, we just see how far each line is indented. Case 2: model->first_indent_ == model->body_indent_ Here, we find end-of-paragraph lines by looking for "short lines." W

Source from the content-addressed store, hash-verified

805// We mark a line as short (end of paragraph) if the offside indent
806// is greater than eop_threshold.
807void MarkRowsWithModel(GenericVector<RowScratchRegisters> *rows,
808 int row_start, int row_end,
809 const ParagraphModel *model,
810 bool ltr,
811 int eop_threshold) {
812 if (!AcceptableRowArgs(0, 0, __func__, rows, row_start, row_end))
813 return;
814 for (int row = row_start; row < row_end; row++) {
815 bool valid_first = ValidFirstLine(rows, row, model);
816 bool valid_body = ValidBodyLine(rows, row, model);
817 if (valid_first && !valid_body) {
818 (*rows)[row].AddStartLine(model);
819 } else if (valid_body && !valid_first) {
820 (*rows)[row].AddBodyLine(model);
821 } else if (valid_body && valid_first) {
822 bool after_eop = (row == row_start);
823 if (row > row_start) {
824 if (eop_threshold > 0) {
825 if (model->justification() == JUSTIFICATION_LEFT) {
826 after_eop = (*rows)[row - 1].rindent_ > eop_threshold;
827 } else {
828 after_eop = (*rows)[row - 1].lindent_ > eop_threshold;
829 }
830 } else {
831 after_eop = FirstWordWouldHaveFit((*rows)[row - 1], (*rows)[row],
832 model->justification());
833 }
834 }
835 if (after_eop) {
836 (*rows)[row].AddStartLine(model);
837 } else {
838 (*rows)[row].AddBodyLine(model);
839 }
840 } else {
841 // Do nothing. Stray row.
842 }
843 }
844}
845
846// GeometricClassifierState holds all of the information we'll use while
847// trying to determine a paragraph model for the text lines in a block of

Callers 2

GeometricClassifyFunction · 0.85

Calls 7

AcceptableRowArgsFunction · 0.85
ValidFirstLineFunction · 0.85
ValidBodyLineFunction · 0.85
FirstWordWouldHaveFitFunction · 0.85
AddStartLineMethod · 0.80
AddBodyLineMethod · 0.80
justificationMethod · 0.80

Tested by

no test coverage detected