def write_json_corpus ( documents , fnm ) : with codecs . open ( fnm , 'wb' , 'ascii' ) as f : for document in documents : f . write ( json . dumps ( document ) + '\n' ) return documents
how to save a corpus in python
Write a lisst of Text instances as JSON corpus on disk . A JSON corpus contains one document per line encoded in JSON .
def write_json_corpus(documents, fnm):
    """Write a lisst of Text instances as JSON corpus on disk.
    A JSON corpus contains one document per line, encoded in JSON.

    Parameters
    ----------
    documents: iterable of estnltk.text.Text
        The documents of the corpus
    fnm: str
        The path to save the corpus.
    """
    with codecs.open(fnm, 'wb', 'ascii') as f:
        for document in documents:
            f.write(json.dumps(document) + '\n')
    return documents