def corpus_to_vw(corpus):
 for entries in corpus:
  line = [u'|']
  for (word_id, count) in entries:
   line.append(u'{0}:{1}'.format(word_id, count))
  (yield u' '.join(line))

def corpus_to_vw ( corpus ) : for entries in corpus : line = [ u'|' ] for ( word_id , count ) in entries : line . append ( u'{0}:{1}' . format ( word_id , count ) ) ( yield u' ' . join ( line ) )
iterate over corpus .