[sword-svn] r2709 - trunk/src/modules

scribe at crosswire.org scribe at crosswire.org
Wed Jul 11 06:37:13 MST 2012


Author: scribe
Date: 2012-07-11 06:37:13 -0700 (Wed, 11 Jul 2012)
New Revision: 2709

Modified:
   trunk/src/modules/swmodule.cpp
Log:
added morph (lemma at morphology) field for searching


Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2012-07-10 23:09:41 UTC (rev 2708)
+++ trunk/src/modules/swmodule.cpp	2012-07-11 13:37:13 UTC (rev 2709)
@@ -1088,7 +1088,9 @@
 
 	SWBuf proxBuf;
 	SWBuf proxLem;
+	SWBuf proxMorph;
 	SWBuf strong;
+	SWBuf morph;
 
 	char err = Error();
 	while (!err) {
@@ -1096,6 +1098,7 @@
 
 		proxBuf = "";
 		proxLem = "";
+		proxMorph = "";
 
 		// computer percent complete so we can report to our progress callback
 		float per = (float)mindex / highIndex;
@@ -1124,8 +1127,10 @@
 			AttributeTypeList::iterator words;
 			AttributeList::iterator word;
 			AttributeValue::iterator strongVal;
+			AttributeValue::iterator morphVal;
 
 			strong="";
+			morph="";
 			words = getEntryAttributes().find("Word");
 			if (words != getEntryAttributes().end()) {
 				for (word = words->second.begin();word != words->second.end(); word++) {
@@ -1142,7 +1147,16 @@
 									continue;	// no text? let's skip
 							}
 							strong.append(strongVal->second);
+							morph.append(strongVal->second);
+							morph.append('@');
+							SWBuf tmp = "Morph";
+							if (partCount > 1) tmp.appendFormatted(".%d", i+1);
+							morphVal = word->second.find(tmp);
+							if (morphVal != word->second.end()) {
+								morph.append(morphVal->second);
+							}
 							strong.append(' ');
+							morph.append(' ');
 						}
 					}
 				}
@@ -1161,6 +1175,7 @@
 
 			if (strong.length() > 0) {
 				doc->add(*_CLNEW Field(_T("lemma"), (wchar_t *)utf8ToWChar(strong).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
+				doc->add(*_CLNEW Field(_T("morph"), (wchar_t *)utf8ToWChar(morph).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
 //printf("setting fields (%s).\ncontent: %s\nlemma: %s\n", (const char *)*key, content, strong.c_str());
 			}
 
@@ -1184,9 +1199,11 @@
 					if (content && *content) {
 						// build "strong" field
 						strong = "";
+						morph = "";
 						AttributeTypeList::iterator words;
 						AttributeList::iterator word;
 						AttributeValue::iterator strongVal;
+						AttributeValue::iterator morphVal;
 
 						words = getEntryAttributes().find("Word");
 						if (words != getEntryAttributes().end()) {
@@ -1204,7 +1221,16 @@
 												continue;	// no text? let's skip
 										}
 										strong.append(strongVal->second);
+										morph.append(strongVal->second);
+										morph.append('@');
+										SWBuf tmp = "Morph";
+										if (partCount > 1) tmp.appendFormatted(".%d", i+1);
+										morphVal = word->second.find(tmp);
+										if (morphVal != word->second.end()) {
+											morph.append(morphVal->second);
+										}
 										strong.append(' ');
+										morph.append(' ');
 									}
 								}
 							}
@@ -1212,8 +1238,11 @@
 						proxBuf += content;
 						proxBuf.append(' ');
 						proxLem += strong;
-						if (proxLem.length())
+						proxMorph += morph;
+						if (proxLem.length()) {
 							proxLem.append("\n");
+							proxMorph.append("\n");
+						}
 					}
 					(*this)++;
 					err = Error();
@@ -1235,9 +1264,11 @@
 						if (content && *content) {
 							// build "strong" field
 							strong = "";
+							morph = "";
 							AttributeTypeList::iterator words;
 							AttributeList::iterator word;
 							AttributeValue::iterator strongVal;
+							AttributeValue::iterator morphVal;
 
 							words = getEntryAttributes().find("Word");
 							if (words != getEntryAttributes().end()) {
@@ -1255,7 +1286,16 @@
 													continue;	// no text? let's skip
 											}
 											strong.append(strongVal->second);
+											morph.append(strongVal->second);
+											morph.append('@');
+											SWBuf tmp = "Morph";
+											if (partCount > 1) tmp.appendFormatted(".%d", i+1);
+											morphVal = word->second.find(tmp);
+											if (morphVal != word->second.end()) {
+												morph.append(morphVal->second);
+											}
 											strong.append(' ');
+											morph.append(' ');
 										}
 									}
 								}
@@ -1264,8 +1304,11 @@
 							proxBuf += content;
 							proxBuf.append(' ');
 							proxLem += strong;
-							if (proxLem.length())
+							proxMorph += morph;
+							if (proxLem.length()) {
 								proxLem.append("\n");
+								proxMorph.append("\n");
+							}
 						}
 					} while (tkcheck->nextSibling());
 					tkcheck->parent();
@@ -1282,6 +1325,7 @@
 		}
 		if (proxLem.length() > 0) {
 			doc->add(*_CLNEW Field(_T("proxlem"), (wchar_t *)utf8ToWChar(proxLem).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED) );
+			doc->add(*_CLNEW Field(_T("proxmorph"), (wchar_t *)utf8ToWChar(proxMorph).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED) );
 			good = true;
 		}
 		if (good) {




More information about the sword-cvs mailing list