aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alternative_book_names.csv66
-rwxr-xr-xcli.py2
-rw-r--r--pyble.py46
3 files changed, 102 insertions, 12 deletions
diff --git a/alternative_book_names.csv b/alternative_book_names.csv
new file mode 100644
index 0000000..b15c852
--- /dev/null
+++ b/alternative_book_names.csv
@@ -0,0 +1,66 @@
+"Genesis","Gen","Ge","Gn"
+"Exodus","Exo","Ex","Exod"
+"Leviticus","Lev","Le","Lv"
+"Numbers","Num","Nu","Nm","Nb"
+"Deuteronomy","Deut","Dt"
+"Joshua","Josh","Jos","Jsh"
+"Judges","Judg","Jdg","Jg","Jdgs"
+"Ruth","Rth","Ru"
+"1 Samuel","1 Sam","1 Sa","1Samuel","1S","I Sa","1 Sm","1Sa","I Sam","1Sam","I Samuel","1st Samuel","First Samuel"
+"2 Samuel","2 Sam","2 Sa","2S","II Sa","2 Sm","2Sa","II Sam","2Sam","II Samuel","2Samuel","2nd Samuel","Second Samuel"
+"1 Kings","1 Kgs","1 Ki","1K","I Kgs","1Kgs","I Ki","1Ki","I Kings","1Kings","1st Kgs","1st Kings","First Kings","First Kgs","1Kin"
+"2 Kings","2 Kgs","2 Ki","2K","II Kgs","2Kgs","II Ki","2Ki","II Kings","2Kings","2nd Kgs","2nd Kings","Second Kings","Second Kgs","2Kin"
+"1 Chronicles","1 Chron","1 Ch","I Ch","1Ch","1 Chr","I Chr","1Chr","I Chron","1Chron","I Chronicles","1Chronicles","1st Chronicles","First Chronicles"
+"2 Chronicles","2 Chron","2 Ch","II Ch","2Ch","II Chr","2Chr","II Chron","2Chron","II Chronicles","2Chronicles","2nd Chronicles","Second Chronicles"
+"Ezra","Ezra","Ezr"
+"Nehemiah","Neh","Ne"
+"Esther","Esth","Es"
+"Job","Job","Job","Jb"
+"Psalm","Pslm","Ps","Psalms","Psa","Psm","Pss"
+"Proverbs","Prov","Pr","Prv"
+"Ecclesiastes","Eccles","Ec","Ecc","Qoh","Qoheleth"
+"Song of Solomon","Song","So","Canticle of Canticles","Canticles","Song of Songs","SOS"
+"Isaiah","Isa","Is"
+"Jeremiah","Jer","Je","Jr"
+"Lamentations","Lam","La"
+"Ezekiel","Ezek","Eze","Ezk"
+"Daniel","Dan","Da","Dn"
+"Hosea","Hos","Ho"
+"Joel","Joel","Joe","Jl"
+"Amos","Amos","Am"
+"Obadiah","Obad","Ob"
+"Jonah","Jnh","Jon"
+"Micah","Micah","Mic"
+"Nahum","Nah","Na"
+"Habakkuk","Hab","Hab"
+"Zephaniah","Zeph","Zep","Zp"
+"Haggai","Haggai","Hag","Hg"
+"Zechariah","Zech","Zec","Zc"
+"Malachi","Mal","Mal","Ml"
+"Matthew","Matt","Mt"
+"Mark","Mrk","Mk","Mr"
+"Luke","Luk","Lk"
+"John","John","Jn","Jhn"
+"Acts","Acts","Ac"
+"Romans","Rom","Ro","Rm"
+"1 Corinthians","1 Cor","1 Co","I Co","1Co","I Cor","1Cor","I Corinthians","1Corinthians","1st Corinthians","First Corinthians"
+"2 Corinthians","2 Cor","2 Co","II Co","2Co","II Cor","2Cor","II Corinthians","2Corinthians","2nd Corinthians","Second Corinthians"
+"Galatians","Gal","Ga"
+"Ephesians","Ephes","Eph"
+"Philippians","Phil","Php"
+"Colossians","Col","Col"
+"1 Thessalonians","1 Thess","1 Th","I Th","1Th","I Thes","1Thes","I Thess","1Thess","I Thessalonians","1Thessalonians","1st Thessalonians","First Thessalonians"
+"2 Thessalonians","2 Thess","2 Th","II Th","2Th","II Thes","2Thes","II Thess","2Thess","II Thessalonians","2Thessalonians","2nd Thessalonians","Second Thessalonians"
+"1 Timothy","1 Tim","1 Ti","I Ti","1Ti","I Tim","1Tim","I Timothy","1Timothy","1st Timothy","First Timothy"
+"2 Timothy","2 Tim","2 Ti","II Ti","2Ti","II Tim","2Tim","II Timothy","2Timothy","2nd Timothy","Second Timothy"
+"Titus","Titus","Tit"
+"Philemon","Philem","Phm"
+"Hebrews","Hebrews","Heb"
+"James","James","Jas","Jm"
+"1 Peter","1 Pet","1 Pe","I Pe","1Pe","I Pet","1Pet","I Pt","1 Pt","1Pt","I Peter","1Peter","1st Peter","First Peter"
+"2 Peter","2 Pet","2 Pe","II Pe","2Pe","II Pet","2Pet","II Pt","2 Pt","2Pt","II Peter","2Peter","2nd Peter","Second Peter"
+"1 John","1 John","1 Jn","I Jn","1Jn","I Jo","1Jo","I Joh","1Joh","I Jhn","1 Jhn","1Jhn","I John","1John","1st John","First John"
+"2 John","2 John","2 Jn","II Jn","2Jn","II Jo","2Jo","II Joh","2Joh","II Jhn","2 Jhn","2Jhn","II John","2John","2nd John","Second John"
+"3 John","3 John","3 Jn","III Jn","3Jn","III Jo","3Jo","III Joh","3Joh","III Jhn","3 Jhn","3Jhn","III John","3John","3rd John","Third John"
+"Jude","Jude","Jud"
+"Revelation","Rev","Re","The Revelation"
diff --git a/cli.py b/cli.py
index bcb4c94..085a0bc 100755
--- a/cli.py
+++ b/cli.py
@@ -34,6 +34,8 @@ def init(filename):
click.echo('Initialising pyble database...')
db = setup_database(filename)
setup_tables(db)
+ click.echo('Inserting common book names...')
+ setup_fill_alternative_book_names(db)
click.echo('Done.')
def load_biblehub_line(columns, line):
diff --git a/pyble.py b/pyble.py
index b399a29..79bed00 100644
--- a/pyble.py
+++ b/pyble.py
@@ -1,3 +1,4 @@
+import csv
from orator import DatabaseManager, Model, Schema
class Part(Model):
@@ -8,6 +9,10 @@ class Book(Model):
__timestamps__ = False
__fillable__ = ['canonical_name']
+class AlternativeBookName(Model):
+ __timestamps__ = False
+ __fillable__ = ['book', 'name']
+
class Verse(Model):
__timestamps__ = False
__fillable__ = ['book', 'chapter', 'nr']
@@ -26,7 +31,6 @@ class Passage(Model):
__fillable__ = ['fst', 'snd']
class CrossReference(Model):
- __timestamps__ = False
__fillable__ = ['passage_id1', 'passage_id2', 'relevance']
def setup_tables(db):
@@ -39,6 +43,11 @@ def setup_tables(db):
with schema.create('books') as table:
table.string('canonical_name').primary()
+ with schema.create('alternative_book_names') as table:
+ table.string('name').primary()
+ table.string('book')
+ table.foreign('book').references('canonical_name').on('books')
+
with schema.create('verses') as table:
table.string('book')
table.small_integer('chapter')
@@ -49,6 +58,18 @@ def setup_tables(db):
with schema.create('translations') as table:
table.string('name').primary()
+ with schema.create('translated_verses') as table:
+ table.string('translation')
+ table.string('book')
+ table.small_integer('chapter')
+ table.small_integer('nr')
+ table.string('text')
+ table.foreign('translation').references('name').on('translations')
+ table.foreign(['book', 'chapter', 'nr'])\
+ .references(['book', 'chapter', 'nr']).on('verses')\
+ .on_delete('restrict').on_update('cascade')
+ table.primary(['translation', 'book', 'chapter', 'nr'])
+
with schema.create('passages') as table:
table.increments('id')
table.string('fst_book')
@@ -69,20 +90,21 @@ def setup_tables(db):
with schema.create('crossreferences') as table:
table.integer('passage_id1')
table.integer('passage_id2')
+ table.timestamps()
table.small_integer('relevance').default(0)
table.foreign('passage_id1').references('id').on('passages')
table.foreign('passage_id2').references('id').on('passages')
table.primary(['passage_id1', 'passage_id2'])
- with schema.create('translated_verses') as table:
- table.string('translation')
- table.string('book')
- table.small_integer('chapter')
- table.small_integer('nr')
- table.string('text')
- table.foreign('translation').references('name').on('translations')
- table.foreign(['book', 'chapter', 'nr'])\
- .references(['book', 'chapter', 'nr']).on('verses')\
- .on_delete('restrict').on_update('cascade')
- table.primary(['translation', 'book', 'chapter', 'nr'])
+def setup_fill_alternative_book_names(db):
+ with open('alternative_book_names.csv', 'r') as csvfile:
+ reader = csv.reader(csvfile, delimiter=',', quotechar='"')
+ db.begin_transaction()
+ for names in reader:
+ canonical_name = names[0]
+ Book.first_or_create(canonical_name=canonical_name)
+ for name in names:
+ AlternativeBookName.first_or_create(
+ book=canonical_name, name=name)
+ db.commit()