summaryrefslogtreecommitdiffstats
path: root/versification/v11nsys.pl
diff options
context:
space:
mode:
Diffstat (limited to 'versification/v11nsys.pl')
-rw-r--r--versification/v11nsys.pl146
1 files changed, 81 insertions, 65 deletions
diff --git a/versification/v11nsys.pl b/versification/v11nsys.pl
index 1d19713..b8a0c78 100644
--- a/versification/v11nsys.pl
+++ b/versification/v11nsys.pl
@@ -10,6 +10,66 @@
###############################################################################
+$mode = "xml";
+$count = "last";
+$aMode = "";
+$warn = 0;
+
+if (@ARGV[0] ne "") {
+ $n = 0;
+ while (@ARGV[$n] ne "") {
+ if (@ARGV[$n] eq "--vpl") {
+ $mode = "vpl";
+ print "Set interpretation mode to VPL.\n";
+ }
+ elsif (@ARGV[$n] eq "--imp") {
+ $mode = "imp";
+ print "Set interpretation mode to IMP.\n";
+ }
+ elsif (@ARGV[$n] eq "--osis") {
+ $mode = "osis";
+ print "Set interpretation mode to OSIS.\n";
+ }
+ elsif (@ARGV[$n] eq "--xml") {
+ $mode = "xml";
+ }
+ elsif (@ARGV[$n] eq "--count") {
+ $count = "count";
+ print "Set count mode to last.\n";
+ }
+ elsif (@ARGV[$n] eq "--last") {
+ $count = "last";
+ }
+ elsif (@ARGV[$n] eq "--warn") {
+ $warn = 1;
+ print "Warning messages enabled.\n";
+ }
+ elsif (@ARGV[$n] =~ /--abbr=(.+)/) {
+ $aMode = $1;
+ print "Set abbreviation mode to \"$aMode\".\n";
+ }
+ elsif (@ARGV[$n] =~ /^\-+(h|\?|usage)/) {
+ printUsage();
+ exit();
+ }
+ else {
+ push @srcfiles, @ARGV[$n];
+ }
+ $n++;
+ }
+}
+if ($mode eq "xml") {
+ print "Set interpretation mode to CCEL XML.\n";
+}
+if ($count eq "last") {
+ print "Set count mode to last.\n";
+}
+
+if (@srcfiles == 0) {
+ printUsage();
+ exit();
+}
+
sub buildBooksArrays {
if ($lastBook ne "" && $osis{lc($lastBook)} eq "") {
print "ERROR: Unknown book abbreviation: $lastBook in $v11n\n";
@@ -40,7 +100,7 @@ sub buildBooksArrays {
}
sub printUsage() {
- print " v11nsys.pl --? --warn --(vpl|imp|xml|osis) --(count|last) [files]\n\n When run without any arguments, this script looks for the CCEL files: Bible.*.xml.\n\n Otherwise, supply the script with a list of files (or wildcard) and it will attempt to create a v11n system definition on that basis.\n\n --? prints usage (this).\n\n --warn turns on warning messages.\n\n --vpl instructs the script to interpret files as VPL files.\n --imp instructs the script to interpret files as IMP files.\n --xml instructs the script to interpret files as XML files using CCEL's definition format (default).\n --osis instructs the script to interpret files as OSIS XML files.\n\n --count instructs the script to count chapters/verse it encounters.\n --last instructs the script to assume that the last chapter/verse it encounters is equal to the number of chaptes/verses in a book/chapter (default).\n\n"
+ print " v11nsys.pl --? --warn --(vpl|imp|xml|osis) --(count|last) --abbr=[abbrMode] [files]\n\n When run without any arguments, this script looks for the CCEL files: Bible.*.xml.\n\n Otherwise, supply the script with a list of files (or wildcard) and it will attempt to create a v11n system definition on that basis.\n\n --? prints usage (this).\n\n --warn turns on warning messages.\n\n --vpl instructs the script to interpret files as VPL files.\n --imp instructs the script to interpret files as IMP files.\n --xml instructs the script to interpret files as XML files using CCEL's definition format (default).\n --osis instructs the script to interpret files as OSIS XML files.\n\n --count instructs the script to count chapters/verse it encounters.\n --last instructs the script to assume that the last chapter/verse it encounters is equal to the number of chaptes/verses in a book/chapter (default).\n\n --abbr=[abbrMode] instructs the script to use an alternative set of abbreviations (olb, westminster, & lxx are currently defined) in preference to the default, whenever the two conflict.\n\n";
}
# @canons will contain this list of files, these are in a basic XML format.
@@ -71,14 +131,27 @@ foreach $mapfile (@canons) {
$osis{lc($id)} = $id;
$abbrevs{lc($id)} = "$id;"
}
+ elsif ($line =~ /<abbr mode=\"([^\"]+)\">(.+?)<\/abbr>/) {
+ if ($aMode eq $1) {
+ $name = $2;
+ if ($osis{lc($name)} ne "") {
+ if ($warn == 1) {
+ print "WARNING: Duplicate mapping from $name found in $mapfile (<abbr mode=\"\">). Overwriting.\n";
+ }
+ }
+ $osis{lc($name)} = $id;
+ }
+ }
elsif ($line =~ /<abbr>(.+?)<\/abbr>/) {
$name = $1;
if ($osis{lc($name)} eq "") {
$osis{lc($name)} = $id;
}
else {
- if ($warn == 1) {
- print "ERROR: Duplicate mapping from $id found in $mapfile (<abbr>).\n";
+ if ($osis{lc($name)} ne $id) {
+ if ($warn == 1) {
+ print "WARNING: Duplicate mapping from $name found in $mapfile (<abbr>).\n";
+ }
}
}
}
@@ -89,79 +162,22 @@ foreach $mapfile (@canons) {
$abbrevs{lc($id)} .= "$name;"
}
else {
- if ($warn == 1) {
- print "ERROR: Duplicate mapping from $id found in $mapfile (<name>).\n";
+ if ($osis{lc($name)} ne $id) {
+ if ($warn == 1) {
+ print "WARNING: Duplicate mapping from $name found in $mapfile (<name>).\n";
+ }
}
}
+ # Always assign the first <name> value here, which should always be the Sword name of the book; ignore all subsequent <name>s.
if ($idmap{$id} eq "") {
$idmap{$id} = $name;
}
- else {
- # Duplicates most likely indicate alternate names, so ignore them.
- if ($warn == 1) {
- print "ERROR: Duplicate mapping from $id found in $mapfile.\n";
- }
- }
}
}
close (MAP);
}
-$mode = "xml";
-$count = "last";
-$warn = 0;
-
-if (@ARGV[0] ne "") {
- $n = 0;
- while (@ARGV[$n] ne "") {
- if (@ARGV[$n] eq "--vpl") {
- $mode = "vpl";
- print "Set interpretation mode to VPL.\n";
- }
- elsif (@ARGV[$n] eq "--imp") {
- $mode = "imp";
- print "Set interpretation mode to IMP.\n";
- }
- elsif (@ARGV[$n] eq "--osis") {
- $mode = "osis";
- print "Set interpretation mode to OSIS.\n";
- }
- elsif (@ARGV[$n] eq "--xml") {
- $mode = "xml";
- }
- elsif (@ARGV[$n] eq "--count") {
- $count = "count";
- print "Set count mode to last.\n";
- }
- elsif (@ARGV[$n] eq "--last") {
- $count = "last";
- }
- elsif (@ARGV[$n] eq "--warn") {
- $warn = 1;
- print "Warning messages enabled.\n";
- }
- elsif (@ARGV[$n] =~ /^\-+(h|\?|usage)/) {
- printUsage();
- exit();
- }
- else {
- push @srcfiles, @ARGV[$n];
- }
- $n++;
- }
-}
-if ($mode eq "xml") {
- print "Set interpretation mode to CCEL XML.\n";
-}
-if ($count eq "last") {
- print "Set count mode to last.\n";
-}
-
-if (@srcfiles == 0) {
- printUsage();
-}
-
foreach $infile (@srcfiles) {
if ($infile =~ /^Bible.+xml$/) {
$infile =~ /^Bible(\.(.+))?\.xml/;