def read_left_context_phones(filename):
    "Reads, checks, and returns a list of left-context phones, in text form, one\n       per line.  Returns a list of strings, e.g. ['a', 'ah', ..., '#nonterm_bos' ]"
    ans = [line.strip(' \t\r\n') for line in open(filename, 'r', encoding='latin-1')]
    if (len(ans) == 0):
        raise RuntimeError('The file {0} contains no left-context phones.'.format(filename))
    whitespace = re.compile('[ \t]+')
    for s in ans:
        if (len(whitespace.split(s)) != 1):
            raise RuntimeError("The file {0} contains an invalid line '{1}'".format(filename, s))
    if (len(set(ans)) != len(ans)):
        raise RuntimeError('Duplicate nonterminal symbols are present in file {0}'.format(filename))
    return ans
Reads, checks, and returns a list of left-context phones, in text form, one
per line.  Returns a list of strings, e.g. ['a', 'ah', ..., '#nonterm_bos' ]
def read_left_context_phones(filename):
    "Reads, checks, and returns a list of left-context phones, in text form, one\n       per line.  Returns a list of strings, e.g. ['a', 'ah', ..., '#nonterm_bos' ]"
    ans = [line.strip(' \t\r\n') for line in open(filename, 'r', encoding='latin-1')]
    if (len(ans) == 0):
        raise RuntimeError('The file {0} contains no left-context phones.'.format(filename))
    whitespace = re.compile('[ \t]+')
    for s in ans:
        if (len(whitespace.split(s)) != 1):
            raise RuntimeError("The file {0} contains an invalid line '{1}'".format(filename, s))
    if (len(set(ans)) != len(ans)):
        raise RuntimeError('Duplicate nonterminal symbols are present in file {0}'.format(filename))
    return ans