def sentence_iterator(corpus_iterator):
 current_sentence = []
 for l in corpus_iterator:
  if (l == (None, None)):
   if current_sentence:
    (yield current_sentence)
    current_sentence = []
   else:
    sys.stderr.write('WARNING: Got empty input file/stream.\n')
    raise StopIteration
  else:
   current_sentence.append(l)
 if current_sentence:
  (yield current_sentence)

def sentence_iterator ( corpus_iterator ) : current_sentence = [ ] for l in corpus_iterator : if ( l == ( None , None ) ) : if current_sentence : ( yield current_sentence ) current_sentence = [ ] else : sys . stderr . write ( 'WARNING: Got empty input file/stream.\n' ) raise StopIteration else : current_sentence . append ( l ) if current_sentence : ( yield current_sentence )
return an iterator object that yields one sentence at a time .