|
a/src/rcldb/stemdb.cpp |
|
b/src/rcldb/stemdb.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: stemdb.cpp,v 1.9 2007-05-24 09:35:02 dockes Exp $ (C) 2005 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: stemdb.cpp,v 1.10 2007-08-01 10:04:53 dockes Exp $ (C) 2005 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
|
4 |
|
5 |
/**
|
5 |
/**
|
6 |
* Management of the auxiliary databases listing stems and their expansion
|
6 |
* Management of the auxiliary databases listing stems and their expansion
|
7 |
* terms
|
7 |
* terms
|
|
... |
|
... |
216 |
s.erase(s.length()-1);
|
216 |
s.erase(s.length()-1);
|
217 |
return s;
|
217 |
return s;
|
218 |
}
|
218 |
}
|
219 |
|
219 |
|
220 |
/**
|
220 |
/**
|
221 |
* Expand term to list of all terms which stem to the same term.
|
221 |
* Expand term to list of all terms which stem to the same term, for one
|
|
|
222 |
* expansion language
|
222 |
*/
|
223 |
*/
|
223 |
bool stemExpand(const std::string& dbdir,
|
224 |
static bool stemExpandOne(const std::string& dbdir,
|
224 |
const std::string& lang,
|
225 |
const std::string& lang,
|
225 |
const std::string& term,
|
226 |
const std::string& term,
|
226 |
list<string>& result)
|
227 |
list<string>& result)
|
227 |
{
|
228 |
{
|
228 |
try {
|
229 |
try {
|
229 |
Xapian::Stem stemmer(lang);
|
230 |
Xapian::Stem stemmer(lang);
|
230 |
string stem = stemmer(term);
|
231 |
string stem = stemmer(term);
|
231 |
LOGDEB(("stemExpand: [%s] stem-> [%s]\n", term.c_str(), stem.c_str()));
|
232 |
LOGDEB(("stemExpand: [%s] stem-> [%s]\n", term.c_str(), stem.c_str()));
|
|
... |
|
... |
279 |
return false;
|
280 |
return false;
|
280 |
}
|
281 |
}
|
281 |
|
282 |
|
282 |
return true;
|
283 |
return true;
|
283 |
}
|
284 |
}
|
|
|
285 |
|
|
|
286 |
/**
|
|
|
287 |
* Expand term to list of all terms which stem to the same term, add the
|
|
|
288 |
* expansion sets for possibly multiple expansion languages
|
|
|
289 |
*/
|
|
|
290 |
bool stemExpand(const std::string& dbdir,
|
|
|
291 |
const std::string& langs,
|
|
|
292 |
const std::string& term,
|
|
|
293 |
list<string>& result)
|
|
|
294 |
{
|
284 |
|
295 |
|
|
|
296 |
list<string> llangs;
|
|
|
297 |
stringToStrings(langs, llangs);
|
|
|
298 |
for (list<string>::const_iterator it = llangs.begin();
|
|
|
299 |
it != llangs.end(); it++) {
|
|
|
300 |
list<string> oneexp;
|
|
|
301 |
stemExpandOne(dbdir, *it, term, oneexp);
|
|
|
302 |
result.insert(result.end(), oneexp.begin(), oneexp.end());
|
|
|
303 |
}
|
|
|
304 |
result.sort();
|
|
|
305 |
result.unique();
|
|
|
306 |
return true;
|
285 |
}
|
307 |
}
|
|
|
308 |
|
|
|
309 |
|
286 |
}
|
310 |
}
|
|
|
311 |
}
|