Skip to content

Commit

Permalink
fix(get_court_by_paren): try with an exact match
Browse files Browse the repository at this point in the history
add test
  • Loading branch information
quevon24 committed Dec 7, 2024
1 parent 37f237f commit 9c6b387
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions eyecite/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def get_court_by_paren(paren_string: str) -> Optional[str]:

court_code = None
if court_str:
# Try with an exact match, e.g. Pa.
exact_match = next((court["id"] for court in courts if strip_punct(court["citation_string"].replace(" ", "")) == court_str), None)
if exact_match:
return exact_match
# Map the string to a court, if possible.
for court in courts:
# Use startswith because citation strings are often missing final
Expand Down
6 changes: 6 additions & 0 deletions tests/test_FindTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ def test_find_citations(self):
'defendant': 'test',
'court': 'pasuperct',
'pin_cite': '347-348'})]),
# Test with court string exact match
('Commonwealth v. Muniz, 164 A.3d 1189 (Pa. 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

0 comments on commit 9c6b387

Please sign in to comment.