dont generate error for empty abstract this is a problem for python

This commit is contained in:
Jean-Francois Dockes 2012-10-21 17:57:08 +02:00
parent de5763f663
commit 5f0e348216
2 changed files with 11 additions and 8 deletions

View File

@ -290,8 +290,8 @@ abstract_result Query::Native::makeAbstract(Xapian::docid docid,
int imaxoccs, int ictxwords)
{
Chrono chron;
LOGDEB2(("makeAbstract:%d: maxlen %d wWidth %d imaxoccs %d\n", chron.ms(),
m_rcldb->m_synthAbsLen, m_rcldb->m_synthAbsWordCtxLen, imaxoccs));
LOGABS(("makeAbstract: docid %l imaxoccs %d ictxwords %d\n",
long(docid), imaxoccs, ictxwords));
// The (unprefixed) terms matched by this document
vector<string> matchedTerms;
@ -464,15 +464,15 @@ abstract_result Query::Native::makeAbstract(Xapian::docid docid,
}
}
}
LOGABS(("makeAbstract:%d:chosen number of positions %d\n",
chron.millis(), totaloccs));
maxpos += ctxwords + 1;
LOGABS(("makeAbstract:%d:chosen number of positions %d\n",
chron.millis(), totaloccs));
// This can happen if there are term occurences in the keywords
// etc. but not elsewhere ?
if (totaloccs == 0) {
LOGDEB1(("makeAbstract: no occurrences\n"));
return ABSRES_ERROR;
LOGDEB(("makeAbstract: no occurrences\n"));
return ABSRES_OK;
}
// Walk all document's terms position lists and populate slots

View File

@ -318,15 +318,18 @@ abstract_result Query::makeDocAbstract(Doc &doc,
abstract_result ret = ABSRES_ERROR;
XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords),
m_db->m_ndb->xrdb, m_reason);
if (!m_reason.empty())
if (!m_reason.empty()) {
LOGDEB(("makeDocAbstract: makeAbstract error, reason: %s\n",
m_reason.c_str()));
return ABSRES_ERROR;
}
return ret;
}
bool Query::makeDocAbstract(Doc &doc, vector<string>& abstract)
{
vector<Snippet> vpabs;
if (!makeDocAbstract(doc, vpabs))
if (!makeDocAbstract(doc, vpabs))
return false;
for (vector<Snippet>::const_iterator it = vpabs.begin();
it != vpabs.end(); it++) {