Package jazzparser :: Package parsers :: Package tagrank :: Module inspector
[hide private]
[frames] | no frames]

Source Code for Module jazzparser.parsers.tagrank.inspector

 1  """Chart inspector for the tag rank parser. 
 2   
 3  Some small extensions to the CKY chart inspector for the tag rank  
 4  parser. 
 5   
 6  See L{jazzparser.parsers.cky.inspector} for details. 
 7   
 8  """ 
 9  """ 
10  ============================== License ======================================== 
11   Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding 
12    
13   This file is part of The Jazz Parser. 
14    
15   The Jazz Parser is free software: you can redistribute it and/or modify 
16   it under the terms of the GNU General Public License as published by 
17   the Free Software Foundation, either version 3 of the License, or 
18   (at your option) any later version. 
19    
20   The Jazz Parser is distributed in the hope that it will be useful, 
21   but WITHOUT ANY WARRANTY; without even the implied warranty of 
22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
23   GNU General Public License for more details. 
24    
25   You should have received a copy of the GNU General Public License 
26   along with The Jazz Parser.  If not, see <http://www.gnu.org/licenses/>. 
27   
28  ============================ End license ====================================== 
29   
30  """ 
31  __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>"  
32   
33  from jazzparser.parsers.cky.inspector import ChartInspectorThread, \ 
34                      ChartInspectorWindow, CellInspectorWindow 
35  # Gtk version check already done in cky.inspector 
36  import gtk, gobject 
37   
38 -class TagRankCellInspectorWindow(CellInspectorWindow):
39 - def _create_column_data(self):
40 """ 41 Override to add extra column to the cell inspector. 42 43 """ 44 liststore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) 45 # Add all the signs to the store 46 for sign in reversed(sorted(self.signs, key=lambda s: s.probability)): 47 liststore.append(["%f" % sign.probability, "%s" % sign]) 48 return liststore
49
50 - def _create_columns(self):
51 """ 52 Override to add extra column. 53 54 """ 55 # Add a column to the treeview to display the probabilities 56 prob_column = gtk.TreeViewColumn("Probability") 57 self.treeview.append_column(prob_column) 58 # Render the probabilities as text 59 prob_renderer = gtk.CellRendererText() 60 prob_column.pack_start(prob_renderer, True) 61 prob_column.add_attribute(prob_renderer, "text", 0) 62 63 # Add the sign column as before 64 sign_column = gtk.TreeViewColumn("Signs on edge (%d,%d)" % (self.from_node, self.to_node)) 65 self.treeview.append_column(sign_column) 66 # Render the signs as text 67 sign_renderer = gtk.CellRendererText() 68 sign_renderer.set_property('family', 'monospace') 69 sign_column.pack_start(sign_renderer, True) 70 sign_column.add_attribute(sign_renderer, "text", 1) 71 72 # Search signs by the main column 73 self.treeview.set_search_column(1)
74
75 -class TagRankChartInspectorWindow(ChartInspectorWindow):
76 CELL_INSPECTOR_IMPL = TagRankCellInspectorWindow
77
78 -class TagRankChartInspectorThread(ChartInspectorThread):
79 INSPECTOR_IMPL = TagRankChartInspectorWindow
80