Closed erip closed 1 year ago
As a side-note: if I remove the table settings, I actually get many more extractions (whose quality is currently unknown).
Hi @erip Appreciate your interest in the library. What you are seeing is expected because the default value of vertical_strategy
is "lines". This leaves your table settings as
{
"vertical_strategy": "lines",
"explicit_vertical_lines": [65.46, 186.62, 293.08, 413.10, 524.52]
}
and apart from the explicit lines you have specified, it will also include the vertical lines that it has also identified because of the "lines" strategy. Because of this, you are seeing a non-deterministic output.
To make it deterministic, you should provide the vertical_strategy
as "explicit" so that it only includes the lines that you have specified.
{
"vertical_strategy": "explicit",
"explicit_vertical_lines": [65.46, 186.62, 293.08, 413.10, 524.52]
}
Love an easy fix. Thanks, @samkit-jain!
@samkit-jain do you think it makes sense to log a warning if explicit_X_lines
is not empty and the X_strategy
isn't "explicit"? Maybe this could prevent these types of things in the future and it should be a pretty quick fix. If you think so, I can send a PR.
I can understand why this behaviour might be unintuitive. However, I have always considered explicit_...
to be an extension over the X_strategy
. The same is also mentioned in the documentation
If we give out a warning, it would imply that the usage is not the ideal one which is not the case here.
Describe the bug
If I extract a table with a len
N
list ofexplicit_vertical_lines
indicating the[col1_left_line, col1_right_line, col2_right_line, ..., colNminus2_right_line, colNminus1_right_line]
, I find that I often extract many more thanN-1
columns.Code to reproduce the problem
PDF file
Attached dico-karmous.pdf
Expected behavior
When explicitly passed, the number of extracted columns should be determinstic.
What did you expect the result should have been?
The number of extracted columns should match for identically formatted tables across pages.
Actual behavior
A different number of columns is extracted depending on page, with a wide variance in the number of columns.
Additional context
I've tried to "collapse" columns which are completely empty as an artifact of extraction, but it seems like many of the troublemaking columns have some bleedover from previous columns (maybe from stray tabs in the underlying data or similar?); not exactly sure.
Environment