File size: 634 Bytes
0fadcb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224e4de
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import re
parse_date_regex = re.compile(r"([0-9]{1,2}/[0-9]{1,2}/[0-9]{4})")
parse_phone_number_regex = re.compile(r"\+?[0-9]*")


def _find_and_parse(llm_answer, regex):
    match = regex.findall(llm_answer)
    return next(iter(match), None) if match else None


def find_and_parse_date(llm_answer: str) -> str | None:
    return _find_and_parse(llm_answer, parse_date_regex)


def find_and_parse_phone_number(llm_answer: str):
    return _find_and_parse(llm_answer, parse_phone_number_regex)


def check_for_missing_answers(parsed_questions: dict[int, str]):
    return [k for k in parsed_questions if parsed_questions[k] is None]