Jaro similarity: Difference between revisions
m
→{{header|Raku}}: Raku style prefers identifiers with - instead of _
mNo edit summary |
m (→{{header|Raku}}: Raku style prefers identifiers with - instead of _) |
||
Line 2,832:
return 1 if $s eq $t;
my $
my $
my $
my ($matches, @
for ^@s -> $i {
my $start = 0 max $i - $
my $end = $i + $
for $start .. $end -> $j {
next if @
(@
$matches++ and last;
}
Line 2,851:
my ($k, $transpositions) = (0, 0);
for ^@s -> $i {
next unless @
$k++ until @
$transpositions++ if @s[$i] ne @t[$k];
$k++;
}
( $matches/$
}
say jaro(.key, .value).fmt: '%.3f' for
'MARTHA' => 'MARHTA', 'DIXON' => 'DICKSONX', 'JELLYFISH' => 'SMELLYFISH',
'I repeat myself' => 'I repeat myself', '' => '';
</syntaxhighlight>
{{out}}
<pre>0.944
|