Skip to content

Commit 2f4e12d

Browse files
committed
WIP
1 parent bab79d9 commit 2f4e12d

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

t/01-deltas.t

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ use strict;
44

55
use Statistics::Krippendorff;
66

7+
use List::Util qw{ sum };
8+
79
use Test2::V0;
8-
plan 16;
10+
plan 20;
911

1012
my $sk = 'Statistics::Krippendorff'->new(units => []);
1113

@@ -29,3 +31,25 @@ is $sk->delta_jaccard('b,a', 'c,a'), 2/3, 'ba ca';
2931
is $sk->delta_jaccard('b,a', 'a,c'), 2/3, 'ba ac';
3032

3133
is $sk->delta_jaccard('a,b,c', 'b,c,d,e'), 3/5, 'abc bcde';
34+
35+
my @figures = (
36+
[['x,y', 'x,y,z'], ['x,y', 'x,y,z'], ['x', 'x,y,z']],
37+
[['x,y', 'x'], ['x,y', 'y,z'], ['z', 'y,z']]
38+
);
39+
40+
my %means = (jaccard => [4 / 9, 5 / 9],
41+
masi => [10 / 27, 6 / 27]);
42+
for my $figure_index (0 .. $#figures) {
43+
my $figure = $figures[$figure_index];
44+
my @jaccard_deltas = map $sk->delta_jaccard(@$_), @$figure;
45+
my $mean = sum(@jaccard_deltas) / @jaccard_deltas;
46+
is $mean, shift @{ $means{jaccard} }, "fig$figure_index jaccard mean";
47+
48+
if (1 == $figure_index) {
49+
$figure->[1] = ['x', 'z'];
50+
}
51+
52+
my @masi_deltas = map $sk->delta_masi(@$_), @$figure;
53+
my $mean = 1 - sum(@masi_deltas) / @masi_deltas;
54+
is $mean, shift @{ $means{masi} }, "fig$figure_index masi mean";
55+
}

0 commit comments

Comments
 (0)