def make_complaints(self, count=1000): complaints = [] for x in range(0, count): assignment = self.generate_assignment() allegation = self.generate_allegation() complaints.append({ "opaqueId": self.hash(random_string(10)), "serviceType": self.generate_service_type(), "source": self.generate_source(), "occuredDate": random_date(datetime(2014, 1, 1), datetime(2016, 1, 1)).strftime("%Y-%m-%d 0:0:00"), "division": assignment["division"], "precinct": assignment["precinct"], "shift": assignment["shift"], "beat": assignment["beat"], "allegationType": allegation["allegationType"], "allegation": allegation["allegation"], "disposition": self.generate_disposition(), "residentRace": self.generate_race(), "residentSex": self.generate_sex(), "residentAge": str(random.randint(15, 70)), "officerIdentifier": self.hash(random_string(10)), "officerRace": self.generate_race(), "officerSex": self.generate_sex(), "officerAge": str(random.randint(23, 50)), "officerYearsOfService": str(random.randint(0, 27)) }) return complaints
def make_ois(self, count=1000, start_date=datetime.datetime(2014, 1, 1), end_date=datetime.datetime(2016, 1, 1)): incidents = [] for x in range(0, count): assignment = self.generate_assignment() incidents.append({ "opaqueId": self.hash(random_string(10)), "serviceType": self.generate_service_type(), "occuredDate": random_date(start_date, end_date).strftime("%Y-%m-%d 0:0:00"), "occuredTime": "", "division": assignment["division"], "precinct": assignment["precinct"], "shift": assignment["shift"], "beat": assignment["beat"], "disposition": self.generate_disposition(), "residentRace": self.generate_race(), "residentSex": self.generate_sex(), "residentAge": str(random.randint(15, 70)), "residentWeaponUsed": self.generate_ois_resident_force_type(), "residentCondition": self.generate_condition(), "officerIdentifier": self.hash(random_string(10)), "officerForceType": self.generate_ois_officer_force_type(), "officerRace": self.generate_race(), "officerSex": self.generate_sex(), "officerAge": str(random.randint(23, 50)), "officerYearsOfService": random.randint(0, 27), "officerCondition": self.generate_condition() }) return incidents
def make_ois(self, count=1000): incidents = [] for x in range(0, count): assignment = self.generate_assignment() incidents.append({ "opaqueId": self.hash(random_string(10)), "serviceType": self.generate_service_type(), "occuredDate": random_date(datetime(2014, 1, 1), datetime(2016, 1, 1)).strftime("%Y-%m-%d 0:0:00"), "occuredTime": "", "division": assignment["division"], "precinct": assignment["precinct"], "shift": assignment["shift"], "beat": assignment["beat"], "disposition": self.generate_disposition(), "residentRace": self.generate_race(), "residentSex": self.generate_sex(), "residentAge": str(random.randint(15, 70)), "residentWeaponUsed": self.generate_ois_resident_force_type(), "residentCondition": self.generate_condition(), "officerIdentifier": self.hash(random_string(10)), "officerForceType": self.generate_ois_officer_force_type(), "officerRace": self.generate_race(), "officerSex": self.generate_sex(), "officerAge": str(random.randint(23, 50)), "officerYearsOfService": random.randint(0, 27), "officerCondition": self.generate_condition() }) return incidents
def make_complaints(self, count=1000, start_date=datetime.datetime(2014, 1, 1), end_date=datetime.datetime(2016, 1, 1)): # make a smaller pool of officers so that it's possible to have more than one complaint per officer officers = [] officer_count = round(count * .33) for x in range(0, count): officers.append({ "officerIdentifier": self.hash(random_string(10)), "officerRace": self.generate_race(), "officerSex": self.generate_sex(), "officerAge": str(random.randint(23, 50)), "officerYearsOfService": str(random.randint(0, 27)) }) complaints = [] for x in range(0, count): assignment = self.generate_assignment() allegation = self.generate_allegation() new_complaint = { "opaqueId": self.hash(random_string(10)), "serviceType": self.generate_service_type(), "source": self.generate_source(), "occuredDate": random_date(start_date, end_date).strftime("%Y-%m-%d 0:0:00"), "division": assignment["division"], "precinct": assignment["precinct"], "shift": assignment["shift"], "beat": assignment["beat"], "allegationType": allegation["allegationType"], "allegation": allegation["allegation"], "disposition": self.generate_disposition(), "residentRace": self.generate_race(), "residentSex": self.generate_sex(), "residentAge": str(random.randint(15, 70)) } new_complaint.update(random.choice(officers)) complaints.append(new_complaint) return complaints
def make_uof(self, count=1000, start_date=datetime.datetime(2014, 1, 1), end_date=datetime.datetime(2016, 1, 1)): incidents = [] for x in range(0, count): assignment = self.generate_assignment() incidents.append({ "opaqueId": self.hash(random_string(10)), "occuredDate": random_date(start_date, end_date).strftime("%Y-%m-%d 0:0:00"), "occuredTime": "", "division": assignment["division"], "precinct": assignment["precinct"], "shift": assignment["shift"], "beat": assignment["beat"], "disposition": self.generate_disposition(), "officerForceType": self.generate_officer_force_type(), "useOfForceReason": self.generate_use_of_force_reason(), "serviceType": self.generate_service_type(), "arrestMade": self.generate_bool(), "arrestCharges": self.generate_arrest_charges(), "residentWeaponUsed": "", "residentInjured": self.generate_bool(), "residentHospitalized": self.generate_bool(), "officerInjured": self.generate_bool(), "officerHospitalized": self.generate_bool(), "residentRace": self.generate_race(), "residentSex": self.generate_sex(), "residentAge": str(random.randint(15, 70)), "residentCondition": self.generate_condition(), "officerIdentifier": self.hash(random_string(10)), "officerRace": self.generate_race(), "officerSex": self.generate_sex(), "officerAge": str(random.randint(23, 50)), "officerYearsOfService": str(random.randint(0, 27)), "officerCondition": self.generate_condition() }) return incidents
def alter_data(self, incident): for x in range(0, math.floor(len(incident) * self.percent)): field_to_drop = random.choice(list(incident.keys())) if field_to_drop not in self.do_not_mutate: incident[field_to_drop] = random_string(random.randint(0, 140)) return incident
def make_value(self, value_key, **kwargs): ''' make a convincing fake value for the key ''' if value_key in ["arrestMade", "officerInjured", "officerKilled", "reportFiled", "residentInjured", "residentHospitalized", "officerHospitalized", "hasDisposition"]: return self.generate_bool() if value_key in ["opaqueId", "officerIdentifier", "residentIdentifier"]: return self.hash(random_string(10)) if value_key in ["caseNumber"]: return self.generate_case_number() if value_key in ["officerRace", "residentRace"]: return self.generate_race() if value_key in ["officerSex", "residentSex"]: return self.generate_sex() if value_key in ["officerAge", "residentAge"]: return str(random.randint(23, 50)) if value_key in ["officerCondition", "residentCondition"]: return self.generate_condition() if value_key == "officerYearsOfService": return str(random.randint(0, 27)) if value_key == "serviceType": return self.generate_service_type() if value_key == "source": return self.generate_source() if value_key == "occuredDate": return random_date(kwargs['start_date'], kwargs['end_date']).strftime("%Y-%m-%d 0:0:00") if value_key == "occuredTime": return "" if value_key == "division": return self.generate_division(short_name=kwargs['short_name']) if value_key == "precinct": return self.generate_precinct() if value_key == "shift": return self.generate_shift() if value_key == "beat": return self.generate_beat() if value_key == "bureau": return self.generate_bureau(short_name=kwargs['short_name']) if value_key == "assignment": return self.generate_assignment() if value_key == "unit": return self.generate_unit() if value_key == "platoon": return self.generate_platoon() if value_key == "allegationType": return self.generate_allegation_type() if value_key == "allegation": return self.generate_allegation() if value_key == "disposition": return self.generate_disposition() if value_key == "officerForceType": return self.generate_officer_force_type() if value_key == "useOfForceReason": return self.generate_use_of_force_reason() if value_key == "arrestCharges": return self.generate_arrest_charges() if value_key == "residentWeaponUsed": return ""
def make_value(self, value_key, **kwargs): ''' make a convincing fake value for the key ''' if value_key in [ "arrestMade", "officerInjured", "officerKilled", "reportFiled", "residentInjured", "residentHospitalized", "officerHospitalized" ]: return self.generate_bool() if value_key in [ "opaqueId", "officerIdentifier", "residentIdentifier" ]: return self.hash(random_string(10)) if value_key in ["officerRace", "residentRace"]: return self.generate_race() if value_key in ["officerSex", "residentSex"]: return self.generate_sex() if value_key in ["officerAge", "residentAge"]: return str(random.randint(23, 50)) if value_key in ["officerCondition", "residentCondition"]: return self.generate_condition() if value_key == "officerYearsOfService": return str(random.randint(0, 27)) if value_key == "serviceType": return self.generate_service_type() if value_key == "source": return self.generate_source() if value_key == "occuredDate": return random_date(kwargs['start_date'], kwargs['end_date']).strftime("%Y-%m-%d 0:0:00") if value_key == "occuredTime": return "" if value_key == "division": return self.generate_division(short_name=kwargs['short_name']) if value_key == "precinct": return self.generate_precinct() if value_key == "shift": return self.generate_shift() if value_key == "beat": return self.generate_beat() if value_key == "bureau": return self.generate_bureau(short_name=kwargs['short_name']) if value_key == "assignment": return self.generate_assignment() if value_key == "unit": return self.generate_unit() if value_key == "platoon": return self.generate_platoon() if value_key == "allegationType": return self.generate_allegation_type() if value_key == "allegation": return self.generate_allegation() if value_key == "disposition": return self.generate_disposition() if value_key == "officerForceType": return self.generate_officer_force_type() if value_key == "useOfForceReason": return self.generate_use_of_force_reason() if value_key == "arrestCharges": return self.generate_arrest_charges() if value_key == "residentWeaponUsed": return ""