def test_parse(self): path = bllip_wrapper.init_model() rrp = RerankingParser.from_unified_model_dir(path) tree = bllip_wrapper.parse(rrp, 'hello world!') self.assertIsNotNone(tree) print tree.ptb_parse self.assertEqual(str(tree.ptb_parse), '(S1 (S (NP (NN hello) (NN world) (NN !))))')
parser.add_argument("-v", "--verbose", action="store_true", help="print debug information") args = parser.parse_args() if args.verbose: logging.basicConfig(level=logging.DEBUG) if not os.path.isfile(args.input): sys.stderr.write('Cannot find input file: %s\n' % args.input) sys.exit(2) logging.info('Input file: %s' % args.input) logging.info('Output file: %s' % args.output) return args.input, args.output if __name__ == "__main__": inputfilename, outputfilename = parse_argv() model_dir = init_model() logging.info('loading model %s ...' % model_dir) rrp = RerankingParser.from_unified_model_dir(model_dir) collection = parse(inputfilename) collection.clear_infons() collection.infons['tool'] = 'Bllip' collection.infons['process'] = 'parse' parse_bioc(rrp, collection) collection.tobiocfile(outputfilename)
def test_init_model(self): path = bllip_wrapper.init_model() self.assertIsNotNone(path) print 'Model path:', path