(cls, input_file)
Reads a BIO data.
Reads a BIO data.
Reads a BIO data .
def _read_data(cls, input_file):
        """Reads a BIO data."""
        with open(input_file) as f:
            lines = []
            words = []
            labels = []
            for line in f:
                contends = line.strip()
                word = line.strip().split(' ')[0]
                label = line.strip().split(' ')[-1]
                if contends.startswith("-DOCSTART-"):
                    words.append('')
                    continue
                if len(contends) == 0 and words[-1] == '.':
                    l = ' '.join([label for label in labels if len(label) > 0])
                    w = ' '.join([word for word in words if len(word) > 0])
                    lines.append([l, w])
                    words = []
                    labels = []
                    continue
                if len(contends) == 0:
                    continue
                words.append(word)
                labels.append(label)
            return lines
def _read_data ( cls , input_file ) : with open ( input_file ) as f : lines = [ ] words = [ ] labels = [ ] for line in f : contends = line . strip ( ) word = line . strip ( ) . split ( ' ' ) [ 0 ] label = line . strip ( ) . split ( ' ' ) [ - 1 ] if contends . startswith ( "-DOCSTART-" ) : words . append ( '' ) continue if len ( contends ) == 0 and words [ - 1 ] == '.' : l = ' ' . join ( [ label for label in labels if len ( label ) > 0 ] ) w = ' ' . join ( [ word for word in words if len ( word ) > 0 ] ) lines . append ( [ l , w ] ) words = [ ] labels = [ ] continue if len ( contends ) == 0 : continue words . append ( word ) labels . append ( label ) return lines