static MalletCorpus.save_corpus(fname, corpus, id2word=None, metadata=False)[source]

Save a corpus in the Mallet format.

The document id will be generated by enumerating the corpus. That is, it will range between 0 and number of documents in the corpus.

Since Mallet has a language field in the format, this defaults to the string ‘__unknown__’. If the language needs to be saved, post-processing will be required.

This function is automatically called by MalletCorpus.serialize; don’t call it directly, call serialize instead.