Text completion: Difference between revisions

m
m (→‎Sorenson-Dice: add missing suffix)
m (→‎Sorenson-Dice: better DRY)
Line 550:
 
<lang perl6>sub sorenson ($phrase, %hash) {
my $match = bigram $phrase.fc;
%hash.race.map: {
my $this = .value;
Line 558:
 
sub bigram (\these) {
Bag.new( flat these.fc.words.map: { .comb.rotor(2 => -1)».join } )
}
 
 
# Load the dictionary
my %hash = './unixdict.txt'.IO.slurp.fc.words.race.map: { $_ => .&bigram };
 
# Testing
10,327

edits