Package jazzparser :: Package data :: Package input
[hide private]
[frames] | no frames]

Package input

source code


Author: Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>

Submodules [hide private]

Classes [hide private]
  InputReader
Superclass for all sorts of input.
  Input
Superclass for different types of input wrapper.
  DbInput
Wrapper for input from the database, rather than the command line.
  WeightedChordLabelInput
Input wrapper for a lattice of chord labels, including a set of chord labels for each timestep, each with a probability.
  ChordInput
Input wrapper for textual chord input.
  SegmentedMidiInput
Input wrapper for MIDI files with extra information about segmentation, in the form it's needed for the Raphael and Stoddard model and midi supertagging models: that is, offset (start of first bar) and bar length.
  AnnotatedDbInput
Like DbInput, but stores category annotations along with the chords.
  BulkInput
Ways of accepting multiple inputs at once.
  DbBulkInput
A file containing a list of chord sequences.
  ChordBulkInput
A file containing a list of textual chord sequences.
  SegmentedMidiBulkInput
A CSV file containing midi file paths and the parameters for segmenting each one.
  AnnotatedDbBulkInput
Like DbBulkInput, but for AnnotatedDbInput.
  MidiTaggerTrainingBulkInput
Subclass of SegmentedMidiBulkInput for taking training input for midi supertaggers.
  InputTypeError
  InputReadError
Functions [hide private]
 
input_type_name(cls) source code
 
get_input_type(name) source code
 
get_input_type_names(single=True, bulk=True) source code
 
is_bulk_type(cls) source code
(type name, input) pair
detect_input_type(data, allowed=None, allow_bulk=False, errmess='')
Preprocesses input.
source code
InputReader subclass
command_line_input(filename=None, filetype=None, options='', allowed_types=None, default_type=None)
Utility function for processing file input options from the command line.
source code
Variables [hide private]
  INPUT_TYPES = [('db', <class 'jazzparser.data.input.DbInput'>)...
  BULK_INPUT_TYPES = [('bulk-db', <class 'jazzparser.data.input....
  __package__ = 'jazzparser.data.input'
Function Details [hide private]

detect_input_type(data, allowed=None, allow_bulk=False, errmess='')

source code 

Preprocesses input.

The input may be already wrapped using one of the wrappers in this module, or it may be a string. In this case it will be wrapped using ChordInput and the result will be returned.

Parameters:
  • allowed (list of input type names) - (optional) list of data types that are allowed. If the data is in a recognised format, but not one of these, an error will be raised
  • allow_bulk (bool) - if True, accepts bulk input types. If allowed is also given, will check that the bulk input supplies an allowed type of individual inputs
  • errmess (str) - additional error message to include in the output when a disallowed type is encountered. The message reads something like "input of type <type> is not allowed<errmess>..."
Returns: (type name, input) pair
the identified input type and the wrapped-up input, ready to be used by a tagger

command_line_input(filename=None, filetype=None, options='', allowed_types=None, default_type=None)

source code 

Utility function for processing file input options from the command line. Pass in as args the values straight from the command line options to select a filename, filetype and list of options.

Typical command-line options for this purpose (for an optparse option parser op):

op.add_option("--file", "-f", dest="file", action="store", help="use a file to get input from")
op.add_option("--filetype", "--ft", dest="filetype", action="store", help="select the file type for the input file. Use '--filetype help' for a list of available types")
op.add_option("--file-options", "--fopt", dest="file_options", action="store", help="options for the input file. Use '--fopt help', with '--ft <type>', for a list of available options")

Then you can call this function as:

command_line_input(filename=options.file, filetype=options.filetype, options=options.file_options)
Parameters:
  • allowed_types (list of strs) - types of input you want the user to be able to give. If not given, all types are allowed
  • default_type (str) - filetype to assume if no other filetype is given
Returns: InputReader subclass
the input wrapper of appropriate type, or None if no input file was given

Variables Details [hide private]

INPUT_TYPES

Value:
[('db', <class 'jazzparser.data.input.DbInput'>),
 ('db-annotated', <class 'jazzparser.data.input.AnnotatedDbInput'>),
 ('chords', <class 'jazzparser.data.input.ChordInput'>),
 ('segmidi', <class 'jazzparser.data.input.SegmentedMidiInput'>),
 ('labels', <class 'jazzparser.data.input.WeightedChordLabelInput'>)]

BULK_INPUT_TYPES

Value:
[('bulk-db', <class 'jazzparser.data.input.DbBulkInput'>),
 ('bulk-db-annotated',
  <class 'jazzparser.data.input.AnnotatedDbBulkInput'>),
 ('bulk-chords', <class 'jazzparser.data.input.ChordBulkInput'>),
 ('bulk-segmidi',
  <class 'jazzparser.data.input.SegmentedMidiBulkInput'>),
 ('bulk-midi-train',
  <class 'jazzparser.data.input.MidiTaggerTrainingBulkInput'>)]