Stems with unique parent must be in db too so that one can search on stem (which is not a term)
This commit is contained in:
parent
3e2bccd259
commit
dff7753f7f
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: stemdb.cpp,v 1.2 2006-05-02 09:49:06 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: stemdb.cpp,v 1.3 2006-09-19 14:30:39 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,14 +168,10 @@ bool createDb(Xapian::Database& xdb, const string& dbdir, const string& lang)
|
|||||||
} else {
|
} else {
|
||||||
// Changing stems
|
// Changing stems
|
||||||
++stemdiff;
|
++stemdiff;
|
||||||
if (derivs.size() == 1) {
|
// We need an entry even if there is only one derivative
|
||||||
// Exactly one term stems to this. Check for the case where
|
// so that it is possible to search by entering the stem
|
||||||
// the stem itself exists as a term. The code above would not
|
// even if it doesnt exist as a term
|
||||||
// have inserted anything in this case.
|
if (derivs.size() >= 1) {
|
||||||
if (xdb.term_exists(stem))
|
|
||||||
derivs.push_back(stem);
|
|
||||||
}
|
|
||||||
if (derivs.size() > 1) {
|
|
||||||
// Previous stem has multiple derivatives. Enter in db
|
// Previous stem has multiple derivatives. Enter in db
|
||||||
++stemmultiple;
|
++stemmultiple;
|
||||||
Xapian::Document newdocument;
|
Xapian::Document newdocument;
|
||||||
@ -237,6 +233,8 @@ list<string> stemExpand(const string& dbdir, const string& lang,
|
|||||||
}
|
}
|
||||||
Xapian::Document doc = sdb.get_document(*did);
|
Xapian::Document doc = sdb.get_document(*did);
|
||||||
string data = doc.get_data();
|
string data = doc.get_data();
|
||||||
|
|
||||||
|
// Build expansion list from database data
|
||||||
// No need for a conftree, but we need to massage the data a little
|
// No need for a conftree, but we need to massage the data a little
|
||||||
string::size_type pos = data.find_first_of("=");
|
string::size_type pos = data.find_first_of("=");
|
||||||
++pos;
|
++pos;
|
||||||
@ -244,8 +242,10 @@ list<string> stemExpand(const string& dbdir, const string& lang,
|
|||||||
if (pos == string::npos || pos1 == string::npos ||pos1 <= pos) { // ??
|
if (pos == string::npos || pos1 == string::npos ||pos1 <= pos) { // ??
|
||||||
explist.push_back(term);
|
explist.push_back(term);
|
||||||
return explist;
|
return explist;
|
||||||
}
|
}
|
||||||
stringToStrings(data.substr(pos, pos1-pos), explist);
|
stringToStrings(data.substr(pos, pos1-pos), explist);
|
||||||
|
|
||||||
|
// If the user term itself is not in the list, add it.
|
||||||
if (find(explist.begin(), explist.end(), term) == explist.end()) {
|
if (find(explist.begin(), explist.end(), term) == explist.end()) {
|
||||||
explist.push_back(term);
|
explist.push_back(term);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user