Package jazzparser :: Package formalisms :: Package music_halfspan :: Package semantics
[hide private]
[frames] | no frames]

Package semantics

source code

Semantics module for the music_halfspan formalism.

Lambda calculus semantics for the halfspan formalism. This is the form of the semantics described in our paper appendix and in my 2nd-year review.


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

Submodules [hide private]

Classes [hide private]
  Semantics
hash(x)
  DummyLogicalForm
  EnharmonicCoordinate
A four-dimensional coordinate.
  LexicalCoordinate
When a logical form is read in from the lexicon, coordinates must be specified relative to the root of the chord.
  GhostCoordinate
Wrapper that stores an EnharmonicCoordinate.
  List
The Path or List data structure.
  ListCat
Represents the concatenation of multiple Lists.
  Coordination
Special operator to represent coordination.
  Variable
Standard variable implementation overridden to add time processing.
  LambdaAbstraction
Standard abstraction implementation overridden to add time processing.
  FunctionApplication
Standard application implementation overridden to add time processing.
  Predicate
Superclass of literal predicates (such as leftonto).
  Leftonto
A leftonto predicate literal.
  Rightonto
A rightonto predicate literal, analagous to Leftonto.
  Now
A special predicate that doesn't change its argument at all, except to set its start time to be no later than the start time associated with the predicate.
  PathCoordinate
Simple subclass of EnharmonicCoordinate to store points on a path directly.
  CoordinateList
Just a list of enharmonic coordinates, forming a tonal space path.
  SemanticsStringBuildError
  SemanticsPostProcessError
  KeyInferenceError
Functions [hide private]
 
apply(fn, arg, grammar=None)
Applies fn to arg by creating a FunctionApplication and returns the result.
source code
 
compose(f, g, grammar=None)
Performs logical composition in this semantic formalism.
source code
 
multi_apply(*args) source code
 
multi_abstract(*args) source code
 
concatenate(lst1, lst2)
Returns the concatenation of the two lists.
source code
 
make_absolute_lf_from_relative(sems, root_coord) source code
 
list_lf_to_coordinates(lst, start_block=(0, 0))
Produces a list of (x,y) coordinates in the tonal space, given a List or CoordinateList.
source code
 
list_lf_to_functions(lst)
Like list_lf_to_coordinates, but produces a list of (function,time) pairs instead of (coordinate,time).
source code
 
sign_to_coordinates(sign) source code
 
semantics_to_coordinates(sems)
Generates a list of (coordinates,time) tuples given a parse result.
source code
 
semantics_to_functions(sems)
Generates a list of (function,time) tuples given a parse result.
source code
 
backoff_states_to_lf(states)
Builds a logical form given a list of states and the chords they were assigned to.
source code
 
semantics_to_keys(sems)
Gets a list of keys implied by a logical form.
source code
 
semantics_from_string(string)
Builds a Semantics instance from a string representation of the logical form.
source code
Variables [hide private]
  FORMALISM_NAME = 'music_halfspan'
  INTERVAL_TO_NN = {0: (0, 0), 1: (-1, -1), 2: (2, 0), 3: (1, -1...
  __package__ = 'jazzparser.formalisms.music_halfspan.semantics'
Function Details [hide private]

apply(fn, arg, grammar=None)

source code 

Applies fn to arg by creating a FunctionApplication and returns the result. This is used for formalism-unspecific access to this feature.

concatenate(lst1, lst2)

source code 

Returns the concatenation of the two lists. Uses existing instances passed in, so make sure they're copies if you don't want your original objects modified.

list_lf_to_coordinates(lst, start_block=(0, 0))

source code 

Produces a list of (x,y) coordinates in the tonal space, given a List or CoordinateList.

Parameters:
  • lst (List) - list from the semantics representing constraints on a TS path
  • start_block (pair of ints) - enharmonic block to start in (if other than the default (0,0))
Returns:
2D coordinates of the path through the tonal space and the times at which they were reached.

list_lf_to_functions(lst)

source code 

Like list_lf_to_coordinates, but produces a list of (function,time) pairs instead of (coordinate,time).

Parameters:
  • lst (List) - list from the semantics representing constraints on a TS path
Returns:
function strings of points on the path through the tonal space and the times at which they were reached.

semantics_to_coordinates(sems)

source code 

Generates a list of (coordinates,time) tuples given a parse result.

Raises:
  • ValueError - if the result can't produce a list of coordinates.

semantics_to_functions(sems)

source code 

Generates a list of (function,time) tuples given a parse result.

Raises:
  • ValueError - if the result can't produce a list of coordinates.

backoff_states_to_lf(states)

source code 

Builds a logical form given a list of states and the chords they were assigned to. Accepts a list of labels,time and return a logical form for the formalism (a Semantics in this case).

This uses the special logical form classes CoordinateList and PathCoordinate.

semantics_from_string(string)

source code 

Builds a Semantics instance from a string representation of the logical form. This is mainly for testing and debugging and shouldn't be used in the wild (in the parser, for example). This is not how we construct logical forms out of the lexicon: they're specified in XML, which is a safer way to build LFs, though more laborious to write.

The strings may be constructed as follows.

Tonic semantics: "<x,y>". This will build an EnharmonicCoordinate.

List: "[ITEM0, ITEM1, ...]". This will build a List.

List concatenation: "LIST0+LIST1", that is with infix notation. This will build a ListCat.

Variable: "$x0". Begin every variable with a $, as if you're writing PHP or Bash, or something. Use any variable name and, optionally, a number. If no number is given, 0 will be used by default.

Predicates - leftonto, rightonto: "leftonto(...)", etc. Builds a FunctionApplication with the predicate as its functor.

Now: "now@x(...)". Works like the other predicates, but has the special "@x" value to give it a time.

Lambda abstraction: "\$x.EXPR". Use a backslash to represent a lambda. You can have multiple abstracted variables, which will result in multiple nested abstractions. EXPR can be any expression.

Function application: "(FUNCTOR ARGUMENT)". Always enclose a function application in brackets, even if you wouldn't write them.

Note that the output is not beta-reduced.


Variables Details [hide private]

INTERVAL_TO_NN

Value:
{0: (0, 0),
 1: (-1, -1),
 2: (2, 0),
 3: (1, -1),
 4: (0, 1),
 5: (-1, 0),
 6: (-2, -1),
 7: (1, 0),
...