From 7f46f0e00e359e881136c1d85c8a16823b8bde42 Mon Sep 17 00:00:00 2001 From: "Troy A. Griffitts" Date: Tue, 5 Feb 2013 13:19:50 +0000 Subject: updated to build against latest SWORD trunk git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@411 07627401-56e2-0310-80f4-f8cd0041bdcd --- flashtools/flash.cpp | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'flashtools') diff --git a/flashtools/flash.cpp b/flashtools/flash.cpp index 2ee86b9..52b5dea 100644 --- a/flashtools/flash.cpp +++ b/flashtools/flash.cpp @@ -187,6 +187,12 @@ SWBuf escapedUTF8(SWBuf inText) { void outputCSV(const vector &wordList) { // output header cout + << "FreqKJV|" + << "Greek|" + << "Strongs|" + << "TranslationInAV" + << "\n"; +/* << "FreqKJV|" << "PointedHeb|" << "Meaning|" @@ -205,6 +211,7 @@ void outputCSV(const vector &wordList) { << "FullMeaning|" << "TranslationInAV" << "\n"; +*/ for (vector::const_iterator it = wordList.begin(); it != wordList.end(); it++) { const Word &w = (*it); @@ -213,9 +220,13 @@ void outputCSV(const vector &wordList) { if (gh == 'G' || gh == 'H') { s << 1; } - s = itoa(atoi(s.c_str())).c_str(); -// cout << w->freq << "|" << escapedUTF8(w->utf8).c_str() << "|" << w->strong << "|" << prettyKJVFreq(w->kjvFreq).c_str() << "\n"; + s = itoa(atoi(s.c_str())).c_str(); cout + << w.freq << "|" + << escapedUTF8(w.utf8).c_str() << "|" + << w.strong << "|" + << prettyKJVFreq(w.kjvFreq).c_str() +/* << w.freq << "|" << hebrew[s]["UTF8"] << "|" << hebrew[s]["Meaning"] << "|" @@ -233,6 +244,7 @@ void outputCSV(const vector &wordList) { << hebrew[s]["Notes"] << "|" << hebrew[s]["FullMeaning"] << "|" << hebrew[s]["TranslationInAV"] +*/ << "\n"; } std::cout << std::endl; @@ -321,23 +333,22 @@ void outputFlash(const vector &wordList, const char *outputDir = ".", bool * (useful for generating complete OT or NT strongs word lists) * */ -vector processWords(const char *range, bool addAll = true) { +vector processWords(const char *range, bool addAll = true, SWBuf modName = "KJV") { SWMgr manager; map wordList; - SWModule *tmpBible = manager.getModule("KJV"); + SWModule *tmpBible = manager.getModule(modName); if (!tmpBible) { cerr << "Unable to locate KJV module" << endl; exit(1); } SWModule &bible = *tmpBible; - VerseKey parser; - ListKey r = parser.ParseVerseList(range, 0, true); - r.Persist(true); - bible.setKey(r); - for (bible = TOP; !bible.Error(); bible++) { - bible.RenderText(); // force an entry lookup to resolve key to something in the index + VerseKey *parser = (VerseKey *)bible.createKey(); + ListKey r = parser->parseVerseList(range, 0, true); + for (r = TOP; !r.popError(); r++) { + bible.setKey(r); + bible.renderText(); // force an entry lookup to resolve key to something in the index AttributeList &words = bible.getEntryAttributes()["Word"]; for (AttributeList::iterator word = words.begin(); word != words.end(); word++) { @@ -389,13 +400,13 @@ vector processWords(const char *range, bool addAll = true) { // this assures we have an entry for every word, even if it is not // present in the module r = TOP; - if (VerseKey(r).Testament() == 1) { + if (VerseKey(r).getTestament() == 1) { for (SectionMap::iterator it = hebrew.Sections.begin(); it != hebrew.Sections.end(); it++) { wordList[(SWBuf)"H0"+it->first].utf8; // just access to be sure created. We'll add later. } } r = BOTTOM; - if (VerseKey(r).Testament() == 2) { + if (VerseKey(r).getTestament() == 2) { for (SectionMap::iterator it = greek.Sections.begin(); it != greek.Sections.end(); it++) { wordList[(SWBuf)"G"+it->first].utf8; } @@ -428,6 +439,8 @@ vector processWords(const char *range, bool addAll = true) { } sort(sorted.begin(), sorted.end(), compareFreq); + delete parser; + return sorted; } @@ -443,6 +456,7 @@ void usage(const char *app, const char *error = 0) { fprintf(stderr, " -d \t\t definition to use (default k):\n"); fprintf(stderr, "\t\t\t\t m - short meaning; k - KJV collation\n"); fprintf(stderr, " -r <\"range\">\t\t verse range\n"); + fprintf(stderr, " -m <\"module name\">\t\t module name to use (default \"KJV\")\n"); fprintf(stderr, " -f \t\t include special font name for lesson\n"); fprintf(stderr, " -h\t\t\t display this help message\n\n"); exit(-1); @@ -450,8 +464,9 @@ void usage(const char *app, const char *error = 0) { int main(int argc, char **argv) { + const int REQUIRED = 0; // Let's test our command line arguments - if (argc < 1) { + if (argc < REQUIRED+1) { // this never happens since we don't have any required argument count usage(*argv); } @@ -462,6 +477,7 @@ int main(int argc, char **argv) { SWBuf range = "Mat-Rev"; SWBuf fontName = ""; SWBuf outDir = "."; + SWBuf modName = "KJV"; int count = 25; for (int i = 1; i < argc; i++) { @@ -486,6 +502,10 @@ int main(int argc, char **argv) { if (i+1 < argc) range = argv[++i]; else usage(*argv, "-r requires <\"range\">"); } + else if (!strcmp(argv[i], "-m")) { + if (i+1 < argc) modName = argv[++i]; + else usage(*argv, "-m requires <\"module name\">"); + } else if (!strcmp(argv[i], "-f")) { if (i+1 < argc) fontName = argv[++i]; else usage(*argv, "-f requires <\"fontName\">"); @@ -504,10 +524,10 @@ int main(int argc, char **argv) { } if (csv) { - outputCSV(processWords(range)); + outputCSV(processWords(range, true, modName)); } else { - outputFlash(processWords(range), outDir, (def == 'k'), count, (fontName.length()?fontName.c_str():0)); + outputFlash(processWords(range, true, modName), outDir, (def == 'k'), count, (fontName.length()?fontName.c_str():0)); } return 0; -- cgit