fix: read a law citation's bare date parenthetical as a date, not a publisher - #344
Open
aseem-ai wants to merge 1 commit into
Open
fix: read a law citation's bare date parenthetical as a date, not a publisher#344aseem-ai wants to merge 1 commit into
aseem-ai wants to merge 1 commit into
Conversation
The publisher group precedes the month group, so "(May 2, 1999)" left the month name in publisher and month empty. A parenthetical opening with a month is a date, not a publisher.
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
Fixes #326
Summary
18 U.S.C. § 1 (May 2, 1999)storedpublisher="May"and leftmonthempty. The publisher group sits before the month group in
POST_LAW_CITATION_REGEX, so a leading month name satisfied the publishertoken first and the month subpattern never saw it.
(West Jan. 1, 2012)was always right, because a real publisher came first.
This is the direction suggested in the issue: a negative lookahead keeps the
publisher token off a month name. The same trick already appears a few lines
up in
POST_FULL_CITATION_REGEX, which uses aMONTH_REGEXlookahead tostop the court group from swallowing a date.
The month has to be followed by a space, a comma, or the closing paren, so a
publisher that merely starts with a month name —
(Mayhew 1999)— is stilla publisher.
One incidental change:
(May)on its own is now a parenthetical rather thanpublisher="May", which seems the better of the two readings.Tests
python -m unittest discover -s tests -p 'test_*.py'→ 56 tests, OK.New test
test_law_citation_bare_date_parentheticalfails on main(
publisher='May'vspublisher=None) and passes here. It covers(May 2, 1999),(Jan. 1, 2012), the day-less(May 1999), the(West Jan. 1, 2012)and(West 1999)controls that already worked, and(Mayhew 1999)as the false positive.Diffed metadata across the surrounding law parentheticals before and after:
(Lexis Jun. 2018),(Consol. 1999),(West),(2007),(West 2009)withet seq.,(Lexis Supp. 2010),(2005-06),(repealed) (ignore this),(1987), plus410 U.S. 113 (1973)andFoo v. Bar, 1 U.S. 1 (May 2, 1999). Only the bare-date rows change.Extraction over
tests/assets/opinion.txtis unchanged at 170 citations.Note on #330
#330 is open against these same lines for #325 and rewrites the publisher
character class. The two changes are orthogonal — this one adds a lookahead
in front of the token, that one widens what the token accepts — but whichever
lands second will want a rebase. Merge #330 first and I will rebase this on
top.
AI Disclosure