User:HighInBC/notes
Homoglyph testing
- Please note that I know this code is in a terrible state, I am just prototyping it and it is not even near presentable yet. Chillum 18:23, 7 September 2009 (UTC)
#!/usr/bin/perl
use strict;
use utf8;
use LWP::Simple;
use Data::Dumper;
my $test_string = lc('S0opa d3wd (0)ri \/\/|-|3@|Z');
my $target_word = lc('on wheels');
my $data = get('http://en.wikipedia.org/wiki/User:HBC_NameWatcherBot/Homoglyphs?action=raw')."\n";
utf8::upgrade($data);
my @lines = split("\n", $data);
my @homoglyphs;
LINE: foreach my $line (@lines) {
next LINE unless ($line =~ m|^;(.+?):\s*(.+)$|);
my $symbol = $1;
my @matches = split(/\s+/,$2);
for (@matches) {$_ = quotemeta($_)};
push (@homoglyphs, $symbol, \@matches)
}
#print Dumper(\@homoglyphs);
#__END__
print "Comparing '$test_string' against '$target_word' taking into account homogylphs\n\n";
my $target_pattern = $target_word;
while (scalar(@homoglyphs)) {
my ($str, $ra_values) = (shift(@homoglyphs),shift(@homoglyphs));
next unless (scalar(@{$ra_values}));
my $pattern = ('('.join('|', $str,@{$ra_values}).')');
print "$str -> $pattern\n";
$target_pattern =~ s"$str"$pattern"ig; #"
print "\t$target_pattern\n";
}
if ($test_string =~ m"($target_pattern)"i) {
print "\n\tMatch: '$1' matches '$target_word'.\n";
}
Result:
Comparing 's0opa d3wd 0ri \/\/|-|3&|z' against 'on wheels' taking into account homogylphs ee -> (\Qee\E|\Qea\E) on wh(ee|ea)ls aa -> (\Qaa\E|\Qee\E) on wh(ee|ea)ls a -> (\Qa\E|\Q4\E|\Qci\E|\Qaye\E|\Qci\E|\Q/\\\E|\Q/-\\\E|\Q\@\E|\Q∂\E|\Qλ\E|\Q\&\E) on wh(ee|e(a|4|ci|aye|ci|\/\\|\/\-\\|\@|∂|λ|\&))ls b -> (\Qb\E|\Q13\E|\Q!3\E|\Q8\E|\Qß\E|\Q13\E|\QI3\E|\Q|3\E|\QP>\E|\Q|:\E|\Q!3\E|\Q(3\E|\Q/3\E|\Q\\3\E|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z|(2|z))) 0 -> (\Q0\E|\Qo\E|\Q()\E|\Q(0)\E) (o|(0|o|\(\)|\(0\))|\(\)|\((0|o|\(\)|\(0\))\))(n|ri) (w|vv|\\\/\\\/)(h|\|\-\|)((e|(3|E))(e|(3|E))|(e|(3|E))(a|4|(c|(k|c))(i|(l|i|(1|i|l|\!)|\!|\|)|(1|i|l|\!)|\!|\|)|ay(e|(3|E))|(c|(k|c))(i|(l|i|(1|i|l|\!)|\!|\|)|(1|i|l|\!)|\!|\|)|\/\\|\/\-\\|\@|∂|λ|\&))(l|i|(1|i|l|\!)|\!|\|)(s|\$|(5|s)|(z|(2|z))) Match: '0ri \/\/|-|3&|z' matches 'on wheels'.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.