cosmetics: list -> vector in more places
This commit is contained in:
+15
-15
@@ -217,8 +217,8 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
|
||||
doc.xdocid = docid;
|
||||
|
||||
// Other, not predefined meta fields:
|
||||
list<string> keys = parms.getNames(string());
|
||||
for (list<string>::const_iterator it = keys.begin();
|
||||
vector<string> keys = parms.getNames(string());
|
||||
for (vector<string>::const_iterator it = keys.begin();
|
||||
it != keys.end(); it++) {
|
||||
if (doc.meta.find(*it) == doc.meta.end())
|
||||
parms.get(*it, doc.meta[*it]);
|
||||
@@ -228,9 +228,9 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
|
||||
}
|
||||
|
||||
// Remove prefixes (caps) from a list of terms.
|
||||
static void noPrefixList(const list<string>& in, list<string>& out)
|
||||
static void noPrefixList(const vector<string>& in, vector<string>& out)
|
||||
{
|
||||
for (list<string>::const_iterator qit = in.begin();
|
||||
for (vector<string>::const_iterator qit = in.begin();
|
||||
qit != in.end(); qit++) {
|
||||
if ('A' <= qit->at(0) && qit->at(0) <= 'Z') {
|
||||
string term = *qit;
|
||||
@@ -252,10 +252,10 @@ static void noPrefixList(const list<string>& in, list<string>& out)
|
||||
#define LOGABS LOGDEB2
|
||||
#endif
|
||||
#if 0
|
||||
static void listList(const string& what, const list<string>&l)
|
||||
static void listList(const string& what, const vector<string>&l)
|
||||
{
|
||||
string a;
|
||||
for (list<string>::const_iterator it = l.begin(); it != l.end(); it++) {
|
||||
for (vector<string>::const_iterator it = l.begin(); it != l.end(); it++) {
|
||||
a = a + *it + " ";
|
||||
}
|
||||
LOGDEB(("%s: %s\n", what.c_str(), a.c_str()));
|
||||
@@ -273,10 +273,10 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||
LOGDEB2(("makeAbstract:%d: maxlen %d wWidth %d\n", chron.ms(),
|
||||
m_rcldb->m_synthAbsLen, m_rcldb->m_synthAbsWordCtxLen));
|
||||
|
||||
list<string> terms;
|
||||
vector<string> terms;
|
||||
|
||||
{
|
||||
list<string> iterms;
|
||||
vector<string> iterms;
|
||||
query->getMatchTerms(docid, iterms);
|
||||
noPrefixList(iterms, terms);
|
||||
if (terms.empty()) {
|
||||
@@ -289,13 +289,13 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||
// Retrieve db-wide frequencies for the query terms (we do this once per
|
||||
// query, using all the query terms, not only the document match terms)
|
||||
if (query->m_nq->termfreqs.empty()) {
|
||||
list<string> iqterms, qterms;
|
||||
vector<string> iqterms, qterms;
|
||||
query->getQueryTerms(iqterms);
|
||||
noPrefixList(iqterms, qterms);
|
||||
// listList("Query terms: ", qterms);
|
||||
double doccnt = xrdb.get_doccount();
|
||||
if (doccnt == 0) doccnt = 1;
|
||||
for (list<string>::const_iterator qit = qterms.begin();
|
||||
for (vector<string>::const_iterator qit = qterms.begin();
|
||||
qit != qterms.end(); qit++) {
|
||||
query->m_nq->termfreqs[*qit] = xrdb.get_termfreq(*qit) / doccnt;
|
||||
LOGABS(("makeAbstract: [%s] db freq %.1e\n", qit->c_str(),
|
||||
@@ -312,7 +312,7 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||
double totalweight = 0;
|
||||
double doclen = xrdb.get_doclength(docid);
|
||||
if (doclen == 0) doclen = 1;
|
||||
for (list<string>::const_iterator qit = terms.begin();
|
||||
for (vector<string>::const_iterator qit = terms.begin();
|
||||
qit != terms.end(); qit++) {
|
||||
Xapian::TermIterator term = xrdb.termlist_begin(docid);
|
||||
term.skip_to(*qit);
|
||||
@@ -338,7 +338,7 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
|
||||
|
||||
// Build a sorted by quality term list.
|
||||
multimap<double, string> byQ;
|
||||
for (list<string>::const_iterator qit = terms.begin();
|
||||
for (vector<string>::const_iterator qit = terms.begin();
|
||||
qit != terms.end(); qit++) {
|
||||
if (termQcoefs.find(*qit) != termQcoefs.end())
|
||||
byQ.insert(pair<double,string>(termQcoefs[*qit], *qit));
|
||||
@@ -1481,10 +1481,10 @@ bool Db::needUpdate(const string &udi, const string& sig)
|
||||
|
||||
|
||||
// Return list of existing stem db languages
|
||||
list<string> Db::getStemLangs()
|
||||
vector<string> Db::getStemLangs()
|
||||
{
|
||||
LOGDEB(("Db::getStemLang\n"));
|
||||
list<string> dirs;
|
||||
vector<string> dirs;
|
||||
if (m_ndb == 0 || m_ndb->m_isopen == false)
|
||||
return dirs;
|
||||
dirs = StemDb::getLangs(m_basedir);
|
||||
@@ -1724,7 +1724,7 @@ bool Db::stemExpand(const string &lang, const string &term,
|
||||
list<string> dirs = m_extraDbs;
|
||||
dirs.push_front(m_basedir);
|
||||
for (list<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
|
||||
list<string> more;
|
||||
vector<string> more;
|
||||
StemDb::stemExpand(*it, lang, term, more);
|
||||
LOGDEB1(("Db::stemExpand: Got %d from %s\n",
|
||||
more.size(), it->c_str()));
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ class Db {
|
||||
}
|
||||
|
||||
/** List existing stemming databases */
|
||||
std::list<std::string> getStemLangs();
|
||||
std::vector<std::string> getStemLangs();
|
||||
|
||||
#ifdef TESTING_XAPIAN_SPELL
|
||||
/** Return spelling suggestion */
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "xapian.h"
|
||||
@@ -240,7 +239,7 @@ bool Query::setQuery(RefCntr<SearchData> sdata)
|
||||
}
|
||||
|
||||
|
||||
bool Query::getQueryTerms(list<string>& terms)
|
||||
bool Query::getQueryTerms(vector<string>& terms)
|
||||
{
|
||||
if (ISNULL(m_nq))
|
||||
return false;
|
||||
@@ -261,11 +260,11 @@ bool Query::getQueryTerms(list<string>& terms)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Query::getMatchTerms(const Doc& doc, list<string>& terms)
|
||||
bool Query::getMatchTerms(const Doc& doc, vector<string>& terms)
|
||||
{
|
||||
return getMatchTerms(doc.xdocid, terms);
|
||||
}
|
||||
bool Query::getMatchTerms(unsigned long xdocid, list<string>& terms)
|
||||
bool Query::getMatchTerms(unsigned long xdocid, vector<string>& terms)
|
||||
{
|
||||
if (ISNULL(m_nq) || !m_nq->xenquire) {
|
||||
LOGERR(("Query::getMatchTerms: no query opened\n"));
|
||||
@@ -421,10 +420,10 @@ bool Query::getDoc(int xapi, Doc &doc)
|
||||
return m_db->m_ndb->dbDataToRclDoc(docid, data, doc);
|
||||
}
|
||||
|
||||
list<string> Query::expand(const Doc &doc)
|
||||
vector<string> Query::expand(const Doc &doc)
|
||||
{
|
||||
LOGDEB(("Rcl::Query::expand()\n"));
|
||||
list<string> res;
|
||||
vector<string> res;
|
||||
if (ISNULL(m_nq) || !m_nq->xenquire) {
|
||||
LOGERR(("Query::expand: no query opened\n"));
|
||||
return res;
|
||||
|
||||
@@ -17,12 +17,10 @@
|
||||
#ifndef _rclquery_h_included_
|
||||
#define _rclquery_h_included_
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::string;
|
||||
using std::list;
|
||||
using std::vector;
|
||||
#endif
|
||||
|
||||
@@ -72,14 +70,14 @@ class Query {
|
||||
bool getDoc(int i, Doc &doc);
|
||||
|
||||
/** Get possibly expanded list of query terms */
|
||||
bool getQueryTerms(list<string>& terms);
|
||||
bool getQueryTerms(vector<string>& terms);
|
||||
|
||||
/** Return a list of terms which matched for a specific result document */
|
||||
bool getMatchTerms(const Doc& doc, list<string>& terms);
|
||||
bool getMatchTerms(unsigned long xdocid, list<string>& terms);
|
||||
bool getMatchTerms(const Doc& doc, vector<string>& terms);
|
||||
bool getMatchTerms(unsigned long xdocid, vector<string>& terms);
|
||||
|
||||
/** Expand query to look for documents like the one passed in */
|
||||
list<string> expand(const Doc &doc);
|
||||
vector<string> expand(const Doc &doc);
|
||||
|
||||
/** Return the Db we're set for */
|
||||
Db *whatDb();
|
||||
|
||||
@@ -151,15 +151,15 @@ bool SearchData::expandFileTypes(RclConfig *cfg, vector<string>& tps)
|
||||
return false;
|
||||
}
|
||||
vector<string> exptps;
|
||||
list<string> alltypes = cfg->getAllMimeTypes();
|
||||
vector<string> alltypes = cfg->getAllMimeTypes();
|
||||
|
||||
for (vector<string>::iterator it = tps.begin(); it != tps.end(); it++) {
|
||||
if (cfg->isMimeCategory(*it)) {
|
||||
list<string>tps;
|
||||
vector<string>tps;
|
||||
cfg->getMimeCatTypes(*it, tps);
|
||||
exptps.insert(exptps.end(), tps.begin(), tps.end());
|
||||
} else {
|
||||
for (list<string>::const_iterator ait = alltypes.begin();
|
||||
for (vector<string>::const_iterator ait = alltypes.begin();
|
||||
ait != alltypes.end(); ait++) {
|
||||
if (fnmatch(it->c_str(), ait->c_str(), FNM_CASEFOLD)
|
||||
!= FNM_NOMATCH) {
|
||||
|
||||
+10
-10
@@ -48,11 +48,11 @@ static string stemdbname(const string& dbdir, const string& lang)
|
||||
return path_cat(dbdir, cstr_stemdirstem + lang);
|
||||
}
|
||||
|
||||
list<string> getLangs(const string& dbdir)
|
||||
vector<string> getLangs(const string& dbdir)
|
||||
{
|
||||
string pattern = cstr_stemdirstem + "*";
|
||||
list<string> dirs = path_dirglob(dbdir, pattern);
|
||||
for (list<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
|
||||
vector<string> dirs = path_dirglob(dbdir, pattern);
|
||||
for (vector<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
|
||||
*it = path_basename(*it);
|
||||
*it = it->substr(cstr_stemdirstem.length(), string::npos);
|
||||
}
|
||||
@@ -262,10 +262,10 @@ bool createDb(Xapian::Database& xdb, const string& dbdir, const string& lang)
|
||||
return true;
|
||||
}
|
||||
|
||||
static string stringlistdisp(const list<string>& sl)
|
||||
static string stringlistdisp(const vector<string>& sl)
|
||||
{
|
||||
string s;
|
||||
for (list<string>::const_iterator it = sl.begin(); it!= sl.end(); it++)
|
||||
for (vector<string>::const_iterator it = sl.begin(); it!= sl.end(); it++)
|
||||
s += "[" + *it + "] ";
|
||||
if (!s.empty())
|
||||
s.erase(s.length()-1);
|
||||
@@ -279,7 +279,7 @@ static string stringlistdisp(const list<string>& sl)
|
||||
static bool stemExpandOne(const std::string& dbdir,
|
||||
const std::string& lang,
|
||||
const std::string& term,
|
||||
list<string>& result)
|
||||
vector<string>& result)
|
||||
{
|
||||
try {
|
||||
Xapian::Stem stemmer(lang);
|
||||
@@ -347,19 +347,19 @@ static bool stemExpandOne(const std::string& dbdir,
|
||||
bool stemExpand(const std::string& dbdir,
|
||||
const std::string& langs,
|
||||
const std::string& term,
|
||||
list<string>& result)
|
||||
vector<string>& result)
|
||||
{
|
||||
|
||||
list<string> llangs;
|
||||
stringToStrings(langs, llangs);
|
||||
for (list<string>::const_iterator it = llangs.begin();
|
||||
it != llangs.end(); it++) {
|
||||
list<string> oneexp;
|
||||
vector<string> oneexp;
|
||||
stemExpandOne(dbdir, *it, term, oneexp);
|
||||
result.insert(result.end(), oneexp.begin(), oneexp.end());
|
||||
}
|
||||
result.sort();
|
||||
result.unique();
|
||||
sort(result.begin(), result.end());
|
||||
unique(result.begin(), result.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+3
-9
@@ -24,20 +24,16 @@
|
||||
/// Stem databases are stored as separate xapian databases (used as an
|
||||
/// Isam method), in subdirectories of the index.
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <xapian.h>
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::string;
|
||||
using std::list;
|
||||
namespace Rcl {
|
||||
namespace StemDb {
|
||||
#endif // NO_NAMESPACES
|
||||
|
||||
/// Get languages of existing stem databases
|
||||
extern std::list<std::string> getLangs(const std::string& dbdir);
|
||||
extern std::vector<std::string> getLangs(const std::string& dbdir);
|
||||
/// Delete stem database for given language
|
||||
extern bool deleteDb(const std::string& dbdir, const std::string& lang);
|
||||
/// Create stem database for given language
|
||||
@@ -47,10 +43,8 @@ extern bool createDb(Xapian::Database& xdb,
|
||||
extern bool stemExpand(const std::string& dbdir,
|
||||
const std::string& langs,
|
||||
const std::string& term,
|
||||
list<string>& result);
|
||||
#ifndef NO_NAMESPACES
|
||||
std::vector<std::string>& result);
|
||||
}
|
||||
}
|
||||
#endif // NO_NAMESPACES
|
||||
|
||||
#endif /* _STEMDB_H_INCLUDED_ */
|
||||
|
||||
Reference in New Issue
Block a user