Commit 804b0de
committed
table: probe candidate tables against CHARS instead of get_textbox()
cells_to_tables()'s no-text filter passed the module-global TEXTPAGE to
page.get_textbox(), but that global is never assigned anywhere -- its
comment ('textpage for cell text extraction') suggests a global
statement was lost at some point; make_chars() and find_tables() only
ever bind locals of the same name. Every probe therefore built a fresh
full-page TextPage and Python-walked all of its characters
(JM_copy_rectangle), ~24ms per candidate table -- the largest single
find_tables() cost after character extraction (~30% of wall time on a
503-page table corpus).
The same characters are already available in CHARS in identical page
space, so scan those instead (built lazily, only when a candidate
survives the geometric checks), with the same strict-overlap rule as
JM_rects_overlap() and the same whitespace-only rejection. Drop the
now-unreferenced TEXTPAGE global.
Measured on the 503-page corpus: every produced table's (bbox, cells)
is hash-identical; find_tables() mean wall time drops 106.1 -> 75.9
ms/page (-28%).1 parent 6923195 commit 804b0de
1 file changed
Lines changed: 23 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
167 | 166 | | |
168 | 167 | | |
169 | 168 | | |
| |||
1540 | 1539 | | |
1541 | 1540 | | |
1542 | 1541 | | |
1543 | | - | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
1544 | 1564 | | |
1545 | 1565 | | |
1546 | 1566 | | |
| |||
1552 | 1572 | | |
1553 | 1573 | | |
1554 | 1574 | | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
| 1575 | + | |
1561 | 1576 | | |
1562 | 1577 | | |
1563 | 1578 | | |
| |||
0 commit comments