Package jazzparser :: Package taggers :: Package full :: Module tagger
[hide private]
[frames] | no frames]

Source Code for Module jazzparser.taggers.full.tagger

 1  """A tagger that returns all available tag for every word. 
 2   
 3  A trivial full tagger. Assigns all possible tags to every word.  
 4  No statistics, no nothing. 
 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 jazzparser import settings 
32  from jazzparser.utils.input import assign_durations, strip_input 
33  from jazzparser.taggers import Tagger, process_chord_input 
34  from jazzparser.data import Fraction 
35  from jazzparser.utils.options import ModuleOption 
36   
37 -class FullTagger(Tagger):
38 """ 39 The input to this should just be a string. It will assign all 40 possible categories to each word. All signs will have equal 41 probability. 42 """ 43 COMPATIBLE_FORMALISMS = [ 44 'music_roman', 45 'music_keyspan', 46 'music_halfspan', 47 ] 48 TAGGER_OPTIONS = [] 49 INPUT_TYPES = ['db', 'chords'] 50
51 - def __init__(self, *args, **kwargs):
52 super(FullTagger, self).__init__(*args, **kwargs) 53 process_chord_input(self)
54
55 - def get_signs_for_word(self, index, offset=0):
56 if offset > 0: 57 return [] 58 else: 59 features = { 60 'duration' : self.durations[index], 61 'time' : self.times[index], 62 } 63 all_signs = self.grammar.get_signs_for_word(self.input[index], extra_features=features) 64 return [(sign, sign.tag, 1.0/len(all_signs)) for sign in all_signs]
65
66 - def get_word(self, index):
67 return self.input[index]
68