From 8bde98b763b611c24338ef1461c4293c02971f8a Mon Sep 17 00:00:00 2001 From: dockes Date: Tue, 9 May 2006 10:15:14 +0000 Subject: [PATCH] perform stem expansion using all active dbs --- src/rcldb/rcldb.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/rcldb/rcldb.cpp b/src/rcldb/rcldb.cpp index 505f996a..2f4f83d8 100644 --- a/src/rcldb/rcldb.cpp +++ b/src/rcldb/rcldb.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.74 2006-04-30 07:44:20 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.75 2006-05-09 10:15:14 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -125,6 +125,27 @@ class Native { return true; return false; } + + /// Perform stem expansion across all dbs configured for searching + list stemExpand(const string& lang, + const string& term) + { + list dirs = m_extraDbs; + dirs.push_front(m_basedir); + list exp; + for (list::iterator it = dirs.begin(); + it != dirs.end(); it++) { + list more = StemDb::stemExpand(*it, lang, term); + LOGDEB1(("Native::stemExpand: Got %d from %s\n", + more.size(), it->c_str())); + exp.splice(exp.end(), more); + } + exp.sort(); + exp.unique(); + LOGDEB1(("Native::stemExpand: final count %d \n", exp.size())); + return exp; + } + }; Db::Db() @@ -854,7 +875,7 @@ static void stringToXapianQueries(const string &iq, dumb_string(term, term1); // Possibly perform stem compression/expansion if (!nostemexp && (opts & Db::QO_STEM)) { - exp = StemDb::stemExpand(m_ndb->m_basedir, stemlang,term1); + exp = m_ndb->stemExpand(stemlang,term1); } else { exp.push_back(term1); } @@ -1064,8 +1085,7 @@ list Db::completions(const string &root, const string &lang, int max) res.push_back(*it); ++n; } else { - list stemexps = - StemDb::stemExpand(m_ndb->m_basedir, lang, *it); + list stemexps = m_ndb->stemExpand(lang, *it); unsigned int cnt = (int)stemexps.size() > max - n ? max - n : stemexps.size(); list::iterator sit = stemexps.begin();