improved detection of incomplete snippets lists

This commit is contained in:
Jean-Francois Dockes
2013-02-26 15:49:36 +01:00
parent 87120798c2
commit 3abfd00635
6 changed files with 47 additions and 25 deletions
+12 -9
View File
@@ -309,9 +309,9 @@ int Query::Native::getFirstMatchPage(Xapian::docid docid, string& term)
//
// DatabaseModified and other general exceptions are catched and
// possibly retried by our caller
abstract_result Query::Native::makeAbstract(Xapian::docid docid,
vector<Snippet>& vabs,
int imaxoccs, int ictxwords)
int Query::Native::makeAbstract(Xapian::docid docid,
vector<Snippet>& vabs,
int imaxoccs, int ictxwords)
{
Chrono chron;
LOGABS(("makeAbstract: docid %ld imaxoccs %d ictxwords %d\n",
@@ -381,7 +381,7 @@ abstract_result Query::Native::makeAbstract(Xapian::docid docid,
LOGABS(("makeAbstract:%d: mxttloccs %d ctxwords %d\n",
chron.ms(), maxtotaloccs, ctxwords));
abstract_result ret = ABSRES_OK;
int ret = ABSRES_OK;
// Let's go populate
for (map<double, vector<string> >::reverse_iterator mit = byQ.rbegin();
@@ -466,11 +466,14 @@ abstract_result Query::Native::makeAbstract(Xapian::docid docid,
}
// Group done ?
if (grpoccs >= maxgrpoccs)
if (grpoccs >= maxgrpoccs) {
ret |= ABSRES_TRUNC;
LOGABS(("Db::makeAbstract: max group occs cutoff\n"));
break;
}
// Global done ?
if (totaloccs >= maxtotaloccs) {
ret = ABSRES_TRUNC;
ret |= ABSRES_TRUNC;
LOGABS(("Db::makeAbstract: max occurrences cutoff\n"));
break;
}
@@ -480,7 +483,7 @@ abstract_result Query::Native::makeAbstract(Xapian::docid docid,
}
if (totaloccs >= maxtotaloccs) {
ret = ABSRES_TRUNC;
ret |= ABSRES_TRUNC;
LOGABS(("Db::makeAbstract: max1 occurrences cutoff\n"));
break;
}
@@ -511,7 +514,7 @@ abstract_result Query::Native::makeAbstract(Xapian::docid docid,
if (has_prefix(*term))
continue;
if (m_q->m_snipMaxPosWalk > 0 && cutoff-- < 0) {
ret = ABSRES_TERMMISS;
ret |= ABSRES_TERMMISS;
LOGDEB0(("makeAbstract: max term count cutoff %d\n",
m_q->m_snipMaxPosWalk));
break;
@@ -522,7 +525,7 @@ abstract_result Query::Native::makeAbstract(Xapian::docid docid,
for (pos = xrdb.positionlist_begin(docid, *term);
pos != xrdb.positionlist_end(docid, *term); pos++) {
if (m_q->m_snipMaxPosWalk > 0 && cutoff-- < 0) {
ret = ABSRES_TERMMISS;
ret |= ABSRES_TERMMISS;
LOGDEB0(("makeAbstract: max term count cutoff %d\n",
m_q->m_snipMaxPosWalk));
break;
+4 -4
View File
@@ -264,16 +264,16 @@ bool Query::getQueryTerms(vector<string>& terms)
return true;
}
abstract_result Query::makeDocAbstract(Doc &doc,
vector<Snippet>& abstract,
int maxoccs, int ctxwords)
int Query::makeDocAbstract(Doc &doc,
vector<Snippet>& abstract,
int maxoccs, int ctxwords)
{
LOGDEB(("makeDocAbstract: maxoccs %d ctxwords %d\n", maxoccs, ctxwords));
if (!m_db || !m_db->m_ndb || !m_db->m_ndb->m_isopen || !m_nq) {
LOGERR(("Query::makeDocAbstract: no db or no nq\n"));
return ABSRES_ERROR;
}
abstract_result ret = ABSRES_ERROR;
int ret = ABSRES_ERROR;
XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords),
m_db->m_ndb->xrdb, m_reason);
if (!m_reason.empty()) {
+3 -3
View File
@@ -33,7 +33,7 @@ enum abstract_result {
ABSRES_ERROR = 0,
ABSRES_OK = 1,
ABSRES_TRUNC = 2,
ABSRES_TERMMISS = 3
ABSRES_TERMMISS = 4
};
// Snippet entry for makeDocAbstract
@@ -110,8 +110,8 @@ class Query {
// Returned as a snippets vector
bool makeDocAbstract(Doc &doc, std::vector<std::string>& abstract);
// Returned as a vector of pair<page,snippet> page is 0 if unknown
abstract_result makeDocAbstract(Doc &doc, std::vector<Snippet>& abst,
int maxoccs= -1, int ctxwords = -1);
int makeDocAbstract(Doc &doc, std::vector<Snippet>& abst,
int maxoccs= -1, int ctxwords = -1);
/** Retrieve page number for first match for term */
int getFirstMatchPage(Doc &doc, std::string& term);
+2 -2
View File
@@ -59,8 +59,8 @@ public:
}
/** Return a list of terms which matched for a specific result document */
bool getMatchTerms(unsigned long xdocid, std::vector<std::string>& terms);
abstract_result makeAbstract(Xapian::docid id, vector<Snippet>&,
int maxoccs = -1, int ctxwords = -1);
int makeAbstract(Xapian::docid id, vector<Snippet>&,
int maxoccs = -1, int ctxwords = -1);
int getFirstMatchPage(Xapian::docid docid, std::string& term);
void setDbWideQTermsFreqs();
double qualityTerms(Xapian::docid docid,