1 """Gold standard comparison shell tools
2
3 Some additional tools for the Jazz Parser interactive shell for
4 comparing results to a gold standard.
5
6 """
7 """
8 ============================== License ========================================
9 Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding
10
11 This file is part of The Jazz Parser.
12
13 The Jazz Parser is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 The Jazz Parser is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with The Jazz Parser. If not, see <http://www.gnu.org/licenses/>.
25
26 ============================ End license ======================================
27
28 """
29 __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>"
30
31 from .tools import Tool
32
56
85 state.formalism.Syntax.Sign.__str__ = _mark_str(state.formalism.Syntax.Sign.__str__)
86
87
88 for i,chord in enumerate(gs_seq.iterator()):
89 tag = chord.category
90 found = False
91 for sign in state.parser.chart.get_signs(i, i+1):
92
93 if hasattr(sign, 'tag') and sign.tag == tag:
94 found = True
95 print "Found correct tag for position %d: %s" % (i,sign)
96 sign._str_prepend = "***"
97 if not found:
98 print "Correct tag not found for position %d" % i
99 state._markcorrect_run = True
100
102 from .shell import ShellError
103 if not hasattr(state, 'gs_sequences'):
104 raise ShellError, "The no gold standard has been loaded. Use the loadgs command to load a file."
105
107 _check_gs_loaded(state)
108 if id not in state.gs_sequences.ids:
109 raise ShellError, "The loaded gold standard doesn't include the sequence with id %s" % id
110
112 from .shell import ShellError
113 if state.seq_id is None:
114 raise ShellError, "Not sequence id available for parsed sequence: cannot run this tool"
115 return state.seq_id
116