Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion segeval/similarity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __boundary_confusion_matrix__(*args, **kwargs):
# Add weighted near misses
for transposition in statistics['transpositions']:
match = transposition[2]
matrix[match][match] += fnc_weight_t([transposition], n_t)
matrix[match][match] += (1 - fnc_weight_t([transposition], n_t))
# Add confusion errors
for substitution in statistics['substitutions']:
hyp, ref = substitution
Expand Down
10 changes: 10 additions & 0 deletions segeval/similarity/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ def test_boundary_confusion_matrix(self):
self.assertEqual(cm[1][1], Decimal('1.5'))
self.assertEqual(cm[2][2], 0)

def test_boundary_confusion_matrix_wide_transposition(self):
cm1 = boundary_confusion_matrix([5,5], [4,6], n_t=4)
self.assertEqual(cm1[None][1], 0)
self.assertEqual(cm1[1][None], 0)
self.assertEqual(cm1[1][1], Decimal('0.75'))
cm2 = boundary_confusion_matrix([5,5], [2,8], n_t=4)
self.assertEqual(cm2[None][1], 0)
self.assertEqual(cm2[1][None], 0)
self.assertEqual(cm2[1][1], Decimal('0.25'))

def test_boundary_statistics(self):
'''
Test boundary statistics.
Expand Down