I'm currently builting a script for a church here in town to parse through the Bible and find select verses. I currently am using the KJV which is just in a single .txt file. Here is some sample from the text file:
1:1 In the beginning God created the heaven and the earth.
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.
I am creating the script to simply run and then I can type a verse name such as Genesis 1:1 and the verse would pop up. I currently have about 75% of the Script done. I am now having problem with the command of searching for the text. I understand that I need to use a for loop to count the index of my input (John for example) and then store that index from the abrevrBook array. I think of it as book[1] = abrevrBook[1] so if I input Genesis, you want to have the program search for gen. Here's my code:
#!/usr/bin/python
bible = {}
for line in open("KJV.txt"):
(line, key, val) = line.split('|')
bible[str(key.rstrip(' ').lstrip(' '))] = val.rstrip('\n').lstrip(' ')
book = ["Genesis", "Exodus", "Leviticus", "Numbers", "Deuteronomy",
"Joshua", "Judges", "Ruth", "1Samuel", "2Samuel", "1Kings",
"2Kings", "1Chronicles", "2Chronicles", "Ezra", "Nehemiah",
"Esther", "Job", "Psalms", "Proverbs", "Ecclesiastes",
"Songs", "Isaiah", "Jeremiah", "Lamentations", "Ezekiel",
"Daniel", "Hosea", "Joel", "Amos", "Obadiah", "Jonah",
"Micah", "Nahum", "Habakkuk", "Zephaniah", "Haggai", "Zechariah",
"Malachi", "Matthew", "Mark", "Luke", "John", "Acts", "Romans",
"1Corinthians", "2Corinthians", "Galatians", "Ephesians",
"Phillipians", "Colossians", "1Thessalonians", "2Thessalonians",
"1Timothy", "2Timothy", "Titus", "Philemon", "Hebrews", "James",
"1Peter", "2Peter", "1John", "2John", "3John", "Jude", "Revelation" ]
abrevBook = ["gen", "exo", "lev", "num", "deu", "jos", "jdg",
"rut", "1sa", "2sa", "1ki", "2ki", "1ch", "2ch",
"ezr", "neh", "est", "job", "psa", "pro", "ecc",
"son", "isa", "jer", "lam", "eze", "dan", "hos",
"joe", "amo", "oba", "jon", "mic", "nah", "hab",
"zep", "hag", "zec", "mal", "mat", "mar", "luk",
"joh", "act", "rom", "1co", "2co", "gal", "eph",
"phi", "col", "1th", "2th", "1ti", "2ti", "tit",
"phl", "heb", "jam", "1pe", "2pe", "1jo", "2jo",
"3jo", "jud", "rev"]
So, I know I need to store my search term (gen 1:1) in a string (or array) so that I can get
if bible.has_key(search):
stringToOutput = bible.get(search)
I'm confused on how to get this part done though. Thank you in advance.