Skip to content

Issue 242 - Fix court detection when parenthetical includes date #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Fixes:
citations #237
- Update `maybe_balance_style_tags` to account for party names and intro words
inside the style tag #231
- Fixes court detection with court/date parenthetical contains the month and day, e.g., `(C.D. Cal. Feb. 9, 2015)` #242

## Current

Expand Down
33 changes: 22 additions & 11 deletions eyecite/regexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,32 +219,43 @@ def short_cite_re(regex):
# Post full citation regex:
# Capture metadata after a full cite. For example given the citation "1 U.S. 1"
# with the following text:
# 1 U.S. 1, 4-5, 2 S. Ct. 2, 6-7 (4th Cir. 2012) (overruling foo)
# 1 U.S. 1, 4-5, 2 S. Ct. 2, 6-7 (4th Cir. Jan. 1, 2012) (overruling foo)
# we want to capture:
# pin_cite = 4-5
# extra = 2 S. Ct. 2, 6-7
# court = 4th Cir.
# month = Jan.
# day = 1
# year = 2012
# parenthetical = overruling foo
POST_FULL_CITATION_REGEX = rf"""
(?: # handle a full cite with a valid year paren:
# content before year paren:
(?: # handle a full cite with a valid court+date paren:
# content before court+date paren:
(?:
# pin cite with comma and extra:
{PIN_CITE_REGEX}?
,?\ ?
(?P<extra>[^(;]*)
)
# content within year paren:
[\(\[](?:
# court and year:
(?P<court>[^)]+)\ {YEAR_REGEX}|
# just year:
{YEAR_REGEX}
)[\)\]]
# content within court+date paren:
[\(\[] # opening paren or bracket
(?:
(?:
(?P<court>.*?) # treat anything before date as court
(?= # lookahead to stop when we see a month or year
\s+{MONTH_REGEX} |
\s+{YEAR_REGEX}
)
)?
\ ?
(?P<month>{MONTH_REGEX})?\ ? # optional month
(?P<day>\d{{1,2}})?\,?\ ? # optional day and comma
(?P<year>{YEAR_REGEX}) # year is required
)
[\)\]] # closing paren or bracket
# optional parenthetical comment:
{PARENTHETICAL_REGEX}
| # handle a pin cite with no valid year paren:
| # handle a pin cite with no valid court+date paren:
{PIN_CITE_REGEX}
)
"""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_CourtsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def test_parenthetical_court_parser(self):
"State Kennedy, 666 P.2d 1316, 1326 (Or. 1983)": "or",
"State v. Michael J., 875 A.2d 510, 534-35 (Conn. 2005)": "conn",
"Commonwealth v. Muniz, 164 A.3d 1189 (Pa. 2017)": "pa",
"Commonwealth v. Shaffer, 209 A.3d 957, 969 (Pa. Jan. 1, 2019)": "pa",
"Sixty-Eight Liquors, Inc. v. Colvin, 118 S.W.3d 171 (Ky. Aug. 2, 2003)": "ky",
"Wisniewski v. Johns-Manville Corp., 812 F.2d 81, 83 (3rd Cir. June 30, 1987).": "ca3",
"Wallace v. Cellco P'ship, No. CV 14-8052-DSF (AS), 2015 WL 13908106, at *7 (C.D. Cal. Feb. 9, 2015)": "cacd",
}
for key in samples.keys():
eyecite_result = get_citations(key)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_FindTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ def test_find_citations(self):
metadata={'plaintiff': 'Commonwealth',
'defendant': 'Muniz',
'court': 'pa'})]),
# Test with month/day in court parenthetical
('Commonwealth v. Muniz, 164 A.3d 1189 (Pa. Feb. 9, 2017)',
[case_citation(page='1189', reporter='A.3d', volume='164', year=2017,
metadata={'plaintiff': 'Commonwealth',
'defendant': 'Muniz',
'court': 'pa'})]),
# Parallel cite with parenthetical
('bob lissner v. test 1 U.S. 12, 347-348, 1 S. Ct. 2, 358 (4th Cir. 1982) (overruling foo)',
[case_citation(page='12', year=1982,
Expand Down
Loading