877 TBOX best_box = guess_box;
880 TBOX adjusted = guess_box;
885 const int kMidGuessY = (guess_box.
bottom() + guess_box.
top()) / 2;
890 bool found_good_border =
false;
905 int previous_below = 0;
906 const int kMaxChances = 10;
907 int chances = kMaxChances;
908 while (bottom != last_bottom) {
914 table->set_bounding_box(adjusted);
915 if (table->FindWhitespacedStructure() &&
928 chances = kMaxChances;
929 double max_row_height =
kMaxRowSize * table->median_cell_height();
931 table->space_below() >= previous_below) ||
932 (table->CountFilledCellsInRow(0) > 1 &&
933 table->row_height(0) < max_row_height)) {
935 best_below = table->space_below();
936 best_cols =
MAX(table->column_count(), best_cols);
937 found_good_border =
true;
940 previous_below = table->space_below();
948 last_bottom = bottom;
952 if (!found_good_border)
956 found_good_border =
false;
960 int previous_above = 0;
961 chances = kMaxChances;
964 while (last_top != top) {
967 table->set_bounding_box(adjusted);
968 if (table->FindWhitespacedStructure() &&
970 int last_row = table->row_count() - 1;
975 chances = kMaxChances;
976 double max_row_height =
kMaxRowSize * table->median_cell_height();
978 table->space_above() >= previous_above) ||
979 (table->CountFilledCellsInRow(last_row) > 1 &&
980 table->row_height(last_row) < max_row_height)) {
982 best_above = table->space_above();
983 best_cols =
MAX(table->column_count(), best_cols);
984 found_good_border =
true;
987 previous_above = table->space_above();
1000 if (!found_good_border)
1009 table->set_bounding_box(best_box);
1010 return table->FindWhitespacedStructure();
const double kMarginFactor
const double kRequiredColumns
int NextHorizontalSplit(int left, int right, int y, bool top_to_bottom)
static bool IsWeakTableRow(StructuredTable *table, int row)