Repository navigation
Conversation
ArifRasim
force-pushed
the
ar/text-replace
branch
from
January 15, 2024 05:53
b56037b to
8928445
Compare
Collaborator
|
Hey! As camelot is dead, we try to build a maintained fork at Do you want to open the PR against that branch so that we can merge your improvement? |
bosd
added a commit
to bosd/camelot
that referenced
this pull request
May 20, 2026
bosd
added a commit
to bosd/camelot
that referenced
this pull request
May 20, 2026
…elot-dev#482) text_strip already lets the caller remove characters / substrings. The 2024 feature request camelot-dev#481 by @ArifRasim asked for the symmetric operation: replace a substring with a different one. Motivating example was '\n' → ' ' to fix words that PDF text extraction had split across line breaks. API: read_pdf(..., replace_text={pattern: replacement, ...}). Keys are literal substrings (regex metacharacters escaped), and when several keys could match at the same position the longest one wins (the obvious user expectation; the implementation pre-sorts by length descending). Implementation: * New utils.text_replace(text, replacements) helper, dict or list-of-pairs accepted, empty keys skipped, Unicode-safe. * New replace_text= constructor argument on BaseParser / TextBaseParser / Stream / Network / Lattice / Hybrid; stored as self.replace_text on the parser. * Applied at the single central cell-text-emission site in BaseParser._generate_table_pos_errors (after the existing strip/split/flag-size pipeline). One spot; no plumbing down into flag_font_size etc. * 'replace_text' added to common_kwargs so validate_input / remove_extra accept it for all flavors. Closes camelot-dev#481. Closes camelot-dev#482.
bosd
added a commit
to bosd/camelot
that referenced
this pull request
May 20, 2026
bosd
added a commit
to bosd/camelot
that referenced
this pull request
May 20, 2026
…elot-dev#482) text_strip already lets the caller remove characters / substrings. The 2024 feature request camelot-dev#481 by @ArifRasim asked for the symmetric operation: replace a substring with a different one. Motivating example was '\n' → ' ' to fix words that PDF text extraction had split across line breaks. API: read_pdf(..., replace_text={pattern: replacement, ...}). Keys are literal substrings (regex metacharacters escaped), and when several keys could match at the same position the longest one wins (the obvious user expectation; the implementation pre-sorts by length descending). Implementation: * New utils.text_replace(text, replacements) helper, dict or list-of-pairs accepted, empty keys skipped, Unicode-safe. * New replace_text= constructor argument on BaseParser / TextBaseParser / Stream / Network / Lattice / Hybrid; stored as self.replace_text on the parser. * Applied at the single central cell-text-emission site in BaseParser._generate_table_pos_errors (after the existing strip/split/flag-size pipeline). One spot; no plumbing down into flag_font_size etc. * 'replace_text' added to common_kwargs so validate_input / remove_extra accept it for all flavors. Closes camelot-dev#481. Closes camelot-dev#482.
bosd
added a commit
to bosd/camelot
that referenced
this pull request
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added feature replace text. SImilar to strip_text now texts can be replaced as key value pairs when passed to the read_pdf function.
Issue #481