[sword-svn] r219 - trunk/modules/perlconverters

chrislit at crosswire.org chrislit at crosswire.org
Sat Oct 24 23:41:25 MST 2009


Author: chrislit
Date: 2009-10-24 23:41:25 -0700 (Sat, 24 Oct 2009)
New Revision: 219

Modified:
   trunk/modules/perlconverters/imp2osis.pl
Log:
almost complete rewrite to accommodate IMP files not exported via mod2imp

Modified: trunk/modules/perlconverters/imp2osis.pl
===================================================================
--- trunk/modules/perlconverters/imp2osis.pl	2009-10-24 03:08:15 UTC (rev 218)
+++ trunk/modules/perlconverters/imp2osis.pl	2009-10-25 06:41:25 UTC (rev 219)
@@ -4,7 +4,7 @@
 
 ## Licensed under the standard (3-clause) BSD license:
 
-# Copyright (c) 2008 CrossWire Bible Society <http://www.crosswire.org/>
+# Copyright (c) 2008-2009 CrossWire Bible Society <http://www.crosswire.org/>
 # All rights reserved.
 # 
 # Redistribution and use in source and binary forms, with or without
@@ -39,85 +39,568 @@
 
 #########################################################################
 
-$version = "1.0";
-$date = "2008-06-18";
+$version = "2.0";
+$date = "2009-10-24";
 $osisVersion = "2.1.1";
 
