[sword-svn] r2097 - in trunk: . examples/cmdline src/modules/filters

scribe at www.crosswire.org scribe at www.crosswire.org
Sat Oct 6 23:27:35 MST 2007


Author: scribe
Date: 2007-10-06 23:27:34 -0700 (Sat, 06 Oct 2007)
New Revision: 2097

Modified:
   trunk/ChangeLog
   trunk/examples/cmdline/lookup.cpp
   trunk/src/modules/filters/osislemma.cpp
Log:
Modified OSISLemma to only strip lemma parts with
	lemma.* prefix or no prefix



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-10-07 00:40:00 UTC (rev 2096)
+++ trunk/ChangeLog	2007-10-07 06:27:34 UTC (rev 2097)
@@ -10,6 +10,8 @@
 	Applied fix for newer version of gcc which errors if
 		create perms are not passed to ::open
 		(Deji Akingunola <dakingun at gmail dot com>)
+	Modified OSISLemma to only strip lemma parts with
+		lemma.* prefix or no prefix
 
 13-Sep-2007	Troy A. Griffitts <scribe at crosswire.org>
 	Added InstallMgr::getModuleStatus to return a list

Modified: trunk/examples/cmdline/lookup.cpp
===================================================================
--- trunk/examples/cmdline/lookup.cpp	2007-10-07 00:40:00 UTC (rev 2096)
+++ trunk/examples/cmdline/lookup.cpp	2007-10-07 06:27:34 UTC (rev 2097)
@@ -42,6 +42,7 @@
 	// turn all filters to default values
 	manager.setGlobalOption("Headings", "On");
 	manager.setGlobalOption("Strong's Numbers", "On");
+	manager.setGlobalOption("Lemmas", "Off");
 //	manager.setGlobalOption("Greek Accents", "Off");
 
 	target->setKey(argv[2]);

Modified: trunk/src/modules/filters/osislemma.cpp
===================================================================
--- trunk/src/modules/filters/osislemma.cpp	2007-10-07 00:40:00 UTC (rev 2096)
+++ trunk/src/modules/filters/osislemma.cpp	2007-10-07 06:27:34 UTC (rev 2097)
@@ -7,6 +7,7 @@
 
 #include <stdlib.h>
 #include <osislemma.h>
+#include <utilxml.h>
 
 SWORD_NAMESPACE_START
 
@@ -26,42 +27,43 @@
 
 
 char OSISLemma::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
-	if (!option) {	// if we don't want lemmas
-		char token[2048]; // cheese.  Fix.
-		int tokpos = 0;
-		bool intoken = false;
-		bool lastspace = false;
-		SWBuf orig = text;
-		const char *from = orig.c_str();
+	SWBuf token;
+	bool intoken = false;
+	bool lastspace = false;
 
-		//taken out of the loop for speed
-		const char* start = 0;
-		const char* end = 0;
-		
+	const SWBuf orig = text;
+	const char * from = orig.c_str();
+
+	if (!option) {
 		for (text = ""; *from; ++from) {
 			if (*from == '<') {
 				intoken = true;
-				tokpos = 0;
-				token[0] = 0;
+				token = "";
 				continue;
 			}
 			if (*from == '>') {	// process tokens
 				intoken = false;
-				
-				if ((*token == 'w') && (token[1] == ' ')) {
-					start = strstr(token, "lemma=\""); //we leave out the "w " at the start
-					end = start ? strchr(start+7, '"') : 0;
-					
-					if (start && end) { //we want to leave out the morph attribute
-						text.append('<');
-						text.append(token, start-token); //the text before the morph attr
-						text.append(end+1);
-						text.append('>');
-						
-						continue;
+				if (token.startsWith("w ")) {	// Word
+					XMLTag wtag(token);
+					int count = wtag.getAttributePartCount("lemma", ' ');
+					for (int i = 0; i < count; i++) {
+						SWBuf a = wtag.getAttribute("lemma", i, ' ');
+						const char *prefix = a.stripPrefix(':');
+						if ((!prefix) || ((SWBuf)prefix).startsWith("lemma.")) {
+							// remove attribute part
+							wtag.setAttribute("lemma", 0, i, ' ');
+							i--;
+							count--;
+						}
 					}
+					token = wtag;
+					token.trim();
+					// drop <>
+					token << 1;
+					token--;
 				}
 				
+				// keep token in text
 				text.append('<');
 				text.append(token);
 				text.append('>');
@@ -69,9 +71,7 @@
 				continue;
 			}
 			if (intoken) {
-				if (tokpos < 2045)
-					token[tokpos++] = *from;
-					token[tokpos] = 0;
+				token += *from;
 			}
 			else	{
 				text.append(*from);




More information about the sword-cvs mailing list