1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/usr/bin/perl
# @canons will contain this list of files, these are in a basic XML format.
# Each file lists osisIDs along with the English names associated with the
# osisID. These aren't exhaustive, and may or may not overlap (but hopefully
# don't). We are only using these to load mappings from osisIDs.
@canons = (
"canon.bible.xml", # the Bible, broadly defined
# "canon.af.xml", # Apostolic Fathers
# "canon.otp.xml", # OT pseudepigrapha
# "canon.nta.xml", # NT apocrypha
# "canon.lds.xml", # Mormon books
# "canon.naghammadi.xml", # Nag Hammadi Library
# "canon.qumran.xml", # Qumran mss
# "canon.classical.xml", # intended for classical works, currently just Josephus
);
@abbrevsQueue = ();
foreach $mapfile (@canons) {
open MAP, "$mapfile";
while (<MAP>) {
$line = $_;
$line =~ s/<!\-\-.+?\-\->//g;
$line =~ s/\&/\&/g;
if ($line =~ /<id>(.+?)<\/id>/) {
$id = $1;
$osis{lc($id)} = $id;
push @abbrevsQueue, "$id"
}
elsif ($line =~ /<name>(.+?)<\/name>/) {
$name = $1;
if ($osis{lc($name)} eq "") {
$osis{lc($name)} = $id;
push @abbrevsQueue, "$name"
}
else {
if ($warn) {
print "ERROR: Duplicate mapping from $id found in $mapfile.\n";
}
}
if ($idmap{$id} eq "") {
$idmap{$id} = $name;
}
else {
# Duplicates most likely indicate alternate names, so ignore them.
if ($warn) {
print "ERROR: Duplicate mapping from $id found in $mapfile.\n";
}
}
}
}
close (MAP);
}
$abbrevs = "/******************************************************************************\n * Abbreviations - MUST be in alphabetical order & by PRIORITY\n * RULE: first match of entire key\n * (e.g. key: \"1CH\"; match: \"1CHRONICLES\")\n */\n\nconst struct abbrev builtin_abbrevs\[\] = {\n";
@abbrevsQueue = sort @abbrevsQueue;
foreach $a (@abbrevsQueue) {
if ($a =~ /^.+\d/) {
$abbrevs .= "//";
}
$abbrevs .= " {\"" . uc($a) . "\", \"" . $osis{lc($a)} . "\"},\t\t//" . $idmap{$osis{lc($a)}} . "\n";
}
$abbrevs .= " {\"\", \"\"}\n};\n\n\n";
open OUTF, ">builtin_abbrevs.h";
print OUTF $abbrevs;
close OUTF;
|