#!/usr/bin/env python3 import os import re import string import sys as _sys def split_into_sentences(text): # Define the regular expression pattern for sentence splitting pattern = r'(? str: """ Normalize response text. """ if text[:4].lower() in ["yes,", "yes ", "yes."]: text = text[4:].strip() elif text[:3].lower() in ["no,", "no ", "no."]: text = text[3:].strip() if text[0] in string.punctuation and text[0] not in "({[": text = text[1:].strip() new_text = normalize_text(text) if new_text and new_text[-1] not in "!.?)\"'": new_text += "." return new_text def uppercase(string: str) -> str: """ Make the first character of the string uppercase, if the string is non-empty. """ if len(string) == 0: return string else: return string[0].upper() + string[1:]