unstructured
490eeb30 - fix(tsv): honor infer_table_structure when partitioning TSV files (#4513)

Commit
1 day ago
fix(tsv): honor infer_table_structure when partitioning TSV files (#4513) **Summary** `partition_tsv()` silently ignores `infer_table_structure=False`, so callers still receive `Table.metadata.text_as_html`. The flag is passed through by `partition()` but absorbed by `**kwargs` in the TSV partitioner. The fix adds the explicit parameter with the same default (`True`) as the other table partitioners, and sets HTML metadata only when enabled. Tests cover both flag values through `partition_tsv()` and `partition()`. Disabling HTML sends the whole flattened table through the shared text splitter, which exposed latent progress and work-bound defects in that path. The branch therefore also carries the bounded-split fixes already discussed on this PR: a prefix wholly covered by overlap advances, the token window and fallback scans are bounded, the vocabulary bound is shared across HTML cells, the unread suffix is not re-encoded on every split, and a fitting input is not rejected because an earlier prefix overflowed. **This revision (`f256ed23`)** Both findings from the latest review: - **Preferred-separator search:** candidates inside one whitespace run all trim to the same fragment and lstrip to the same remainder. The run is now evaluated once and the remaining matches inside it are skipped, so `"a" + " " * 100_000 + "print(1)"` measures one candidate instead of 100,000. Covered for spaces, newlines, mixed whitespace and a configured tab separator. - **Fallback overlap:** `split_pos > len(fragment)` records that the cut trimmed a trailing whitespace run. That is now combined with `is_whitespace_split`, so the overlap tail gets a separating space when either side of the cut had whitespace. The corrupted `"aprint(1)"` expectation is replaced by `"a print(1)"`; an unbroken-word test still forbids an artificial space when the cut had no whitespace. **Test** - `pytest test_unstructured/chunking test_unstructured/partition/test_tsv.py -q` → `719 passed, 2 skipped in 12.76s` - `ruff check` and `ruff format --check` on the two changed files → clean - `git diff --check` → clean Not run: the full partitioner/extras suites and cross-platform tests. CI is now running on this head; no green check is claimed yet. **Type of change:** bug fix; no new dependency. Related #4373 changes numeric HTML generation, and #3870 fixed a duplicate auto-dispatch kwarg; neither addresses this ignored TSV flag.
Author
Parents
Loading