(wordlist, dbfile, fieldname="_", strip=True)
Writes a word graph file from a list of words.

    >>> # Open a word list file with one word on each line, and write the
    >>> # word graph to a graph file
    >>> wordlist_to_graph_file("mywords.txt", "mywords.dawg")

    :param wordlist: an iterable containing the words for the graph. The words
        must be in sorted order.
    :param dbfile: a filename string or file-like object to write the word
        graph to. This function will close the file.
Writes a word graph file from a list of words.
Writes a word graph file from a list of words .
def wordlist_to_graph_file(wordlist, dbfile, fieldname="_", strip=True):
    """Writes a word graph file from a list of words.

    >>> # Open a word list file with one word on each line, and write the
    >>> # word graph to a graph file
    >>> wordlist_to_graph_file("mywords.txt", "mywords.dawg")

    :param wordlist: an iterable containing the words for the graph. The words
        must be in sorted order.
    :param dbfile: a filename string or file-like object to write the word
        graph to. This function will close the file.
    """

    from whoosh.filedb.structfile import StructFile
    if isinstance(dbfile, string_type):
        dbfile = open(dbfile, "wb")
    if not isinstance(dbfile, StructFile):
        dbfile = StructFile(dbfile)

    gw = fst.GraphWriter(dbfile)
    gw.start_field(fieldname)
    for word in wordlist:
        if strip:
            word = word.strip()
        gw.insert(word)
    gw.finish_field()
    gw.close()
def wordlist_to_graph_file ( wordlist , dbfile , fieldname = "_" , strip = True ) : from whoosh . filedb . structfile import StructFile if isinstance ( dbfile , string_type ) : dbfile = open ( dbfile , "wb" ) if not isinstance ( dbfile , StructFile ) : dbfile = StructFile ( dbfile ) gw = fst . GraphWriter ( dbfile ) gw . start_field ( fieldname ) for word in wordlist : if strip : word = word . strip ( ) gw . insert ( word ) gw . finish_field ( ) gw . close ( )