from baseline.utils import convert_bio_to_iobes import os import argparse parser = argparse.ArgumentParser( description='Translate input sequence to output sequence') parser.add_argument('--io_dir', help='Input/Output dir', default='../data') parser.add_argument('--train_file', help='Training file relative name', default='eng.train') parser.add_argument('--valid_file', help='Validation file relative name', default='eng.testa') parser.add_argument('--test_file', help='Test file relative name', default='eng.testb') parser.add_argument('--suffix', help='Suffix to append', default='.iobes') args = parser.parse_args() convert_bio_to_iobes(os.path.join(args.io_dir, args.train_file), os.path.join(args.io_dir, args.train_file + args.suffix)) convert_bio_to_iobes(os.path.join(args.io_dir, args.valid_file), os.path.join(args.io_dir, args.valid_file + args.suffix)) convert_bio_to_iobes(os.path.join(args.io_dir, args.test_file), os.path.join(args.io_dir, args.test_file + args.suffix))
def test_bio_iobes_i_to_e_at_b(): in_ = ['O', 'B-X', 'I-X', 'B-Y', 'I-Y'] gold = ['O', 'B-X', 'E-X', 'B-Y', 'E-Y'] res = convert_bio_to_iobes(in_) assert res == gold
def test(): spans = generate_spans() gold_bio = generate_bio(spans) res = convert_iobes_to_bio(convert_bio_to_iobes(gold_bio)) assert res == gold_bio
def test_bio_iobes_single_b(): in_ = ['O', 'B-X', 'O'] gold = ['O', 'S-X', 'O'] res = convert_bio_to_iobes(in_) assert res == gold
def test(): spans = generate_spans() bio = generate_bio(spans) gold_iobes = generate_iobes(spans) iobes = convert_bio_to_iobes(bio) assert iobes == gold_iobes