Text completion: Difference between revisions

Content added Content deleted
m (→‎Sorenson-Dice: add missing suffix)
m (→‎Sorenson-Dice: better DRY)
Line 550: Line 550:


<lang perl6>sub sorenson ($phrase, %hash) {
<lang perl6>sub sorenson ($phrase, %hash) {
my $match = bigram $phrase.fc;
my $match = bigram $phrase;
%hash.race.map: {
%hash.race.map: {
my $this = .value;
my $this = .value;
Line 558: Line 558:


sub bigram (\these) {
sub bigram (\these) {
Bag.new( flat these.words.map: { .comb.rotor(2 => -1)».join } )
Bag.new( flat these.fc.words.map: { .comb.rotor(2 => -1)».join } )
}
}




# Load the dictionary
# Load the dictionary
my %hash = './unixdict.txt'.IO.slurp.fc.words.race.map: { $_ => .&bigram };
my %hash = './unixdict.txt'.IO.slurp.words.race.map: { $_ => .&bigram };


# Testing
# Testing