[sword-svn] r560 - trunk/migratetags

scribe at crosswire.org scribe at crosswire.org
Tue Apr 18 19:29:55 EDT 2023


Author: scribe
Date: 2023-04-18 19:29:55 -0400 (Tue, 18 Apr 2023)
New Revision: 560

Modified:
   trunk/migratetags/migratetags.cpp
Log:
added option to pass a different strongs source for OT


Modified: trunk/migratetags/migratetags.cpp
===================================================================
--- trunk/migratetags/migratetags.cpp	2023-04-18 09:35:52 UTC (rev 559)
+++ trunk/migratetags/migratetags.cpp	2023-04-18 23:29:55 UTC (rev 560)
@@ -21,7 +21,8 @@
 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 @@
 	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 @@
 }
 
 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 @@
 			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 @@
 		}
 		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 @@
 		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 @@
 		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 (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 @@
 		if (orig[i] == '<') {
 			inTag = true;
 		}
-		else if (orig[i] == '>') {
+		else if (inTag && orig[i] == '>') {
 			inTag = false;
 			XMLTag t = tag.c_str();
 			bool skipTag = false;



More information about the sword-cvs mailing list