query: add duplication indicator to relevancy rating

This commit is contained in:
Jean-Francois Dockes 2011-01-17 16:04:07 +01:00
parent 34511918d9
commit 93fb51d59b
5 changed files with 21 additions and 21 deletions

View File

@ -727,7 +727,7 @@ Query_fetchone(recoll_QueryObject* self, PyObject *, PyObject *)
// Move some data from the dedicated fields to the meta array to make // Move some data from the dedicated fields to the meta array to make
// fetching attributes easier. Is this actually needed ? Useful for // fetching attributes easier. Is this actually needed ? Useful for
// url and relevancy rating which are also formatted . // url which is also formatted .
Rcl::Doc *doc = result->doc; Rcl::Doc *doc = result->doc;
printableUrl(rclconfig->getDefCharset(), doc->url, printableUrl(rclconfig->getDefCharset(), doc->url,
doc->meta[Rcl::Doc::keyurl]); doc->meta[Rcl::Doc::keyurl]);
@ -735,10 +735,6 @@ Query_fetchone(recoll_QueryObject* self, PyObject *, PyObject *)
doc->meta[Rcl::Doc::keyipt] = doc->ipath; doc->meta[Rcl::Doc::keyipt] = doc->ipath;
doc->meta[Rcl::Doc::keyfs] = doc->fbytes; doc->meta[Rcl::Doc::keyfs] = doc->fbytes;
doc->meta[Rcl::Doc::keyds] = doc->dbytes; doc->meta[Rcl::Doc::keyds] = doc->dbytes;
char pc[20];
sprintf(pc, "%02d %%", doc->pc);
doc->meta[Rcl::Doc::keyrr] = pc;
return (PyObject *)result; return (PyObject *)result;
} }

View File

@ -90,9 +90,6 @@ void ResListPager::displayDoc(int i, Rcl::Doc& doc, const HiliteData& hdata,
} else { } else {
percent = doc.pc; percent = doc.pc;
} }
// Percentage of 'relevance'
char perbuf[20];
sprintf(perbuf, "%3d%% ", percent);
// Determine icon to display if any // Determine icon to display if any
string iconpath = iconPath(doc.mimetype); string iconpath = iconPath(doc.mimetype);
@ -186,7 +183,7 @@ void ResListPager::displayDoc(int i, Rcl::Doc& doc, const HiliteData& hdata,
subs["L"] = linksbuf.rdbuf()->str(); subs["L"] = linksbuf.rdbuf()->str();
subs["N"] = numbuf; subs["N"] = numbuf;
subs["M"] = doc.mimetype; subs["M"] = doc.mimetype;
subs["R"] = perbuf; subs["R"] = doc.meta[Rcl::Doc::keyrr];
subs["S"] = sizebuf; subs["S"] = sizebuf;
subs["T"] = escapeHtml(doc.meta[Rcl::Doc::keytt]); subs["T"] = escapeHtml(doc.meta[Rcl::Doc::keytt]);
subs["U"] = url; subs["U"] = url;

View File

@ -140,7 +140,7 @@ static const string keycap("caption");
// Turn data record from db into document fields // Turn data record from db into document fields
bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data, bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
Doc &doc, int percent) Doc &doc)
{ {
LOGDEB2(("Db::dbDataToRclDoc: data:\n%s\n", data.c_str())); LOGDEB2(("Db::dbDataToRclDoc: data:\n%s\n", data.c_str()));
ConfSimple parms(data); ConfSimple parms(data);
@ -161,10 +161,6 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
doc.meta[Doc::keyabs] = doc.meta[Doc::keyabs].substr(rclSyntAbs.length()); doc.meta[Doc::keyabs] = doc.meta[Doc::keyabs].substr(rclSyntAbs.length());
doc.syntabs = true; doc.syntabs = true;
} }
char buf[20];
sprintf(buf,"%.2f", float(percent) / 100.0);
doc.pc = percent;
doc.meta[Doc::keyrr] = buf;
parms.get(Doc::keyipt, doc.ipath); parms.get(Doc::keyipt, doc.ipath);
parms.get(Doc::keyfs, doc.fbytes); parms.get(Doc::keyfs, doc.fbytes);
parms.get(Doc::keyds, doc.dbytes); parms.get(Doc::keyds, doc.dbytes);
@ -1721,6 +1717,7 @@ bool Db::getDoc(const string &udi, Doc &doc)
// Initialize what we can in any case. If this is history, caller // Initialize what we can in any case. If this is history, caller
// will make partial display in case of error // will make partial display in case of error
doc.meta[Rcl::Doc::keyrr] = "100%";
doc.pc = 100; doc.pc = 100;
string uniterm = make_uniterm(udi); string uniterm = make_uniterm(udi);
@ -1741,7 +1738,7 @@ bool Db::getDoc(const string &udi, Doc &doc)
Xapian::Document xdoc = m_ndb->xrdb.get_document(*docid); Xapian::Document xdoc = m_ndb->xrdb.get_document(*docid);
string data = xdoc.get_data(); string data = xdoc.get_data();
doc.meta[Rcl::Doc::keyudi] = udi; doc.meta[Rcl::Doc::keyudi] = udi;
return m_ndb->dbDataToRclDoc(*docid, data, doc, 100); return m_ndb->dbDataToRclDoc(*docid, data, doc);
} catch (const Xapian::DatabaseModifiedError &e) { } catch (const Xapian::DatabaseModifiedError &e) {
m_reason = e.get_msg(); m_reason = e.get_msg();
m_ndb->xrdb.reopen(); m_ndb->xrdb.reopen();

View File

@ -77,8 +77,7 @@ class Db::Native {
string makeAbstract(Xapian::docid id, Query *query); string makeAbstract(Xapian::docid id, Query *query);
bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc, bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc);
int percent);
/** Compute list of subdocuments for a given udi. We look for documents /** Compute list of subdocuments for a given udi. We look for documents
* indexed by a parent term matching the udi, the posting list for the * indexed by a parent term matching the udi, the posting list for the

View File

@ -357,12 +357,23 @@ bool Query::getDoc(int xapi, Doc &doc)
return false; return false;
} }
doc.meta[Rcl::Doc::keyudi] = udi; doc.meta[Rcl::Doc::keyudi] = udi;
char scc[30];
sprintf(scc, "%d", collapsecount); doc.pc = pc;
doc.meta[Rcl::Doc::keycc] = scc; char buf[200];
if (collapsecount>0) {
LOGDEB(("COLLAPSECOUNET %d\n", collapsecount));
sprintf(buf,"%3d%% (%d)", pc, collapsecount+1);
} else {
sprintf(buf,"%3d%%", pc);
}
doc.meta[Doc::keyrr] = buf;
sprintf(buf, "%d", collapsecount);
doc.meta[Rcl::Doc::keycc] = buf;
// Parse xapian document's data and populate doc fields // Parse xapian document's data and populate doc fields
return m_db->m_ndb->dbDataToRclDoc(docid, data, doc, pc); return m_db->m_ndb->dbDataToRclDoc(docid, data, doc);
} }
list<string> Query::expand(const Doc &doc) list<string> Query::expand(const Doc &doc)