Repository navigation
fix(grep): document="EX-10.1" selects exactly EX-10.1; literal matches keep source offsets - #1397
Merged
Merged
Conversation
…s keep source offsets (5qqy, 6th2) 5qqy: Filing._attachment_matches tested document.upper() in doc_type, a substring match, so "EX-10.1" also selected EX-10.10..EX-10.19. Replaced by _select_attachments, which sees the whole list: an exact filename wins, then an exact document type, and the old substring match applies only when nothing matched exactly, so "EX-10" still selects every EX-10 exhibit. PR #1380 added only an exact-filename check ahead of the substring test, which leaves the type collision in place. SeeQC's S-1 (0001213900-26-073222): "agreement" in EX-10.1 is 133 matches; the old filter returned 378, adding EX-10.10/11/12. 6th2: the literal branch of _grep_text found positions in text.lower() and sliced the original text with them. "İ".lower() is two characters, so each one before a match shifted it by one. Literal search now runs re.escape(pattern) with IGNORECASE over the original text. It keeps the old scan's overlapping matches ("aa" in "aaa" is two) by searching again from m.start() + 1 rather than using finditer; regex mode is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Beads edgartools-5qqy and edgartools-6th2 (salvaged from closed PR #1380).
5qqy:
document="EX-10.1"also searched EX-10.10 through EX-10.19Filing._attachment_matchesmatched the document type by substring. It's replaced by_select_attachments, which looks at the whole attachment list and applies a precedence: an exact filename wins, then an exact document type, and the substring match applies only when nothing matched exactly. That meansdocument="EX-10"still selects every EX-10 exhibit. PR #1380 only added an exact-filename check ahead of the substring test, which left the type collision in place.Ground truth, SeeQC's S-1 (
0001213900-26-073222): "agreement" in EX-10.1 (a Stockholder Support Agreement) gives 133 matches. The old filter returned 378, adding the EX-10.10/11/12 employment agreements.6th2: literal grep shifted matches after characters whose lowercase is longer
The literal branch found positions in
text.lower()and sliced the original text with them."İ".lower()is two characters, so each one before a match shifted the result by one. Literal search now runsre.escape(pattern)withIGNORECASEover the original text.It keeps the old scan's overlapping matches ("aa" in "aaa" gives two) by searching again from
m.start() + 1rather than usingfinditer, which would have silently dropped them. Regex mode is unchanged.Verification
grep()) and literal offsets (the İ case, source casing, overlap, regex metacharacters in a literal).grep.py; the end-to-end and SeeQC tests fail on the old_filings.py.test-fast: the only failure is the dt1f1 20-F test, which also fails on main.grep()docstring anddocs/guides/full-text-search.mddescribe the precedence.🤖 Generated with Claude Code