[sword-svn] r1935 - in trunk/src/modules: . filters

scribe at crosswire.org scribe at crosswire.org
Thu Jun 29 22:37:18 MST 2006


Author: scribe
Date: 2006-06-29 22:37:16 -0700 (Thu, 29 Jun 2006)
New Revision: 1935

Modified:
   trunk/src/modules/filters/osisplain.cpp
   trunk/src/modules/swmodule.cpp
Log:
Fix formatting
Fix OSISPlain strongs word searching to be consistent with thmlplain

Modified: trunk/src/modules/filters/osisplain.cpp
===================================================================
--- trunk/src/modules/filters/osisplain.cpp	2006-06-29 23:22:22 UTC (rev 1934)
+++ trunk/src/modules/filters/osisplain.cpp	2006-06-30 05:37:16 UTC (rev 1935)
@@ -18,6 +18,7 @@
 #include <osisplain.h>
 #include <utilxml.h>
 #include <ctype.h>
+#include <versekey.h>
 
 SWORD_NAMESPACE_START
 
@@ -36,22 +37,24 @@
 	addEscapeStringSubstitute("gt", ">");
 	addEscapeStringSubstitute("quot", "\"");
 
-        setTokenCaseSensitive(true);
-        addTokenSubstitute("title", "\n");
-        addTokenSubstitute("/title", "\n");
-        addTokenSubstitute("/l", "\n");
-        addTokenSubstitute("lg", "\n");
-        addTokenSubstitute("/lg", "\n");
+	   setTokenCaseSensitive(true);
+	   addTokenSubstitute("title", "\n");
+	   addTokenSubstitute("/title", "\n");
+	   addTokenSubstitute("/l", "\n");
+	   addTokenSubstitute("lg", "\n");
+	   addTokenSubstitute("/lg", "\n");
 }
 
 
 bool OSISPlain::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
