|
tesseract
3.03
|
#include <ocrpara.h>
Public Member Functions | |
| ParagraphModel (tesseract::ParagraphJustification justification, int margin, int first_indent, int body_indent, int tolerance) | |
| ParagraphModel () | |
| bool | ValidFirstLine (int lmargin, int lindent, int rindent, int rmargin) const |
| bool | ValidBodyLine (int lmargin, int lindent, int rindent, int rmargin) const |
| tesseract::ParagraphJustification | justification () const |
| int | margin () const |
| int | first_indent () const |
| int | body_indent () const |
| int | tolerance () const |
| bool | is_flush () const |
| bool | Comparable (const ParagraphModel &other) const |
| STRING | ToString () const |
| ParagraphModel::ParagraphModel | ( | tesseract::ParagraphJustification | justification, |
| int | margin, | ||
| int | first_indent, | ||
| int | body_indent, | ||
| int | tolerance | ||
| ) | [inline] |
Definition at line 116 of file ocrpara.h.
: justification_(justification), margin_(margin), first_indent_(first_indent), body_indent_(body_indent), tolerance_(tolerance) { // Make one of {first_indent, body_indent} is 0. int added_margin = first_indent; if (body_indent < added_margin) added_margin = body_indent; margin_ += added_margin; first_indent_ -= added_margin; body_indent_ -= added_margin; }
| ParagraphModel::ParagraphModel | ( | ) | [inline] |
Definition at line 135 of file ocrpara.h.
: justification_(tesseract::JUSTIFICATION_UNKNOWN), margin_(0), first_indent_(0), body_indent_(0), tolerance_(0) { }
| int ParagraphModel::body_indent | ( | ) | const [inline] |
| bool ParagraphModel::Comparable | ( | const ParagraphModel & | other | ) | const |
Definition at line 80 of file ocrpara.cpp.
{
if (justification_ != other.justification_)
return false;
if (justification_ == JUSTIFICATION_CENTER ||
justification_ == JUSTIFICATION_UNKNOWN)
return true;
int tolerance = (tolerance_ + other.tolerance_) / 4;
return NearlyEqual(margin_ + first_indent_,
other.margin_ + other.first_indent_, tolerance) &&
NearlyEqual(margin_ + body_indent_,
other.margin_ + other.body_indent_, tolerance);
}
| int ParagraphModel::first_indent | ( | ) | const [inline] |
| bool ParagraphModel::is_flush | ( | ) | const [inline] |
Definition at line 171 of file ocrpara.h.
{
return (justification_ == tesseract::JUSTIFICATION_LEFT ||
justification_ == tesseract::JUSTIFICATION_RIGHT) &&
abs(first_indent_ - body_indent_) <= tolerance_;
}
| tesseract::ParagraphJustification ParagraphModel::justification | ( | ) | const [inline] |
| int ParagraphModel::margin | ( | ) | const [inline] |
| int ParagraphModel::tolerance | ( | ) | const [inline] |
| STRING ParagraphModel::ToString | ( | ) | const |
Definition at line 93 of file ocrpara.cpp.
| bool ParagraphModel::ValidBodyLine | ( | int | lmargin, |
| int | lindent, | ||
| int | rindent, | ||
| int | rmargin | ||
| ) | const |
Definition at line 63 of file ocrpara.cpp.
{
switch (justification_) {
case JUSTIFICATION_LEFT:
return NearlyEqual(lmargin + lindent, margin_ + body_indent_,
tolerance_);
case JUSTIFICATION_RIGHT:
return NearlyEqual(rmargin + rindent, margin_ + body_indent_,
tolerance_);
case JUSTIFICATION_CENTER:
return NearlyEqual(lindent, rindent, tolerance_ * 2);
default:
// shouldn't happen
return false;
}
}
| bool ParagraphModel::ValidFirstLine | ( | int | lmargin, |
| int | lindent, | ||
| int | rindent, | ||
| int | rmargin | ||
| ) | const |
Definition at line 46 of file ocrpara.cpp.
{
switch (justification_) {
case JUSTIFICATION_LEFT:
return NearlyEqual(lmargin + lindent, margin_ + first_indent_,
tolerance_);
case JUSTIFICATION_RIGHT:
return NearlyEqual(rmargin + rindent, margin_ + first_indent_,
tolerance_);
case JUSTIFICATION_CENTER:
return NearlyEqual(lindent, rindent, tolerance_ * 2);
default:
// shouldn't happen
return false;
}
}