Difference between revisions of "DevTools:Misc"

From CrossWire Bible Society
Jump to: navigation, search
(Book Names)
(Chapters per book)
 
Line 93: Line 93:
 
</pre>
 
</pre>
  
== Chapters per book ==
+
=== Chapters per book ===
  
 
KJV-v11n:
 
KJV-v11n:

Latest revision as of 18:22, 10 January 2018

Some miscellaneous development tools are available in a Subversion repository available at:

http://crosswire.org/svn/sword-tools/

This contains tools, programs and libraries in various languages that are usually used for the creation of modules. It includes scripts that module authors may use in their preparation of modules. These are mainly undocumented and not intended for any public release. Documentation of some of these tools can be found below or in the READMEs in the repository.

thml2osis

This is an XSLT program that attempts to convert ThML sources (such as those on CCEL) into valid OSIS, as losslessly as possible. The OSIS can then be used for creating SWORD modules. See the README in the relevant directory for more information.

Scripts and Filters

sed scripts

To create ThML cross references out of (<Book> <Chapter>:<Verse>) type references:

sed -e 's/\(\(\([123][CJKPST]\|[AC-Z]\)[a-z]\+\.\?\)\? *[0-9]\+:[0-9]\+\
\([-,:]\( \?[0-9]\+\)\?\)*\)\([a-z]\|ff\.\)\?\([],.;:)=]\| \
[A-Za-z(=[]\)/<scripRef passage="\1">\1\6<\/scripRef>\7/g'

Swapping badly formatted references <verse>:<chapter> to <chapter>:<verse> can be done with this script.

sed -e 's/\([0-9]\+\):\([0-9]\+\)/\2:\1/g'

Script constants

Below are assorted constants/data that may be useful to script authors. Semi-arbitrarily, they will generally be in the form of Python data structures.

OSIS Book Abbreviations

66-book Bible:

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'
    )

USFM Book Abbreviations

USFMbook = (
    # Theoretically, these are laid out according to <BooksPresent>,
    # but I can really only guess without a spec ***Need to check
    '',
    #OT
    'GEN', 'EXO', 'LEV', 'NUM', 'DEU', 'JOS', 'JDG', 'RUT', '1SA', '2SA',
    '1KI', '2KI', '1CH', '2CH', 'EZR', 'NEH', 'EST', 'JOB', 'PSA', 'PRO',
    'ECC', 'SNG', 'ISA', 'JER', 'LAM', 'EZK', 'DAN', 'HOS', 'JOL', 'AMO',
    'OBA', 'JON', 'MIC', 'NAM', 'HAB', 'ZEP', 'HAG', 'ZEC', 'MAL',
    #NT
    'MAT', 'MRK', 'LUK', 'JHN', 'ACT', 'ROM', '1CO', '2CO', 'GAL', 'EPH',
    'PHP', 'COL', '1TH', '2TH', '1TI', '2TI', 'TIT', 'PHM', 'HEB', 'JAS',
    '1PE', '2PE', '1JN', '2JN', '3JN', 'JUD', 'REV',
    #APOC
    'TOB', 'JDT', 'ESG', 'WIS', 'SIR', 'BAR', 'LJE', 'S3Y', 'SUS', 'BEL',
    '1MA', '2MA', '3MA', '4MA', '1ES', '2ES', 'MAN',
    # Following this is just an uneducated guess
    'PS2', 'ODA', 'PSS', 'JSA', 'JSB', 'TBS', 'SST', 'DNT', 'BLT', 'ADE'
    );

Book Names

66-book Bible, English:

BookName = (
    '',
    #OT
    'Genesis', 'Exodus', 'Leviticus', 'Numbers', 'Deuteronomy', 'Joshua', 'Judges', 'Ruth',
    '1 Samuel', '2 Samuel', '1 Kings', '2 Kings', '1 Chronicles', '2 Chronicles', 'Ezra',
    'Nehemiah', 'Esther', 'Job', 'Psalms', 'Proverbs', 'Ecclesiastes', 'Song of Solomon',
    'Isaiah', 'Jeremiah', 'Lamentations', 'Ezekiel', 'Daniel', 'Hosea', 'Joel', 'Amos',
    'Obadiah', 'Jonah', 'Micah', 'Nahum', 'Habakkuk', 'Zephaniah', 'Haggai', 'Zechariah',
    'Malachi',
    #NT
    'Matthew', 'Mark', 'Luke', 'John', 'Acts', 'Romans', '1 Corinthians', '2 Corinthians',
    'Galatians', 'Ephesians', 'Philippians', 'Colossians', '1 Thessalonians', '2 Thessalonians',
    '1 Timothy', '2 Timothy', 'Titus', 'Philemon', 'Hebrews', 'James', '1 Peter', '2 Peter',
    '1 John', '2 John', '3 John', 'Jude', 'Revelation'
    )

Chapters per book

KJV-v11n:

ChaptersInBook = (
     0,
     #OT
     50, 40, 27, 36, 34, 24, 21, 4, 31, 24, 22, 25, 29, 36, 10, 13, 10, 42, 150, 31, 12, 8,
     66, 52, 5, 48, 12, 14, 3, 9, 1, 4, 7, 3, 3, 3, 2, 14, 4,
     #NT
     28, 16, 24, 21, 28, 16, 16, 13, 6, 6, 4, 4, 5, 3, 6, 4, 3, 1, 13, 5, 5, 3, 5, 1, 1, 1, 22
     )

See also