diff --git a/CHANGES.md b/CHANGES.md index 0b58cc5..d9b1986 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/eyecite/regexes.py b/eyecite/regexes.py index 175a274..eaf20c2 100644 --- a/eyecite/regexes.py +++ b/eyecite/regexes.py @@ -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[^(;]*) ) - # content within year paren: - [\(\[](?: - # court and year: - (?P[^)]+)\ {YEAR_REGEX}| - # just year: - {YEAR_REGEX} - )[\)\]] + # content within court+date paren: + [\(\[] # opening paren or bracket + (?: + (?: + (?P.*?) # treat anything before date as court + (?= # lookahead to stop when we see a month or year + \s+{MONTH_REGEX} | + \s+{YEAR_REGEX} + ) + )? + \ ? + (?P{MONTH_REGEX})?\ ? # optional month + (?P\d{{1,2}})?\,?\ ? # optional day and comma + (?P{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} ) """ diff --git a/tests/test_CourtsTest.py b/tests/test_CourtsTest.py index 21313c8..e8fafaa 100644 --- a/tests/test_CourtsTest.py +++ b/tests/test_CourtsTest.py @@ -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) diff --git a/tests/test_FindTest.py b/tests/test_FindTest.py index eeba9c9..95a18b1 100644 --- a/tests/test_FindTest.py +++ b/tests/test_FindTest.py @@ -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,