869 TBOX best_box = guess_box;
872 TBOX adjusted = guess_box;
877 const int kMidGuessY = (guess_box.
bottom() + guess_box.
top()) / 2;
882 bool found_good_border =
false;
897 int previous_below = 0;
898 const int kMaxChances = 10;
899 int chances = kMaxChances;
900 while (bottom != last_bottom) {
906 table->set_bounding_box(adjusted);
907 if (table->FindWhitespacedStructure() &&
920 chances = kMaxChances;
921 double max_row_height =
kMaxRowSize * table->median_cell_height();
923 table->space_below() >= previous_below) ||
924 (table->CountFilledCellsInRow(0) > 1 &&
925 table->row_height(0) < max_row_height)) {
927 best_below = table->space_below();
928 best_cols =
MAX(table->column_count(), best_cols);
929 found_good_border =
true;
932 previous_below = table->space_below();
940 last_bottom = bottom;
944 if (!found_good_border)
948 found_good_border =
false;
952 int previous_above = 0;
953 chances = kMaxChances;
956 while (last_top != top) {
959 table->set_bounding_box(adjusted);
960 if (table->FindWhitespacedStructure() &&
962 int last_row = table->row_count() - 1;
967 chances = kMaxChances;
968 double max_row_height =
kMaxRowSize * table->median_cell_height();
970 table->space_above() >= previous_above) ||
971 (table->CountFilledCellsInRow(last_row) > 1 &&
972 table->row_height(last_row) < max_row_height)) {
974 best_above = table->space_above();
975 best_cols =
MAX(table->column_count(), best_cols);
976 found_good_border =
true;
979 previous_above = table->space_above();
992 if (!found_good_border)
1001 table->set_bounding_box(best_box);
1002 return table->FindWhitespacedStructure();
int NextHorizontalSplit(int left, int right, int y, bool top_to_bottom)
const double kMarginFactor
const double kRequiredColumns
static bool IsWeakTableRow(StructuredTable *table, int row)