def fscore_match(self, sem1, sem2): if sem1 is None or sem2 is None: alignment_score = 0.0 else: alignment_score = tonal_space_alignment_score(sem1.lf, sem2.lf) if sem1 is None: len1 = 0.0 else: len1 = tonal_space_length(sem1) if sem2 is None: len2 = 0.0 else: len2 = tonal_space_length(sem2) return alignment_score,len1,len2
def distance(self, sem1, sem2): # Handle the extra 'dist' case if self.options['output'] == 'dist': # If one input is empty, we consider all points to have been deleted if sem1 is None: return tonal_space_length(sem2) elif sem2 is None: return tonal_space_length(sem1) # Compute the score using our standard TS distance computation # This is based on the alignment score of the optimal alignment # of the two sequences return tonal_space_distance(sem1.lf, sem2.lf) else: # Otherwise the superclass takes care of everything return super(TonalSpaceEditDistance, self).distance(sem1, sem2)