line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## -*- Cperl -*- |
2
|
|
|
|
|
|
|
package Text::Bastardize; |
3
|
|
|
|
|
|
|
$VERSION = 0.08; |
4
|
1
|
|
|
1
|
|
601
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1527
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
8
|
|
|
|
|
|
|
# Copyright (C) 1999-2006 Julian Fondren |
9
|
|
|
|
|
|
|
# Licensed as with perl itself. |
10
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
1
|
|
|
1
|
1
|
69
|
my $proto = shift; |
14
|
1
|
|
33
|
|
|
11
|
my $class = ref($proto) || $proto; |
15
|
1
|
|
|
|
|
2
|
my $self = []; |
16
|
1
|
|
|
|
|
5
|
bless($self, $class) |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
9
|
|
|
9
|
1
|
16
|
sub peek { @{+shift} } |
|
9
|
|
|
|
|
47
|
|
20
|
|
|
|
|
|
|
sub charge { |
21
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
22
|
1
|
|
|
|
|
2
|
@{$self} = @_; |
|
1
|
|
|
|
|
6
|
|
23
|
1
|
|
|
|
|
3
|
$self |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub disemvowel { |
27
|
1
|
|
|
1
|
1
|
9
|
my @d = shift->peek; |
28
|
1
|
|
|
|
|
23
|
s/\B[aeiou]\B//ig for @d; |
29
|
|
|
|
|
|
|
@d |
30
|
1
|
|
|
|
|
28
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub rot13 { |
33
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
34
|
1
|
|
|
|
|
3
|
map { tr/a-zA-Z/n-za-mN-ZA-M/; $_ } $self->peek |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
26
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub k3wlt0k { |
38
|
|
|
|
|
|
|
# a slightly modified version of Fmh's t0k.pl |
39
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
40
|
1
|
|
|
|
|
4
|
my @k = $self->peek; |
41
|
1
|
|
|
|
|
3
|
for (@k) { |
42
|
1
|
|
|
|
|
3
|
y/A-Z/a-z/; |
43
|
1
|
|
|
|
|
8
|
s/\bth/d/sg; |
44
|
1
|
|
|
|
|
2
|
s/ck\b/x0r/sg; |
45
|
1
|
|
|
|
|
2
|
s/cking\b/x0ring/sg; |
46
|
1
|
|
|
|
|
3
|
s/cked\b/x0red/sg; |
47
|
1
|
|
|
|
|
2
|
s/cker/x0r/sg; |
48
|
1
|
|
|
|
|
4
|
s/or/er/sg; |
49
|
1
|
|
|
|
|
2
|
s/ing/in/sg; |
50
|
1
|
|
|
|
|
2
|
s/cause/cus/sg; |
51
|
1
|
|
|
|
|
4
|
s/fu/f00/sg; |
52
|
1
|
|
|
|
|
2
|
s/word/werd/sg; |
53
|
1
|
|
|
|
|
2
|
s/oo/ew/sg; |
54
|
1
|
|
|
|
|
2
|
s/for/4/sg; |
55
|
1
|
|
|
|
|
10
|
s/ate/8/sg; |
56
|
1
|
|
|
|
|
2
|
y/uaes itz clo/v34z 17s s10/; |
57
|
1
|
|
|
|
|
3
|
s/\'//sg; |
58
|
1
|
|
|
|
|
1
|
s/\./.../sg; |
59
|
1
|
|
|
|
|
3
|
s/!/!!!/sg; |
60
|
1
|
|
|
|
|
3
|
s/\?/???/sg; |
61
|
1
|
|
|
|
|
2
|
s/\bc/k/sg; |
62
|
1
|
|
|
|
|
4
|
s/00/o0/sg; |
63
|
1
|
|
|
|
|
3
|
s/0rk/r0k/sg; |
64
|
1
|
|
|
|
|
2
|
s/y0v/j00/sg; |
65
|
1
|
|
|
|
|
2
|
s/[ck]o01/k3wl/sg; |
66
|
1
|
|
|
|
|
2
|
s/741k/t0k/sg; |
67
|
1
|
|
|
|
|
2
|
s/j00\B/j3r/sg; |
68
|
1
|
|
|
|
|
2
|
s/3z/z3/sg; |
69
|
1
|
|
|
|
|
2
|
s/3r/ur/sg; |
70
|
1
|
|
|
|
|
3
|
y/a-z/A-Z/; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
@k |
73
|
1
|
|
|
|
|
26
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub rdct { |
76
|
1
|
|
|
1
|
1
|
9
|
my $self = shift; |
77
|
1
|
|
|
|
|
2
|
my @r = $self->peek; |
78
|
1
|
|
|
|
|
4
|
for (@r) { |
79
|
1
|
|
|
|
|
2
|
y/A-Z/a-z/; |
80
|
1
|
|
|
|
|
7
|
y/!#.,?\'\";//; |
81
|
1
|
|
|
|
|
5
|
s/of/uv/sg; |
82
|
1
|
|
|
|
|
2
|
s/one/1/sg; |
83
|
1
|
|
|
|
|
9
|
s/\b(?:a|e)//sg; |
84
|
1
|
|
|
|
|
2
|
s/a?n?ks/x/sg; |
85
|
1
|
|
|
|
|
2
|
s/you/u/sg; |
86
|
1
|
|
|
|
|
2
|
s/are/r/sg; |
87
|
1
|
|
|
|
|
2
|
s/youre?/ur/sg; |
88
|
1
|
|
|
|
|
14
|
s/\B(?:a|e|i|o|u)\B//sg; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
@r |
91
|
1
|
|
|
|
|
26
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# 7Oct2006: I don't care about this right now; |
94
|
|
|
|
|
|
|
# presumably it works. Will look it over for the |
95
|
|
|
|
|
|
|
# next release. |
96
|
|
|
|
|
|
|
sub pig { |
97
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
98
|
1
|
|
|
|
|
17
|
my @pig; # what is to be returned, the final result |
99
|
|
|
|
|
|
|
my @piggie; # a word-by-word splitting of each element |
100
|
0
|
|
|
|
|
0
|
my $allupper; |
101
|
0
|
|
|
|
|
0
|
my $firstupper; |
102
|
1
|
|
|
|
|
3
|
my $i = 0; |
103
|
1
|
|
|
|
|
4
|
for my $v ($self->peek()) { # by line |
104
|
1
|
|
|
|
|
8
|
@piggie = split(/ /, $v); |
105
|
1
|
|
|
|
|
3
|
for my $w (@piggie) { # by word |
106
|
11
|
100
|
|
|
|
29
|
"\U$w" eq $w ? $allupper = 1 : $allupper = 0; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# append "way" if word starts with an un'y' vowel |
109
|
11
|
100
|
|
|
|
6175
|
if (substr($w, 0, 1) =~ /a|e|i|o|u/i) { |
110
|
3
|
50
|
|
|
|
21
|
$allupper ? $w .= "WAY" : $w .= "way"; |
111
|
|
|
|
|
|
|
} |
112
|
11
|
100
|
|
|
|
34
|
"\u\L$w" eq $w ? $firstupper = 1 : $firstupper = 0; |
113
|
11
|
50
|
|
|
|
31
|
$w =lc $w unless $allupper; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# copy leading consonants to the end of the word, |
116
|
|
|
|
|
|
|
# not counting "qu" |
117
|
11
|
|
|
|
|
46
|
until (substr($w, 0, 1) =~ /a|e|i|o|u|y/i) { |
118
|
10
|
50
|
|
|
|
28
|
unless (substr($w, 0, 2) eq "qu") { |
119
|
10
|
|
|
|
|
68
|
$w = join '', reverse unpack ('aa*', $w); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
11
|
100
|
|
|
|
27
|
$w .= "ay" unless substr($w,-2,2) eq "ay"; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# sickness. |
125
|
11
|
100
|
|
|
|
32
|
if ($w =~ /[.!?,%]/s) { |
126
|
2
|
|
|
|
|
6
|
$w =~ s/([,.!?])//s; |
127
|
2
|
50
|
|
|
|
11
|
$w .= $1 if $1; |
128
|
|
|
|
|
|
|
} |
129
|
11
|
50
|
|
|
|
28
|
if ($w =~ /[\$]/s) { |
130
|
0
|
|
|
|
|
0
|
$w =~ s/([\$])//s; |
131
|
0
|
0
|
|
|
|
0
|
$w .= $1 if $1; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
11
|
50
|
|
|
|
23
|
$w = ucfirst $w if $firstupper; |
135
|
11
|
|
|
|
|
20
|
$piggie[$i++] = $w; |
136
|
|
|
|
|
|
|
} |
137
|
1
|
|
|
|
|
6
|
push(@pig, join(' ', @piggie)); |
138
|
|
|
|
|
|
|
} |
139
|
1
|
|
|
|
|
41
|
return @pig; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub rev { |
143
|
1
|
|
|
1
|
1
|
9
|
my $self = shift; |
144
|
1
|
|
|
|
|
3
|
map { scalar reverse $_ } $self->peek; |
|
1
|
|
|
|
|
43
|
|
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub censor { |
148
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
149
|
1
|
|
|
|
|
3
|
my @censor; |
150
|
1
|
|
|
|
|
2
|
LINE: foreach my $l ($self->peek()) { |
151
|
1
|
|
|
|
|
2
|
my @w; |
152
|
1
|
|
|
|
|
6
|
WORD: foreach my $w (split / /, $l) { |
153
|
11
|
100
|
100
|
|
|
42
|
$w =~ y/aeiouAEIOU/**********/ |
154
|
|
|
|
|
|
|
unless (length $w > 10 or length $w < 4); |
155
|
11
|
|
|
|
|
22
|
push @w, $w; |
156
|
|
|
|
|
|
|
} |
157
|
1
|
|
|
|
|
8
|
push @censor, (join ' ', @w); |
158
|
|
|
|
|
|
|
} |
159
|
1
|
|
|
|
|
33
|
@censor; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub n20e { |
163
|
|
|
|
|
|
|
# numerical_abbreviation |
164
|
1
|
|
|
1
|
1
|
8
|
my $self = shift; |
165
|
1
|
|
|
|
|
2
|
my @n20e; |
166
|
1
|
|
|
|
|
4
|
LINE: foreach my $l ($self->peek()) { |
167
|
1
|
|
|
|
|
2
|
my @w; |
168
|
1
|
|
|
|
|
5
|
WORD: foreach my $w (split / /, $l) { |
169
|
11
|
|
|
|
|
15
|
my $chars = length $w; |
170
|
11
|
100
|
|
|
|
24
|
if ($chars <= 6) { |
171
|
8
|
|
|
|
|
16
|
push @w, $w; |
172
|
8
|
|
|
|
|
20
|
next WORD; |
173
|
|
|
|
|
|
|
} |
174
|
3
|
|
|
|
|
17
|
my @chars = (substr($w, 0, 1), substr($w, -1, 1)); |
175
|
3
|
|
|
|
|
34
|
push @w, ($chars[0] . ($chars - 2) . $chars[1]); |
176
|
|
|
|
|
|
|
} |
177
|
1
|
|
|
|
|
7
|
push @n20e, (join ' ', @w); |
178
|
|
|
|
|
|
|
} |
179
|
1
|
|
|
|
|
39
|
@n20e; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
__END__ |