Package jazzparser :: Package taggers :: Package segmidi :: Package chordclass :: Module tools
[hide private]
[frames] | no frames]

Source Code for Module jazzparser.taggers.segmidi.chordclass.tools

 1  """Interactive shell tools for the chordclass tagger. 
 2   
 3  """ 
 4  """ 
 5  ============================== License ======================================== 
 6   Copyright (C) 2008, 2010-12 University of Edinburgh, Mark Granroth-Wilding 
 7    
 8   This file is part of The Jazz Parser. 
 9    
10   The Jazz Parser is free software: you can redistribute it and/or modify 
11   it under the terms of the GNU General Public License as published by 
12   the Free Software Foundation, either version 3 of the License, or 
13   (at your option) any later version. 
14    
15   The Jazz Parser is distributed in the hope that it will be useful, 
16   but WITHOUT ANY WARRANTY; without even the implied warranty of 
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
18   GNU General Public License for more details. 
19    
20   You should have received a copy of the GNU General Public License 
21   along with The Jazz Parser.  If not, see <http://www.gnu.org/licenses/>. 
22   
23  ============================ End license ====================================== 
24   
25  """ 
26  __author__ = "Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>"  
27   
28  from jazzparser.shell.tools import Tool 
29   
30 -class StateGridTool(Tool):
31 name = "State grid displayer" 32 commands = [ "states" ] 33 usage = ('states [<time>]', "Show the most probable states for the given timestep, or all timesteps") 34 help = """\ 35 Displays the most probable states from the HMM decoding. 36 """ 37
38 - def run(self, args, state):
39 top_tags = state.tagger.top_tags 40 41 if len(args): 42 time = int(args[0]) 43 timesteps = [(time, top_tags[time])] 44 else: 45 timesteps = enumerate(top_tags) 46 47 # Print out the states for each timestep 48 for time, tags in timesteps: 49 print "### Time %d ###" % time 50 for (prob, (schema, root)) in tags: 51 print " %s, %d (%f)" % (schema, root, prob) 52 print
53