<commit_before>use strict;
use warnings;

use Test::More tests=>8;

BEGIN {use_ok('CXGN::String::FuzzyMatch');}
BEGIN {require_ok('Moose');}
BEGIN {require_ok('String::Approx');}

#use Data::Dumper;

my $query_string = "testing";
my @string_array = qw(test testing texting testing123 testingtesting123 Testing different);
my $max_distance = 1;
my $fuzzy_string_search;
my @string_matches;
my %string_distance_expected;
my %string_distance_result;

ok($fuzzy_string_search = CXGN::String::FuzzyMatch->new(),"Create FuzzyMatch object");
isa_ok($fuzzy_string_search->get_matches($query_string, \@string_array, $max_distance),'ARRAY', "Fuzzy string match returns an array reference");
ok(@string_matches= @{$fuzzy_string_search->get_matches($query_string, \@string_array, $max_distance)},"Get fuzzy string matches");
isa_ok($string_matches[0],'HASH','Match is a hash reference');
$string_distance_expected{'string'}='testing';
$string_distance_expected{'distance'}=0;
is_deeply($string_matches[0], \%string_distance_expected, 'String match returns perfect match');

#print STDERR "\n\nResult:\n".Data::Dumper::Dumper(@string_matches)."\n";

<commit_msg>cleanup FuzzyMatch test<commit_after># A test for fuzzy searching of an array of strings with a query string
## <NAME> (<EMAIL>) 2013

use strict;
use warnings;

use Test::More tests=>8;

BEGIN {use_ok('CXGN::String::FuzzyMatch');}
BEGIN {require_ok('Moose');}
BEGIN {require_ok('String::Approx');}

my $query_string = "testing";
my @string_array = qw(test testing texting testing123 testingtesting123 Testing different);
my $max_distance = 1;
my $fuzzy_string_search;
my @string_matches;
my %string_distance_expected;
my %string_distance_result;

ok($fuzzy_string_search = CXGN::String::FuzzyMatch->new(),"Create FuzzyMatch object");
isa_ok($fuzzy_string_search->get_matches($query_string, \@string_array, $max_distance),'ARRAY', "Fuzzy string match returns an array reference");
ok(@string_matches= @{$fuzzy_string_search->get_matches($query_string, \@string_array, $max_distance)},"Get fuzzy string matches");
isa_ok($string_matches[0],'HASH','Match is a hash reference');
$string_distance_expected{'string'}='testing';
$string_distance_expected{'distance'}=0;
is_deeply($string_matches[0], \%string_distance_expected, 'String match returns perfect match');


{'fraction_non_alphanumeric': 0.149286023366508, 'fraction_numerical': 0.01125054089138901, 'mean_word_length': 10.115384615384615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4482154', 'n_tokens_mistral': 789, 'n_tokens_neox': 737, 'n_words': 167}