stemdb: only need to expand the unac'd term if it differs from raw + comments and traces

This commit is contained in:
Jean-Francois Dockes 2012-11-26 09:13:57 +01:00
parent 499f28a166
commit 7115be2440
3 changed files with 19 additions and 15 deletions

View File

@ -666,8 +666,8 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
#else
if (o_index_stripchars) {
// If the index is raw, we can only come here if nostemexp is unset
// and we just need stem expansion.
// If the index is stripped, we can only come here if
// nostemexp is unset and we just need stem expansion.
db.termMatch(Rcl::Db::ET_STEM, getStemLang(), term, res,
maxexpand, m_field);
goto termmatchtoresult;

View File

@ -59,14 +59,16 @@ bool StemDb::stemExpand(const std::string& langs, const std::string& term,
#ifndef RCL_INDEX_STRIPCHARS
// Expand the unaccented stem
if (!o_index_stripchars) {
for (vector<string>::const_iterator it = llangs.begin();
it != llangs.end(); it++) {
SynTermTransStem stemmer(*it);
XapComputableSynFamMember expander(getdb(), synFamStemUnac,
*it, &stemmer);
string unac;
unacmaybefold(term, unac, "UTF-8", UNACOP_UNAC);
(void)expander.synExpand(unac, result);
string unac;
unacmaybefold(term, unac, "UTF-8", UNACOP_UNAC);
if (term != unac) {
for (vector<string>::const_iterator it = llangs.begin();
it != llangs.end(); it++) {
SynTermTransStem stemmer(*it);
XapComputableSynFamMember expander(getdb(), synFamStemUnac,
*it, &stemmer);
(void)expander.synExpand(unac, result);
}
}
}
#endif
@ -77,7 +79,7 @@ bool StemDb::stemExpand(const std::string& langs, const std::string& term,
sort(result.begin(), result.end());
vector<string>::iterator uit = unique(result.begin(), result.end());
result.resize(uit - result.begin());
LOGDEB0(("stemExpand:%s: %s -> %s\n", langs.c_str(), term.c_str(),
LOGDEB1(("stemExpand:%s: %s -> %s\n", langs.c_str(), term.c_str(),
stringsToString(result).c_str()));
return true;
}

View File

@ -18,12 +18,13 @@
#include "autoconfig.h"
#include <iostream>
#include <algorithm>
#include "debuglog.h"
#include "xmacros.h"
#include "synfamily.h"
#include <iostream>
#include <algorithm>
#include "smallut.h"
using namespace std;
@ -175,7 +176,8 @@ bool XapComputableSynFamMember::synExpand(const string& term,
result.push_back(root);
}
}
LOGDEB(("XapCompSynFamMbr::synExpand([%s]): term [%s] -> [%s]\n",
m_prefix.c_str(), term.c_str(), stringsToString(result).c_str()));
return true;
}