Skip to content

Commit

Permalink
fix(find): Strips whitespace from court strings for matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdahl committed Sep 22, 2023
1 parent 1f408cc commit c9b4d78
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions eyecite/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ def get_court_by_paren(paren_string: str) -> Optional[str]:
needs to be handled after disambiguation has been completed.
"""
court_str = strip_punct(paren_string)
court_str = court_str.replace(" ", "")

court_code = None
if court_str:
# 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):
# Use startswith because citation strings are often missing final
# period, e.g. "2d Cir"
# Remove whitespace because citation strings sometimes lack
# internal spaces, e.g. "Pa.Super."
if court["citation_string"].replace(" ", "").startswith(court_str):
court_code = court["id"]
break

Expand Down

0 comments on commit c9b4d78

Please sign in to comment.