def _manufacture_delivery(name, level, statute): if any([ manu_del_keyword in name for manu_del_keyword in ["delivery", "manu/del", "manufactur"] ]): if any([ schedule_2_keyword in name for schedule_2_keyword in ["2", "ii", "heroin", "cocaine", "meth"] ]): if level == "Felony Unclassified": question_string = "Was the charge for an A Felony or B Felony?" options = { "A Felony": FelonyClassA(), "B Felony": FelonyClassB() } return ChargeClassifier._build_ambiguous_charge_type_with_question( question_string, options) elif any([ schedule_3_keyword in name for schedule_3_keyword in ["3", "iii", "4", " iv"] ]): return ChargeClassifier._classification_by_level( level, statute) else: # The name contains either a "1" or no schedule number, and thus is possibly a marijuana charge. question_string = "Was the underlying substance marijuana?" charge_types_with_question = ChargeClassifier._classification_by_level( level, statute) if level == "Felony Unclassified": felony_unclassified_question_id = ( f"{question_string}-No-{charge_types_with_question.question.question_id}" ) felony_unclassified_question = replace( charge_types_with_question.question, question_id=felony_unclassified_question_id) charge_types = [ MarijuanaEligible() ] + charge_types_with_question.ambiguous_charge_type question = Question( question_string, question_string, { "Yes": Answer(edit={ "charge_type": MarijuanaEligible.__name__ }), "No": Answer(question=felony_unclassified_question), }, ) return AmbiguousChargeTypeWithQuestion( charge_types, question) elif level == "Felony Class A" or level == "Felony Class B": charge_type = charge_types_with_question.ambiguous_charge_type[ 0] options = {"Yes": MarijuanaEligible(), "No": charge_type} return ChargeClassifier._build_ambiguous_charge_type_with_question( question_string, options)
def _classification_by_level(level, statute): if "misdemeanor" in level: return AmbiguousChargeTypeWithQuestion([Misdemeanor()]) if level == "felony class c": return AmbiguousChargeTypeWithQuestion([FelonyClassC()]) if level == "felony class b": if ChargeClassifier._person_felony(statute): return AmbiguousChargeTypeWithQuestion([PersonFelonyClassB()]) else: return AmbiguousChargeTypeWithQuestion([FelonyClassB()]) if level == "felony class a": return AmbiguousChargeTypeWithQuestion([FelonyClassA()]) if level == "felony unclassified": question_string = "Was the charge for an A Felony, B Felony, or C Felony?" options = { "A Felony": FelonyClassA(), "B Felony": FelonyClassB(), "C Felony": FelonyClassC() } return ChargeClassifier._build_ambiguous_charge_type_with_question( question_string, options)
def _manudel_schedule_2_handler(level): if level == "felony unclassified": question_string = "Was the charge for an A Felony or B Felony?" options = {"A Felony": FelonyClassA(), "B Felony": FelonyClassB()} return ChargeClassifier._build_ambiguous_charge_type_with_question( question_string, options)
def _other_criminal_charges(statute): possession_of_weapon_by_prison_inmate = "166275" if statute == possession_of_weapon_by_prison_inmate: return AmbiguousChargeTypeWithQuestion([FelonyClassA()])