From d27801948b5bf68188a372dbacc2bf3182902247 Mon Sep 17 00:00:00 2001 From: George Helman Date: Sun, 30 Apr 2023 14:01:35 -0400 Subject: [PATCH] Start parsing offense record count --- README.md | 2 +- ciprs_reader/parser/section/offense.py | 1 + tests/parsers/test_offense.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e0c4f99..36e3ea7 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ pip install -e . Read CIPRS PDF: ``` -python ciprs_-eader.py ./cypress-example.pdf +python ciprs_reader.py ./cypress-example.pdf ``` Run Jupyter: diff --git a/ciprs_reader/parser/section/offense.py b/ciprs_reader/parser/section/offense.py index 35f9823..faebd16 100644 --- a/ciprs_reader/parser/section/offense.py +++ b/ciprs_reader/parser/section/offense.py @@ -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"], diff --git a/tests/parsers/test_offense.py b/tests/parsers/test_offense.py index bff5b58..1fcfeb6 100644 --- a/tests/parsers/test_offense.py +++ b/tests/parsers/test_offense.py @@ -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["count"] == "54" assert matches["action"] == "CHARGED" assert matches["desc"] == "SPEEDING(80 mph in a 65 mph zone)" assert matches["severity"] == "INFRACTION"