Here are my criteria:
Get a copy of the text of the whole bible
This should be ready to open, read, split up into fields
Use this to create a persistent dictionary variable called bible
Set up your python program so when you type as I have shown, the program will know what you entered on the command line. Do NOT have it prompt you for the words.
Parse that reference meaning get the book, the chapter, the start verse and end verse. Other variations are rev 1:1, rev 12, or rev 10:1-3
When it prints have the output limit to a width of 100 characters wide before wrapping to a new line, which should then be indent enough to have the reference shown on the left and some spaces and the text aligned on the right.
The text in the text file looks like this:
0 | gen 1:1 | In the beginning God created the heaven and the earth.
1 | gen 1:2 | And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
2 | gen 1:3 | And God said, Let there be light: and there was light.
My code so far looks like this:
import os
import sys
import re
word_search = raw_input(r'Enter a word to search: ')
book = open("kjv.txt", "r")
first_lines = {36: 'Genesis', 4812: 'Exodus', 8867: 'Leviticus', 11749: 'Numbers', 15718: 'Deuteronomy',
18909: 'Joshua', 21070: 'Judges', 23340: 'Ruth', 23651: 'I Samuel', 26641: 'II Samuel',
29094: 'I Kings', 31990: 'II Kings', 34706: 'I Chronicles', 37378: 'II Chronicles',
40502: 'Ezra', 41418: 'Nehemiah', 42710: 'Esther', 43352: 'Job', 45937: 'Psalms', 53537: 'Proverbs',
56015: 'Ecclesiastes', 56711: 'The Song of Solomon', 57076: 'Isaih', 61550: 'Jeremiah',
66480: 'Lamentations', 66961: 'Ezekiel', 71548: 'Daniel' }
for ln, line in enumerate(book):
if word_search in line:
first_line = max(l for l in first_lines if l < ln)
bibook = first_lines[first_line]
template = "\nLine: {0}\nString: {1}\nBook:\n"
output = template.format(ln, line, bibook)
print output
I know that It is pretty messed up, so please help to straighten me out.
A summary of what I think I am doing:
Create a dictionary from the text file, then somehow get the user to input a chapter and verse, and then have the program be able to spit those chapter and verses out.