From 96dcc8450443952572e9d3e0ce8c1b3c29fa19bb Mon Sep 17 00:00:00 2001 From: Matt Dahl Date: Thu, 23 Feb 2023 16:08:29 -0500 Subject: [PATCH] fix(find): Strips whitespace from court strings for matching. --- eyecite/helpers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/eyecite/helpers.py b/eyecite/helpers.py index 4380be6..662f71a 100644 --- a/eyecite/helpers.py +++ b/eyecite/helpers.py @@ -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