2012-03-14 14:40:36 -07:00
|
|
|
package DDG::Goodie::FlipText;
|
|
|
|
|
|
|
|
use DDG::Goodie;
|
|
|
|
|
|
|
|
triggers startend => "flip";
|
|
|
|
|
|
|
|
zci is_cached => 1;
|
2012-03-20 21:08:12 -07:00
|
|
|
zci answer_type => "flip_text";
|
2012-03-14 14:40:36 -07:00
|
|
|
|
2012-03-14 23:14:10 -07:00
|
|
|
my %charMap = (
|
|
|
|
"a" => "\x{0250}",
|
|
|
|
"b" => "q",
|
|
|
|
"c" => "\x{0254}",
|
|
|
|
"d" => "p",
|
|
|
|
"e" => "\x{01DD}",
|
|
|
|
"f" => "\x{025F}",
|
|
|
|
"g" => "\x{0183}",
|
|
|
|
"h" => "\x{0265}",
|
|
|
|
"i" => "\x{0131}",
|
|
|
|
"j" => "\x{027E}",
|
|
|
|
"k" => "\x{029E}",
|
|
|
|
"l" => "l",
|
|
|
|
"m" => "\x{026F}",
|
|
|
|
"n" => "u",
|
|
|
|
"o" => "o",
|
|
|
|
"p" => "d",
|
|
|
|
"q" => "b",
|
|
|
|
"r" => "\x{0279}",
|
|
|
|
"s" => "s",
|
|
|
|
"t" => "\x{0287}",
|
|
|
|
"u" => "n",
|
|
|
|
"v" => "\x{028C}",
|
|
|
|
"w" => "\x{028D}",
|
|
|
|
"x" => "x",
|
|
|
|
"y" => "\x{028E}",
|
|
|
|
"z" => "z",
|
|
|
|
"A" => "\x{2200}",
|
|
|
|
"B" => "B",
|
|
|
|
"C" => "\x{0186}",
|
|
|
|
"D" => "D",
|
|
|
|
"E" => "\x{018E}",
|
|
|
|
"F" => "\x{2132}",
|
|
|
|
"G" => "\x{05E4}",
|
|
|
|
"H" => "H",
|
|
|
|
"I" => "I",
|
|
|
|
"J" => "\x{017F}",
|
|
|
|
"K" => "K",
|
|
|
|
"L" => "\x{02E5}",
|
|
|
|
"M" => "W",
|
|
|
|
"N" => "N",
|
|
|
|
"O" => "O",
|
|
|
|
"P" => "\x{0500}",
|
|
|
|
"Q" => "Q",
|
|
|
|
"R" => "R",
|
|
|
|
"S" => "S",
|
|
|
|
"T" => "\x{2534}",
|
|
|
|
"U" => "\x{2229}",
|
|
|
|
"V" => "\x{039B}",
|
|
|
|
"W" => "M",
|
|
|
|
"X" => "X",
|
|
|
|
"Y" => "\x{2144}",
|
|
|
|
"Z" => "Z",
|
|
|
|
"0" => "0",
|
|
|
|
"1" => "\x{0196}",
|
2012-03-15 09:06:16 -07:00
|
|
|
# "2" => "\x{1105}", Doesn't display in tests
|
2012-03-14 23:14:10 -07:00
|
|
|
"3" => "\x{0190}",
|
2012-03-15 09:06:16 -07:00
|
|
|
# "4" => "\x{3123}", Doesn't display in tests
|
2012-03-15 09:43:39 -07:00
|
|
|
# "5" => "\x{03DB}", Doesn't really look like a 5
|
2012-03-14 23:14:10 -07:00
|
|
|
"6" => "9",
|
2012-03-15 09:06:16 -07:00
|
|
|
# "7" => "\x{3125}", Doesn't display in tests
|
2012-03-14 23:14:10 -07:00
|
|
|
"8" => "8",
|
|
|
|
"9" => "6",
|
|
|
|
"," => "'",
|
|
|
|
"." => "\x{02D9}",
|
|
|
|
"?" => "\x{00BF}",
|
|
|
|
"!" => "\x{00A1}",
|
|
|
|
'"' => ",,",
|
|
|
|
"'" => ",",
|
|
|
|
"`" => ",",
|
|
|
|
"(" => ")",
|
|
|
|
")" => "(",
|
|
|
|
"[" => "]",
|
|
|
|
"]" => "[",
|
|
|
|
"{" => "}",
|
|
|
|
"}" => "{",
|
|
|
|
">" => "<",
|
|
|
|
"<" => ">",
|
|
|
|
"_" => "\x{203E}");
|
|
|
|
|
2012-03-14 14:40:36 -07:00
|
|
|
handle remainder => sub {
|
2012-03-14 23:00:32 -07:00
|
|
|
my @string = split(//,reverse $_);
|
2012-03-15 09:51:16 -07:00
|
|
|
my $flippedString;
|
2012-03-14 23:00:32 -07:00
|
|
|
|
2012-05-01 20:26:43 -07:00
|
|
|
for (@string) {
|
2012-03-15 09:06:16 -07:00
|
|
|
|
|
|
|
# Not all uppercase letters can be flipped
|
2012-05-01 20:26:43 -07:00
|
|
|
$_ = lc;
|
2012-03-14 14:40:36 -07:00
|
|
|
|
2012-05-01 20:26:43 -07:00
|
|
|
if ( exists $charMap{$_}) {
|
|
|
|
$flippedString .= $charMap{$_};
|
2012-03-14 23:00:32 -07:00
|
|
|
}
|
|
|
|
else {
|
2012-05-01 20:26:43 -07:00
|
|
|
$flippedString .= $_;
|
2012-03-14 23:00:32 -07:00
|
|
|
}
|
|
|
|
}
|
2012-03-14 14:40:36 -07:00
|
|
|
return $flippedString;
|
|
|
|
};
|
2012-04-15 08:04:36 -07:00
|
|
|
|
|
|
|
1;
|