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

scribe at www.crosswire.org scribe at www.crosswire.org
Sat Dec 2 12:35:41 MST 2006


Author: scribe
Date: 2006-12-02 12:35:39 -0700 (Sat, 02 Dec 2006)
New Revision: 2018

Added:
   trunk/examples/cmdline/listoptions.cpp
Modified:
   trunk/ChangeLog
   trunk/examples/cmdline/Makefile.am
   trunk/examples/cmdline/search.cpp
   trunk/src/modules/filters/osismorphsegmentation.cpp
Log:
	Added example: examples/cmdline/listoptions.cpp
	Added entryAttributes processing for morph segs



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-11-30 15:29:15 UTC (rev 2017)
+++ trunk/ChangeLog	2006-12-02 19:35:39 UTC (rev 2018)
@@ -1,6 +1,10 @@
 API ChangeLog	(see the ChangeLog in each 'apps' directory for
 		app specific changes)
 
+2-Dec-2006	Troy A. Griffitts <scribe at crosswire.org>
+	Added example: examples/cmdline/listoptions.cpp
+	Added entryAttributes processing for morph segs
+
 23-Nov-2006	Daniel Glassey <dglassey at crosswire.org>
 	Use acx_clucene.m4 from CLucene contribs to detect CLucene
 	apply Debian patch for flatapi for 64-bit portability

Modified: trunk/examples/cmdline/Makefile.am
===================================================================
--- trunk/examples/cmdline/Makefile.am	2006-11-30 15:29:15 UTC (rev 2017)
+++ trunk/examples/cmdline/Makefile.am	2006-12-02 19:35:39 UTC (rev 2018)
@@ -2,9 +2,10 @@
 INCLUDES = -I $(top_srcdir)/include
 LDADD = $(top_builddir)/lib/libsword.la
 
-noinst_PROGRAMS = lookup search threaded_search
+noinst_PROGRAMS = lookup search threaded_search listoptions
 
 lookup_SOURCES = lookup.cpp
 search_SOURCES = search.cpp
+listoptions_SOURCES = listoptions.cpp
 threaded_search_SOURCES = threaded_search.cpp
 threaded_search_LDADD = $(LDADD) -lpthread

Added: trunk/examples/cmdline/listoptions.cpp
===================================================================
--- trunk/examples/cmdline/listoptions.cpp	                        (rev 0)
+++ trunk/examples/cmdline/listoptions.cpp	2006-12-02 19:35:39 UTC (rev 2018)
@@ -0,0 +1,21 @@
+#include <iostream>
+#include <swmgr.h>
+
+using sword::SWMgr;
+using sword::StringList;
+using std::cout;
+
+int main(int argc, char **argv)
+{
+	SWMgr library;
+
+	StringList options = library.getGlobalOptions();
+	for (StringList::const_iterator it = options.begin(); it != options.end(); it++) {
+		cout << *it << " (" << library.getGlobalOptionTip(*it) << ")\n";
+		StringList optionValues = library.getGlobalOptionValues(*it);
+		for (StringList::const_iterator it2 = optionValues.begin(); it2 != optionValues.end(); it2++) {
+			cout << "\t" << *it2 << "\n";
+		}
+	}
+	return 0;
+}

Modified: trunk/examples/cmdline/search.cpp
===================================================================
--- trunk/examples/cmdline/search.cpp	2006-11-30 15:29:15 UTC (rev 2017)
+++ trunk/examples/cmdline/search.cpp	2006-12-02 19:35:39 UTC (rev 2018)
@@ -72,10 +72,10 @@
 	 *			>=0 - regex
 	 *			-1  - phrase
 	 *			-2  - multiword
-	 *			-3  - entryAttrib (eg. Word//Strongs/G1234/)
+	 *			-3  - entryAttrib (eg. Word//Lemma/G1234/)
 	 *			-4  - Lucene
    */
-	listkey = target->Search(searchTerm.c_str(), -4, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
+	listkey = target->Search(searchTerm.c_str(), -3, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
 	std::cout << "\n";
 	listkey.sort();
 	while (!listkey.Error()) {

Modified: trunk/src/modules/filters/osismorphsegmentation.cpp
===================================================================
--- trunk/src/modules/filters/osismorphsegmentation.cpp	2006-11-30 15:29:15 UTC (rev 2017)
+++ trunk/src/modules/filters/osismorphsegmentation.cpp	2006-12-02 19:35:39 UTC (rev 2018)
@@ -8,6 +8,8 @@
 #include <osismorphsegmentation.h>
 #include <stdlib.h>
 #include <utilxml.h>
+#include <swmodule.h>
+#include <swbuf.h>
 
 SWORD_NAMESPACE_START
 
@@ -17,7 +19,7 @@
 const SWBuf choices[3] = {"Off", "On", ""};
 const StringList oValues(&choices[0], &choices[2]);
 
-OSISMorphSegmentation::OSISMorphSegmentation() : sword::SWOptionFilter(oName, oTip, &oValues) {
+OSISMorphSegmentation::OSISMorphSegmentation() : SWOptionFilter(oName, oTip, &oValues) {
 	setOptionValue("Off");
 }
 
@@ -25,7 +27,7 @@
 OSISMorphSegmentation::~OSISMorphSegmentation() {}
 
 
-char OSISMorphSegmentation::processText(SWBuf &text, const SWKey * /*key*/, const SWModule * /*module*/) {
+char OSISMorphSegmentation::processText(SWBuf &text, const SWKey * /*key*/, const SWModule *module) {
 	SWBuf token;
 	bool intoken    = false;
 	bool hide       = false;
@@ -34,6 +36,10 @@
 	const char *from = orig.c_str();
 
 	XMLTag tag;
+	SWBuf tagText = "";
+	unsigned int morphemeNum = 0;
+	bool inMorpheme = false;
+	SWBuf buf;
 
 	for (text = ""; *from; ++from) {
 		if (*from == '<') {
@@ -50,8 +56,15 @@
 
 				if (!tag.isEndTag() && tag.getAttribute("type") && !strcmp("morph", tag.getAttribute("type"))) {  //<seg type="morph"> start tag
 					hide = !option; //only hide if option is Off
+					tagText = "";
+					inMorpheme = true;
 				}
 
+				if (tag.isEndTag()) {
+						buf.setFormatted("%.3d", morphemeNum++);
+						module->getEntryAttributes()["Morpheme"][buf]["body"] = tagText;
+						inMorpheme = false;
+				}
 				if (hide) { //hides start and end tags as long as hide is set
 
 					if (tag.isEndTag()) { //</seg>
@@ -63,11 +76,15 @@
 			} //end of seg tag handling
 
 			text.append('<');
-
 			text.append(token);
-
 			text.append('>');
 
+			if (inMorpheme) {
+				tagText.append('<');
+				tagText.append(token);
+				tagText.append('>');
+			}
+
 			hide = false;
 
 			continue;
@@ -78,9 +95,11 @@
 		}
 		else { //copy text which is not inside of a tag
 			text.append(*from);
+			if (inMorpheme) {
+				tagText.append(*from);
+			}
 		}
 	}
-
 	return 0;
 }
 




More information about the sword-cvs mailing list