forked from rcackerman/parole-hearing-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.py
63 lines (53 loc) · 1.66 KB
/
process.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import re, time, csv, datetime
import os, sys
import prison_list
from scrape import get_existing_parolees
def format_date(date):
if int(date) <= 50:
date = 2000 + int(date)
return date
elif int(date) > 50 and int(date) < 100:
date = 1900 + int(date)
return date
else:
return date
def get_year_of_entry(parolee):
year_of_entry = format_date(parolee['din'][0:2])
parolee['year of entry'] = year_of_entry
return parolee
def set_security_level(parolee):
"""
Takes a dictionary, finds the facility keys,
and creates a key value pair with the security for that facility.
"""
h_i_facility = parolee['housing or interview facility']
h_r_facility = parolee['housing/release facility']
h_i_sec_level = prison_list.PRISONS[h_i_facility]
h_r_sec_level = prison_list.PRISONS[h_r_facility]
parolee['housing/interview facility security level'] = h_i_sec_level
parolee['housing/release facility security level'] = h_r_sec_level
return parolee
def simplify_outcomes(parolee):
"""
Takes a parolee, finds the outcome,
and creates a key value pair with a simplified outcome.
"""
decisions = {
'ODOP': 'release',
'PAROLED': 'release',
'GRANTED': 'release',
'REINSTATE': 'release',
'OPEN DATE': 'release',
'NO SUSREV': 'release',
'DENIED': 'denial',
'NOT GRANTD': 'denial',
'M V NO S': 'denial',
'M V SUS': 'denial',
'SUST-REV': 'denial',
'RCND&HOLD': 'ambiguous',
'RCND&RELSE': 'ambiguous',
'OR EARLIER': 'ambiguous'
}
parolee_decision = parolee['interview decision']
parolee['interview decision category'] = decisions[parolee_decision]
return parolee