Create a language model (wdnet) for HTK using a very simple single-word grammar

def create_language_model(list_words,
                          grammar_filename,
                          wdnet_filename):
    """Create a language model (wdnet) for HTK using a very simple single-word grammar"""

    # Create the temporary grammar file
    grammar = u''
    grammar += u'$possible_words = '
    grammar += u' | '.join([word for word in list_words])
    grammar += u';\n'

    grammar += u'( [SENT-START] ( $possible_words ) [SENT-END] )\n'

    with codecs.open(grammar_filename, 'w', 'utf-8') as f:
        f.write(grammar)

    # Use HParse to create the wdnet file
    config.htk_command('HParse -A {} {}'.format(grammar_filename, wdnet_filename))

    return