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

Module evaluation

source code

Tonal space path evaluation functions.


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

Functions [hide private]
 
_subst_type(point1, point2) source code
 
_subst_cost(point1, point2) source code
 
_subst_cost_float(point1, point2)
Substitution cost, same as _subst_cost, but returns a value between 0 and 1.
source code
 
_steps_list(seq)
Given a list of (coordinate,function) pairs, produces a similar list that represents the steps between each point in the path and its previous point, maintaining the original functions.
source code
 
_lf_to_coord_funs(sem)
Gets a list of (coordinate,function) pairs from a logical form.
source code
 
tonal_space_distance(sem1, sem2)
Computes the edit distance between the tonal space paths of two logical forms, using a suitable scoring.
source code
 
tonal_space_alignment_costs(sem1, sem2)
Performs the same algorithm as tonal_space_distance, but instead of returning the score returns the counts of deletions, insertions, root (only) substitutions, function (only) substitutions, full substitutions and alignments.
source code
 
tonal_space_alignment(sem1, sem2, distance=False)
Performs the same algorithm as tonal_space_distance and tonal_space_alignment_costs, but returns a list of the operations that produce the optimal alignment: "I" - insertion; "D" - deletion; "A" - alignment; "S" - full substitution; or anything else beginning with "S" to indicate a partial substitution.
source code
 
tonal_space_align(sem1, sem2)
Like the other alignment functions, but returns the list of aligned pairs.
source code
 
tonal_space_precision_recall(sem, gold_sem)
Calculates the precision and recall and f-score of the optimal alignment between the sequence and the gold standard sequence.
source code
 
tonal_space_f_score(sem, gold_sem)
Calculates an f-score for the optimal alignment between the sequence and the gold standard sequence.
source code
 
tonal_space_alignment_score(seq1, seq2)
Assigns a score to the optimal alignment between the two logical forms.
source code
 
tonal_space_length(sem)
Length of the tonal space path represented by the given logical form.
source code
 
tonal_space_local_distance(sem1, sem2)
Like tonal_space_distance, but uses local alignment of seq2 within seq1.
source code
 
tonal_space_local_alignment(sem1, sem2)
Like tonal_space_alignment, but uses local alignment of seq2 within seq1.
source code
 
arrange_alignment(steps1, steps2, ops)
Arrange the steps of an alignment for printing in aligned rows.
source code
Variables [hide private]
  __package__ = 'jazzparser.formalisms.music_halfspan'
Function Details [hide private]

_steps_list(seq)

source code 

Given a list of (coordinate,function) pairs, produces a similar list that represents the steps between each point in the path and its previous point, maintaining the original functions.

The first point yields the step from the origin, ignoring its enharmonic block (in other words, the step from (0,0) within its enharmonic block).

This means that effectively we don't care what enharmonic block the path lies in, only the relative points along the path.

tonal_space_distance(sem1, sem2)

source code 

Computes the edit distance between the tonal space paths of two logical forms, using a suitable scoring. This uses a cost of 2 for deletions and insertions and scores 1 for a substitution that gets either the step or function right, but not both. The result is then divided by 2 (meaning that effectively all costs are 1 and a 0.5 cost is given to half-right substitutions).

The alignment is not between the tonal space points themselves, but between the vectors between each pair of points (that is the points relative to the previous point). This means that a path won't be penalised if part of it is translated by a constant vector, except at the point where it goes wrong.

tonal_space_alignment(sem1, sem2, distance=False)

source code 

Performs the same algorithm as tonal_space_distance and tonal_space_alignment_costs, but returns a list of the operations that produce the optimal alignment: "I" - insertion; "D" - deletion; "A" - alignment; "S" - full substitution; or anything else beginning with "S" to indicate a partial substitution.

Returns the operation list and the two sequences that were compared. If distance=True, also includes the distance metric. Not included by default for backward compatibility.

tonal_space_alignment_score(seq1, seq2)

source code 

Assigns a score to the optimal alignment between the two logical forms.

Think of this as essentially a count of alignments in the optimal alignment. In fact, a pair of points may be partly aligned, in which case they contribute something to this score between 0 and 1.

tonal_space_length(sem)

source code 

Length of the tonal space path represented by the given logical form.

This could be more efficient, but at the moment only gets used in places where it doesn't matter much, so I might as well keep it simple.

tonal_space_local_alignment(sem1, sem2)

source code 

Like tonal_space_alignment, but uses local alignment of seq2 within seq1.

Also returns the distance metric (like tonal_space_local_distance.