- at OSISbook = (
-#OT
- "Gen", "Exod", "Lev", "Num", "Deut", "Josh", "Judg", "Ruth", "1Sam", "2Sam", "1Kgs", "2Kgs", "1Chr", "2Chr", "Ezra", "Neh", "Esth", "Job", "Ps", "Prov", "Eccl", "Song", "Isa", "Jer", "Lam", "Ezek", "Dan", "Hos", "Joel", "Amos", "Obad", "Jonah", "Mic", "Nah", "Hab", "Zeph", "Hag", "Zech", "Mal",
-
-#NT
-"Matt", "Mark", "Luke", "John", "Acts", "Rom", "1Cor", "2Cor", "Gal", "Eph", "Phil", "Col", "1Thess", "2Thess", "1Tim", "2Tim", "Titus", "Phlm", "Heb", "Jas", "1Pet", "2Pet", "1John", "2John", "3John", "Jude", "Rev",
-);
-
 %OSISbook = (
-    "Genesis" => "Gen",
-    "Exodus" => "Exod",
-    "Leviticus" => "Lev",
-    "Numbers" => "Num",
-    "Deuteronomy" => "Deut",
-    "Joshua" => "Josh",
-    "Judges" => "Judg",
-    "Ruth" => "Ruth",
-    "I Samuel" => "1Sam",
-    "II Samuel" => "2Sam",
-    "I Kings" => "1Kgs",
-    "II Kings" => "2Kgs",
-    "I Chronicles" => "1Chr",
-    "II Chronicles" => "2Chr",
-    "Ezra" => "Ezra",
-    "Nehemiah" => "Neh",
-    "Esther" => "Esth",
-    "Job" => "Job",
-    "Psalms" => "Ps",
-    "Proverbs" => "Prov",
-    "Ecclesiastes" => "Eccl",
-    "Song of Solomon" => "Song",
-    "Isaiah" => "Isa",
-    "Jeremiah" => "Jer",
-    "Lamentations" => "Lam",
-    "Ezekiel" => "Ezek",
-    "Daniel" => "Dan",
-    "Hosea" => "Hos",
-    "Joel" => "Joel",
-    "Amos" => "Amos",
-    "Obadiah" => "Obad",
-    "Jonah" => "Jonah",
-    "Micah" => "Mic",
-    "Nahum" => "Nah",
-    "Habakkuk" => "Hab",
-    "Zephaniah" => "Zeph",
-    "Haggai" => "Hag",
-    "Zechariah" => "Zech",
-    "Malachi" => "Mal",
-    "Matthew" => "Matt",
-    "Mark" => "Mark",
-    "Luke" => "Luke",
-    "John" => "John",
-    "Acts" => "Acts",
-    "Romans" => "Rom",
-    "I Corinthians" => "1Cor",
-    "II Corinthians" => "2Cor",
-    "Galatians" => "Gal",
-    "Ephesians" => "Eph",
-    "Philippians" => "Phil",
-    "Colossians" => "Col",
-    "I Thessalonians" => "1Thess",
-    "II Thessalonians" => "2Thess",
-    "I Timothy" => "1Tim",
-    "II Timothy" => "2Tim",
-    "Titus" => "Titus",
-    "Philemon" => "Phlm",
-    "Hebrews" => "Heb",
-    "James" => "Jas",
-    "I Peter" => "1Pet",
-    "II Peter" => "2Pet",
-    "I John" => "1John",
-    "II John" => "2John",
-    "III John" => "3John",
-    "Jude" => "Jude",
-    "Revelation of John" => "Rev"
+	"1 BARUCH" => "Bar",
+	"1 C" => "1Cor",
+	"1 CHRONICLES" => "1Chr",
+	"1 CORINTHIANS" => "1Cor",
+	"1 E" => "1Esd",
+	"1 ENOCH" => "1En",
+	"1 ESDRAS" => "1Esd",
+	"1 JN" => "1John",
+	"1 JOHN" => "1John",
+	"1 K" => "1Kgs",
+	"1 KGDMS" => "1Sam",
+	"1 KGS" => "1Kgs",
+	"1 KING" => "1Kgs",
+	"1 KINGDOMS" => "1Sam",
+	"1 KINGS" => "1Kgs",
+	"1 MACCABEES" => "1Macc",
+	"1 MAKABIAN" => "1Meq",
+	"1 MEQABYAN" => "1Meq",
+	"1 P" => "1Pet",
+	"1 PARALIPOMENON" => "1Chr",
+	"1 PETER" => "1Pet",
+	"1 PTR" => "1Pet",
+	"1 SAMUEL" => "1Sam",
+	"1 THESSALONIANS" => "1Thess",
+	"1 TIMOTHY" => "1Tim",
+	"1BARUCH" => "Bar",
+	"1C" => "1Cor",
+	"1CH" => "1Chr",
+	"1CHR" => "1Chr",
+	"1CHRONICLES" => "1Chr",
+	"1CO" => "1Cor",
+	"1COR" => "1Cor",
+	"1CORINTHIANS" => "1Cor",
+	"1E" => "1Esd",
+	"1EN" => "1En",
+	"1ENOCH" => "1En",
+	"1ESD" => "1Esd",
+	"1ESDRAS" => "1Esd",
+	"1JN" => "1John",
+	"1JO" => "1John",
+	"1JOHN" => "1John",
+	"1K" => "1Kgs",
+	"1KGDMS" => "1Sam",
+	"1KGS" => "1Kgs",
+	"1KI" => "1Kgs",
+	"1KING" => "1Kgs",
+	"1KINGDOMS" => "1Sam",
+	"1KINGS" => "1Kgs",
+	"1MA" => "1Macc",
+	"1MACC" => "1Macc",
+	"1MACCABEES" => "1Macc",
+	"1MAKABIAN" => "1Meq",
+	"1MEQ" => "1Meq",
+	"1MEQABYAN" => "1Meq",
+	"1P" => "1Pet",
+	"1PARALIPOMENON" => "1Chr",
+	"1PE" => "1Pet",
+	"1PET" => "1Pet",
+	"1PETER" => "1Pet",
+	"1PTR" => "1Pet",
+	"1SA" => "1Sam",
+	"1SAM" => "1Sam",
+	"1SAMUEL" => "1Sam",
+	"1TH" => "1Thess",
+	"1THESS" => "1Thess",
+	"1THESSALONIANS" => "1Thess",
+	"1TI" => "1Tim",
+	"1TIM" => "1Tim",
+	"1TIMOTHY" => "1Tim",
+	"2 BARUCH" => "2Bar",
+	"2 C" => "2Cor",
+	"2 CHRONICLES" => "2Chr",
+	"2 CORINTHIANS" => "2Cor",
+	"2 E" => "2Esd",
+	"2 ESDRAS" => "2Esd",
+	"2 JN" => "2John",
+	"2 JOHN" => "2John",
+	"2 K" => "2Kgs",
+	"2 KGDMS" => "2Sam",
+	"2 KGS" => "2Kgs",
+	"2 KING" => "2Kgs",
+	"2 KINGDOMS" => "2Sam",
+	"2 KINGS" => "2Kgs",
+	"2 MACCABEES" => "2Macc",
+	"2 MAKABIAN" => "2Meq",
+	"2 MEQABYAN" => "2Meq",
+	"2 P" => "2Pet",
+	"2 PARALIPOMENON" => "2Chr",
+	"2 PETER" => "2Pet",
+	"2 PTR" => "2Pet",
+	"2 SAMUEL" => "2Sam",
+	"2 THESSALONIANS" => "2Thess",
+	"2 TIMOTHY" => "2Tim",
+	"2BAR" => "2Bar",
+	"2BARUCH" => "2Bar",
+	"2C" => "2Cor",
+	"2CH" => "2Chr",
+	"2CHR" => "2Chr",
+	"2CHRONICLES" => "2Chr",
+	"2CO" => "2Cor",
+	"2COR" => "2Cor",
+	"2CORINTHIANS" => "2Cor",
+	"2E" => "2Esd",
+	"2ESD" => "2Esd",
+	"2ESDRAS" => "2Esd",
+	"2JN" => "2John",
+	"2JO" => "2John",
+	"2JOHN" => "2John",
+	"2K" => "2Kgs",
+	"2KGDMS" => "2Sam",
+	"2KGS" => "2Kgs",
+	"2KI" => "2Kgs",
+	"2KING" => "2Kgs",
+	"2KINGDOMS" => "2Sam",
+	"2KINGS" => "2Kgs",
+	"2MA" => "2Macc",
+	"2MACC" => "2Macc",
+	"2MACCABEES" => "2Macc",
+	"2MAKABIAN" => "2Meq",
+	"2MEQ" => "2Meq",
+	"2MEQABYAN" => "2Meq",
+	"2P" => "2Pet",
+	"2PARALIPOMENON" => "2Chr",
+	"2PE" => "2Pet",
+	"2PET" => "2Pet",
+	"2PETER" => "2Pet",
+	"2PTR" => "2Pet",
+	"2SA" => "2Sam",
+	"2SAM" => "2Sam",
+	"2SAMUEL" => "2Sam",
+	"2TH" => "2Thess",
+	"2THESS" => "2Thess",
+	"2THESSALONIANS" => "2Thess",
+	"2TI" => "2Tim",
+	"2TIM" => "2Tim",
+	"2TIMOTHY" => "2Tim",
+	"3 EZRA" => "1Esd",
+	"3 JN" => "3John",
+	"3 JOHN" => "3John",
+	"3 KGDMS" => "1Kgs",
+	"3 KGS" => "1Kgs",
+	"3 KINGDOMS" => "1Kgs",
+	"3 KINGS" => "1Kgs",
+	"3 MACCABEES" => "3Macc",
+	"3 MAKABIAN" => "3Meq",
+	"3 MEQABYAN" => "3Meq",
+	"3EZRA" => "1Esd",
+	"3JN" => "3John",
+	"3JO" => "3John",
+	"3JOHN" => "3John",
+	"3KGDMS" => "1Kgs",
+	"3KGS" => "1Kgs",
+	"3KINGDOMS" => "1Kgs",
+	"3KINGS" => "1Kgs",
+	"3MA" => "3Macc",
+	"3MACC" => "3Macc",
+	"3MACCABEES" => "3Macc",
+	"3MAKABIAN" => "3Meq",
+	"3MEQ" => "3Meq",
+	"3MEQABYAN" => "3Meq",
+	"4 BARUCH" => "4Bar",
+	"4 EZRA" => "2Esd",
+	"4 KGDMS" => "2Kgs",
+	"4 KGS" => "2Kgs",
+	"4 KINGDOMS" => "2Kgs",
+	"4 KINGS" => "2Kgs",
+	"4 MACCABEES" => "4Macc",
+	"4BAR" => "4Bar",
+	"4BARUCH" => "4Bar",
+	"4EZRA" => "2Esd",
+	"4KGDMS" => "2Kgs",
+	"4KGS" => "2Kgs",
+	"4KINGDOMS" => "2Kgs",
+	"4KINGS" => "2Kgs",
+	"4MA" => "4Macc",
+	"4MACC" => "4Macc",
+	"4MACCABEES" => "4Macc",
+	"5APOCSYRPSS" => "AddPs",
+	"ACT" => "Acts",
+	"ACTS" => "Acts",
+	"ADDDAN" => "AddDan",
+	"ADDESTH" => "AddEsth",
+	"ADDITIONAL PSALM" => "AddPs",
+	"ADDITIONS TO DANIEL" => "AddDan",
+	"ADDITIONS TO ESTHER" => "AddEsth",
+	"ADDPS" => "AddPs",
+	"AMO" => "Amos",
+	"AMOS" => "Amos",
+	"APOCALYPSE OF JOHN" => "Rev",
+	"AZA" => "PrAzar",
+	"AZAR" => "PrAzar",
+	"AZARIAH" => "PrAzar",
+	"BAR" => "Bar",
+	"BARUCH" => "Bar",
+	"BEL" => "Bel",
+	"BEL AND THE DRAGON" => "Bel",
+	"C" => "Col",
+	"CANTICLE OF CANTICLES" => "Song",
+	"COL" => "Col",
+	"COLOSSIANS" => "Col",
+	"D" => "Deut",
+	"DAN" => "Dan",
+	"DANGR" => "DanGr",
+	"DANIEL" => "Dan",
+	"DANIEL (ADDITIONS)" => "AddDan",
+	"DANIEL (GREEK)" => "DanGr",
+	"DEU" => "Deut",
+	"DEUT" => "Deut",
+	"DEUTERONOMY" => "Deut",
+	"DT" => "Deut",
+	"E" => "Exod",
+	"ECC" => "Eccl",
+	"ECCL" => "Eccl",
+	"ECCLESIASTES" => "Eccl",
+	"ECCLESIASTICUS" => "Sir",
+	"ECCLUS" => "Sir",
+	"EK" => "Ezek",
+	"ENOCH" => "1En",
+	"EPH" => "Eph",
+	"EPHESIANS" => "Eph",
+	"EPISTLE OF JEREMIAH" => "EpJer",
+	"EPJ" => "EpJer",
+	"EPJER" => "EpJer",
+	"EPLAO" => "EpLao",
+	"ES" => "Esth",
+	"ESDRAS A" => "1Esd",
+	"ESDRAS B" => "2Esd",
+	"ESDRASA" => "1Esd",
+	"ESDRASB" => "2Esd",
+	"ESG" => "EsthGr",
+	"EST" => "Esth",
+	"ESTER" => "Esth",
+	"ESTH" => "Esth",
+	"ESTHER" => "Esth",
+	"ESTHER (ADDITIONS)" => "AddEsth",
+	"ESTHER (GREEK)" => "EsthGr",
+	"ESTHGR" => "EsthGr",
+	"ETHIOPIC APOCALYPSE OF ENOCH" => "1En",
+	"EXO" => "Exod",
+	"EXOD" => "Exod",
+	"EXODUS" => "Exod",
+	"EZE" => "Ezek",
+	"EZEK" => "Ezek",
+	"EZEKIEL" => "Ezek",
+	"EZK" => "Ezek",
+	"EZR" => "Ezra",
+	"EZRA" => "Ezra",
+	"FIVE APOCRYPHAL SYRIAC PSALMS" => "AddPs",
+	"G" => "Gen",
+	"GAL" => "Gal",
+	"GALATIANS" => "Gal",
+	"GEN" => "Gen",
+	"GENESIS" => "Gen",
+	"GN" => "Gen",
+	"GRDAN" => "DanGr",
+	"GREEK DANIEL" => "DanGr",
+	"GREEK ESTHER" => "EsthGr",
+	"GRESTH" => "EsthGr",
+	"H" => "Heb",
+	"HAB" => "Hab",
+	"HABAKKUK" => "Hab",
+	"HAG" => "Hag",
+	"HAGGAI" => "Hag",
+	"HEB" => "Heb",
+	"HEBREWS" => "Heb",
+	"HOS" => "Hos",
+	"HOSEA" => "Hos",
+	"I" => "Isa",
+	"I BARUCH" => "Bar",
+	"I C" => "1Cor",
+	"I CHRONICLES" => "1Chr",
+	"I CORINTHIANS" => "1Cor",
+	"I E" => "1Esd",
+	"I ENOCH" => "1En",
+	"I ESDRAS" => "1Esd",
+	"I JN" => "1John",
+	"I JOHN" => "1John",
+	"I K" => "1Kgs",
+	"I KGDMS" => "1Sam",
+	"I KGS" => "1Kgs",
+	"I KING" => "1Kgs",
+	"I KINGDOMS" => "1Sam",
+	"I KINGS" => "1Kgs",
+	"I MACCABEES" => "1Macc",
+	"I MAKABIAN" => "1Meq",
+	"I MEQABYAN" => "1Meq",
+	"I P" => "1Pet",
+	"I PARALIPOMENON" => "1Chr",
+	"I PETER" => "1Pet",
+	"I PTR" => "1Pet",
+	"I SAMUEL" => "1Sam",
+	"I THESSALONIANS" => "1Thess",
+	"I TIMOTHY" => "1Tim",
+	"IBARUCH" => "Bar",
+	"IC" => "1Cor",
+	"ICHRONICLES" => "1Chr",
+	"ICORINTHIANS" => "1Cor",
+	"IE" => "1Esd",
+	"IENOCH" => "1En",
+	"IESDRAS" => "1Esd",
+	"II BARUCH" => "2Bar",
+	"II C" => "2Cor",
+	"II CHRONICLES" => "2Chr",
+	"II CORINTHIANS" => "2Cor",
+	"II E" => "2Esd",
+	"II ESDRAS" => "2Esd",
+	"II JN" => "2John",
+	"II JOHN" => "2John",
+	"II K" => "2Kgs",
+	"II KGDMS" => "2Sam",
+	"II KGS" => "2Kgs",
+	"II KING" => "2Kgs",
+	"II KINGDOMS" => "2Sam",
+	"II KINGS" => "2Kgs",
+	"II MACCABEES" => "2Macc",
+	"II MAKABIAN" => "2Meq",
+	"II MEQABYAN" => "2Meq",
+	"II P" => "2Pet",
+	"II PARALIPOMENON" => "2Chr",
+	"II PETER" => "2Pet",
+	"II PTR" => "2Pet",
+	"II SAMUEL" => "2Sam",
+	"II THESSALONIANS" => "2Thess",
+	"II TIMOTHY" => "2Tim",
+	"IIBARUCH" => "2Bar",
+	"IIC" => "2Cor",
+	"IICHRONICLES" => "2Chr",
+	"IICORINTHIANS" => "2Cor",
+	"IIE" => "2Esd",
+	"IIESDRAS" => "2Esd",
+	"III EZRA" => "1Esd",
+	"III JN" => "3John",
+	"III JOHN" => "3John",
+	"III KGDMS" => "1Kgs",
+	"III KGS" => "1Kgs",
+	"III KINGDOMS" => "1Kgs",
+	"III KINGS" => "1Kgs",
+	"III MACCABEES" => "3Macc",
+	"III MAKABIAN" => "3Meq",
+	"III MEQABYAN" => "3Meq",
+	"IIIEZRA" => "1Esd",
+	"IIIJN" => "3John",
+	"IIIJOHN" => "3John",
+	"IIIKGDMS" => "1Kgs",
+	"IIIKGS" => "1Kgs",
+	"IIIKINGDOMS" => "1Kgs",
+	"IIIKINGS" => "1Kgs",
+	"IIIMACCABEES" => "3Macc",
+	"IIIMAKABIAN" => "3Meq",
+	"IIIMEQABYAN" => "3Meq",
+	"IIJN" => "2John",
+	"IIJOHN" => "2John",
+	"IIK" => "2Kgs",
+	"IIKGDMS" => "2Sam",
+	"IIKGS" => "2Kgs",
+	"IIKING" => "2Kgs",
+	"IIKINGDOMS" => "2Sam",
+	"IIKINGS" => "2Kgs",
+	"IIMACCABEES" => "2Macc",
+	"IIMAKABIAN" => "2Meq",
+	"IIMEQABYAN" => "2Meq",
+	"IIP" => "2Pet",
+	"IIPARALIPOMENON" => "2Chr",
+	"IIPETER" => "2Pet",
+	"IIPTR" => "2Pet",
+	"IISAMUEL" => "2Sam",
+	"IITHESSALONIANS" => "2Thess",
+	"IITIMOTHY" => "2Tim",
+	"IJN" => "1John",
+	"IJOHN" => "1John",
+	"IK" => "1Kgs",
+	"IKGDMS" => "1Sam",
+	"IKGS" => "1Kgs",
+	"IKING" => "1Kgs",
+	"IKINGDOMS" => "1Sam",
+	"IKINGS" => "1Kgs",
+	"IMACCABEES" => "1Macc",
+	"IMAKABIAN" => "1Meq",
+	"IMEQABYAN" => "1Meq",
+	"IP" => "1Pet",
+	"IPARALIPOMENON" => "1Chr",
+	"IPETER" => "1Pet",
+	"IPTR" => "1Pet",
+	"ISA" => "Isa",
+	"ISAIAH" => "Isa",
+	"ISAMUEL" => "1Sam",
+	"ITHESSALONIANS" => "1Thess",
+	"ITIMOTHY" => "1Tim",
+	"IV BARUCH" => "4Bar",
+	"IV EZRA" => "2Esd",
+	"IV KGDMS" => "2Kgs",
+	"IV KGS" => "2Kgs",
+	"IV KINGDOMS" => "2Kgs",
+	"IV KINGS" => "2Kgs",
+	"IV MACCABEES" => "4Macc",
+	"IVBARUCH" => "4Bar",
+	"IVEZRA" => "2Esd",
+	"IVKGDMS" => "2Kgs",
+	"IVKGS" => "2Kgs",
+	"IVKINGDOMS" => "2Kgs",
+	"IVKINGS" => "2Kgs",
+	"IVMACCABEES" => "4Macc",
+	"J" => "Josh",
+	"JAM" => "Jas",
+	"JAMES" => "Jas",
+	"JAS" => "Jas",
+	"JB" => "Job",
+	"JD" => "Judg",
+	"JDG" => "Judg",
+	"JDGS" => "Judg",
+	"JDT" => "Jdt",
+	"JER" => "Jer",
+	"JEREMIAH" => "Jer",
+	"JHN" => "John",
+	"JN" => "John",
+	"JO" => "John",
+	"JOB" => "Job",
+	"JOE" => "Joel",
+	"JOEL" => "Joel",
+	"JOH" => "John",
+	"JOHN" => "John",
+	"JOL" => "Joel",
+	"JON" => "Jonah",
+	"JONAH" => "Jonah",
+	"JOS" => "Josh",
+	"JOSH" => "Josh",
+	"JOSHUA" => "Josh",
+	"JS" => "Josh",
+	"JU" => "Jude",
+	"JUB" => "Jub",
+	"JUBILEES" => "Jub",
+	"JUD" => "Jude",
+	"JUDE" => "Jude",
+	"JUDG" => "Judg",
+	"JUDGES" => "Judg",
+	"JUDITH" => "Jdt",
+	"L" => "Luke",
+	"LAM" => "Lam",
+	"LAMENTATIONS" => "Lam",
+	"LAO" => "EpLao",
+	"LAODICEANS" => "EpLao",
+	"LE" => "Lev",
+	"LETJER" => "EpJer",
+	"LETTER OF JEREMIAH" => "EpJer",
+	"LEV" => "Lev",
+	"LEVITICUS" => "Lev",
+	"LK" => "Luke",
+	"LUK" => "Luke",
+	"LUKE" => "Luke",
+	"LV" => "Lev",
+	"MA" => "Matt",
+	"MAL" => "Mal",
+	"MALACHI" => "Mal",
+	"MAN" => "PrMan",
+	"MANASSEH" => "PrMan",
+	"MANASSES" => "PrMan",
+	"MAR" => "Mark",
+	"MARK" => "Mark",
+	"MAT" => "Matt",
+	"MATT" => "Matt",
+	"MATTHEW" => "Matt",
+	"MIC" => "Mic",
+	"MICAH" => "Mic",
+	"MK" => "Mark",
+	"MRK" => "Mark",
+	"MT" => "Matt",
+	"N" => "Num",
+	"NAH" => "Nah",
+	"NAHUM" => "Nah",
+	"NAM" => "Nah",
+	"NEH" => "Neh",
+	"NEHEMIAH" => "Neh",
+	"NM" => "Num",
+	"NUM" => "Num",
+	"NUMBERS" => "Num",
+	"OBA" => "Obad",
+	"OBAD" => "Obad",
+	"OBADIAH" => "Obad",
+	"ODE" => "Odes",
+	"ODES" => "Odes",
+	"P" => "Ps",
+	"PARALEIPOMENA JEREMIOU" => "4Bar",
+	"PARALIPOMENA OF JEREMIAH" => "4Bar",
+	"PHI" => "Phil",
+	"PHIL" => "Phil",
+	"PHILEMON" => "Phlm",
+	"PHILIPPIANS" => "Phil",
+	"PHLM" => "Phlm",
+	"PHM" => "Phlm",
+	"PHP" => "Phil",
+	"PR" => "Prov",
+	"PRA" => "PrAzar",
+	"PRAYER OF AZARIAH" => "PrAzar",
+	"PRAYER OF MANASSEH" => "PrMan",
+	"PRAYER OF MANASSES" => "PrMan",
+	"PRAZAR" => "PrAzar",
+	"PRM" => "PrMan",
+	"PRMAN" => "PrMan",
+	"PRO" => "Prov",
+	"PROV" => "Prov",
+	"PROVERBS" => "Prov",
+	"PS" => "Ps",
+	"PS 151" => "AddPs",
+	"PS151" => "AddPs",
+	"PSA" => "Ps",
+	"PSALM" => "Ps",
+	"PSALM 151" => "AddPs",
+	"PSALM151" => "AddPs",
+	"PSALMS" => "Ps",
+	"PSALMS OF SOLOMON" => "PssSol",
+	"PSM" => "Ps",
+	"PSS" => "Ps",
+	"PSSSOL" => "PssSol",
+	"QOHELET" => "Eccl",
+	"QOHELETH" => "Eccl",
+	"REV" => "Rev",
+	"REVELATION OF JOHN" => "Rev",
+	"ROM" => "Rom",
+	"ROMANS" => "Rom",
+	"RUT" => "Ruth",
+	"RUTH" => "Ruth",
+	"S" => "Song",
+	"S3Y" => "PrAzar",
+	"SI" => "Sir",
+	"SIP" => "SirP",
+	"SIR" => "Sir",
+	"SIRACH" => "Sir",
+	"SIRACH (PROLOGUE)" => "SirP",
+	"SIRP" => "SirP",
+	"SNG" => "Song",
+	"SOL" => "Song",
+	"SOLOMON" => "Song",
+	"SONG" => "Song",
+	"SONG OF SOLOMON" => "Song",
+	"SONG OF SONGS" => "Song",
+	"SONG OF THE THREE CHILDREN" => "PrAzar",
+	"SUS" => "Sus",
+	"SUSANNA" => "Sus",
+	"SYRIAC APOCALYPSE OF BARUCH" => "2Bar",
+	"T" => "Titus",
+	"TB" => "Tob",
+	"TBT" => "Tob",
+	"TIT" => "Titus",
+	"TITUS" => "Titus",
+	"TOB" => "Tob",
+	"TOBIT" => "Tob",
+	"WIS" => "Wis",
+	"WISDOM" => "Wis",
+	"WISDOM OF BEN SIRA" => "Sir",
+	"WISDOM OF JESUS SON OF SIRACH" => "Sir",
+	"WISDOM OF SOLOMON" => "Wis",
+	"ZEC" => "Zech",
+	"ZECH" => "Zech",
+	"ZECHARIAH" => "Zech",
+	"ZEP" => "Zeph",
+	"ZEPH" => "Zeph",
+	"ZEPHANIAH" => "Zeph",
     );
 
 
