Text completion: Difference between revisions
m
→Sorenson-Dice: fewer intermediates
Thundergnat (talk | contribs) m (→Sorenson-Dice: better DRY) |
Thundergnat (talk | contribs) m (→Sorenson-Dice: fewer intermediates) |
||
Line 551:
<lang perl6>sub sorenson ($phrase, %hash) {
my $match = bigram $phrase;
%hash.race.map: { [(2 * +($match ∩ .value) / (+$match + .value)).round(.001), .key] }
Bag.new( flat these.fc.words.map: { .comb.rotor(2 => -1)».join } )▼
}
▲sub bigram (\these) { Bag.new( flat these.fc.words.map: { .comb.rotor(2 => -1)».join } ) }
# Load the dictionary
|