Also close bug
[filters.git] / pirate
1 #!/usr/bin/perl -p
2
3 # an array, not a hash. because order is important
4 @trans_table=(
5 '\bmy\b' => 'me',
6 '\bboss\b' => 'admiral',
7 '\bmanager\b' => 'admiral',
8 '\b[Cc]aptain\b' => "Cap'n",
9 '\bmyself\b' => 'meself',
10 '\byour\b' => 'yer',
11 '\byou\b' => 'ye',
12 '\bfriend\b' => 'matey',
13 '\bfriends\b' => 'maties',
14 '\bco[-]?worker\b' => 'shipmate',
15 '\bco[-]?workers\b' => 'shipmates',
16 '\bearlier\b' => 'afore',
17 '\bold\b' => 'auld',
18 '\bthe\b' => "th'",
19 '\bof\b' => "o'",
20 '\bdon\'t\b' => "dern't",
21 '\bdo not\b' => "dern't",
22 '\bnever\b' => "no nay ne'er",
23 '\bever\b' => "e'er",
24 '\bover\b' => "o'er",
25 '\bYes\b' => 'Aye',
26 '\bNo\b' => 'Nay',
27 '\bdon\'t know\b' => "dinna",
28 '\bhadn\'t\b' => "ha'nae",
29 '\bdidn\'t\b' => "di'nae",
30 '\bwasn\'t\b' => "weren't",
31 '\bhaven\'t\b' => "ha'nae",
32 '\bfor\b' => 'fer',
33 '\bbetween\b' => 'betwixt',
34 '\baround\b' => "aroun'",
35 '\bto\b' => "t'",
36 '\bit\'s\b' => "'tis",
37 '\bIt\'s\b' => 'It be',
38 '\bwoman\b' => 'wench',
39 '\blady\b' => 'wench',
40 '\bwife\b' => 'lady',
41 '\bgirl\b' => 'lass',
42 '\bgirls\b' => 'lassies',
43 '\bguy\b' => 'lubber',
44 '\bman\b' => 'lubber',
45 '\bfellow\b' => 'lubber',
46 '\bdude\b' => 'lubber',
47 '\bboy\b' => 'lad',
48 '\bboys\b' => 'laddies',
49 '\bchildren\b' => 'minnows',
50 '\bkids\b' => 'minnows',
51 '\bhim\b' => 'that scurvey dog',
52 '\bher\b' => 'that comely wench',
53 '\bhim\.\b' => 'that drunken sailor',
54 '\bHe\b' => 'The ornery cuss',
55 '\bShe\b' => 'The winsome lass',
56 '\bhe\'s\b' => 'he be',
57 '\bshe\'s\b' => 'she be',
58 '\bwas\b' => "were bein'",
59 '\bHey\b' => 'Avast',
60 '\bher\.\b' => 'that lovely lass',
61 '\bfood\b' => 'chow',
62 '\broad\b' => 'sea',
63 '\broads\b' => 'seas',
64 '\bstreet\b' => 'river',
65 '\bstreets\b' => 'rivers',
66 '\bhighway\b' => 'ocean',
67 '\bhighways\b' => 'oceans',
68 '\bcar\b' => 'boat',
69 '\bcars\b' => 'boats',
70 '\btruck\b' => 'schooner',
71 '\btrucks\b' => 'schooners',
72 '\bSUV\b' => 'ship',
73 '\bmachine\b' => 'contraption',
74 '\bairplane\b' => 'flying machine',
75 '\bjet\b' => 'flying machine',
76 '\bdriving\b' => 'sailing',
77 '\bdrive\b' => 'sail',
78 '\bwith\b' => "wi'",
79 '\bam\b' => 'be',
80 '\bis\b' => 'be',
81 '\bare\b' => 'be',
82 '\bwas\b' => 'be',
83 '\bwere\b' => 'be',
84 '\bwere\b' => 'be',
85 );
86
87 while (@trans_table) {
88 $key=shift @trans_table;
89 $value=shift @trans_table;
90 s/$key/$value/g;
91 }
92
93 s/ing\b/in'/g;
94 s/ings\b/in's/g;
95 s/(\.( |\t|$))/avast($1,3)/eg;
96 s/([!\?]( \t|$))/avast($1,2)/eg; # Greater chance after exclamation
97 s/\Br\B/roll()/eg;
98
99 sub roll {
100 return 'r' x (rand(5)+1) if rand > 0.5;
101 return 'r';
102 }
103
104 sub avast {
105 my $stub=shift;
106 my $chance=shift;
107
108 my @shouts=(
109 ", avast$stub",
110 "$stub Ahoy!",
111 ", and a bottle of rum!",
112 ", by Blackbeard's sword$stub",
113 ", by Davy Jones' locker$stub",
114 "$stub Walk the plank!",
115 "$stub Aarrr!",
116 "$stub Yaaarrrrr!",
117 ", pass the grog!",
118 ", and dinna spare the whip!",
119 ", with a chest full of booty$stub",
120 ", and a bucket o' chum$stub",
121 ", we'll keel-haul ye!",
122 "$stub Shiver me timbers!",
123 "$stub And hoist the mainsail!",
124 "$stub And swab the deck!",
125 ", ye scurvey dog$stub",
126 "$stub Fire the cannons!",
127 ", to be sure$stub",
128 ", I'll warrant ye$stub",
129 "$stub Arr, me hearty!",
130 );
131
132 if (int rand($chance) == 1) {
133 return @shouts[rand @shouts]." ";
134 }
135 else {
136 return $stub;
137 }
138 }
This page took 0.030127 seconds and 4 git commands to generate.