human
Complete the below
def get_or_generate_txt_vocab(data_dir, vocab_filename, vocab_size, filepatterns):

    ''''Generate a vocabulary from txt files with example-per-line.'
    '''

Can you provide a the Python program you requested?
assistant
#Here is the Python program you requested.
    if isinstance(filepatterns, str):
        filepatterns = [filepatterns]
    def generate():
        tf.logging.info('Generating    vocab    from    %s', filepatterns)
        for filepattern in filepatterns:
            for filename in tf.gfile.Glob(filepattern):
                with tf.gfile.GFile(filename, mode='r') as source_file:
                    for line in source_file:
                        (yield line.strip())
    return get_or_generate_vocab_inner(data_dir, vocab_filename, vocab_size, generator_fn=generate)