def write_corpus_as_vw(corpus, filename):
 LOG.debug(u'Writing corpus to: %s', filename)
 corpus_size = 0
 with utils.smart_open(filename, u'wb') as corpus_file:
  for line in corpus_to_vw(corpus):
   corpus_file.write((line.encode(u'utf-8') + '\n'))
   corpus_size += 1
 return corpus_size

def write_corpus_as_vw ( corpus , filename ) : LOG . debug ( u'Writing corpus to: %s' , filename ) corpus_size = 0 with utils . smart_open ( filename , u'wb' ) as corpus_file : for line in corpus_to_vw ( corpus ) : corpus_file . write ( ( line . encode ( u'utf-8' ) + '\n' ) ) corpus_size += 1 return corpus_size
iterate over corpus .