@@ -154,74 +637,106 @@
 $chap = 0;
 $vers = 0;
 
-sub closeVerse {
-    if ($milestone == 0) {
-	print OUTF "<\/verse>\n";
+sub closeVers {
+    if ($openVers == 1) {
+	if ($milestone == 0) {
+	    print OUTF "<\/verse>\n";
+	}
+	else {
+	    print OUTF "<verse eID=\"$lastosisID\"\/>\n";
+	}
     }
-    else {
-	print OUTF "<verse eID=\"$lastosisID\"\/>\n";
+    $openVers = 0;
+}
+
+sub closeChap {
+    if ($openChap == 1) {
+	print OUTF "<\/chapter>\n";
     }
+    $openChap = 0;
 }
+sub closeBook {
+    if ($openBook == 1) {
+	print OUTF "<\/div>\n";
+    }
+    $openBook = 0;
+}
 
 while (<INF>) {
     $line = $_;
 
-    $line =~ s/[\n\t\r ]+$//;
+    $line =~ s/\s+$//;
 
     if ($line =~ /^\$\$\$(.+)/) {
 	$key = $1;
 	$line = "";
 	$lastosisID = $osisID;
+	$lastBook = $book;
+	$lastChap = $chap;
+	$lastVers = $vers;
 	$osisID = "";
 
 	if ($key =~ /^(.+?) (\d+):(\d+)/) {
-	    $book = $OSISbook{$1};
+	    $book = $OSISbook{uc($1)};
 	    $chap = $2;
 	    $vers = $3;
 	    if ($vers > 0) {
 		$osisID = "$book.$chap.$vers";
 	    }
 
-	    if ($chap == 0) {
-		if ($book ne "Gen" && $book ne "Matt") {
-		    closeVerse();
-		    print OUTF "<\/chapter>\n";
-		    print OUTF "<\/div>\n";
-		}
+	    if ($book ne $lastBook) {
+		closeVers();
+		closeChap();
+		closeBook();
+		
 		print OUTF "<div type=\"book\" osisID=\"$book\">\n";
+		$openBook = 1;
+
+		$lastChap = -1;
+		$lastVers = -1;
 	    }
-	    elsif ($vers == 0) {
-		if ($chap != 1) {
-		    closeVerse();
-		    print OUTF "<\/chapter>\n";
+	    if ($chap ne $lastChap && $chap > 0) {
+		closeVers();
+		if ($lastChap > 0) {
+		    closeChap();
 		}
-		print OUTF "<chapter osisID=\"$book\.$chap\">\n";
+		print OUTF "<chapter osisID=\"$book.$chap\">\n";
+		$openChap = 1;
+
+		$lastVers = -1;
 	    }
-	    else {
-		if ($vers != 1) {
-		    closeVerse();
+	    
+	    if ($vers ne $lastVers && $vers > 0) {
+		if ($lastVers > 0) {
+		    closeVers();
 		}
+
 		if ($milestone == 0) {
 		    print OUTF "<verse osisID=\"$osisID\">\n";
 		}
 		else {
 		    print OUTF "<verse osisID=\"$osisID\" sID=\"$osisID\"\/>\n";
 		}
+		$openVers = 1;
 	    }
-
 	}
 	elsif ($key eq "\[ Module Heading \]") {
 	    #do nothing
 	}
 	elsif ($key eq "\[ Testament 1 Heading \]") {
 	    print OUTF "<div type=\"bookGroup\">\n";
+	    $openTestament = 1;
 	}
 	elsif ($key eq "\[ Testament 2 Heading \]") {
-	    closeVerse();
-	    print OUTF "<\/chapter>\n";
-	    print OUTF "<\/div>\n"; # close book
-	    print OUTF "<\/div>\n"; # close OT (bookGroup)
+	    closeVers();
+	    closeChap();
+	    closeBook();
+	    
+	    if ($openTestament == 1) {
+		print OUTF "<\/div>\n"; # close OT (bookGroup)
+	    }
 	    print OUTF "<div type=\"bookGroup\">\n";
+	    $openTestament = 1;
 	}
 	
     }
@@ -230,10 +745,12 @@
     }
 }
 
-closeVerse();
-print OUTF "<\/chapter>\n";
-print OUTF "<\/div>\n"; # close book
-print OUTF "<\/div>\n"; # close NT (bookGroup)
+closeVers();
+closeChap();
+closeBook();
+if ($openTestament == 1) {
+    print OUTF "<\/div>\n"; # close NT (bookGroup)
+}
 print OUTF "<\/osisText>\n";
 print OUTF "<\/osis>\n";
 




More information about the sword-cvs mailing list