summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTroy A. Griffitts <scribe@crosswire.org>2023-04-18 23:29:55 +0000
committerTroy A. Griffitts <scribe@crosswire.org>2023-04-18 23:29:55 +0000
commit3f45b5d04c1ac41d73173cb438add2cb82581447 (patch)
tree4dc2b3b35ec6038f8d40484602323ea12e5f2be7
parentf304a5a5fe1d4dd2ff7efab2ee07e272ece87840 (diff)
downloadsword-tools-3f45b5d04c1ac41d73173cb438add2cb82581447.tar.gz
added option to pass a different strongs source for OT
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@560 07627401-56e2-0310-80f4-f8cd0041bdcd
-rw-r--r--migratetags/migratetags.cpp51
1 files changed, 37 insertions, 14 deletions
diff --git a/migratetags/migratetags.cpp b/migratetags/migratetags.cpp
index 0ea3ac7..4ec6655 100644
--- a/migratetags/migratetags.cpp
+++ b/migratetags/migratetags.cpp
@@ -21,7 +21,8 @@ using namespace std;
Matcher *matcher = new GNTMatcher();
// hard code your from and to modules here or pass them on the command line with -
-SWBuf strongsSourceModuleName = "WHNU";
+SWBuf strongsSourceModuleNameOT = "";
+SWBuf strongsSourceModuleNameNT = "WHNU";
SWBuf targetModuleName = "NA28FromImp";
SWBuf targetTEIFile = "";
@@ -50,7 +51,8 @@ void usage(const char *progName, const char *error = 0) {
if (error) fprintf(stderr, "\n%s: %s\n", progName, error);
fprintf(stderr, "\n=== migratetags (Revision $Rev$) Migrate word morphology from one module to another.\n");
fprintf(stderr, "\nusage: %s [options]\n", progName);
- fprintf(stderr, " -ss <moduleName>\t provide the Strong's source module name\n");
+ fprintf(stderr, " -ss <moduleName>\t provide the Strong's source module name for both OT and NT\n");
+ fprintf(stderr, " -ssot <moduleName>\t provide a different Strong's source module name for the OT\n");
fprintf(stderr, " -l \t\t include lexical and source information\n");
fprintf(stderr, " -t <moduleName>\t provide the target module name\n");
fprintf(stderr, " -tei <filename>\t provide the target tei filename\n");
@@ -89,7 +91,8 @@ bool getNextVerse(VerseKey *targetModKey, SWBuf *targetModText) {
}
FileDesc *targetInput = 0;
-bool getNextVerseTEI(VerseKey *targetModKey, SWBuf *targetModText) {
+bool getNextVerseTEI(VerseKey *targetModKeyNT, VerseKey *targetModKeyOT, VerseKey *&targetModKey, SWBuf *targetModText) {
+ targetModKey = targetModKeyNT;
static bool finished = false;
static bool fileEnd = false;
static SWBuf line = "";
@@ -184,10 +187,12 @@ bool getNextVerseTEI(VerseKey *targetModKey, SWBuf *targetModText) {
SWBuf osisID = (bookName.size() ? bookName : bookNum);
osisID.appendFormatted(".%s.%s", chapter.c_str(), verse.c_str());
(*targetModKey) = osisID;
+ if (targetModKey->getError() || targetModKey->getTestament() == 1) {
+ targetModKey = targetModKeyOT;
+ (*targetModKey) = osisID;
+ }
}
-
}
-
return true;
}
@@ -209,10 +214,17 @@ int main(int argc, char **argv) {
}
else if (!strcmp(argv[i], "-ss")) {
if ((i + 1) < argc) {
- strongsSourceModuleName = argv[++i];
+ strongsSourceModuleNameNT = argv[++i];
+ if (!strongsSourceModuleNameOT.length()) strongsSourceModuleNameOT = argv[i];
}
else usage(progName, "-ss argument requires a module name.");
}
+ else if (!strcmp(argv[i], "-ssot")) {
+ if ((i + 1) < argc) {
+ strongsSourceModuleNameOT = argv[++i];
+ }
+ else usage(progName, "-ssot argument requires a module name.");
+ }
else if (!strcmp(argv[i], "-t")) {
if ((i + 1) < argc) {
targetModuleName = argv[++i];
@@ -255,13 +267,20 @@ int main(int argc, char **argv) {
targetMod = m;
}
- m = lib.getModule(strongsSourceModuleName.c_str());
+ m = lib.getModule(strongsSourceModuleNameNT.c_str());
if (!m) {
- cerr << "\nERROR: couldn't find Strong's source module: " << strongsSourceModuleName.c_str() << ".\n";
+ cerr << "\nERROR: couldn't find Strong's source module: " << strongsSourceModuleNameNT.c_str() << ".\n";
if (argc < 2) usage(progName, "Use -ss to supply Strong's source module name");
exit(1);
}
- SWModule &fromMod = *m;
+ SWModule &fromModNT = *m;
+ m = lib.getModule(strongsSourceModuleNameOT.c_str());
+ if (!m) {
+ cerr << "\nERROR: couldn't find Strong's source module: " << strongsSourceModuleNameOT.c_str() << ".\n";
+ if (argc < 2) usage(progName, "Use -ssot to supply OT Strong's source module name");
+ exit(1);
+ }
+ SWModule &fromModOT = *m;
for (int i = 0; i < optionExceptionFile.size(); ++i) {
SWBuf fileName = optionExceptionFile[i];
@@ -269,14 +288,18 @@ int main(int argc, char **argv) {
else (*exceptionFile) += SWConfig(fileName);
}
- VerseKey *targetModKey = (VerseKey *)(targetInput ? fromMod.createKey() : targetMod->createKey());
- targetModKey->setIntros(true);
+ VerseKey *targetModKeyNT = (VerseKey *)(targetInput ? fromModNT.createKey() : targetMod->createKey());
+ VerseKey *targetModKeyOT = (VerseKey *)(targetInput ? fromModOT.createKey() : targetMod->createKey());
+ targetModKeyOT->setIntros(true);
+ targetModKeyNT->setIntros(true);
SWBuf targetModText;
SWConfig *lex = 0;
if (optionIncludeLex) {
lex = new SWConfig("../flashtools/greek.conf");
}
- while ((targetInput ? getNextVerseTEI(targetModKey, &targetModText) : getNextVerse(targetModKey, &targetModText))) {
+ VerseKey *targetModKey = targetModKeyNT;
+ while ((targetInput ? getNextVerseTEI(targetModKeyNT, targetModKeyOT, targetModKey, &targetModText) : getNextVerse(targetModKey, &targetModText))) {
+ SWModule &fromMod = (targetModKey == targetModKeyNT ? fromModNT : fromModOT);
if (targetModKey->getError()) {
cout << targetModText;
cout << endl;
@@ -451,7 +474,7 @@ if (optionDebug) {
if (targetWordTags[i] == -1 && !strstr(ignoreSeries, targetWords[i])) {
if (!warned) {
cerr << "*** Error: didn't match all words: " << targetModKey->getText() << endl;
- cerr << strongsSourceModuleName.c_str() << ":";
+ cerr << (targetModKey->getTestament() == 2 ? strongsSourceModuleNameNT.c_str() : strongsSourceModuleNameOT.c_str()) << ":";
for (int j = 0; j < fromWords.size(); ++j) {
cerr << " " << fromWords[j];
}
@@ -530,7 +553,7 @@ SWBuf findCanonicalBibleText(SWBuf orig, BibMap &bibMap, BibMap &wTags) {
if (orig[i] == '<') {
inTag = true;
}
- else if (orig[i] == '>') {
+ else if (inTag && orig[i] == '>') {
inTag = false;
XMLTag t = tag.c_str();
bool skipTag = false;