Text completion: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→Sorenson-Dice: better DRY) |
Thundergnat (talk | contribs) m (→Sorenson-Dice: fewer intermediates) |
||
Line 551: | Line 551: | ||
<lang perl6>sub sorenson ($phrase, %hash) { |
<lang perl6>sub sorenson ($phrase, %hash) { |
||
my $match = bigram $phrase; |
my $match = bigram $phrase; |
||
%hash.race.map: { |
%hash.race.map: { [(2 * +($match ∩ .value) / (+$match + .value)).round(.001), .key] } |
||
my $this = .value; |
|||
[(2 * +($match ∩ $this) / (+$match + $this)).round(.001), .key] |
|||
} |
|||
} |
|||
sub bigram (\these) { |
|||
⚫ | |||
} |
} |
||
⚫ | |||
# Load the dictionary |
# Load the dictionary |