Advertisement
Guest User

Untitled

a guest
Sep 12th, 2012
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.10 KB | None | 0 0
  1. module Lolcat
  2.     REPL = {
  3.             /what/     => %w/wut whut/,   /you\b/   => %w/yu yous yoo u/,
  4.             /cture/    => ['kshur'],          /unless/    => ['unles'],
  5.             /the\b/=> ['teh'],            /more/      => ['moar'],
  6.             /my/       => %w/muh mah/,    /are/       => %w/r is ar/,
  7.             /eese/     => ['eez'],            /ph/        => ['f'],
  8.             /as\b/   => ['az'],             /seriously/ => ['srsly'],
  9.             /er\b/   => ['r'],              /sion/      => ['shun'],
  10.             /just/     => ['jus'],            /ose\b/   => ['oze'],
  11.             /eady/     => ['eddy'],           /ome?\b/  => ['um'],
  12.             /of\b/   => %w/of ov of/,   /uestion/ => ['wesjun'],
  13.             /want/     => %w/wants/,          /ead\b/   => ['edd'],
  14.             /ucke/     => %w/ukki ukke/,  /sion/      => ['shun'],
  15.             /eak/      => %w/ekk/,            /age/       => ['uj'],
  16.             /like/     => %w/likes liek/, /love/      => %w/loves lub lubs luv/,
  17.             /\bis\b/ => %w/ar teh ar/,  /nd\b/   => ['n'],
  18.             /who/      => %w/hoo/,            /\'/      => [''],
  19.            /ese\b/  => %w/eez/,            /outh/      => %w/owf/,
  20.            /scio/     => ['shu'],            /esque/     => %w/esk/,
  21.            /ture/     => ['chur'],           /\btoo?\b/=> %w/to t 2 to t/,
  22.            /tious/    => ['shus'],           /sure\b/  => ['shur'],
  23.            /tty\b/  => ['tteh'],           /were/      => ['was'],
  24.            /ok\b/   => %w/'k kay/ ,   /\ba\b/   => [''],
  25.             /ym/       => ['im'],             /thy\b/   => ['fee'],
  26.             /\wly\w/ => ['li'],             /que\w/   => ['kwe'],
  27.             /oth/      => ['udd'],            /ease/      => ['eez'],
  28.             /ing\b/  => %w/in ins ng ing/,
  29.             /have/   => %w/has hav haz a/,
  30.             /your/     => %w/yur ur yore yoar/,
  31.             /ove\b/  =>  %w/oov ove uuv uv oove/,
  32.             /for/      => %w/for 4 fr fur for foar/,
  33.             /thank/    => %w/fank tank thx thnx/,
  34.             /good/     => %w/gud goed guud gude gewd/,
  35.             /really/   => %w/rly rily rilly rilley/,
  36.             /world/    => %w/wurrld whirld wurld wrld/,
  37.             /i'?m\b/     => ['im'],
  38.            /(?!e)ight/   => ['ite'],
  39.            /(?!ues)tion/ => ['shun'],
  40.            /you\'?re/    => %w/yore yr/,
  41.            /\boh\b(?!.*hai)/  => %w/o ohs/,
  42.            /can\si\s(?:ple(?:a|e)(?:s|z)e?)?\s?have\sa/ => ['i can has'],
  43.            /(?:hello|\bhi\b|\bhey\b|howdy|\byo\b),?/    => ['oh hai,'],
  44.            /(?:god|allah|buddah?|diety)/                => ['ceiling cat'],
  45.        }
  46.    
  47.    def self.translate(sentence)
  48.        self.translate! sentence.dup
  49.    end
  50.    
  51.    def self.translate!(sentence)
  52.        sentence.downcase!
  53.        REPL.keys.each do |key|
  54.            while key =~ sentence
  55.                sentence.sub!(key, REPL[key].sample)
  56.            end
  57.        end
  58.        return sentence.upcase!
  59.    end
  60.    
  61. end
  62.  
  63. class String
  64.    
  65.    def to_lol
  66.        Lolcat.translate(self)
  67.    end
  68.    
  69.    def to_lol!
  70.        Lolcat.translate!(self)
  71.    end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement