[sword-svn] r1909 - in trunk: . bindings/corba/java
bindings/corba/java/src/org/crosswire/sword/orb
examples/cmdline include src/keys src/modules
scribe at crosswire.org
scribe at crosswire.org
Tue Apr 25 00:18:38 MST 2006
Author: scribe
Date: 2006-04-25 00:18:34 -0700 (Tue, 25 Apr 2006)
New Revision: 1909
Modified:
trunk/ChangeLog
trunk/bindings/corba/java/Makefile
trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java
trunk/examples/cmdline/search.cpp
trunk/include/swmodule.h
trunk/src/keys/versekey.cpp
trunk/src/modules/swmodule.cpp
Log:
Changed SWModule::search to fill result set up with more
specialized SWKey objects, instead of always SWKey
Changed SWModule::search to use CLucene better for
non-VerseKey modules
Added basic proximity searching with CLucene searches
Added ListKey::sort()
Removed some debug output from Java bindings
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-04-25 06:01:30 UTC (rev 1908)
+++ trunk/ChangeLog 2006-04-25 07:18:34 UTC (rev 1909)
@@ -1,6 +1,14 @@
API ChangeLog (see the ChangeLog in each 'apps' directory for
- app specific changes
+ app specific changes)
+25-Apr-2006 Troy A. Griffitts <scribe at crosswire.org>
+ Changed SWModule::search to fill result set up with more
+ specialized SWKey objects, instead of always SWKey
+ Changed SWModule::search to use CLucene better for
+ non-VerseKey modules
+ Added basic proximity searching with CLucene searches
+ Added ListKey::sort()
+
14-Apr-2006 Troy A. Griffitts <scribe at crosswire.org>
Added EntryAttribute support to SWIG bindings (from mreimer)
Modified: trunk/bindings/corba/java/Makefile
===================================================================
--- trunk/bindings/corba/java/Makefile 2006-04-25 06:01:30 UTC (rev 1908)
+++ trunk/bindings/corba/java/Makefile 2006-04-25 07:18:34 UTC (rev 1909)
@@ -1,5 +1,5 @@
TOMCAT_HOME=/usr/local/tomcat
-instdir=/home/scribe/src/swordweb/webapp
+instdir=/home/swordweb/livehtml/webapp
all: src/org/crosswire/sword/orb/SWMgr.java classes/org/crosswire/sword/orb/SwordOrb.class
src/org/crosswire/sword/orb/SWMgr.java: ../swordorb.idl
Modified: trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java
===================================================================
--- trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java 2006-04-25 06:01:30 UTC (rev 1908)
+++ trunk/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java 2006-04-25 07:18:34 UTC (rev 1909)
@@ -28,8 +28,8 @@
retVal.testConnection();
System.out.println("testConnection successful");
}
- catch(org.omg.CORBA.SystemException e) {
- e.printStackTrace();
+ catch(Exception e) {
+// e.printStackTrace();
retVal = null;
System.out.println("failed in attach");
}
@@ -88,7 +88,7 @@
retVal = attach();
}
catch(org.omg.CORBA.SystemException e) {
- e.printStackTrace();
+// e.printStackTrace();
retVal = null;
}
if (retVal == null) {
Modified: trunk/examples/cmdline/search.cpp
===================================================================
--- trunk/examples/cmdline/search.cpp 2006-04-25 06:01:30 UTC (rev 1908)
+++ trunk/examples/cmdline/search.cpp 2006-04-25 07:18:34 UTC (rev 1909)
@@ -76,6 +76,7 @@
*/
listkey = target->Search(searchTerm.c_str(), -4, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
std::cout << "\n";
+ listkey.sort();
while (!listkey.Error()) {
std::cout << (const char *)listkey << std::endl;
listkey++;
Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h 2006-04-25 06:01:30 UTC (rev 1908)
+++ trunk/include/swmodule.h 2006-04-25 07:18:34 UTC (rev 1909)
@@ -99,7 +99,7 @@
/** the current key */
SWKey *key;
- ListKey listkey;
+ ListKey listKey;
char *modname;
char *moddesc;
char *modtype;
@@ -355,7 +355,7 @@
* @param percent Callback function to get the current search status in %.
* @param percentUserData User data that is given to the callback function as parameter.
*
- * @return listkey set to verses that contain istr
+ * @return ListKey set to verses that contain istr
*/
virtual ListKey &search(const char *istr, int searchType = 0, int flags = 0,
SWKey * scope = 0,
Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp 2006-04-25 06:01:30 UTC (rev 1908)
+++ trunk/src/keys/versekey.cpp 2006-04-25 07:18:34 UTC (rev 1909)
@@ -1458,7 +1458,12 @@
int VerseKey::compare(const SWKey &ikey)
{
- VerseKey ivkey = (const char *)ikey;
+ const SWKey *testKey = &ikey;
+ const VerseKey *vkey = (const VerseKey *)SWDYNAMIC_CAST(VerseKey, testKey);
+ if (vkey) {
+ return _compare(*vkey);
+ }
+ const VerseKey ivkey = (const char *)ikey;
return _compare(ivkey);
}
Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp 2006-04-25 06:01:30 UTC (rev 1908)
+++ trunk/src/modules/swmodule.cpp 2006-04-25 07:18:34 UTC (rev 1909)
@@ -395,12 +395,12 @@
* justCheckIfSupported - if set, don't search, only tell if this
* function supports requested search.
*
- * RET: listkey set to verses that contain istr
+ * RET: ListKey set to verses that contain istr
*/
ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *scope, bool *justCheckIfSupported, void (*percent)(char, void *), void *percentUserData) {
- listkey.ClearList();
+ listKey.ClearList();
#ifdef USELUCENE
SWBuf target = getConfigEntry("AbsoluteDataPath");
@@ -416,13 +416,13 @@
*justCheckIfSupported = true;
}
#endif
- return listkey;
+ return listKey;
}
- SWKey *savekey = 0;
- SWKey *searchkey = 0;
+ SWKey *saveKey = 0;
+ SWKey *searchKey = 0;
+ SWKey *resultKey = CreateKey();
regex_t preg;
- SWKey textkey;
char **words = 0;
char *wordBuf = 0;
int wordCount = 0;
@@ -435,15 +435,15 @@
if (!key->Persist()) {
- savekey = CreateKey();
- *savekey = *key;
+ saveKey = CreateKey();
+ *saveKey = *key;
}
- else savekey = key;
+ else saveKey = key;
- searchkey = (scope)?scope->clone():(key->Persist())?key->clone():0;
- if (searchkey) {
- searchkey->Persist(1);
- setKey(*searchkey);
+ searchKey = (scope)?scope->clone():(key->Persist())?key->clone():0;
+ if (searchKey) {
+ searchKey->Persist(1);
+ setKey(*searchKey);
}
(*percent)(perc, percentUserData);
@@ -482,21 +482,26 @@
// Make sure our scope for this search is bounded by
// something we can test
// In the future, add bool SWKey::isValid(const char *tryString);
- VerseKey vk;
bool freeTestKey = false;
+
+ // only enforce range if we're VerseKey decendant
+ bool enforceRange = SWDYNAMIC_CAST(VerseKey, resultKey);
+
SWKey *testKey = 0;
- SWTRY {
- testKey = SWDYNAMIC_CAST(VerseKey, ((scope)?scope:key));
+ if (enforceRange) {
+ SWTRY {
+ testKey = SWDYNAMIC_CAST(VerseKey, ((scope)?scope:key));
+ if (!testKey) {
+ testKey = SWDYNAMIC_CAST(ListKey, ((scope)?scope:key));
+ }
+ }
+ SWCATCH ( ... ) {}
if (!testKey) {
- testKey = SWDYNAMIC_CAST(ListKey, ((scope)?scope:key));
+ testKey = new ListKey();
+ *testKey = ((VerseKey *)resultKey)->ParseVerseList((const char *)((scope)?scope:key), *resultKey, true);
+ freeTestKey = true;
}
}
- SWCATCH ( ... ) {}
- if (!testKey) {
- testKey = new ListKey();
- *testKey = vk.ParseVerseList((const char *)((scope)?scope:key), vk, true);
- freeTestKey = true;
- }
lucene::index::IndexReader *ir;
lucene::search::IndexSearcher *is;
ir = IndexReader::open(target);
@@ -517,17 +522,22 @@
// set a temporary verse key to this module position
lucene_wcstoutf8(utfBuffer, doc.get(_T("key")), MAX_CONV_SIZE);
- vk = utfBuffer; //TODO Does vk always accept utf8?
+ *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 scope
- // Try to set our scope key to this verse key
- *testKey = vk;
-
- // check to see if it set ok and if so, add to our return list
- if (*testKey == vk) {
- listkey << (const char *) vk;
- listkey.GetElement()->userData = (void *)((__u32)(h->score(i)*100));
+ // 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);
@@ -617,8 +627,8 @@
}
if (searchType >= 0) {
if (!regexec(&preg, StripText(), 0, 0, 0)) {
- textkey = KeyText();
- listkey << textkey;
+ *resultKey = *getKey();
+ listKey << *resultKey;
}
}
@@ -626,8 +636,8 @@
else if (searchType == -1) {
sres = ((flags & REG_ICASE) == REG_ICASE) ? stristr(StripText(), istr) : strstr(StripText(), istr);
if (sres) { //it's also in the StripText(), so we have a valid search result item now
- textkey = KeyText();
- listkey << textkey;
+ *resultKey = *getKey();
+ listKey << *resultKey;
}
}
@@ -652,8 +662,8 @@
} while ( (loopCount < 2) && (foundWords == wordCount));
if ((loopCount == 2) && (foundWords == wordCount)) { //we found the right words in both raw and stripped text, which means it's a valid result item
- textkey = KeyText();
- listkey << textkey;
+ *resultKey = *getKey();
+ listKey << *resultKey;
}
}
@@ -707,8 +717,8 @@
sres = ((flags & REG_ICASE) == REG_ICASE) ? stristr(i3Start->second.c_str(), words[3]) : strstr(i3Start->second.c_str(), words[3]);
}
if (sres) {
- textkey = KeyText();
- listkey << textkey;
+ *resultKey = *getKey();
+ listKey << *resultKey;
break;
}
}
@@ -730,19 +740,23 @@
free(wordBuf);
}
- setKey(*savekey);
+ setKey(*saveKey);
- if (!savekey->Persist())
- delete savekey;
+ if (!saveKey->Persist())
+ delete saveKey;
- if (searchkey)
- delete searchkey;
+ if (searchKey)
+ delete searchKey;
+ delete resultKey;
- listkey = TOP;
+ listKey = TOP;
processEntryAttributes(savePEA);
+
+
(*percent)(100, percentUserData);
- return listkey;
+
+ return listKey;
}
@@ -765,7 +779,7 @@
*
* ENT: buf - buffer to Render instead of current module position
*
- * RET: listkey set to verses that contain istr
+ * RET: this module's text at specified key location massaged by RenderText filters
*/
const char *SWModule::RenderText(const char *buf, int len, bool render) {
@@ -810,23 +824,23 @@
*/
const char *SWModule::RenderText(SWKey *tmpKey) {
- SWKey *savekey;
+ SWKey *saveKey;
const char *retVal;
if (!key->Persist()) {
- savekey = CreateKey();
- *savekey = *key;
+ saveKey = CreateKey();
+ *saveKey = *key;
}
- else savekey = key;
+ else saveKey = key;
setKey(*tmpKey);
retVal = RenderText();
- setKey(*savekey);
+ setKey(*saveKey);
- if (!savekey->Persist())
- delete savekey;
+ if (!saveKey->Persist())
+ delete saveKey;
return retVal;
}
@@ -841,23 +855,23 @@
*/
const char *SWModule::StripText(SWKey *tmpKey) {
- SWKey *savekey;
+ SWKey *saveKey;
const char *retVal;
if (!key->Persist()) {
- savekey = CreateKey();
- *savekey = *key;
+ saveKey = CreateKey();
+ *saveKey = *key;
}
- else savekey = key;
+ else saveKey = key;
setKey(*tmpKey);
retVal = StripText();
- setKey(*savekey);
+ setKey(*saveKey);
- if (!savekey->Persist())
- delete savekey;
+ if (!saveKey->Persist())
+ delete saveKey;
return retVal;
}
@@ -899,8 +913,8 @@
signed char SWModule::createSearchFramework(void (*percent)(char, void *), void *percentUserData) {
#ifdef USELUCENE
- SWKey *savekey = 0;
- SWKey *searchkey = 0;
+ SWKey *saveKey = 0;
+ SWKey *searchKey = 0;
SWKey textkey;
char *word = 0;
char *wordBuf = 0;
@@ -924,15 +938,15 @@
// save key information so as not to disrupt original
// module position
if (!key->Persist()) {
- savekey = CreateKey();
- *savekey = *key;
+ saveKey = CreateKey();
+ *saveKey = *key;
}
- else savekey = key;
+ else saveKey = key;
- searchkey = (key->Persist())?key->clone():0;
- if (searchkey) {
- searchkey->Persist(1);
- setKey(*searchkey);
+ searchKey = (key->Persist())?key->clone():0;
+ if (searchKey) {
+ searchKey->Persist(1);
+ setKey(*searchKey);
}
IndexWriter *writer = NULL;
@@ -1054,8 +1068,8 @@
//printf("setting fields (%s).\ncontent: %s\nlemma: %s\n", (const char *)*key, content, strong.c_str());
}
- printf("setting fields (%s).\n", (const char *)*key);
- fflush(stdout);
+//printf("setting fields (%s).\n", (const char *)*key);
+//fflush(stdout);
}
// don't write yet, cuz we have to see if we're the first of a prox block (5:1 or chapter5/verse1
@@ -1068,7 +1082,7 @@
VerseKey saveKey = *vkcheck;
while ((!err) && (*vkcheck <= chapMax)) {
//printf("building proxBuf from (%s).\nproxBuf.c_str(): %s\n", (const char *)*key, proxBuf.c_str());
-printf("building proxBuf from (%s).\n", (const char *)*key);
+//printf("building proxBuf from (%s).\n", (const char *)*key);
// build "strong" field
strong = "";
@@ -1112,8 +1126,8 @@
if (!tkcheck->hasChildren()) {
if (!tkcheck->previousSibling()) {
do {
-printf("building proxBuf from (%s).\n", (const char *)*key);
-fflush(stdout);
+//printf("building proxBuf from (%s).\n", (const char *)*key);
+//fflush(stdout);
// build "strong" field
strong = "";
@@ -1154,12 +1168,12 @@
}
if (proxBuf.length() > 0) {
- printf("proxBuf before (%s).\n%s\n", (const char *)*key, proxBuf.c_str());
+//printf("proxBuf before (%s).\n%s\n", (const char *)*key, proxBuf.c_str());
proxBuf = StripText(proxBuf);
lucene_utf8towcs(wcharBuffer, proxBuf, MAX_CONV_SIZE); //keyText must be utf8
- printf("proxBuf after (%s).\n%s\n", (const char *)*key, proxBuf.c_str());
+//printf("proxBuf after (%s).\n%s\n", (const char *)*key, proxBuf.c_str());
doc->add( *Field::UnStored(_T("prox"), wcharBuffer) );
@@ -1171,8 +1185,8 @@
good = true;
}
if (good) {
-printf("writing (%s).\n", (const char *)*key);
-fflush(stdout);
+//printf("writing (%s).\n", (const char *)*key);
+//fflush(stdout);
writer->addDocument(doc);
}
delete doc;
@@ -1187,13 +1201,13 @@
delete an;
// reposition module back to where it was before we were called
- setKey(*savekey);
+ setKey(*saveKey);
- if (!savekey->Persist())
- delete savekey;
+ if (!saveKey->Persist())
+ delete saveKey;
- if (searchkey)
- delete searchkey;
+ if (searchKey)
+ delete searchKey;
processEntryAttributes(savePEA);
More information about the sword-cvs
mailing list