Text completion: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→Sorenson-Dice: add missing suffix) |
Thundergnat (talk | contribs) 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 |
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 |
my %hash = './unixdict.txt'.IO.slurp.words.race.map: { $_ => .&bigram }; |
||
# Testing |
# Testing |