testing with math::combinatorics
DESCRIPTION
TRANSCRIPT
![Page 1: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/1.jpg)
Testing with Math::Combinatorics
Anirvan Chatterjee
www.chatterjee.net
![Page 2: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/2.jpg)
We run a comparison shopping site for new and used books
![Page 3: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/3.jpg)
Booksellers give us icky data
Henry Wadsworth Longfellow
Henry, Wadsworth Longfellow
Longfellow. H
H.W.Longfellow
Henri Longfellow
LONGFELLOW, HENRY WA.
Longfellow, Henry Wadssworth.
![Page 4: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/4.jpg)
Lots and lots of icky dataLongfellow, Henry
Wadsworth.LONGFELLOW, HENRY
WADSWORTH.Longfellow, Henry Longfellow, Henry WadworthLongfellow, Henry
Wadsworth. Edited By Anna H. Smith
Longfellow, H. W.LONGFELLOW, H.W.,LONGFELLOW, Henry
Wadsworth, edited byHenry W. LongfellowLongfellow. HLongfellow, H. WHenry Wadsworth
Longfellow, et alLongfellow, Henrry
WadsworthLONGFELLOW, HENRY
WADSWORTHLongfellow, H.Longfellow Henry WadsworthHenry LongfellowLongfellow H. W.Longfellow, Wadsworth
Henry
Longfellow, Henry Wadsworth
Longfellow, Henry Wadsworth [Signed]
Longfellow, Henry W.
Longfellow,Henry Wadsworth
Henry Wadsworth Longfellow
Henry, Wadsworth Longfellow
Henry, Wadsworth Longfellow
Longfellow, Henry Wadsworh
LONGFELLOW, H.W.
LONGFELLOW WADSWORTH, Henry
LONGFELLOW,H.W.
LONGFELLOW, Henry
Longfellow H. W
Longfellow, H.W.
LONGFELLOW Henry Wadsworth
H.W.Longfellow
Longfellow, Henry, W.
LONGFELLOW, Henry Wadsworrth
Longfellow, Henry Wadsworth [1807 - 1882].,
Longfellow. H.
LONGFELLOW, Henry Wadsworth
Longfellow, Henry Wadsworth (translated)
Henry Wadworth Longfellow
Longfellow Henry W
Henri Longfellow
Longfellow, (Henry Wadsworth)
Longfellow, Henry Wadsworth;
LONGFELLOW, H. W
Longfellow. H.W
Longfellow Henry W.
Longfellow, Henry Wadsworth,
H.W. LONGFELLOW
LONGFELLOW, HENRY WA.
Longfellow, Henry W.[adsworth]
Longfellow, H.W
Longfellow, (H. W.)
Longfellow, Henry Wadsworth"
HENRY WADSWORTH LONGFELLOW
LONGFELLOW, H. W.
longfellow, Henry Wadsworth
Longfellow, Henry W
Longfellow, Henry Longfellow
HENRY W. LONGFELLOW
Longfellow, , Henry W
Longfellow, Henry. Wadsworth.
Longfellow , Henry Wadsworth
Longfellow, Henry Wadsworth [Signed],
Longfellow, Henry W.,
Wadsworth Longfellow, Henry
WADSWORTH LONGFELLOW, HENRY
LONGFELLOW, Henry W.
Longfellow, Henry, Wadsworth
LONGFELLOW, (HENRY WADSWORTH)
Longfellow, Henry Wadssworth.
Longfellow H
LONGFELLOW, H.W
![Page 5: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/5.jpg)
We use clustering algorithms
my @authors =
author_cluster(
‘Henry Longfellow’
‘H.W.Longfellow (1807-82)’,
‘Henri Longfelow’);
# one single author cluster
is @authors, 1;
![Page 6: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/6.jpg)
Testing is critical
use Test::More tests => 2;
@authors = author_cluster( ‘Isaac Asimov’, ‘ASIMOV, Isaac’);is @authors, 1;
@authors = author_cluster( ‘Isaac Asimov’, ‘Issac Asimov’);is @authors, 1;
![Page 7: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/7.jpg)
We want to test combinations
author_cluster(A)
author_cluster(B)
author_cluster(C)
author_cluster(A, B)
author_cluster(A, C)
author_cluster(B, C)
author_cluster(A, B, C)
![Page 8: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/8.jpg)
We want to test permutations
author_cluster(A, B, C)
author_cluster(A, C, B)
author_cluster(B, A, C)
author_cluster(B, C, A)
author_cluster(C, A, B)
author_cluster(C, B, A)
![Page 9: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/9.jpg)
Math::Combinatoricsmakes things easy
![Page 10: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/10.jpg)
Iterate through combinations
my @data =
qw( A B C );
for my $i (1..@data) {
my $c = new Math::Combinatorics data => \@data, count => $i;
while (my @combination = $c->next_combination) {
print @combination, q{ };
}
}
# A B C AB AC BC ABC
![Page 11: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/11.jpg)
Add every permutation
my @data = qw( A B C );
for my $i (1..@data) { my $c = new Math::Combinatorics data => \@data, count => $i; while (my @combination = $c->next_combination) { my $p = new Math::Combinatorics data => \@combination; while (my @permutation = $p->next_permutation) { print @permutation, q{ }; } }}
# A B C AB BA AC CA BC CB ABC ACB BAC BCA CAB CBA
![Page 12: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/12.jpg)
Plug in the tests
my @data =
(‘Longfellow, Henry’, ‘H.W.Longfellow’, etc.)
for my $i (1..@data) {
my $c = new Math::Combinatorics data => \@data, count => $i;
while (my @combination = $c->next_combination) {
my $p = new Math::Combinatorics data => \@combination;
while (my @permutation = $p->next_permutation) {
test_author_clustering(@permutations);
}
}
}
![Page 13: Testing with Math::Combinatorics](https://reader036.vdocument.in/reader036/viewer/2022082916/54b927094a7959fc4d8b45bc/html5/thumbnails/13.jpg)
Tested codemeans happier users.
Yay, testing.