def _attempt_to_commit(name, level, statute):
     if (level == "misdemeanor class a"
             or level == "felony class c") and "attempt to commit" in name:
         question_string = "Was the underlying conduct a sex crime?"
         charge_type_by_level = ChargeClassifier._classification_by_level(
             level, statute).ambiguous_charge_type[0]
         options = {"Yes": SexCrime(), "No": charge_type_by_level}
         return ChargeClassifier._build_ambiguous_charge_type_with_question(
             question_string, options)
     if level == "felony class b" and "attempt to commit" in name:
         question_string = "Was this a drug-related charge?"
         drug_crime_question_string = "Was the underlying substance marijuana?"
         drug_crime_options = {
             "Yes": MarijuanaEligible(),
             "No": FelonyClassB()
         }
         drug_crime_classification = ChargeClassifier._build_ambiguous_charge_type_with_question(
             drug_crime_question_string, drug_crime_options)
         drug_crime_question_id = f"{question_string}-Yes-{drug_crime_classification.question.question_id}"  # type: ignore
         drug_crime_question = replace(drug_crime_classification.question,
                                       question_id=drug_crime_question_id)
         charge_types = drug_crime_classification.ambiguous_charge_type + [
             PersonFelonyClassB()
         ]
         question = Question(
             question_string,
             question_string,
             {
                 "Yes":
                 Answer(question=drug_crime_question),
                 "No":
                 Answer(edit={"charge_type": PersonFelonyClassB.__name__}),
             },
         )
         return AmbiguousChargeTypeWithQuestion(charge_types, question)
Example #2
0
 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)
Example #3
0
 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 _pcs_schedule_2_handler(level):
     if level == "felony unclassified":
         question_string = "Was the charge for a B Felony or C Felony?"
         options = {"B Felony": FelonyClassB(), "C Felony": FelonyClassC()}
         return ChargeClassifier._build_ambiguous_charge_type_with_question(
             question_string, options)