# Work out the minimal span to show all errors gold_spans = set([(node.label, node.span[0], node.span[1]) for node in gold_tree.get_nodes()]) test_spans = set([(node.label, node.span[0], node.span[1]) for node in test_tree.get_nodes()]) diff = gold_spans.symmetric_difference(test_spans) width = [1e5, -1] for span in diff: if span[2] - span[1] == 1: continue if span[1] < width[0]: width[0] = span[1] if span[2] > width[1]: width[1] = span[2] mprint('\n\\scalebox{\\derivscale}{', out, 'tex') mprint(render_tree.tex_synttree(test_tree, gold_spans, span=width), out, 'tex') mprint( '}\n\\small\n(a) Parser output\n\n\\vspace{3mm}\n\\scalebox{\\derivscale}{', out, 'tex') mprint(render_tree.tex_synttree(gold_tree, test_spans, span=width), out, 'tex') mprint('}\n\\small\n(b) Gold tree\n\\pagebreak', out, 'tex') mprint("", out, 'all') match = stats['out'][0] gold = stats['out'][1] test = stats['out'][2] p, r, f = nlp_eval.calc_prf(match, gold, test) mprint("Overall %s: %.2f %.2f %.2f" % ('out', p * 100, r * 100, f * 100), out, 'out')
if gold_tree is not None: treebanks.remove_trivial_unaries(gold_tree) # Print tree if out_format == 's': print render_tree.text_tree(tree, single_line=True) elif out_format == 'm': print render_tree.text_tree(tree, single_line=False) elif out_format == 'o': print render_tree.text_ontonotes(tree) elif out_format == 'p': print render_tree.text_POS_tagged(tree) elif out_format == 't': if gold_tree is None: print '\\scalebox{\\derivscale}{' print render_tree.tex_synttree(tree) print '}\n\\small\n\\pagebreak' else: print '\\scalebox{\\derivscale}{' other_spans = gold_tree.span_dict() print render_tree.tex_synttree(tree, other_spans) print '}\n\\small\n\\pagebreak' print '\\scalebox{\\derivscale}{' other_spans = tree.span_dict() print render_tree.tex_synttree(gold_tree, other_spans) print '}\n\\small\n\\pagebreak' elif out_format == 'w': print render_tree.text_words(tree) if out_format == 't': print '\\end{document}'
stats['out'][2] += test p, r, f = nlp_eval.calc_prf(match, gold, test) mprint("Eval: %.2f %.2f %.2f" % (p*100, r*100, f*100), out, 'out') # Work out the minimal span to show all errors gold_spans = set([(node.label, node.span[0], node.span[1]) for node in gold_tree.get_nodes()]) test_spans = set([(node.label, node.span[0], node.span[1]) for node in test_tree.get_nodes()]) diff = gold_spans.symmetric_difference(test_spans) width = [1e5, -1] for span in diff: if span[2] - span[1] == 1: continue if span[1] < width[0]: width[0] = span[1] if span[2] > width[1]: width[1] = span[2] mprint('\n\\scalebox{\\derivscale}{', out, 'tex') mprint(render_tree.tex_synttree(test_tree, gold_spans, span=width), out, 'tex') mprint( '}\n\\small\n(a) Parser output\n\n\\vspace{3mm}\n\\scalebox{\\derivscale}{', out, 'tex') mprint(render_tree.tex_synttree(gold_tree, test_spans, span=width), out, 'tex') mprint( '}\n\\small\n(b) Gold tree\n\\pagebreak', out, 'tex') mprint("", out, 'all') match = stats['out'][0] gold = stats['out'][1] test = stats['out'][2] p, r, f = nlp_eval.calc_prf(match, gold, test) mprint("Overall %s: %.2f %.2f %.2f" % ('out', p*100, r*100, f*100), out, 'out') mprint('\\end{document}', out, 'tex')