[sword-svn] r2193 - in trunk: examples/cmdline include src/modules

scribe at www.crosswire.org scribe at www.crosswire.org
Wed Sep 3 06:22:12 MST 2008


Author: scribe
Date: 2008-09-03 06:22:12 -0700 (Wed, 03 Sep 2008)
New Revision: 2193

Modified:
   trunk/examples/cmdline/lookup.cpp
   trunk/examples/cmdline/search.cpp
   trunk/include/treekey.h
   trunk/src/modules/swmodule.cpp
Log:
Some cleanup and small optimizations


Modified: trunk/examples/cmdline/lookup.cpp
===================================================================
--- trunk/examples/cmdline/lookup.cpp	2008-08-16 16:42:29 UTC (rev 2192)
+++ trunk/examples/cmdline/lookup.cpp	2008-09-03 13:22:12 UTC (rev 2193)
@@ -10,6 +10,7 @@
 using sword::SWModule;
 using sword::FMT_WEBIF;
 using sword::FMT_HTMLHREF;
+using sword::FMT_RTF;
 using sword::ModMap;
 using sword::AttributeTypeList;
 using sword::AttributeList;

Modified: trunk/examples/cmdline/search.cpp
===================================================================
--- trunk/examples/cmdline/search.cpp	2008-08-16 16:42:29 UTC (rev 2192)
+++ trunk/examples/cmdline/search.cpp	2008-09-03 13:22:12 UTC (rev 2193)
@@ -17,7 +17,7 @@
 	 *			-3  - entryAttrib (eg. Word//Lemma/G1234/)
 	 *			-4  - Lucene
    */
-char SEARCH_TYPE=-2;
+char SEARCH_TYPE=-4;
 
 char printed = 0;
 void percentUpdate(char percent, void *userData) {

Modified: trunk/include/treekey.h
===================================================================
--- trunk/include/treekey.h	2008-08-16 16:42:29 UTC (rev 2192)
+++ trunk/include/treekey.h	2008-09-03 13:22:12 UTC (rev 2193)
@@ -54,6 +54,7 @@
 		TreeKey *treeKey;
 	public:
 		PositionChangeListener() {}
+		virtual ~PositionChangeListener() {}
 		virtual void positionChanged() = 0;
 		TreeKey *getTreeKey() { return treeKey; }
 		void setTreeKey(TreeKey *tk) { treeKey = tk; }

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2008-08-16 16:42:29 UTC (rev 2192)
+++ trunk/src/modules/swmodule.cpp	2008-09-03 13:22:12 UTC (rev 2193)
@@ -458,15 +458,6 @@
 	}
 
 	(*percent)(perc, percentUserData);
-	// MAJOR KLUDGE: VerseKey::Index still return index within testament.
-	// 	VerseKey::NewIndex should be moved to Index and Index should be some
-	// 	VerseKey specific name
-	VerseKey *vkcheck = 0;
-	SWTRY {
-		vkcheck = SWDYNAMIC_CAST(VerseKey, key);
-	}
-	SWCATCH (...) {}
-	// end MAJOR KLUDGE
 
 	*this = BOTTOM;
 	long highIndex = key->Index();
@@ -505,6 +496,7 @@
 			(*percent)(80, percentUserData);
 
 			// iterate thru each good module position that meets the search
+			bool checkBounds = getKey()->isBoundSet();
 			for (long i = 0; i < h->length(); i++) {
 				Document &doc = h->doc(i);
 
@@ -512,12 +504,15 @@
 				lucene_wcstoutf8(utfBuffer, doc.get(_T("key")), MAX_CONV_SIZE);	
 				*resultKey = utfBuffer; //TODO Does a key always accept utf8?
 
-				// check to see if it sets ok (in our range?) and if so, add to our return list
-				*getKey() = *resultKey;
-				if (*getKey() == *resultKey) {
-					listKey << *resultKey;
-					listKey.GetElement()->userData = (void *)((__u32)(h->score(i)*100));
+				// check to see if it sets ok (within our bounds) and if not, skip
+				if (checkBounds) {
+					*getKey() = *resultKey;
+					if (*getKey() != *resultKey) {
+						continue;
+					}
 				}
+				listKey << *resultKey;
+				listKey.GetElement()->userData = (void *)((__u32)(h->score(i)*100));
 			}
 			(*percent)(98, percentUserData);
 		}
@@ -588,7 +583,6 @@
 		per *= 93;
 		per += 5;
 		char newperc = (char)per;
-//		char newperc = (char)(5+(93*(((float)((vkcheck)?vkcheck->NewIndex():key->Index()))/highIndex)));
 		if (newperc > perc) {
 			perc = newperc;
 			(*percent)(perc, percentUserData);
@@ -596,7 +590,6 @@
 		else if (newperc < perc) {
 #ifndef _MSC_VER
 			std::cerr << "Serious error: new percentage complete is less than previous value\n";
-			std::cerr << "using vk? " << ((vkcheck)?"yes":"no") << "\n";
 			std::cerr << "index: " << (key->Index()) << "\n";
 			std::cerr << "highIndex: " << highIndex << "\n";
 			std::cerr << "newperc ==" << (int)newperc << "%" << "is smaller than\n";
@@ -1043,7 +1036,7 @@
 			}
 
 			lucene_utf8towcs(wcharBuffer, keyText, MAX_CONV_SIZE); //keyText must be utf8
-			doc->add( *Field::Text(_T("key"), wcharBuffer ) );
+			doc->add( *(new Field("key", wcharBuffer, Field::STORE_YES | Field::INDEX_TOKENIZED)));
 
 			if (includeKeyInSearch) {
 				c = keyText;




More information about the sword-cvs mailing list