You are to write a C++ program that creates a Bible concordance for a given set of words. For each word, the
concordance will list the word followed by the book, chapter, and verse containing the word. The word list will be in a filecalled words.txt, and it will contain one word per line as shown in the box below.
The file will not contain hyphenated words like Christ-like or multiple words like Holy Spirit.
Your program will search every line of the Bible for each occurrence of the word. The entire
text of the Bible (King James Version) can be found in
\\cs1\Classes\comp170\Concordance\bible.txt. An excerpt is shown below:
Book 01 Genesis
001:001 In the beginning God created the heaven and the earth.
001:002 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.
Etc…
050:026 So Joseph died, being an hundred and ten years old: and they
embalmed him, and he was put in a coffin in Egypt.
Book 02 Exodus
001:001 Now these are the names of the children of Israel, which came
into Egypt; every man and his household came with Jacob.
001:002 Reuben, Simeon, Levi, and Judah,
Etc…
Note that the beginning of each book is on a line that starts with Book XX where XX corresponds to the book’s order.
Then there is a tab character followed by the book’s title. Verses always start with XXX:YYY where XXX is the chapter and
YYY is the verse. Long verses are continued on the next line with 8 spaces preceding it. A blank line always separates
each verse.
Given the words.txt above, your program will output the concordance to a text file called conc.txt. The concordance
should be formatted with a single tab before each passage like so:
Christ
Matthew 1:1
Matthew 1:16
Matthew 1:17
Etc…
righteous
Genesis 7:1
Genesis 18:23
Etc…
Damascus
Genesis 14:15
Genesis 15:2
2 Samuel 8:5
Etc…
Christ
righteous
Damascus
Note that the chapter and verses have been altered; the string 015:002 is changed to 15:2.
Your program should match words from words.txt with the Bible verses very carefully. If God is the word being searched for, it should match God and god, but it should not match godly or Magod. This means the find function is not sufficient for doing the string search. You will need to write your own string searching/matching function which is case insensitive and makes sure there are no alpha characters before or after the matched string (anti-god and God’s should also match).
You will likely find one or more of the following functions to be useful in writing your function:
string s = “Jesus, the 1 Christ”;
if (isalpha(s[5])) // returns false
if (isdigit(s[11])) // returns true
char lowercase = tolower(s[0]); // returns 'j'
if (s.compare(0, 5, “Jesus”) == 0) // returns 0
When determining if a word is contained in a verse, you may find it useful to first put the entire verse into a single string.
This means you will read potentially multiple lines and place them all into a single string. Then you can use your custom
search function to tell you if the word occurs in the verse.
Your program should also output its status to the screen since it can take a long time for your program to run. Here is an
example:
Building concordance...
Processing Christ...
Processing righteous...
Processing Damascus...
Done. Wrote to conc.txt.
In the \\cs1\Classes\comp170\Concordance folder, you will find a words.txt and the resulting conc.txt file that my
program produced. You may find this useful for testing your program (comparing your results with mine). I’ve also
provided my BibleConcordance.exe and BibleConcordance-EX.exe (solution to extra credit) files so you can do further
testing.
You will find it useful to use some type of file comparison program to check your results with mine. ExamDiff is a good
freeware program (search for it with Google).
Like the previous projects, make sure your code adheres to McCown’s Writing Clean Code handout. Submit your program
to Easel (http://cs.harding.edu/easel/) by the due date.
McChallenge Extra Credit: You can get 1% added to your final grade for improving your program so that the output in
conc.txt contains the five surrounding words (two words in front of the key word and two words behind it) next to each
verse. Only words within the sentence should be displayed, so if there are less than five words, display the entire
sentence. If the key word is at the beginning of the sentence, display the four words after it; if it at the end of the
sentence, display the four words in front, etc. Display three spaces between the verse and the five words. Here is
example output:
Christ
Matthew 1:1 of Jesus Christ, the son
Matthew 1:16 Jesus, who is called Christ.
Matthew 1:17 Babylon unto Christ are fourteen
I also have an executable of the working program. If anybody want's to get the executable just email me and i will send it to you. My email address is sharris2@harding.edu.
Ok So here is what i want to do first. I want to read in a word to find from, words.txt. Here is what i have done so far.
include<iostream>
#include<string>
#include<fstream>
using namespace std;
void main()
{
ifstream bible;
ifstream words;
ofstream concordance;
string word_in;
concordance.open("conc.txt");
bible.open("bible.txt");
words.open("words.txt");
while(!words.eof())
{
getline(words,word_in);
}
}
Now i want to find a way to identify the various books of the bible.
This post has been edited by Steffan: 05 December 2008 - 06:43 PM

New Topic/Question
Reply




MultiQuote






|