Your SlideShare is downloading. ×
0
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Testing with Math::Combinatorics
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Testing with Math::Combinatorics

1,114

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,114
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Testing with Math::Combinatorics Anirvan Chatterjee www.chatterjee.net
  • 2. We run a comparison shopping site for new and used books
  • 3. Booksellers give us icky data
    • Henry Wadsworth Longfellow
    • Henry, Wadsworth Longfellow
    • Longfellow. H
    • H.W.Longfellow
    • Henri Longfellow
    • LONGFELLOW, HENRY WA.
    • Longfellow, Henry Wadssworth.
  • 4. Lots and lots of icky data
    • Longfellow, Henry Wadsworth.
    • LONGFELLOW, HENRY WADSWORTH.
    • Longfellow, Henry
    • Longfellow, Henry Wadworth
    • Longfellow, Henry Wadsworth. Edited By Anna H. Smith
    • Longfellow, H. W.
    • LONGFELLOW, H.W.,
    • LONGFELLOW, Henry Wadsworth, edited by
    • Henry W. Longfellow
    • Longfellow. H
    • Longfellow, H. W
    • Henry Wadsworth Longfellow, et al
    • Longfellow, Henrry Wadsworth
    • LONGFELLOW, HENRY WADSWORTH
    • Longfellow, H.
    • Longfellow Henry Wadsworth
    • Henry Longfellow
    • Longfellow 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
  • 5. We use clustering algorithms
    • my @authors =
    • author_cluster (
    • ‘ Henry Longfellow’
    • ‘ H.W.Longfellow (1807-82)’,
    • ‘ Henri Longfelow’);
    • # one single author cluster
    • is @authors, 1 ;
  • 6. 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 ;
  • 7. 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 )
  • 8. 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 )
  • 9. Math::Combinatorics makes things easy
  • 10. 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
  • 11. 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
  • 12. 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);
    • }
    • }
    • }
  • 13. Tested code means happier users. Yay, testing.

×