diff --git a/book.cpp b/book.cpp index 704acf6..1447010 100644 --- a/book.cpp +++ b/book.cpp @@ -9,16 +9,16 @@ Book::Book (string n) { // cerr << "Book " << n << " created" << endl; } -void Book::setInfo(string n) { - info = n; +void Book::setModuleName(string n) { + moduleName = n; } string Book::getName() { return name; } -string Book::getInfo() { - return info; +string Book::getModuleName() { + return moduleName; } void Book::addVerse(string n, string i, vector t) { diff --git a/book.dox b/book.dox index 4a66701..4eb4a13 100644 --- a/book.dox +++ b/book.dox @@ -16,7 +16,7 @@ private: string name; /// /// Sword module name of the book, e.g. "LXX". - string info; + string moduleName; /// /// A Bible verse, in its traditional meaning. typedef struct Verse { @@ -41,23 +41,23 @@ public: /// Create a new book with a name, e.g. "Genesis". Book(string name); /// Set the Sword module for the book, e.g. "LXX". - void setInfo(string info); + void setModuleName(string moduleName); /// Get the Sword module name for the book, e.g. "LXX". - string getInfo(); + string getModuleName(); /// Get the book name, e.g. "Genesis". string getName(); /// Add a verse to a book. - void addVerse(string text, string verseInfo, vector tokens) { + void addVerse(string text, string info, vector tokens) { /// @short Add a verse to a book. /// Append a new verse to a Bible book by specifying the verse of the text /// in a-z encoding (without spaces and punctuation and setting the tokens). /// @param text The Greek text in a-z encoding, with no spaces or punctuation. - /// @param verseInfo The traditional verse numbering, e.g. "3:16". + /// @param info The traditional verse numbering, e.g. "3:16". /// @param tokens Tokenized form of the verse. }; /// Get the a-z encoded string of the verse defined by traditional numbering, e.g. "3:16". - string getVerse(string verseInfo); + string getVerse(string info); /// Get the traditional numbering of the verse that contains the given character position in the book, /// by appending a position modifier +N that gives the shift of characters to the beginning of the verse. string getVerseInfoStart(int position); @@ -73,17 +73,17 @@ public: /// Get the a-z encoded string of the whole book. string getText(); /// Get the tokenized form of the verse defined by traditional numbering, e.g. "3:16". - vector getVerseTokens(string verseInfo); + vector getVerseTokens(string info); /// Get the tokenized form of the whole book. vector getTokens(); /// Get the character position of the start of verse defined by traditional numbering, e.g. "3:16". - int getVerseStart(string verseInfo); + int getVerseStart(string info); /// Get the character position of the end of verse defined by traditional numbering, e.g. "3:16". - int getVerseEnd(string verseInfo); + int getVerseEnd(string info); /// Get the token position of the start of verse defined by traditional numbering, e.g. "3:16". - int getVerseTokensStart(string verseInfo); + int getVerseTokensStart(string info); /// Get the token position of the end of verse defined by traditional numbering, e.g. "3:16". - int getVerseTokensEnd(string verseInfo); + int getVerseTokensEnd(string info); /// Set the text of a whole book. It is useful if the book is created by using the cache. void setText(string text); diff --git a/book.h b/book.h index b75a63e..970b886 100644 --- a/book.h +++ b/book.h @@ -10,7 +10,7 @@ class Book { private: string name; - string info; + string moduleName; typedef struct Verse { int start; int length; @@ -23,22 +23,22 @@ class Book vector tokens; public: Book(string name); - void setInfo(string info); - string getInfo(); + void setModuleName(string moduleName); + string getModuleName(); string getName(); - void addVerse(string text, string verseInfo, vector tokens); - string getVerse(string verseInfo); + void addVerse(string text, string info, vector tokens); + string getVerse(string info); string getVerseInfoStart(int position); string getVerseInfoEnd(int position); string getVerseTokensInfoStart(int position); string getVerseTokensInfoEnd(int position); string getText(); - vector getVerseTokens(string verseInfo); + vector getVerseTokens(string info); vector getTokens(); - int getVerseStart(string verseInfo); - int getVerseEnd(string verseInfo); - int getVerseTokensStart(string verseInfo); - int getVerseTokensEnd(string verseInfo); + int getVerseStart(string info); + int getVerseEnd(string info); + int getVerseTokensStart(string info); + int getVerseTokensEnd(string info); // to load a book from cache: void setText(string text); void addVerse(int start, int length, string info, int tokensStart, int tokensLength); diff --git a/books.cpp b/books.cpp index b6db5b4..9522d10 100644 --- a/books.cpp +++ b/books.cpp @@ -450,7 +450,7 @@ int addBook_cached(string moduleName) { char reference[8]; // Psalms 119:176 needs 7 characters + "\n" int start, end, tokensStart, tokensEnd; try { - while (fscanf(verseFile, "%s %d %d %d %d", &reference, &start, &end, &tokensStart, &tokensEnd) != EOF) { + while (fscanf(verseFile, "%7s %d %d %d %d", reference, &start, &end, &tokensStart, &tokensEnd) != EOF) { if (bookName == "Psalms") { vector r; boost::split(r, reference, boost::is_any_of(":")); @@ -467,7 +467,7 @@ int addBook_cached(string moduleName) { fclose(verseFile); add_vocabulary_item(bookName); - book.setInfo(moduleName); + book.setModuleName(moduleName); books.push_back(book); } psalmsInfos.push_back(pi); @@ -538,8 +538,8 @@ int addBook(string moduleName, string firstVerse, string lastVerse, bool removeA if (verse.size() > 0) { string verseInfo = module->getKeyText(); if (!firstInfoSet) { - lastBook.setInfo(module->getBibliography().c_str()); - lastBook.setInfo(moduleName); + lastBook.setModuleName(module->getBibliography().c_str()); + lastBook.setModuleName(moduleName); firstInfoSet = true; } string verseText = processVerse(verse.c_str()); @@ -573,8 +573,8 @@ int addBook(string moduleName, string firstVerse, string lastVerse, bool removeA add_vocabulary_item(lastBookName); // new book Book book = Book(bookName); - book.setInfo(module->getBibliography().c_str()); - book.setInfo(moduleName); + book.setModuleName(module->getBibliography().c_str()); + book.setModuleName(moduleName); lastBook = book; lastBookName = bookName; @@ -650,7 +650,7 @@ int addBooks() { Book getBook(string book, string info) { for (int i=0; i info; boost::split(info, f, boost::is_any_of(",")); return stoi(info[0]); @@ -912,7 +912,7 @@ string find(string text, string moduleName) { return info[1] + "," + info[2]; } -vector find_min_unique(string text, string moduleName, int verb) { +vector find_min_unique(string text, string moduleName, bool verbose) { int long_limit = 10000; int extreme_limit = 50000; vector retval; @@ -942,7 +942,7 @@ vector find_min_unique(string text, string moduleName, int verb) { int unique = find(subtext, moduleName, 2, 0); if (unique == 1) { is_unique[i][j] = 1; - if (verb == 1) { + if (verbose) { info("Text " + subtext + " is minimal unique."); } retval.push_back(subtext); @@ -955,7 +955,7 @@ vector find_min_unique(string text, string moduleName, int verb) { return retval; } -string _extend(string moduleName1, string moduleName2, string book2, int pos2S, int pos2E, int verb) { +string _extend(string moduleName1, string moduleName2, string book2, int pos2S, int pos2E, bool verbose) { Book b2 = getBook(book2, moduleName2); string text = b2.getText().substr(pos2S, pos2E - pos2S + 1); @@ -995,7 +995,7 @@ string _extend(string moduleName1, string moduleName2, string book2, int pos2S, string verse1infoE = b1.getVerseInfoEnd(pos1E); string verse2infoS = b2.getVerseInfoStart(pos2S); string verse2infoE = b2.getVerseInfoEnd(pos2E); - if (verb == 1) { + if (verbose) { info("Extended match is " + ot_color + moduleName1 + " " + book1 + " " + verse1infoS + " " + verse1infoE + reset_color + " = " + nt_color + moduleName2 + " " + book2 + " " + verse2infoS + " " + verse2infoE + reset_color + " (" @@ -1023,7 +1023,7 @@ vector find_all(string text, string moduleName, int maxFound) { string book; for (int i=0; i searchTokenset(string moduleName, vector pattern, int length string book; for (int i=0; i bookTokens = b.getTokens(); int tokensLength = bookTokens.size(); diff --git a/books.h b/books.h index af0adec..d204bc5 100644 --- a/books.h +++ b/books.h @@ -16,8 +16,8 @@ int findBestFit(string book1, string info1, string verseInfo1s, string verseInfo string book2, string info2, string verseInfo2s, string verseInfo2e); string processVerse(const string &verse); string getText(string book, string info, string VerseInfoS, string VerseInfoE, int startOffset, int endOffset); -int find(string text, string moduleName, int maxFound, int verb); -vector find_min_unique(string text, string moduleName, int verb); +int find(string text, string moduleName, int maxFound, bool verbose); +vector find_min_unique(string text, string moduleName, bool verbose); void extend(string moduleName1, string moduleName2, string book2, string verse2S, int start, string verse2E, int end); void getrefs(string moduleName2, string moduleName1, string book1, string verse1S, diff --git a/cli.cpp b/cli.cpp index f2d7532..6e3d093 100644 --- a/cli.cpp +++ b/cli.cpp @@ -438,7 +438,7 @@ string cli_process(char *buf) { error(errorFindEmpty); goto end; } - find(text[index], rest, maxresults, 1); + find(text[index], rest, maxresults, true); goto end; } @@ -564,7 +564,7 @@ string cli_process(char *buf) { goto end; } string rest = input.substr(input.find(" ") + 1); - find_min_unique(text[0], rest, 1); + find_min_unique(text[0], rest, true); goto end; } diff --git a/fingerprint.dox b/fingerprint.dox index a91335c..29aa15b 100644 --- a/fingerprint.dox +++ b/fingerprint.dox @@ -9,8 +9,8 @@ typedef struct fingerprint { } fingerprint; /// Compute the fingerprint of a passage. -fingerprint getFingerprint(Book b, int start, int length) { - /// @param b A book in a Bible edition. +fingerprint getFingerprint(Book book, int start, int length) { + /// @param book A book in a Bible edition. /// @param start Start of the passage in characters. /// @param length Length of the passage in characters. }; diff --git a/fingerprint.h b/fingerprint.h index a99652b..c298521 100644 --- a/fingerprint.h +++ b/fingerprint.h @@ -9,7 +9,7 @@ typedef struct fingerprint { unsigned short int data [N][N]; } fingerprint; -fingerprint getFingerprint(Book b, int start, int length); +fingerprint getFingerprint(Book book, int start, int length); fingerprint getFingerprint(string text); int dist(fingerprint f1, fingerprint f2); int dist(string text1, string text2);