class_docstr: Corpus in Blei's LDA-C format.
  
  The corpus is represented as two files: one describing the documents, and another
  describing the mapping between words and their ids.
  
  Each document is one line::
  
      N fieldId1:fieldValue1 fieldId2:fieldValue2 ... fieldIdN:fieldValueN
  
  
  The vocabulary is a file with words, one word per line; word at line K has an implicit `id=K`.
class_docstr_tok: ["Corpus","in","Blei","'s","LDA-C","format",".","The","corpus","is","represented","as","two","files",":","one","describing","the","documents",",","and","another","describing","the","mapping","between","words","and","their","ids",".","Each","document","is","one","line",":",":","N","fieldId1",":","fieldValue1","fieldId2",":","fieldValue2","...","fieldIdN",":","fieldValueN","The","vocabulary","is","a","file","with","words",",","one","word","per","line",";","word","at","line","K","has","an","implicit","`","id=K","`","."]
docstr: Save a corpus in the LDA-C format.
  
  Notes
  -----
  There are actually two files saved: `fname` and `fname.vocab`, where `fname.vocab` is the vocabulary file.
  
  Parameters
  ----------
  fname : str
      Path to output file.
  corpus : iterable of iterable of (int, float)
      Input corpus in BoW format.
  id2word : dict of (str, str), optional
      Mapping id -> word for `corpus`.
  metadata : bool, optional
      THIS PARAMETER WILL BE IGNORED.
  
  Returns
  -------
  list of int
      Offsets for each line in file (in bytes).
docstr_tok: ["Save","a","corpus","in","the","LDA-C","format",".","Notes","--","--","-","There","are","actually","two","files","saved",":","`","fname","`","and","`","fname.vocab","`",",","where","`","fname.vocab","`","is","the","vocabulary","file",".","Parameters","--","--","--","--","--","fname",":","str","Path","to","output","file",".","corpus",":","iterable","of","iterable","of","(","int",",","float",")","Input","corpus","in","BoW","format",".","id2word",":","dict","of","(","str",",","str",")",",","optional","Mapping","id","-",">","word","for","`","corpus","`",".","metadata",":","bool",",","optional","THIS","PARAMETER","WILL","BE","IGNORED",".","Returns","--","--","--","-","list","of","int","Offsets","for","each","line","in","file","(","in","bytes",")","."]
code: def save_corpus(fname, corpus, id2word=None, metadata=False):
      """Save a corpus in the LDA-C format.
  
      Notes
      -----
      There are actually two files saved: `fname` and `fname.vocab`, where `fname.vocab` is the vocabulary file.
  
      Parameters
      ----------
      fname : str
          Path to output file.
      corpus : iterable of iterable of (int, float)
          Input corpus in BoW format.
      id2word : dict of (str, str), optional
          Mapping id -> word for `corpus`.
      metadata : bool, optional
          THIS PARAMETER WILL BE IGNORED.
  
      Returns
      -------
      list of int
          Offsets for each line in file (in bytes).
  
      """
      if id2word is None:
          logger.info(
              "no word id mapping provided; initializing from corpus"
          )
          id2word = utils.dict_from_corpus(corpus)
          num_terms = len(id2word)
      elif id2word:
          num_terms = 1 + max(id2word)
      else:
          num_terms = 0
  
      logger.info(
          "storing corpus in Blei's LDA-C format into %s", fname
      )
      with utils.open(fname, "wb") as fout:
          offsets = []
          for doc in corpus:
              doc = list(doc)
              offsets.append(fout.tell())
              parts = ["%i:%g" % p for p in doc if abs(p[1]) > 1e-7]
              fout.write(
                  utils.to_utf8("%i %s\n" % (len(doc), " ".join(parts)))
              )
  
      # write out vocabulary, in a format compatible with Blei's topics.py script
      fname_vocab = utils.smart_extension(fname, ".vocab")
      logger.info(
          "saving vocabulary of %i words to %s", num_terms, fname_vocab
      )
      with utils.open(fname_vocab, "wb") as fout:
          for featureid in range(num_terms):
              fout.write(
                  utils.to_utf8("%s\n" % id2word.get(featureid, "---"))
              )
  
      return offsets
  
file_path: gensim/gensim/corpora/bleicorpus.py
imports: from __future__ import with_statement
  from os import path
  import logging
  from gensim import utils
  from gensim.corpora import IndexedCorpus
label_desc: Use image node_id 4 for calling the BleiCorpus obj's underlying member method code with example usage: obj.save_corpus(fname, corpus, id2word, metadata) and returns: offsets