Skip to content

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
freelawproject:mainfrom
aseem-ai:fix/law-date-parenthetical-publisher
Open

fix: read a law citation's bare date parenthetical as a date, not a publisher#344
aseem-ai wants to merge 1 commit into
freelawproject:mainfrom
aseem-ai:fix/law-date-parenthetical-publisher

Conversation

@aseem-ai

@aseem-ai aseem-ai commented Sep 1, 2026

Copy link
Copy Markdown

Fixes

Fixes #326

Summary

18 U.S.C. § 1 (May 2, 1999) stored publisher="May" and left month
empty. The publisher group sits before the month group in
POST_LAW_CITATION_REGEX, so a leading month name satisfied the publisher
token 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 a MONTH_REGEX lookahead to
stop 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 still
a publisher.

One incidental change: (May) on its own is now a parenthetical rather than
publisher="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_parenthetical fails on main
(publisher='May' vs publisher=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) with et seq., (Lexis Supp. 2010), (2005-06),
(repealed) (ignore this), (1987), plus 410 U.S. 113 (1973) and
Foo v. Bar, 1 U.S. 1 (May 2, 1999). Only the bare-date rows change.
Extraction over tests/assets/opinion.txt is 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

  • No AI tools were used to create the content of this PR.
  • Parts of this PR were created with the help of an AI tool, and I have carefully reviewed all of its content and take full responsibility for it.

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.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bare date parenthetical (e.g. "(May 2, 1999)") mis-captures the month as publisher

1 participant