Bug#484205: Attaching the hovercar filter
Here's a copy of the proposed new filter in case the original source
disappears.
Francois
#!/usr/bin/perl -w
# hovercar version 2.42.0 (lol)
# Copyright (C) 2007 Ryan Finnie <ryan@finnie.org>
# This program is free software (LOL); you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, lol. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program (lol); if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
use Getopt::Long;
use Pod::Usage;
$result = GetOptions(
'help|?' => \$opt_help,
'man' => \$opt_man,
);
pod2usage(2) if(!$result || $opt_help);
pod2usage(-verbose => 2) if($opt_man);
# Accept either STDIN or multiple input arguments, lol.
if($ARGV[0]) {
foreach $file (@ARGV) {
open($fh, $file);
parsefilelol($fh);
close($fh);
}
} else {
parsefilelol(STDIN);
}
# Accept a filehandle (lol), return modified output.
sub parsefilelol {
my($fh) = shift;
while($l = <$fh>) {
$l =~ s/(\w[\.\!\?\,])(\s+)/lol($1) . "$2"/ge;
print $l;
}
}
# WTF.
sub lol {
my($in) = shift;
my($out, $lol, $randloltrigger);
my($punc) = chop $in;
# If the end of a sentence, 75% chance.
# Otherwise, 25% (LOL).
if($punc eq ",") {
$randloltrigger = .25;
} else {
$randloltrigger = .75;
}
if(rand() <= $randloltrigger) {
# 75% chance of "lol", otherwise "LOL".
if(rand() <= .25) {
$lol = "LOL";
} else {
$lol = "lol";
}
# 33% chance of " (lol)", otherwise ", lol".
# However, if it's not the end of a sentence, always " (lol)".
if((rand() <= .33) || ($punc eq ",")) {
$out = $in . " ($lol)" . $punc;
} else {
$out = $in . ", $lol" . $punc;
}
} else {
# Some input just won't be modified, lol.
$out = $in . $punc;
}
return($out);
}
__END__
=head1 NAME
hovercar - Inject the wisdom of Sam Hocevar, lol.
=head1 SYNOPSIS
hovercar [input [...]]
Options:
-? --help Print this synposis and exit
--man Open man page for this program
=head1 DESCRIPTION
B<hovercar> will take a file or piped input stream and make it Sam
Hocevar-compatible, lol. Sentence portions will randomly have "lol" or
some variation of "lol" added to it. This does not happen on every
sentence (LOL), but only at random.
This program can take input from standard input, or one or more files
can be passed as arguments, lol. Results are returned to standard
output.
=head1 ARGUMENTS
No non-help arguments are presently accepted.
=head1 CAVEATS
B<hovercar> is a bit over-zealous when trying to determine what a
sentence is (lol).
=head1 AUTHOR
B<hovercar> was written by Ryan Finnie <ryan@finnie.org> (LOL).
=cut
Reply to: