Updates to derived languages scripts, preparing for possible future uses.

This commit is contained in:
Curt Mills 2008-08-31 20:52:34 +00:00
parent c970737659
commit 8d52f59134
6 changed files with 345 additions and 186 deletions

View file

@ -53,15 +53,15 @@ fi
# Generate derived language files
echo -n " 1) Generating derived language files"
(cd config; ../scripts/langPigLatin.pl <language-English.sys >language-PigLatin.sys)
(cd config; ../scripts/langPigLatin.pl -split <language-English.sys >language-PigLatin.sys)
echo -n "."
(cd config; ../scripts/langElmerFudd.pl <language-English.sys >language-ElmerFudd.sys)
(cd config; ../scripts/langElmerFudd.pl -split <language-English.sys >language-ElmerFudd.sys)
echo -n "."
(cd config; ../scripts/langMuppetsChef.pl <language-English.sys >language-MuppetsChef.sys)
(cd config; ../scripts/langMuppetsChef.pl -split <language-English.sys >language-MuppetsChef.sys)
echo -n "."
(cd config; ../scripts/langOldeEnglish.pl <language-English.sys >language-OldeEnglish.sys)
(cd config; ../scripts/langOldeEnglish.pl -split <language-English.sys >language-OldeEnglish.sys)
echo -n "."
(cd config; ../scripts/langPirateEnglish.pl <language-English.sys >language-PirateEnglish.sys)
(cd config; ../scripts/langPirateEnglish.pl -split <language-English.sys >language-PirateEnglish.sys)
echo "."
echo "Bootstrap complete."

View file

@ -1,4 +1,4 @@
#!/usr/bin/perl -n
#!/usr/bin/perl -W
# $Id$
@ -25,13 +25,12 @@
# Run it like this:
#
# cd xastir/config
# ../scripts/langElmerFudd.pl <language-English.sys >language-ElmerFudd.sys
# ../scripts/langElmerFudd.pl -split <language-English.sys >language-ElmerFudd.sys
# or
# ../scripts/langElmerFudd.pl <some-input-file >some-output-file
#
# If you would like, replace the language-English.sys file in the
# destination directory (usually "/usr/local/share/xastir/config")
# with this new file (renaming it to "language-English.sys" of
# course), then restart Xastir and you'll have it displaying in
# ElmerFudd-speak!
# "-split": Translate 2nd part of line only (Xastir language file).
# Without it: Translate entire text.
# Regex strings derived from:
@ -43,35 +42,68 @@
my @regexs = (
"[rl]:w",
"[RL]:W",
"([qQ])u:$1w",
"th(\b):f$1",
"TH(\b):F$1",
"Qu:Qw",
"qu:qw",
"th(\b):f",
"TH(\b):F",
"th:d",
"Th:D",
"([nN])[.]:$1, uh-hah-hah-hah."
"N[.]:N, uh-hah-hah-hah.",
"n[.]:n, uh-hah-hah-hah."
);
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
print "# language-ElmerFudd.sys, translated from language-English.sys\n";
print "# Please do not edit this derived file.\n";
next;
# Check whether we're translating an Xastir language file or plain
# text:
# "-split" present: Translate the 2nd piece of each line.
# "-split" absent: Translate the entire text.
my $a;
if ($#ARGV < 0) { $a = ""; }
else { $a = shift; }
$do_split = 0;
if (length($a) > 0 && $a =~ m/-split/) {
$do_split = 1;
}
# Skip other comment lines
if (m/^#/) { next; }
# Split each incoming line by the '|' character
@pieces = split /\|/;
while ( <> ) {
foreach my $test (@regexs) {
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
print "# language-ElmerFudd.sys, translated from language-English.sys\n";
print "# Please do not edit this derived file.\n";
next;
}
# Skip other comment lines
if (m/^#/) {
next;
}
if ($do_split) {
# Split each incoming line by the '|' character
@pieces = split /\|/;
}
foreach my $test (@regexs) {
@reg_parts = split /\:/, $test;
# Modify the second portion of each line only
$pieces[1] =~ s/$reg_parts[0]/$reg_parts[1]/;
if ($do_split) {
# Translate the second portion of each line only
$pieces[1] =~ s/$reg_parts[0]/$reg_parts[1]/g;
}
else {
# Translate the entire line of text
s/$reg_parts[0]/$reg_parts[1]/g;
}
}
if ($do_split) {
# Combine the line again for output to STDOUT
print join '|', @pieces;
}
else {
print;
}
}
# Combine the line again for output to STDOUT
print join '|', @pieces;

View file

@ -1,4 +1,4 @@
#!/usr/bin/perl -n
#!/usr/bin/perl -W
# $Id$
@ -25,13 +25,12 @@
# Run it like this:
#
# cd xastir/config
# ../scripts/langMuppetsChef.pl <language-English.sys >language-MuppetsChef.sys
# ../scripts/langMuppetsChef.pl -split <language-English.sys >language-MuppetsChef.sys
# or
# ../scripts/langMuppetsChef.pl <some-input-file >some-output-file
#
# If you would like, replace the language-English.sys file in the
# destination directory (usually "/usr/local/share/xastir/config")
# with this new file (renaming it to "language-English.sys" of
# course), then restart Xastir and you'll have it displaying in
# Muppets Chef-speak!
# "-split": Translate 2nd part of line only (Xastir language file).
# Without it: Translate entire text.
# Regex strings derived from:
@ -41,32 +40,40 @@
my @regexs = (
"a([nu]):u$1",
"A([nu]):U$1",
"a\B:e",
"A\B:E",
"en\b:ee",
"\Bew:oo",
"\Be\b:e-a",
"\be:i",
"\bE:I",
"\Bf:ff",
"\Bir:ur",
"(\w*?)i(\w*?)$:$1ee$2",
"\bow:oo",
"\bo:oo",
"\bO:Oo",
"An:Un",
"an:un",
"Au:Uu",
"au:uu",
"a\\b:e",
"A\\b:E",
"en\\b:ee",
"\\bew:oo",
"\\be\\b:e-a",
"\\be:i",
"\\bE:I",
"\\bf:ff",
"\\bir:ur",
# Can't get substitutions in the s/// portion below correct.
# Changing the below to compensate (somewhat).
# "(\\w*?)i(\\w*?)\$:$1ee$2",
"i:ee",
"I:Ee",
"\\bow:oo",
"\\bo:oo",
"\\bO:Oo",
"the:zee",
"The:Zee",
"th\b:t",
"\Btion:shun",
"\Bu:oo",
"\BU:Oo",
"th\\b:t",
"\\btion:shun",
"\\bu:oo",
"\\bU:Oo",
"v:f",
"V:F",
"w:w",
"W:W",
"([a-z])[.]:$&. Bork Bork Bork!"
"([a-z])[.]:\$&. Bork Bork Bork!"
# From the text-filter-suite:
# '%an%' => 'un',
@ -74,33 +81,33 @@ my @regexs = (
#
# '%au%' => 'oo',
# '%Au%' => 'Oo',
# '%(\w)ew%' => '$1oo',
# '%(\w)ow%' => '$1oo',
# '%(\W)o%' => '$1oo',
# '%(\W)O%' => '$1Oo',
# '%(\w)u%' => '$1oo',
# '%(\w)U%' => '$1Oo',
# '%(\\w)ew%' => '$1oo',
# '%(\\w)ow%' => '$1oo',
# '%(\\W)o%' => '$1oo',
# '%(\\W)O%' => '$1Oo',
# '%(\\w)u%' => '$1oo',
# '%(\\w)U%' => '$1Oo',
#
# '%a(\w)%' => 'e$1',
# '%A(\w)%' => 'E$1',
# '%en(\W)%' => 'ee$1',
# '%a(\\w)%' => 'e$1',
# '%A(\\w)%' => 'E$1',
# '%en(\\W)%' => 'ee$1',
#
# '%(\w)e(\W)%' => '$1e-a$2',
# '%(\W)e%' => '$1i',
# '%(\W)E%' => '$1I',
# '%(\\w)e(\\W)%' => '$1e-a$2',
# '%(\\W)e%' => '$1i',
# '%(\\W)E%' => '$1I',
#
# '%(\w)f%' => '$1ff',
# '%(\\w)f%' => '$1ff',
#
# '%(\w)ir%' => '$1ur',
# '%(\\w)ir%' => '$1ur',
#
# '%([a-m])i%' => '$1ee',
# '%([A-M])i%' => '$1EE',
#
# '%(\w)o%' => '$1u',
# '%(\\w)o%' => '$1u',
# '%the%' => 'zee',
# '%The%' => 'Zee',
# '%th(\W)%' => 't$1',
# '%(\w)tion%' => '$1shun',
# '%th(\\W)%' => 't$1',
# '%(\\w)tion%' => '$1shun',
# '%v%' => 'f',
# '%V%' => 'F',
# '%w%' => 'v',
@ -110,31 +117,62 @@ my @regexs = (
# '%o{2,}%' => 'oo',
# '%e{2,}%' => 'ee',
#
# '%([\.!\?])\s*(</[^>]+>)?\s*$%' => '$1 Bork Bork Bork!$2',
# '%([\.!\?])\\s*(</[^>]+>)?\\s*$%' => '$1 Bork Bork Bork!$2',
);
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
# Check whether we're translating an Xastir language file or plain
# text:
# "-split" present: Translate the 2nd piece of each line.
# "-split" absent: Translate the entire text.
my $a;
if ($#ARGV < 0) { $a = ""; }
else { $a = shift; }
$do_split = 0;
if (length($a) > 0 && $a =~ m/-split/) {
$do_split = 1;
}
while ( <> ) {
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
print "# language-MuppetsChef.sys, translated from language-English.sys\n";
print "# Please do not edit this derived file.\n";
next;
}
# Skip other comment lines
if (m/^#/) { next; }
}
# Skip other comment lines
if (m/^#/) {
next;
}
# Split each incoming line by the '|' character
@pieces = split /\|/;
if ($do_split) {
# Split each incoming line by the '|' character
@pieces = split /\|/;
}
foreach my $test (@regexs) {
foreach my $test (@regexs) {
@reg_parts = split /\:/, $test;
# Modify the second portion of each line only
$pieces[1] =~ s/$reg_parts[0]/$reg_parts[1]/;
if ($do_split) {
# Translate the second portion of each line only
$pieces[1] =~ s/$reg_parts[0]/$reg_parts[1]/g;
}
else {
# Translate the entire line of text
s/$reg_parts[0]/$reg_parts[1]/g;
}
}
if ($do_split) {
# Combine the line again for output to STDOUT
print join '|', @pieces;
}
else {
print;
}
}
# Combine the line again for output to STDOUT
print join '|', @pieces;

View file

@ -1,4 +1,5 @@
#!/usr/bin/perl -n
#!/usr/bin/perl
##!/usr/bin/perl -W
# $Id$
@ -25,13 +26,12 @@
# Run it like this:
#
# cd xastir/config
# ../scripts/langOldeEnglish.pl <language-English.sys >language-OldeEnglish.sys
# ../scripts/langOldeEnglish.pl -split <language-English.sys >language-OldeEnglish.sys
# or
# ../scripts/langOldeEnglish.pl <some-input-file >some-output-file
#
# If you would like, replace the language-English.sys file in the
# destination directory (usually "/usr/local/share/xastir/config")
# with this new file (renaming it to "language-English.sys" of
# course), then restart Xastir and you'll have it displaying in
# OldeEnglish!
# "-split": Translate 2nd part of line only (Xastir language file).
# Without it: Translate entire text.
# Regex strings derived from:
@ -39,6 +39,9 @@
# http://www.siafoo.net/snippet/133
# NOTE: The $1/$2 substitutions are working at the point the regex
# is used, so those portions of the original string disappear. Need
# to fix this!
my @regexs = (
"i([bcdfghjklmnpqrstvwxyz])e\b:y$1",
"i([bcdfghjklmnpqrstvwxyz])e:y$1$1e",
@ -86,27 +89,59 @@ my @regexs = (
"when:whan"
);
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
# Check whether we're translating an Xastir language file or plain
# text:
# "-split" present: Translate the 2nd piece of each line.
# "-split" absent: Translate the entire text.
my $a;
if ($#ARGV < 0) { $a = ""; }
else { $a = shift; }
$do_split = 0;
if (length($a) > 0 && $a =~ m/-split/) {
$do_split = 1;
}
while ( <> ) {
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
print "# language-OldeEnglish.sys, translated from language-English.sys\n";
print "# Please do not edit this derived file.\n";
next;
}
# Skip other comment lines
if (m/^#/) { next; }
}
# Skip other comment lines
if (m/^#/) {
next;
}
# Split each incoming line by the '|' character
@pieces = split /\|/;
if ($do_split) {
# Split each incoming line by the '|' character
@pieces = split /\|/;
}
foreach my $test (@regexs) {
foreach my $test (@regexs) {
@reg_parts = split /\:/, $test;
# Modify the second portion of each line only
$pieces[1] =~ s/$reg_parts[0]/$reg_parts[1]/;
if ($do_split) {
# Translate the second portion of each line only
$pieces[1] =~ s/$reg_parts[0]/$reg_parts[1]/g;
}
else {
# Translate the entire line of text
s/$reg_parts[0]/$reg_parts[1]/g;
}
}
if ($do_split) {
# Combine the line again for output to STDOUT
print join '|', @pieces;
}
else {
print;
}
}
# Combine the line again for output to STDOUT
print join '|', @pieces;

View file

@ -1,4 +1,4 @@
#!/usr/bin/perl -n
#!/usr/bin/perl -W
# $Id$
@ -25,35 +25,58 @@
# Run it like this:
#
# cd xastir/config
# ../scripts/langPigLatin.pl <language-English.sys >language-PigLatin.sys
# ../scripts/langPigLatin.pl -split <language-English.sys >language-PigLatin.sys
# or
# ../scripts/langPigLatin.pl <some-input-file >some-output-file
#
# If you would like, replace the language-English.sys file in the
# destination directory (usually "/usr/local/share/xastir/config")
# with this new file (renaming it to "language-English.sys" of
# course), then restart Xastir and you'll have it displaying in Pig
# Latin!
# "-split": Translate 2nd part of line only (Xastir language file).
# Without it: Translate entire text.
# Regex strings derived from:
# http://www.perlmonks.org/?node_id=3586
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
# Check whether we're translating an Xastir language file or plain
# text:
# "-split" present: Translate the 2nd piece of each line.
# "-split" absent: Translate the entire text.
my $a;
if ($#ARGV < 0) { $a = ""; }
else { $a = shift; }
$do_split = 0;
if (length($a) > 0 && $a =~ m/-split/) {
$do_split = 1;
}
while ( <> ) {
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
print "# language-PigLatin.sys, translated from language-English.sys\n";
print "# Please do not edit this derived file.\n";
next;
}
# Skip other comment lines
if (m/^#/) {
next;
}
if ($do_split) {
# Split each incoming line by the '|' character
@pieces = split /\|/;
# Translate the second portion of each line only
$pieces[1] =~ s/\b(qu|y(?=[^t])|[^\W\daeiouy]*)([a-z']+)/$2.($1||"w")."ay"/eg;
# Combine the line again for output to STDOUT
print join '|', @pieces;
}
else {
# Translate the entire line of text
s/\b(qu|y(?=[^t])|[^\W\daeiouy]*)([a-z']+)/$2.($1||"w")."ay"/eg;
print;
}
}
# Skip other comment lines
if (m/^#/) { next; }
# Split each line by the '|' character
@pieces = split /\|/;
# Modify the second portion of each line only
$pieces[1] =~ s/\b(qu|y(?=[^t])|[^\W\daeiouy]*)([a-z']+)/$2.($1||w).ay/eg;
# Combine the line again for output to STDOUT
print join '|', @pieces;

View file

@ -1,4 +1,4 @@
#!/usr/bin/perl -n
#!/usr/bin/perl -W
# $Id$
@ -25,13 +25,12 @@
# Run it like this:
#
# cd xastir/config
# ../scripts/langPirateEnglish.pl <language-English.sys >language-PirateEnglish.sys
# ../scripts/langPirateEnglish.pl -split <language-English.sys >language-PirateEnglish.sys
# or
# ../scripts/langPirateEnglish.pl <some-input-file >some-output-file
#
# If you would like, replace the language-English.sys file in the
# destination directory (usually "/usr/local/share/xastir/config")
# with this new file (renaming it to "language-English.sys" of
# course), then restart Xastir and you'll have it displaying in
# Pirate-speak!
# "-split": Translate 2nd part of line only (Xastir language file).
# Without it: Translate entire text.
# Regex strings derived from:
@ -52,7 +51,8 @@ my @regexs = (
"\\bkb7uvc\\b:scurvy dog",
"\\bwa7nwp\\b:cabin boy",
"\\b[Mm]ap\\b:Treasure Map",
"\\b([xX]astir)\\b:HMS $1",
"\\bXastir\\b:HMS Xastir",
"\\bxastir\\b:HMS xastir",
"\\bXASTIR\\b:HMS XASTIR",
"\\bStation:Ship",
"\\bstation:ship",
@ -237,7 +237,7 @@ my @regexs = (
"\\bguy\\b:feller",
"\\bfellow\\b:feller",
"\\bidiot\\b:scalawag",
"\\ing\\b:in\'",
"ing\\b:in\'",
"\\bin\\b:\'n",
"\\bis\\b:be",
"\\bit\'s\\b:\'tis",
@ -453,36 +453,36 @@ my @regexs = (
# Randomize use of this array, both in order and in frequency of
# use. Not currently used at all.
my @shouts = (
", avast$stub",
"$stub Ahoy!",
", and a bottle of rum!",
", by Blackbeard's sword$stub",
", by Davy Jones' locker$stub",
"$stub Walk the plank!",
"$stub Aarrr!",
"$stub Yaaarrrrr!",
", pass the grog!",
", and dinna spare the whip!",
", with a chest full of booty$stub",
", and a bucket o' chum$stub",
", we'll keel-haul ye!",
"$stub Shiver me timbers!",
"$stub And hoist the mainsail!",
"$stub And swab the deck!",
", ye scurvey dog$stub",
"$stub Fire the cannons!",
", to be sure$stub",
", I'll warrant ye$stub",
", on a dead man's chest!",
"$stub Load the cannons!",
"$stub Prepare to be boarded!",
", I'll warrant ye$stub",
"$stub Ye'll be sleepin' with the fishes!",
"$stub The sharks will eat well tonight!",
"$stub Oho!",
"$stub Fetch me spyglass!",
);
#my @shouts = (
# ", avast$stub",
# "$stub Ahoy!",
# ", and a bottle of rum!",
# ", by Blackbeard's sword$stub",
# ", by Davy Jones' locker$stub",
# "$stub Walk the plank!",
# "$stub Aarrr!",
# "$stub Yaaarrrrr!",
# ", pass the grog!",
# ", and dinna spare the whip!",
# ", with a chest full of booty$stub",
# ", and a bucket o' chum$stub",
# ", we'll keel-haul ye!",
# "$stub Shiver me timbers!",
# "$stub And hoist the mainsail!",
# "$stub And swab the deck!",
# ", ye scurvey dog$stub",
# "$stub Fire the cannons!",
# ", to be sure$stub",
# ", I'll warrant ye$stub",
# ", on a dead man's chest!",
# "$stub Load the cannons!",
# "$stub Prepare to be boarded!",
# ", I'll warrant ye$stub",
# "$stub Ye'll be sleepin' with the fishes!",
# "$stub The sharks will eat well tonight!",
# "$stub Oho!",
# "$stub Fetch me spyglass!",
# );
# Randomize use of this array both in order and frequency of use.
# Not currently used at all.
@ -497,29 +497,60 @@ my @openings = (
'Arrrr! '
);
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
print "# language-PirateEnglish.sys, translated from language-English.sys\n";
print "# Please do not edit this derived file.\n";
# Check whether we're translating an Xastir language file or plain
# text:
# "-split" present: Translate the 2nd piece of each line.
# "-split" absent: Translate the entire text.
my $a;
if ($#ARGV < 0) { $a = ""; }
else { $a = shift; }
$do_split = 0;
if (length($a) > 0 && $a =~ m/-split/) {
$do_split = 1;
}
while ( <> ) {
# Change the "Id:" RCS tag to show that we translated the file.
if (m/^#.*\$Id:/) {
print "# language-PirateEnglish.sys, translated from language-English.sys\n";
print "# Please do not edit this derived file.\n";
next;
}
# Skip other comment lines
if (m/^#/) {
next;
}
# Skip other comment lines
if (m/^#/) { next; }
}
# Split each incoming line by the '|' character
@pieces = split /\|/;
if ($do_split) {
# Split each incoming line by the '|' character
@pieces = split /\|/;
}
foreach my $test (@regexs) {
foreach my $test (@regexs) {
@reg_parts = split /\:/, $test;
@reg_parts = split /\:/, $test;
# Modify the second portion of each line only
$pieces[1] =~ s/$reg_parts[0]/$reg_parts[1]/;
if ($do_split) {
# Translate the second portion of each line only
$pieces[1] =~ s/$reg_parts[0]/$reg_parts[1]/g;
}
else {
# Translate the entire line of text
s/$reg_parts[0]/$reg_parts[1]/g;
}
}
# Add an opening phrase to each line randomly?
if ($do_split) {
# Combine the line again for output to STDOUT
print join '|', @pieces;
}
else {
print;
}
}
# Add an opening phrase to each line randomly?
# Combine the line again for output to STDOUT
print join '|', @pieces;