Skip to content

Commit

Permalink
Handle citation strings
Browse files Browse the repository at this point in the history
Closes #61
  • Loading branch information
anseljh committed Nov 18, 2022
1 parent 915b010 commit 792b08f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

## Current Version

- 0.10.10 (2022-11-08): Various improvements to courts-db
- 0.10.11 (2022-11-17): Handle citation strings ([#61](https://github.com/freelawproject/courts-db/issues/61))

## Past Versions

- 0.10.10 (2022-11-08): Various improvements to courts-db

- 0.10.9 (2022-10-14): Updates to courts-db

- 0.10.8 (2022-09-08): Add variation indiana tax court to match cl
Expand Down
4 changes: 3 additions & 1 deletion courts_db/data/courts.json
Original file line number Diff line number Diff line change
Expand Up @@ -26846,7 +26846,7 @@
},
{
"case_types": [],
"citation_string": "E.D.N.Y",
"citation_string": "E.D.N.Y.",
"court_url": "http://www.nyed.uscourts.gov/",
"dates": [
{
Expand All @@ -26860,6 +26860,7 @@
}
],
"examples": [
"E.D.N.Y.",
"United States District Court E D New York",
"United States District Court Eastern of New York",
"District Court E D New York",
Expand Down Expand Up @@ -48189,6 +48190,7 @@
}
],
"examples": [
"W.D. Wash.",
"United States District Court Western Distict of Washington At Seattle",
"United States District Court For The Western Division of Washington",
"United States District Court Westhern District"
Expand Down
18 changes: 18 additions & 0 deletions courts_db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,23 @@ def gather_regexes(courts):
court.get("location"),
)
)
# Add a regex for the court's citation string, e.g. "W.D. Wash."
# See #61: https://github.com/freelawproject/courts-db/issues/61
regexes.append((
citation_to_regex(court["citation_string"]),
court["id"],
court["name"],
court["type"],
court.get("location"),
))

return regexes

def citation_to_regex(citation_str: str):
reg_elements = citation_str.split(".")
reg_str = ""
for element in reg_elements:
if element != "":
reg_str += element.strip() + "\.\s?"
regex = re.compile(reg_str, (re.I | re.U))
return regex
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import find_packages, setup

VERSION = "0.10.10"
VERSION = "0.10.11"
AUTHOR = "Free Law Project"
EMAIL = "[email protected]"
HERE = os.path.abspath(os.path.dirname(__file__))
Expand Down

0 comments on commit 792b08f

Please sign in to comment.