Keep only the main Snippet-producing makeabstract in rclquery, further
  formatting done in using modules
This was just a bad idea. The common methods are also used by the python module
This commit is contained in:
Jean-Francois Dockes
2019-05-17 10:19:03 +02:00
parent a5810508ed
commit 8ddcc578ac
4 changed files with 55 additions and 41 deletions
+1 -15
View File
@@ -20,8 +20,6 @@
#include <time.h>
#include <list>
#include <sstream>
#include <vector>
#include "docseqdb.h"
#include "rcldb.h"
@@ -29,7 +27,6 @@
#include "wasatorcl.h"
using std::list;
using std::vector;
DocSequenceDb::DocSequenceDb(std::shared_ptr<Rcl::Db> db,
std::shared_ptr<Rcl::Query> q, const string &t,
@@ -117,18 +114,7 @@ bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
return false;
if (m_q->whatDb() &&
m_queryBuildAbstract && (doc.syntabs || m_queryReplaceAbstract)) {
vector<Rcl::Snippet> vpabs;
m_q->makeDocAbstract(doc, vpabs);
for (const auto& snippet : vpabs) {
string chunk;
if (snippet.page > 0) {
std::ostringstream ss;
ss << snippet.page;
chunk += string(" [p ") + ss.str() + "] ";
}
chunk += snippet.snippet;
vabs.push_back(chunk);
}
m_q->makeDocAbstract(doc, vabs);
}
if (vabs.empty())
vabs.push_back(doc.meta[Rcl::Doc::keyabs]);
+2 -16
View File
@@ -56,19 +56,6 @@ bool dump_contents(RclConfig *rclconfig, Rcl::Doc& idoc)
return true;
}
static const string cstr_ellipsis("...");
static void stringAbstract(Rcl::Query& query, Rcl::Doc doc, string& abstract)
{
abstract.clear();
vector<Rcl::Snippet> vpabs;
query.makeDocAbstract(doc, vpabs);
for (const auto& snippet : vpabs) {
abstract.append(snippet.snippet);
abstract.append(cstr_ellipsis);
}
}
void output_fields(vector<string> fields, Rcl::Doc& doc,
Rcl::Query& query, Rcl::Db& rcldb, bool printnames)
{
@@ -83,7 +70,7 @@ void output_fields(vector<string> fields, Rcl::Doc& doc,
string out;
if (!it->compare("abstract")) {
string abstract;
stringAbstract(query, doc, abstract);
query.makeDocAbstract(doc, abstract);
base64_encode(abstract, out);
} else if (!it->compare("xdocid")) {
char cdocid[30];
@@ -425,8 +412,7 @@ endopts:
}
if (op_flags & OPT_A) {
string abstract;
stringAbstract(query, doc, abstract);
if (abstract.size()) {
if (query.makeDocAbstract(doc, abstract)) {
cout << "ABSTRACT" << endl;
cout << abstract << endl;
cout << "/ABSTRACT" << endl;