def read_conll(file_):
 sents = []
 for sent_str in file_.read().strip().split(u'\n\n'):
  ids = []
  words = []
  heads = []
  labels = []
  tags = []
  for (i, line) in enumerate(sent_str.split(u'\n')):
   (word, pos_string, head_idx, label) = _parse_line(line)
   words.append(word)
   if (head_idx < 0):
    head_idx = i
   ids.append(i)
   heads.append(head_idx)
   labels.append(label)
   tags.append(pos_string)
  text = u' '.join(words)
  annot = (ids, words, tags, heads, labels, ([u'O'] * len(ids)))
  sents.append((None, [(annot, [])]))
 return sents

def read_conll ( file_ ) : sents = [ ] for sent_str in file_ . read ( ) . strip ( ) . split ( u'\n\n' ) : ids = [ ] words = [ ] heads = [ ] labels = [ ] tags = [ ] for ( i , line ) in enumerate ( sent_str . split ( u'\n' ) ) : ( word , pos_string , head_idx , label ) = _parse_line ( line ) words . append ( word ) if ( head_idx < 0 ) : head_idx = i ids . append ( i ) heads . append ( head_idx ) labels . append ( label ) tags . append ( pos_string ) text = u' ' . join ( words ) annot = ( ids , words , tags , heads , labels , ( [ u'O' ] * len ( ids ) ) ) sents . append ( ( None , [ ( annot , [ ] ) ] ) ) return sents
read a standard conll/malt-style format .