Skip to content

Instantly share code, notes, and snippets.

@Mouq
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mouq/8d6548b27e614bff1abf to your computer and use it in GitHub Desktop.
Save Mouq/8d6548b27e614bff1abf to your computer and use it in GitHub Desktop.
my Bag %confusable;
my Str @chars;
say 'processing confusables.txt ...';
for <confusables.txt>.&open.lines[10..*] {
my @s = .split("\t");
if not defined $_.index('#') and @s == 4 or
@s == 5 && defined @s[4].index('#')
{
@chars.push: @s[2].words.map({ :16(~$_).chr }).join;
} elsif @chars {
my $b = bag @chars;
%confusable{$_} := $b for @chars;
undefine @chars;
}
}
say 'done processing';
for lines() {
say .comb.map({ ( %confusable{$_} // $_ ).pick }).join;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment