def disambiguate_record(ambiguous_record, questions_data): questions_as_list = [ from_dict(data_class=Question, data=question) for id, question in questions_data.items() ] questions = dict( list(map(lambda q: (q.ambiguous_charge_id, q), questions_as_list))) updated_ambiguous_record = RecordMerger.filter_ambiguous_record( ambiguous_record, questions_as_list) record = RecordCreator.analyze_ambiguous_record( updated_ambiguous_record) return questions, record
def build_response(ambiguous_record: AmbiguousRecord, questions_data: Dict[str, Any]): questions = [ from_dict(data_class=Question, data=question) for id, question in questions_data.items() ] questions_as_dict = dict( list(map(lambda q: (q.ambiguous_charge_id, q), questions))) updated_ambiguous_record = RecordMerger.filter_ambiguous_record( ambiguous_record, questions) record = RecordCreator.analyze_ambiguous_record( updated_ambiguous_record) record_summary = RecordSummarizer.summarize(record, questions_as_dict) response_data = {"data": {"record": record_summary}} return json.dumps(response_data, cls=ExpungeModelEncoder)