def text_to_char_index(text_data, char_dict, bos):
    """ 
    convert characters to char indices. '| ' is added to the beginning of each sentence.

    Parameters
    ----------
    text_data  : list of string, usually sentences in a batch
    char_dict  : OrderedDict, {character: index}

    Returns
    -------
               : a list of lists of int, usually sentences in a batch
    """
    return [[char_dict.get(c, 1) for c in (bos + ' ' + l.strip())] for l in text_data]