[PERL] Language Inflation (lustiges kleines Script)
lima-city → Forum → Die eigene Homepage → Promotion
brauche
code
deflation
double
first
frage
http
internet
klang
kropf
programm
sex
single
string
suchen
text
umkehrung
url
weiteren fragen
zahl
-
Hi Leute,
Ich, bzw ich und mein Halbonkel haben ein lustiges kleines Script geschrieben (Perl), mit dessen Hilfe man einen Text (englisch) "aufblähen" (inflate) kann. Jede Zahl, sowohl numerisch als auch phonetisch (d.h. egal ob tatsächlich eine Zahl, oder nur vom Klang her) wird um eins erhöht.
z.B.:
It was a wonderful night
wird zu
It was a twoderful night
Kleiner Tipp: Sucht euch einen Text von George W. Bush aus dem Internet und inflated ihn mit dem Programm, es lohnt sich :D
HIer der Code:
use strict; my %inflations = ( 'one' => 'two', 'won' => 'two', 'wan' => 'two', 'two' => 'three', 'too' => 'three', 'to' => 'three', 'three' => 'four', 'tree' => 'for', 'free' => 'four', 'four' => 'five', 'for' => 'five', 'fur' => 'five', 'fer' => 'five', 'five' => 'six', 'six' => 'seven', 'sicks' => 'seven', 'sics' => 'seven', 'seven' => 'eight', 'eight' => 'nine', 'ate' => 'nine', 'nine' => 'ten', 'nign' => 'ten', 'ten' => 'eleven', 'tan' => 'eleven', 'eleven' => 'twelve', 'first' => 'second', 'thirst' => 'second', 'thurst' => 'second', 'second' => 'third', 'third' => 'fourth', 'fourth' => 'fifth', 'forth' => 'fifth', 'fifth' => 'sixth', 'fice' => 'sixe', 'fici' => 'sixi', 'phis' => 'sixs', 'sixth' => 'seventh', 'seventh' => 'eigth', 'eighth' => 'ninth', 'ninth' => 'tenth', 'tenth' => 'eleventh', 'eleventh' => 'twelvth', 'once' => 'twice', 'ones' => 'twoes', 'twice' => 'thrice', 'thrice' => 'four times', 'single' => 'double', 'singul' => 'doubl', 'double' => 'triple', 'triple' => 'quadruple', 'quadruple' => 'quintuple', 'quint' => 'sex', 'sex' => 'sept', 'sept' => 'oct', 'oct' => 'nov', 'nov' => 'dec', 'dec' => 'undec', 'half' => 'one-and-a-half', 'primar' => 'secondar', 'secondar' => 'tertiar', ); sub inflate { my ($string, $words_ref) = @_; my @words = sort { length $b <=> length $a } keys %$words_ref; my $word_re = join "|", @words; my @tokens = split /($word_re)/i, $string; foreach (0..$#tokens) { next unless $_ & 1; $tokens[$_] = $words_ref->{lc $tokens[$_]}; } return join '', @tokens; } while (<>) { $_ = inflate($_, \%inflations); print $_; }
Und hier die Umkehrung (deflation), wurde von mir umgeschrieben, arbeitet jedoch nicht perfekt (natürlich):
use strict; my %inflations = ( 'one' => 'zero', 'won' => 'zero', 'wan' => 'zero', 'two' => 'one', 'too' => 'one', 'to' => 'one', 'three' => 'two', 'tree' => 'two', 'free' => 'two', 'four' =>'three', 'for' => 'three', 'fur' => 'three', 'fer' => 'three', 'five' => 'four', 'six' => 'five', 'sicks' => 'five', 'sics' => 'five', 'seven' => 'six', 'eight' => 'seven', 'ate' => 'seven', 'nine' => 'eight', 'nign' => 'eight', 'ten' => 'nine', 'tan' => 'nine', 'eleven' => 'ten', 'twelve' => 'eleven', 'first' => 'none', 'thirst' => 'none', 'thurst' => 'none', 'second' => 'first', 'third' => 'second', 'fourth' => 'third', 'forth' => 'third', 'fifth' => 'fourth', 'fice' => 'fourth', 'fici' => 'fourth', 'phis' => 'fourth', 'sixth' => 'fifth', 'seventh' => 'sixth', 'eigth' => 'seventh', 'ninth' => 'eighth', 'tenth' => 'ninth', 'eleventh' => 'tenth', 'twelvth' => 'eleventh', 'once' => 'never', 'ones' => 'zeroes', 'twice' => 'once', 'twoes' => 'ones', 'thrice' => 'twice', 'four times' => 'thrice', 'double' => 'single', 'doubl' => 'singul', 'triple' => 'double', 'quadruple' => 'triple', 'quintuple' => 'quadruple', 'sex' => 'quint', 'sept' => 'sex', 'oct' => 'sept', 'nov' => 'oct', 'dec' => 'nov', 'undec' => 'dec', 'one-and-a-half' => 'half', 'secondar' => 'primar', 'tertiar' => 'secondar', ); sub inflate { my ($string, $words_ref) = @_; my @words = sort { length $b <=> length $a } keys %$words_ref; my $word_re = join "|", @words; my @tokens = split /($word_re)/i, $string; foreach (0..$#tokens) { next unless $_ & 1; $tokens[$_] = $words_ref->{lc $tokens[$_]}; } return join '', @tokens; } while (<>) { $_ = inflate($_, \%inflations); print $_; }
Ich hoffe ihr habt euren Spaß :D
Zum ausführen empfehle ich Strawberry Perl, bei weiteren Fragen, einfach fragen ;)
mfg,
InfinitySounds -
Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!
lima-city: Gratis werbefreier Webspace für deine eigene Homepage
-
Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!
lima-city: Gratis werbefreier Webspace für deine eigene Homepage