<commit_before>package DDG::Goodie::FlipText;

use DDG::Goodie;

triggers startend => "flip", "mirror", "spin", "rotate";

zci is_cached => 1;
zci answer_type => "flip_text";

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}",
#	"2" => "\x{1105}", Doesn't display in tests
	"3" => "\x{0190}",
#	"4" => "\x{3123}", Doesn't display in tests
#	"5" => "\x{03DB}", Doesn't really look like a 5
	"6" => "9",
#	"7" => "\x{3125}", Doesn't display in tests
	"8" => "8",
	"9" => "6",
	"," => "'",
	"." => "\x{02D9}",
	"?" => "\x{00BF}",
	"!" => "\x{00A1}",
	'"' => ",,",
	"'" => ",",
	"`" => ",",
	"(" => ")",
	")" => "(",
	"[" => "]",
	"]" => "[",
	"{" => "}",
	"}" => "{",
	">" => "<",
	"<" => ">",
	"_" => "\x{203E}");

handle remainder => sub {

	my @string = split(//, reverse $_);
	my $flippedString; 

	for (@string) {

		# Not all uppercase letters can be flipped
		$_ = lc;

		if ( exists $charMap{$_}) {
			$flippedString .= $charMap{$_};
		}
		else {
			$flippedString .= $_;
		}
	}

	

	return $flippedString;
};

1;<commit_msg>make FlipText reversable<commit_after>package DDG::Goodie::FlipText;

use DDG::Goodie;

triggers startend => "flip", "mirror", "spin", "rotate";

zci is_cached => 1;
zci answer_type => "flip_text";

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}",
#	"2" => "\x{1105}", Doesn't display in tests
	"3" => "\x{0190}",
#	"4" => "\x{3123}", Doesn't display in tests
#	"5" => "\x{03DB}", Doesn't really look like a 5
	"6" => "9",
#	"7" => "\x{3125}", Doesn't display in tests
	"8" => "8",
	"9" => "6",
	"," => "'",
	"." => "\x{02D9}",
	"?" => "\x{00BF}",
	"!" => "\x{00A1}",
	'"' => ",,",
	"'" => ",",
	"`" => ",",
	"(" => ")",
	")" => "(",
	"[" => "]",
	"]" => "[",
	"{" => "}",
	"}" => "{",
	">" => "<",
	"<" => ">",
	"_" => "\x{203E}");

handle remainder => sub {

    my %reverseCharMap = reverse %charMap;
	my @string = split(//, reverse $_);
	my $flippedString; 

	for (@string) {

		# Not all uppercase letters can be flipped
		$_ = lc;

		if ( exists $charMap{$_}) {
			$flippedString .= $charMap{$_};
		} elsif (exists $reverseCharMap{$_}) {
            $flippedString .= $reverseCharMap{$_};
        } else {
			$flippedString .= $_;
		}
	}

	

	return $flippedString;
};

1;
{'fraction_non_alphanumeric': 0.4019308943089431, 'fraction_numerical': 0.07317073170731707, 'mean_word_length': 2.948846539618857, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 171, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2102727', 'n_tokens_mistral': 2267, 'n_tokens_neox': 2068, 'n_words': 396}