Spaces:
Sleeping
Sleeping
File size: 496 Bytes
0fadcb9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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)
|