Skip to content

Commit

Permalink
Addressing issue freelawproject#84
Browse files Browse the repository at this point in the history
  • Loading branch information
devlux76 committed Dec 25, 2021
1 parent 7e58997 commit 2590595
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 5 additions & 7 deletions eyecite/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,16 @@ def get_court_by_paren(paren_string: str) -> Optional[str]:
Does not work on SCOTUS, since that court lacks parentheticals, and
needs to be handled after disambiguation has been completed.
"""
court_str = strip_punct(paren_string)

#remove punctuation and convert to upper case
court_str = re.sub(r'[^\w\s]', '',paren_string).upper()
court_code = None
if court_str:
# Map the string to a court, if possible.
# Map the string to a court, if possible.
for court in courts:
# Use startswith because citations are often missing final period,
# e.g. "2d Cir"
if court["citation_string"].startswith(court_str):
#remove punctuation and convert to upper case because punctuation is often unreliable
if re.sub(r'[^\w\s]', '',court["citation_string"]).upper() == court_str:
court_code = court["id"]
break

return court_code


Expand Down
6 changes: 6 additions & 0 deletions tests/test_FindTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ def test_find_citations(self):
[case_citation(metadata={'plaintiff': 'lissner',
'defendant': 'test'},
year=1982)]),
# Test to disambiguate SC & Supreme Court
('lissner v. test, 263 F.Supp. 26 (S.C. 1967)',
[case_citation(volume='263',page='26', year=1967, reporter='F.Supp.',
metadata={'plaintiff': 'lissner',
'defendant' : 'test',
'court' : 'sc'})]),
# Test with court and extra information
('bob lissner v. test 1 U.S. 12, 347-348 (4th Cir. 1982)',
[case_citation(page='12', year=1982,
Expand Down

0 comments on commit 2590595

Please sign in to comment.