Package jazzparser :: Package taggers :: Package segmidi :: Package chordlabel :: Module tagger :: Class ChordLabelNgramTagger
[hide private]
[frames] | no frames]

Class ChordLabelNgramTagger

source code

   object --+    
            |    
tagger.Tagger --+
                |
               ChordLabelNgramTagger

Tagger that loads a chord labeling model to assign chord labels to MIDI data, then hands over to a chord supertagger to process the output of the labeler.

Instance Methods [hide private]
 
__init__(self, grammar, input, options={}, logger=None, *args, **kwargs)
The tagger must have reference to the grammar being used to parse the input.
source code
 
get_signs(self, offset=0)
Returns a list of tuples (start, end, signtup).
source code
 
get_word(self, index)
Returns the input word at this index.
source code
 
get_string_input(self)
Returns a list of string representations of the inputs.
source code
 
lexical_probability(self, start_time, end_time, span_label)
Lexical probabilities for a probabilistic parser.
source code
 
single_step_lexical_probability(self, time, span_label) source code

Inherited from tagger.Tagger: get_all_signs, get_tag_probability, get_word_duration

Inherited from tagger.Tagger (private): _get_input_length, _get_name

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]

Inherited from tagger.Tagger: check_options

Class Variables [hide private]
  COMPATIBLE_FORMALISMS = ['music_halfspan']
  TAGGER_OPTIONS = MultiChordNgramTagger.TAGGER_OPTIONS+ [Module...
Tagger-specific options.
  INPUT_TYPES = ['segmidi']
List of allowed input datatypes.
  name = 'chordlabel'
  shell_tools = Tagger.shell_tools+ [tools.ChordLabelTool(),]
Interactive shell tools available when this tagger is used.
  LEXICAL_PROBABILITY = True
Some models provide lexical probabilities that the parsing models can use.
Properties [hide private]

Inherited from tagger.Tagger: input_length

Inherited from object: __class__

Method Details [hide private]

__init__(self, grammar, input, options={}, logger=None, *args, **kwargs)
(Constructor)

source code 

The tagger must have reference to the grammar being used to parse the input. It must also be given the full input when instantiated. The format of this input will depend on the tagger: for example, it might be a string or a MIDI file.

Parameters:
  • original_input - the input in its original, unprocessed form. This will usually be a string. This is optional, but in some circumstances things might fall apart if it hasn't been given. E.g. using a backoff model as backoff from a tagging model requires the original input to be passed to the backoff model.
  • logger - optional progress logger. Logging will be sent to this during initialization of the tagger and tagging. If not given, the logging will be lost. Subclasses may access the logger (or a dummy logger if none was given) in self.logger.
Overrides: object.__init__
(inherited documentation)

get_signs(self, offset=0)

source code 

Returns a list of tuples (start, end, signtup). These represent spans to be added to the chart, start and end being the start and end nodes.

Each signtup is a (sign,tag,probability) tuple representing a sign that the tagger wishes to add to the chart in this position. How many are returned is up to the tagger (it may wish to return more in cases where there are no clear winners, for example). If the tag is not found in the grammar, sign will be None.

Returned list is sorted by probability, highest first.

offset may be set >0 in order to retrieve further signs once some have already been returned. If offset=k, the tagger should disregard all the signs that would have been returned for offset<k and return the next bunch - as many as it sees fit. offset is incremented each time the parse fails.

The simplest approach, and that employed by most taggers, has some signs for each word and none spanning more than one word. That is, the tuples in the list would be of the form (wordnum, wordnum+1, signtup). This is by no means required, though: some taggers will want to add multi-node spans to the chart.

Overrides: tagger.Tagger.get_signs
(inherited documentation)

get_word(self, index)

source code 

Returns the input word at this index. This does not need to be a string, but must have a sensible __str__, so that it can be converted to a readable string. The purpose of this is to provide a readable form of the input for the parser to store in derivation traces.

Overrides: tagger.Tagger.get_word
(inherited documentation)

get_string_input(self)

source code 

Returns a list of string representations of the inputs. This is just a convenience function, which uses whatever representation gets returned by get_word() to produce a representation of the whole input.

Overrides: tagger.Tagger.get_string_input
(inherited documentation)

lexical_probability(self, start_time, end_time, span_label)

source code 

Lexical probabilities for a probabilistic parser. This will only get used if the parsing model can't compute a probability itself (i.e. in the case of MIDI input).


Class Variable Details [hide private]

TAGGER_OPTIONS

Tagger-specific options. List of ModuleOptions.

Value:
MultiChordNgramTagger.TAGGER_OPTIONS+ [ModuleOption('labeling_model', \
help_text= "Model name for chord labeler", usage= "labeling_model=M, w\
here M is a trained chord labeling model", required= True), ModuleOpti\
on('partition_labeler', filter= str_to_bool, help_text= "By default, t\
he chord labeling model is not loaded " "with a partition number, even\
 if the supertagging model is. " "If this is True, the same partition \
number will be used for " "the labeler's model as was given to the sup\
ertagger.", usage= "partition_labeler=B, where B is True or False", de\
...