Rework .extract_words and add use_text_flow param

Taking @samkit-jain's smart question about sort-order into account, this
commit reworks `.extract_words`, making the sorting more explicit, and
adding an option to *not* sort, via `use_text_flow=True`, which follows
the original PDF's text flow, rather than presorting all characters top-down,
left-right.

To do so required rethinking the word-delineation logic,
which in turn motivated a shift toward a more object-oriented approach
(especially to keep track of settings without passing them from function
to function). Now `.extract_text`'s logic is encapsulated in a new class,
`TextExtractor`.
This commit is contained in:
Jeremy Singer-Vine
2020-08-30 18:16:50 -04:00
parent 08cf2ec8e1
commit 84f91811df
4 changed files with 134 additions and 85 deletions
Binary file not shown.