Skip to content

Commit

Permalink
Merge pull request #66 from deardurham/add_count
Browse files Browse the repository at this point in the history
Start parsing offense record count
  • Loading branch information
georgehelman authored May 1, 2023
2 parents cc71d6c + 7d33c56 commit de49e30
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 2 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,22 @@ Example output:

Pre-requisites:

Mac
```
brew cask install pdftotext
```

Ubuntu
```
sudo apt-get install -y poppler-utils
```

```
wget --no-check-certificate https://dl.xpdfreader.com/xpdf-tools-linux-4.04.tar.gz \
&& tar -xvf xpdf-tools-linux-4.04.tar.gz \
&& cp xpdf-tools-linux-4.04/bin64/pdftotext /usr/local/bin/pdftotext-4
```

Setup:

```bash
Expand All @@ -66,7 +78,7 @@ pip install -e .
Read CIPRS PDF:

```
python ciprs_-eader.py ./cypress-example.pdf
python ciprs_reader.py ./cypress-example.pdf
```

Run Jupyter:
Expand Down
1 change: 1 addition & 0 deletions ciprs_reader/parser/section/offense.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def clean(self, matches):

def extract(self, matches, report):
record = {
"Count": matches["num"],
"Action": matches["action"],
"Description": matches["desc"],
"Severity": matches["severity"],
Expand Down
1 change: 1 addition & 0 deletions tests/parsers/test_offense.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_offense_record_charged_with_number(report, state):
"""
matches = offense.OffenseRecordRowWithNumber(report, state).match(string)
assert matches is not None, "Regex match failed"
assert matches["num"] == "54"
assert matches["action"] == "CHARGED"
assert matches["desc"] == "SPEEDING(80 mph in a 65 mph zone)"
assert matches["severity"] == "INFRACTION"
Expand Down
1 change: 1 addition & 0 deletions tests/test_records/expected_output/test_redacted_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
{
"Records": [
{
"Count": "01",
"Action": "CHARGED",
"Description": "POSSESS MARIJUANA UP TO 1/2 OZ",
"Severity": "MISDEMEANOR",
Expand Down
Loading

0 comments on commit de49e30

Please sign in to comment.