Created
March 6, 2009 03:37
-
-
Save mattn/74741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
use String::Trigram; | |
my @cmpBase = qw(もまんが もみんが ももんが うみんが); | |
my $trig = new String::Trigram(cmpBase => \@cmpBase); | |
my %result; | |
my $numOfSimStrings = $trig->getSimilarStrings("ももんが", \%result); | |
print "Found $numOfSimStrings similar strings.\n"; | |
foreach (keys %result) { | |
print "Similar string $_ has a similarity of ", sprintf ("%02f", ($result{$_} * 100)), "%\n"; | |
} | |
# Similar string もみんが has a similarity of 33.333333% | |
# Similar string うみんが has a similarity of 20.000000% | |
# Similar string ももんが has a similarity of 100.000000% | |
# Similar string もまんが has a similarity of 33.333333% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment