fix: keep the pin cite on an Id. citation that refers to a section - #343
Open
aseem-ai wants to merge 1 commit into
Open
fix: keep the pin cite on an Id. citation that refers to a section#343aseem-ai wants to merge 1 commit into
aseem-ai wants to merge 1 commit into
Conversation
The section mark is tokenized separately, and match_on_tokens stopped at any non-string token, so "Id. § 1985" lost its pin cite and left the mark behind as its own UnknownCitation. The mark's text is ordinary pin cite vocabulary, so scanning now reads through it, and a mark absorbed into the preceding citation is no longer reported twice.
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.
Fixes
Refs #299 — deliberately not
Fixes, see the note at the end.Summary
Id. § 1985lost its pin cite, and the section mark was reported as aseparate
UnknownCitation. A plainId. at 5was always fine, so this onlyhit
Id.cites pointing at a section.The cause is the one named in the issue: the mark is its own token, and
match_on_tokens()stops at any non-string token whenstrings_only=True,so the scan never saw past it. This is fix option 2 from the issue.
Two changes in
helpers.py:match_on_tokens()reads through aSectionTokeninstead of stopping atit. The mark is a marker, not a citation, and its text is already pin cite
vocabulary —
PIN_CITE_TOKEN_REGEXhas listed§{1,2}as a label allalong, it just never got to see one.
filter_citations()drops anUnknownCitationthat overlaps the citationbefore it. Once the mark is part of the pin cite it is not a citation of
its own, and this also silences the "Unknown overlap case" warning the
pairing was logging. A mark inside a parenthetical is still kept, by the
rule directly above.
Tests
python -m unittest discover -s tests -p 'test_*.py'→ 56 tests, OK.New test
test_id_citation_with_section_pin_citefails on main (the strayUnknownCitationis the extra element) and passes here. It covers42 U.S.C. § 1983. Id. § 1985.,Id. §§ 5-7., the gluedId. §5.form,Id. § 5, 7., a guard thatId. at 5still works, and a guard that a markno citation absorbs is still reported on its own.
match_on_tokens()is shared, so I read its six call sites and diffedbehaviour on the neighbours, including the backward scans for party names
and
supraantecedents:§ 3.1 (2d ed. 1977), Strawberry Hill, 725 S.W.2d at 176,1 U.S. 1 (citing § 5),§ 5. Adarand, supra, at 240,lorem ipsum see §99 of the U.S. code.,Fla. Stat. § 120.68 (2007),Mass. Gen. Laws ch. 1, §§ 2-3. All byte-identical before and after. Extraction overtests/assets/opinion.txtis unchanged at 170 citations.Why this is
Refsand notFixesThe example in the issue,
Id. § 394-ccc(2)-(3), still does not produce apin cite after this change — but for an unrelated reason.
394-cccis asection number with letters in it, which is #146, and #331 is open for it.
Widening
PIN_CITE_TOKEN_REGEXto swallow that shape would put a statutesection grammar inside the pin cite every case citation uses (
at 5-ccc(2)would start matching) and would overlap #331, so I have left it alone.
Say the word if you would rather this close #299 and track the lettered
form solely on #146.
AI Disclosure