Skip to content

Commit

Permalink
Merge pull request #32 from deardurham/offense-ampersand
Browse files Browse the repository at this point in the history
Catch offenses with ampersands
  • Loading branch information
copelco authored May 27, 2020
2 parents 4b6ac16 + 38b8d69 commit 736423e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ciprs/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class OffenseRecordRowWithNumber(Parser):
"""

# pylint: disable=line-too-long
pattern = r"\s*(?P<num>[\d]+)\s*(?P<action>\w+)\s+(?P<desc>[\w \-\(\)]+)[ ]{2,}(?P<severity>\w+)[ ]{2,}(?P<law>[\w. \-\(\)]+)"
pattern = r"\s*(?P<num>[\d]+)\s*(?P<action>\w+)\s+(?P<desc>.+)[ ]{2,}(?P<severity>\w+)[ ]{2,}(?P<law>[\w. \-\(\)]+)"

def extract(self, matches, report):
record = {
Expand Down
10 changes: 10 additions & 0 deletions tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ def test_offense_record_charged_with_number(line):
assert matches["law"] == "G.S. 20-141(B)"


def test_offense_record_charged_with_number__ampersand():
string = "54 CHARGED SPEEDING(80 & 65 mph zone) INFRACTION G.S. 20-141(B)" # noqa
matches = parsers.OffenseRecordRowWithNumber().match(string)
assert matches is not None, "Regex match failed"
assert matches["action"] == "CHARGED"
assert matches["desc"] == "SPEEDING(80 & 65 mph zone)"
assert matches["severity"] == "INFRACTION"
assert matches["law"] == "G.S. 20-141(B)"


def test_offense_record_arrainged():
string = "ARRAIGNED SPEEDING(80 mph in a 65 mph zone) INFRACTION G.S. 20-141(B) 4450" # noqa
matches = parsers.OffenseRecordRow().match(string)
Expand Down

0 comments on commit 736423e

Please sign in to comment.