-        // manually process if it wasn't a simple substitution
+	   // manually process if it wasn't a simple substitution
 	if (!substituteToken(buf, token)) {
 		MyUserData *u = (MyUserData *)userData;
+		VerseKey *vk = SWDYNAMIC_CAST(VerseKey, u->key);
+		char testament = (vk) ? vk ->Testament() : 2;	// default to NT
 		if (((*token == 'w') && (token[1] == ' ')) ||
 		    ((*token == '/') && (token[1] == 'w') && (!token[2]))) {
-	                u->tag = token;
+				 u->tag = token;
 			
 			bool start = false;
 			if (*token == 'w') {
@@ -83,29 +86,36 @@
 				buf.append('>');
 			}
 			if ((attrib = u->tag.getAttribute("lemma"))) {
-				int count = u->tag.getAttributePartCount("lemma");
+				int count = u->tag.getAttributePartCount("lemma", ' ');
 				int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
 				do {
-					attrib = u->tag.getAttribute("lemma", i);
+					char gh;
+					attrib = u->tag.getAttribute("lemma", i, ' ');
 					if (i < 0) i = 0;	// to handle our -1 condition
 					val = strchr(attrib, ':');
 					val = (val) ? (val + 1) : attrib;
-					if ((strchr("GH", *val)) && (isdigit(val[1])))
+					if ((strchr("GH", *val)) && (isdigit(val[1]))) {
+						gh = *val;
 						val++;
+					}
+					else {
+						gh = (testament>1) ? 'G' : 'H';
+					}
 					if ((!strcmp(val, "3588")) && (lastText.length() < 1))
 						show = false;
 					else	{
-						buf.append(" {<");
+						buf.append(" <");
+						buf.append(gh);
 						buf.append(val);
-						buf.append(">}");
+						buf.append(">");
 					}
 				} while (++i < count);
 			}
 			if ((attrib = u->tag.getAttribute("morph")) && (show)) {
-				int count = u->tag.getAttributePartCount("morph");
+				int count = u->tag.getAttributePartCount("morph", ' ');
 				int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
 				do {
-					attrib = u->tag.getAttribute("morph", i);
+					attrib = u->tag.getAttribute("morph", i, ' ');
 					if (i < 0) i = 0;	// to handle our -1 condition
 					val = strchr(attrib, ':');
 					val = (val) ? (val + 1) : attrib;

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2006-06-29 23:22:22 UTC (rev 1934)
+++ trunk/src/modules/swmodule.cpp	2006-06-30 05:37:16 UTC (rev 1935)
@@ -508,59 +508,59 @@
 		}
 		lucene::index::IndexReader    *ir = 0;
 		lucene::search::IndexSearcher *is = 0;
-      Query                          *q = 0;
-      Hits                           *h = 0;
-      try {
-        ir = IndexReader::open(target);
-        is = new IndexSearcher(ir);
-        (*percent)(10, percentUserData);
+		Query                          *q = 0;
+		Hits                           *h = 0;
+		try {
+			ir = IndexReader::open(target);
+			is = new IndexSearcher(ir);
+			(*percent)(10, percentUserData);
 
-        standard::StandardAnalyzer analyzer;
-        lucene_utf8towcs(wcharBuffer, istr, MAX_CONV_SIZE); //TODO Is istr always utf8?
-  		  q = QueryParser::parse(wcharBuffer, _T("content"), &analyzer);
-   	  (*percent)(20, percentUserData);
-	     h = is->search(q);
-	     (*percent)(80, percentUserData);
+			standard::StandardAnalyzer analyzer;
+			lucene_utf8towcs(wcharBuffer, istr, MAX_CONV_SIZE); //TODO Is istr always utf8?
+			q = QueryParser::parse(wcharBuffer, _T("content"), &analyzer);
+			(*percent)(20, percentUserData);
+			h = is->search(q);
+			(*percent)(80, percentUserData);
 
-        // iterate thru each good module position that meets the search
-        for (long i = 0; i < h->length(); i++) {
-           Document &doc = h->doc(i);
+			// iterate thru each good module position that meets the search
+			for (long i = 0; i < h->length(); i++) {
+				Document &doc = h->doc(i);
 
-           // set a temporary verse key to this module position
-           lucene_wcstoutf8(utfBuffer, doc.get(_T("key")), MAX_CONV_SIZE);	
-           *resultKey = utfBuffer; //TODO Does a key always accept utf8?
-           if (enforceRange) {
-              // check scope
-              // Try to set our scope key to this verse key
-              *testKey = *resultKey;
+				// set a temporary verse key to this module position
+				lucene_wcstoutf8(utfBuffer, doc.get(_T("key")), MAX_CONV_SIZE);	
+				*resultKey = utfBuffer; //TODO Does a key always accept utf8?
+				if (enforceRange) {
+					// check scope
+					// Try to set our scope key to this verse key
+					*testKey = *resultKey;
 
-              // check to see if it set ok and if so, add to our return list
-              if (*testKey == *resultKey) {
-                 listKey << *resultKey;
-                 listKey.GetElement()->userData = (void *)((__u32)(h->score(i)*100));
-              }
-           }
-           else {
-              listKey << *resultKey;
-              listKey.GetElement()->userData = (void *)((__u32)(h->score(i)*100));
-           }
-        }
-        (*percent)(98, percentUserData);
-      }
-      catch (...) {
-         q = 0;
-         // invalid clucene query
-      }
-      delete h;
-      delete q;
+					// check to see if it set ok and if so, add to our return list
+					if (*testKey == *resultKey) {
+						listKey << *resultKey;
+						listKey.GetElement()->userData = (void *)((__u32)(h->score(i)*100));
+					}
+				}
+				else {
+					listKey << *resultKey;
+					listKey.GetElement()->userData = (void *)((__u32)(h->score(i)*100));
+				}
+			}
+			(*percent)(98, percentUserData);
+		}
+		catch (...) {
+			q = 0;
+			// invalid clucene query
+		}
+		delete h;
+		delete q;
 
-      delete is;
-      if (ir) {
-         ir->close();
-      }
-      if (freeTestKey) {
-         delete testKey;
-      }
+		delete is;
+		if (ir) {
+			ir->close();
+		}
+		if (freeTestKey) {
+			delete testKey;
+		}
 	}
 #endif
 



More information about the sword-cvs mailing list