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

Package input

source code

Author: Mark Granroth-Wilding <>

Submodules [hide private]

Classes [hide private]
Superclass for all sorts of input.
Superclass for different types of input wrapper.
Wrapper for input from the database, rather than the command line.
Input wrapper for a lattice of chord labels, including a set of chord labels for each timestep, each with a probability.
Input wrapper for textual chord input.
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.
Like DbInput, but stores category annotations along with the chords.
Ways of accepting multiple inputs at once.
A file containing a list of chord sequences.
A file containing a list of textual chord sequences.
A CSV file containing midi file paths and the parameters for segmenting each one.
Like DbBulkInput, but for AnnotatedDbInput.
Subclass of SegmentedMidiBulkInput for taking training input for midi supertaggers.
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 ''>)...
  BULK_INPUT_TYPES = [('bulk-db', <class '
  __package__ = ''
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.

  • 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)
  • 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]


[('db', <class ''>),
 ('db-annotated', <class ''>),
 ('chords', <class ''>),
 ('segmidi', <class ''>),
 ('labels', <class ''>)]


[('bulk-db', <class ''>),
  <class ''>),
 ('bulk-chords', <class ''>),
  <class ''>),
  <class ''>)]