import re


def txt2list(txt_path=None):
    """
    Load txt file and split the sentences into a list of strings
    """
    if txt_path is None:
        raise ValueError("txt_path must be specified as a named argument! \
        E.g. txt_path=../dataset/yourfile.txt")

    # Read input sequences from .txt file and put them in a list
    with open(txt_path) as f:
        text = f.read()
    sentences = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s', text)
    try:
        sentences.remove('') # remove possible empty strings
    except:
        None
    
    return sentences