Skip to content

Commit 0ececc8

Browse files
committed
Add tests for the MASI distance
1 parent 7a21987 commit 0ececc8

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

t/01-deltas.t

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,30 @@ is $sk->delta_jaccard('a,b,c', 'b,c,d,e'), 3/5, 'abc bcde';
3434

3535
is $sk->delta_masi('1,2', '1,2,3,4'), 2/3, 'masi';
3636

37+
# Passonneau 2006
38+
# Note that the results are different than stated in the article, I fixed
39+
# errors found in the article, results confirmed by Passonneau via e-mail.
3740
my @figures = (
38-
[['x,y', 'x,y,z'], ['x,y', 'x,y,z'], ['x', 'x,y,z']],
41+
[['x,y', 'x,y,z'], ['x,y', 'x,y,z'], ['z', 'x,y,z']],
3942
[['x,y', 'x'], ['x,y', 'y,z'], ['z', 'y,z']]
4043
);
4144

4245
my %means = (jaccard => [4 / 9, 5 / 9],
43-
masi => [10 / 27, 6 / 27]);
46+
masi => [2 / 9, 0]);
4447
for my $figure_index (0 .. $#figures) {
4548
my $figure = $figures[$figure_index];
49+
my $figure_number = 2 + $figure_index;
4650
my @jaccard_deltas = map $sk->delta_jaccard(@$_), @$figure;
4751
my $j_mean = sum(@jaccard_deltas) / @jaccard_deltas;
48-
is $j_mean, shift @{ $means{jaccard} }, "fig$figure_index jaccard mean";
52+
is $j_mean, shift @{ $means{jaccard} }, "fig$figure_number jaccard mean";
4953

50-
if (1 == $figure_index) {
51-
$figure->[1] = ['x', 'z'];
54+
if (0 == $figure_index) {
55+
$figure = [['y', 'y,z'], ['x', 'x,z'], ['','x,y']];
5256
} else {
53-
#$figure = [['y', 'y,z'], ['x', 'x,z'], ['x','x,y']];
57+
$figure = [['y', ''], ['x', 'z'], ['', 'y']];
5458
}
5559

5660
my @masi_deltas = map $sk->delta_masi(@$_), @$figure;
5761
my $m_mean = 1 - sum(@masi_deltas) / @masi_deltas;
58-
is $m_mean, shift @{ $means{masi} }, "fig$figure_index masi mean";
62+
is $m_mean, shift @{ $means{masi} }, "fig$figure_number masi mean";
5963
}

0 commit comments

Comments
 (0)