GUI snippets window: add options for the max list length and for sorting the snippets by page number
This commit is contained in:
parent
eb83ebfec6
commit
3ccd2364b9
@ -164,10 +164,6 @@ void rwSettings(bool writing)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abstract snippet separator
|
|
||||||
SETTING_RW(prefs.abssep, "/Recoll/prefs/reslist/abssep", String,"…");
|
|
||||||
if (!writing && prefs.abssep == "")
|
|
||||||
prefs.abssep = "…";
|
|
||||||
SETTING_RW(prefs.reslistdateformat, "/Recoll/prefs/reslist/dateformat",
|
SETTING_RW(prefs.reslistdateformat, "/Recoll/prefs/reslist/dateformat",
|
||||||
String," %Y-%m-%d %H:%M:%S %z");
|
String," %Y-%m-%d %H:%M:%S %z");
|
||||||
if (!writing && prefs.reslistdateformat == "")
|
if (!writing && prefs.reslistdateformat == "")
|
||||||
@ -224,6 +220,13 @@ void rwSettings(bool writing)
|
|||||||
Int, 250);
|
Int, 250);
|
||||||
SETTING_RW(prefs.syntAbsCtx, "/Recoll/prefs/query/syntAbsCtx",
|
SETTING_RW(prefs.syntAbsCtx, "/Recoll/prefs/query/syntAbsCtx",
|
||||||
Int, 4);
|
Int, 4);
|
||||||
|
// Abstract snippet separator
|
||||||
|
SETTING_RW(prefs.abssep, "/Recoll/prefs/reslist/abssep", String,"…");
|
||||||
|
if (!writing && prefs.abssep == "")
|
||||||
|
prefs.abssep = "…";
|
||||||
|
SETTING_RW(prefs.snipwMaxLength, "/Recoll/prefs/snipwin/maxlen", Int, 1000);
|
||||||
|
SETTING_RW(prefs.snipwSortByPage,"/Recoll/prefs/snipwin/bypage", Bool, false);
|
||||||
|
|
||||||
SETTING_RW(prefs.autoSuffs, "/Recoll/prefs/query/autoSuffs", String, "");
|
SETTING_RW(prefs.autoSuffs, "/Recoll/prefs/query/autoSuffs", String, "");
|
||||||
SETTING_RW(prefs.autoSuffsEnable,
|
SETTING_RW(prefs.autoSuffsEnable,
|
||||||
"/Recoll/prefs/query/autoSuffsEnable", Bool, false);
|
"/Recoll/prefs/query/autoSuffsEnable", Bool, false);
|
||||||
|
|||||||
@ -57,8 +57,6 @@ class PrefsPack {
|
|||||||
QString reslistformat;
|
QString reslistformat;
|
||||||
string creslistformat;
|
string creslistformat;
|
||||||
QString reslistheadertext;
|
QString reslistheadertext;
|
||||||
// Abstract snippet separator
|
|
||||||
QString abssep;
|
|
||||||
// Date strftime format
|
// Date strftime format
|
||||||
QString reslistdateformat;
|
QString reslistdateformat;
|
||||||
string creslistdateformat;
|
string creslistdateformat;
|
||||||
@ -86,6 +84,15 @@ class PrefsPack {
|
|||||||
// Abstract preferences. Building abstracts can slow result display
|
// Abstract preferences. Building abstracts can slow result display
|
||||||
bool queryBuildAbstract;
|
bool queryBuildAbstract;
|
||||||
bool queryReplaceAbstract;
|
bool queryReplaceAbstract;
|
||||||
|
// Synthetized abstract length (chars) and word context size (words)
|
||||||
|
int syntAbsLen;
|
||||||
|
int syntAbsCtx;
|
||||||
|
// Abstract snippet separator
|
||||||
|
QString abssep;
|
||||||
|
// Snippets window max list size
|
||||||
|
int snipwMaxLength;
|
||||||
|
// Snippets window sort by page (dflt: by weight)
|
||||||
|
bool snipwSortByPage;
|
||||||
bool startWithAdvSearchOpen;
|
bool startWithAdvSearchOpen;
|
||||||
// Try to display html if it exists in the internfile stack.
|
// Try to display html if it exists in the internfile stack.
|
||||||
bool previewHtml;
|
bool previewHtml;
|
||||||
@ -122,10 +129,6 @@ class PrefsPack {
|
|||||||
QStringList restableFields;
|
QStringList restableFields;
|
||||||
vector<int> restableColWidths;
|
vector<int> restableColWidths;
|
||||||
|
|
||||||
// Synthetized abstract length and word context size
|
|
||||||
int syntAbsLen;
|
|
||||||
int syntAbsCtx;
|
|
||||||
|
|
||||||
// Remembered term match mode
|
// Remembered term match mode
|
||||||
int termMatchType;
|
int termMatchType;
|
||||||
|
|
||||||
|
|||||||
@ -107,6 +107,7 @@ void SnippetsW::init()
|
|||||||
connect(nextPB, SIGNAL(clicked()), this, SLOT(slotEditFindNext()));
|
connect(nextPB, SIGNAL(clicked()), this, SLOT(slotEditFindNext()));
|
||||||
connect(prevPB, SIGNAL(clicked()), this, SLOT(slotEditFindPrevious()));
|
connect(prevPB, SIGNAL(clicked()), this, SLOT(slotEditFindPrevious()));
|
||||||
|
|
||||||
|
delete browserw;
|
||||||
#if defined(USING_WEBKIT)
|
#if defined(USING_WEBKIT)
|
||||||
browserw = new QWebView(this);
|
browserw = new QWebView(this);
|
||||||
verticalLayout->insertWidget(0, browserw);
|
verticalLayout->insertWidget(0, browserw);
|
||||||
@ -165,7 +166,8 @@ void SnippetsW::init()
|
|||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
|
|
||||||
vector<Rcl::Snippet> vpabs;
|
vector<Rcl::Snippet> vpabs;
|
||||||
m_source->getAbstract(m_doc, vpabs);
|
m_source->getAbstract(m_doc, vpabs,
|
||||||
|
prefs.snipwMaxLength, prefs.snipwSortByPage);
|
||||||
|
|
||||||
HighlightData hdata;
|
HighlightData hdata;
|
||||||
m_source->getTerms(hdata);
|
m_source->getTerms(hdata);
|
||||||
|
|||||||
@ -45,15 +45,15 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="qtermStyleLE">
|
<widget class="QLineEdit" name="qtermStyleLE">
|
||||||
<property name="toolTip">
|
|
||||||
<string>Query terms highlighting in results. <br>Maybe try something like "color:red;background:yellow" for something more lively than the default blue...</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>50</width>
|
<width>50</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Query terms highlighting in results. <br>Maybe try something like "color:red;background:yellow" for something more lively than the default blue...</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -137,12 +137,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="previewActiveLinksCB">
|
<widget class="QCheckBox" name="previewActiveLinksCB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Make links inside the preview window clickable, and start an external browser when they are clicked.</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Activate links in preview.</string>
|
<string>Activate links in preview.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
|
||||||
<string>Make links inside the preview window clickable, and start an external browser when they are clicked.</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -527,6 +527,52 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="snipwMaxLenLBL">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Maximum number of snippets displayed in the snippets window</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="snipwMaxLenSB">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>10000000</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1000</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="snipwByPageCB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sort snippets by page number (default: by weigth).</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -903,12 +949,12 @@ May be slow for big documents.</string>
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="ptransPB">
|
<widget class="QPushButton" name="ptransPB">
|
||||||
<property name="text">
|
|
||||||
<string>Paths translations</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Set path translations for the selected index or for the main one if no selection exists.</string>
|
<string>Set path translations for the selected index or for the main one if no selection exists.</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Paths translations</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@ -184,7 +184,8 @@ void UIPrefsDialog::setFromPrefs()
|
|||||||
string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit());
|
string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit());
|
||||||
snipCssPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
snipCssPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
||||||
}
|
}
|
||||||
|
snipwMaxLenSB->setValue(prefs.snipwMaxLength);
|
||||||
|
snipwByPageCB->setChecked(prefs.snipwSortByPage);
|
||||||
paraFormat = prefs.reslistformat;
|
paraFormat = prefs.reslistformat;
|
||||||
headerText = prefs.reslistheadertext;
|
headerText = prefs.reslistheadertext;
|
||||||
|
|
||||||
@ -301,6 +302,8 @@ void UIPrefsDialog::accept()
|
|||||||
prefs.reslistformat = prefs.dfltResListFormat;
|
prefs.reslistformat = prefs.dfltResListFormat;
|
||||||
paraFormat = prefs.reslistformat;
|
paraFormat = prefs.reslistformat;
|
||||||
}
|
}
|
||||||
|
prefs.snipwMaxLength = snipwMaxLenSB->value();
|
||||||
|
prefs.snipwSortByPage = snipwByPageCB->isChecked();
|
||||||
|
|
||||||
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
|
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ struct ResListEntry {
|
|||||||
|
|
||||||
/** Sort specification. */
|
/** Sort specification. */
|
||||||
class DocSeqSortSpec {
|
class DocSeqSortSpec {
|
||||||
public:
|
public:
|
||||||
DocSeqSortSpec() : desc(false) {}
|
DocSeqSortSpec() : desc(false) {}
|
||||||
bool isNotNull() const {return !field.empty();}
|
bool isNotNull() const {return !field.empty();}
|
||||||
void reset() {field.erase();}
|
void reset() {field.erase();}
|
||||||
@ -50,12 +50,12 @@ class DocSeqSortSpec {
|
|||||||
/** Filtering spec. This is only used to filter by doc category for now, hence
|
/** Filtering spec. This is only used to filter by doc category for now, hence
|
||||||
the rather specialized interface */
|
the rather specialized interface */
|
||||||
class DocSeqFiltSpec {
|
class DocSeqFiltSpec {
|
||||||
public:
|
public:
|
||||||
DocSeqFiltSpec() {}
|
DocSeqFiltSpec() {}
|
||||||
enum Crit {DSFS_MIMETYPE, DSFS_QLANG, DSFS_PASSALL};
|
enum Crit {DSFS_MIMETYPE, DSFS_QLANG, DSFS_PASSALL};
|
||||||
void orCrit(Crit crit, const std::string& value) {
|
void orCrit(Crit crit, const std::string& value) {
|
||||||
crits.push_back(crit);
|
crits.push_back(crit);
|
||||||
values.push_back(value);
|
values.push_back(value);
|
||||||
}
|
}
|
||||||
std::vector<Crit> crits;
|
std::vector<Crit> crits;
|
||||||
std::vector<std::string> values;
|
std::vector<std::string> values;
|
||||||
@ -75,7 +75,7 @@ class DocSeqFiltSpec {
|
|||||||
the current one will have to do for now.
|
the current one will have to do for now.
|
||||||
*/
|
*/
|
||||||
class DocSequence {
|
class DocSequence {
|
||||||
public:
|
public:
|
||||||
DocSequence(const std::string &t) : m_title(t) {}
|
DocSequence(const std::string &t) : m_title(t) {}
|
||||||
virtual ~DocSequence() {}
|
virtual ~DocSequence() {}
|
||||||
|
|
||||||
@ -92,29 +92,26 @@ class DocSequence {
|
|||||||
/** Get next page of documents. This accumulates entries into the result
|
/** Get next page of documents. This accumulates entries into the result
|
||||||
* list parameter (doesn't reset it). */
|
* list parameter (doesn't reset it). */
|
||||||
virtual int getSeqSlice(int offs, int cnt,
|
virtual int getSeqSlice(int offs, int cnt,
|
||||||
std::vector<ResListEntry>& result);
|
std::vector<ResListEntry>& result);
|
||||||
|
|
||||||
/** Get abstract for document. This is special because it may take time.
|
/** Get abstract for document. This is special because it may take time.
|
||||||
* The default is to return the input doc's abstract fields, but some
|
* The default is to return the input doc's abstract fields, but some
|
||||||
* sequences can compute a better value (ie: docseqdb) */
|
* sequences can compute a better value (ie: docseqdb) */
|
||||||
virtual bool getAbstract(Rcl::Doc& doc, std::vector<std::string>& abs) {
|
virtual bool getAbstract(Rcl::Doc& doc, std::vector<std::string>& abs) {
|
||||||
abs.push_back(doc.meta[Rcl::Doc::keyabs]);
|
abs.push_back(doc.meta[Rcl::Doc::keyabs]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual bool getAbstract(Rcl::Doc& doc,
|
virtual bool getAbstract(Rcl::Doc& doc, std::vector<Rcl::Snippet>& abs,
|
||||||
std::vector<Rcl::Snippet>& abs)
|
int, bool) {
|
||||||
{
|
abs.push_back(Rcl::Snippet(0, doc.meta[Rcl::Doc::keyabs]));
|
||||||
abs.push_back(Rcl::Snippet(0, doc.meta[Rcl::Doc::keyabs]));
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
virtual int getFirstMatchPage(Rcl::Doc&, std::string&)
|
virtual int getFirstMatchPage(Rcl::Doc&, std::string&) {
|
||||||
{
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
/** Get duplicates. */
|
/** Get duplicates. */
|
||||||
virtual bool docDups(const Rcl::Doc&, std::vector<Rcl::Doc>&)
|
virtual bool docDups(const Rcl::Doc&, std::vector<Rcl::Doc>&) {
|
||||||
{
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool getEnclosing(Rcl::Doc&, Rcl::Doc&);
|
virtual bool getEnclosing(Rcl::Doc&, Rcl::Doc&);
|
||||||
@ -124,43 +121,44 @@ class DocSequence {
|
|||||||
|
|
||||||
/** Get title for result list */
|
/** Get title for result list */
|
||||||
virtual std::string title()
|
virtual std::string title()
|
||||||
{
|
{
|
||||||
return m_title;
|
return m_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Can do snippets ? */
|
/** Can do snippets ? */
|
||||||
virtual bool snippetsCapable()
|
virtual bool snippetsCapable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/** Get description for underlying query */
|
/** Get description for underlying query */
|
||||||
virtual std::string getDescription() = 0;
|
virtual std::string getDescription() = 0;
|
||||||
|
|
||||||
/** Get search terms (for highlighting abstracts). Some sequences
|
/** Get search terms (for highlighting abstracts). Some sequences
|
||||||
* may have no associated search terms. Implement this for them. */
|
* may have no associated search terms. Implement this for them. */
|
||||||
virtual void getTerms(HighlightData& hld)
|
virtual void getTerms(HighlightData& hld)
|
||||||
{
|
{
|
||||||
hld.clear();
|
hld.clear();
|
||||||
}
|
}
|
||||||
virtual std::list<std::string> expand(Rcl::Doc &)
|
virtual std::list<std::string> expand(Rcl::Doc &)
|
||||||
{
|
{
|
||||||
return std::list<std::string>();
|
return std::list<std::string>();
|
||||||
}
|
}
|
||||||
virtual std::string getReason()
|
virtual std::string getReason()
|
||||||
{
|
{
|
||||||
return m_reason;
|
return m_reason;
|
||||||
}
|
}
|
||||||
/** Optional functionality. */
|
/** Optional functionality. */
|
||||||
virtual bool canFilter() {return false;}
|
virtual bool canFilter() {return false;}
|
||||||
virtual bool canSort() {return false;}
|
virtual bool canSort() {return false;}
|
||||||
virtual bool setFiltSpec(const DocSeqFiltSpec &) {return false;}
|
virtual bool setFiltSpec(const DocSeqFiltSpec &) {return false;}
|
||||||
virtual bool setSortSpec(const DocSeqSortSpec &) {return false;}
|
virtual bool setSortSpec(const DocSeqSortSpec &) {return false;}
|
||||||
virtual std::shared_ptr<DocSequence> getSourceSeq() {return std::shared_ptr<DocSequence>();}
|
virtual std::shared_ptr<DocSequence> getSourceSeq() {
|
||||||
|
return std::shared_ptr<DocSequence>();}
|
||||||
|
|
||||||
static void set_translations(const std::string& sort, const std::string& filt)
|
static void set_translations(const std::string& sort,
|
||||||
{
|
const std::string& filt) {
|
||||||
o_sort_trans = sort;
|
o_sort_trans = sort;
|
||||||
o_filt_trans = filt;
|
o_filt_trans = filt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -172,7 +170,7 @@ protected:
|
|||||||
static std::string o_filt_trans;
|
static std::string o_filt_trans;
|
||||||
std::string m_reason;
|
std::string m_reason;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_title;
|
std::string m_title;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -182,75 +180,65 @@ protected:
|
|||||||
class DocSeqModifier : public DocSequence {
|
class DocSeqModifier : public DocSequence {
|
||||||
public:
|
public:
|
||||||
DocSeqModifier(std::shared_ptr<DocSequence> iseq)
|
DocSeqModifier(std::shared_ptr<DocSequence> iseq)
|
||||||
: DocSequence(""), m_seq(iseq)
|
: DocSequence(""), m_seq(iseq)
|
||||||
{}
|
{}
|
||||||
virtual ~DocSeqModifier() {}
|
virtual ~DocSeqModifier() {}
|
||||||
|
|
||||||
virtual bool getAbstract(Rcl::Doc& doc, std::vector<std::string>& abs)
|
virtual bool getAbstract(Rcl::Doc& doc, std::vector<std::string>& abs) {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return false;
|
||||||
return false;
|
return m_seq->getAbstract(doc, abs);
|
||||||
return m_seq->getAbstract(doc, abs);
|
|
||||||
}
|
}
|
||||||
virtual bool getAbstract(Rcl::Doc& doc,
|
virtual bool getAbstract(Rcl::Doc& doc, std::vector<Rcl::Snippet>& abs,
|
||||||
std::vector<Rcl::Snippet>& abs)
|
int maxlen, bool bypage) override {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return false;
|
||||||
return false;
|
return m_seq->getAbstract(doc, abs, maxlen, bypage);
|
||||||
return m_seq->getAbstract(doc, abs);
|
|
||||||
}
|
}
|
||||||
/** Get duplicates. */
|
/** Get duplicates. */
|
||||||
virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
|
virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups) {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return false;
|
||||||
return false;
|
return m_seq->docDups(doc, dups);
|
||||||
return m_seq->docDups(doc, dups);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool snippetsCapable()
|
virtual bool snippetsCapable() {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return false;
|
||||||
return false;
|
return m_seq->snippetsCapable();
|
||||||
return m_seq->snippetsCapable();
|
|
||||||
}
|
}
|
||||||
virtual std::string getDescription()
|
virtual std::string getDescription() {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return "";
|
||||||
return "";
|
return m_seq->getDescription();
|
||||||
return m_seq->getDescription();
|
|
||||||
}
|
}
|
||||||
virtual void getTerms(HighlightData& hld)
|
virtual void getTerms(HighlightData& hld) {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return;
|
||||||
return;
|
m_seq->getTerms(hld);
|
||||||
m_seq->getTerms(hld);
|
|
||||||
}
|
}
|
||||||
virtual bool getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
|
virtual bool getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc) {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return false;
|
||||||
return false;
|
return m_seq->getEnclosing(doc, pdoc);
|
||||||
return m_seq->getEnclosing(doc, pdoc);
|
|
||||||
}
|
}
|
||||||
virtual std::string getReason()
|
virtual std::string getReason() {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return string();
|
||||||
return string();
|
return m_seq->getReason();
|
||||||
return m_seq->getReason();
|
|
||||||
}
|
}
|
||||||
virtual std::string title()
|
virtual std::string title() {
|
||||||
{
|
return m_seq->title();
|
||||||
return m_seq->title();
|
|
||||||
}
|
}
|
||||||
virtual std::shared_ptr<DocSequence> getSourceSeq()
|
virtual std::shared_ptr<DocSequence> getSourceSeq() {
|
||||||
{
|
return m_seq;
|
||||||
return m_seq;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::shared_ptr<Rcl::Db> getDb() {
|
virtual std::shared_ptr<Rcl::Db> getDb() {
|
||||||
if (!m_seq)
|
if (!m_seq)
|
||||||
return 0;
|
return 0;
|
||||||
return m_seq->getDb();
|
return m_seq->getDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<DocSequence> m_seq;
|
std::shared_ptr<DocSequence> m_seq;
|
||||||
@ -263,23 +251,21 @@ class RclConfig;
|
|||||||
class DocSource : public DocSeqModifier {
|
class DocSource : public DocSeqModifier {
|
||||||
public:
|
public:
|
||||||
DocSource(RclConfig *config, std::shared_ptr<DocSequence> iseq)
|
DocSource(RclConfig *config, std::shared_ptr<DocSequence> iseq)
|
||||||
: DocSeqModifier(iseq), m_config(config)
|
: DocSeqModifier(iseq), m_config(config)
|
||||||
{}
|
{}
|
||||||
virtual bool canFilter() {return true;}
|
virtual bool canFilter() {return true;}
|
||||||
virtual bool canSort() {return true;}
|
virtual bool canSort() {return true;}
|
||||||
virtual bool setFiltSpec(const DocSeqFiltSpec &);
|
virtual bool setFiltSpec(const DocSeqFiltSpec &);
|
||||||
virtual bool setSortSpec(const DocSeqSortSpec &);
|
virtual bool setSortSpec(const DocSeqSortSpec &);
|
||||||
virtual bool getDoc(int num, Rcl::Doc &doc, std::string *sh = 0)
|
virtual bool getDoc(int num, Rcl::Doc &doc, std::string *sh = 0) {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return false;
|
||||||
return false;
|
return m_seq->getDoc(num, doc, sh);
|
||||||
return m_seq->getDoc(num, doc, sh);
|
|
||||||
}
|
}
|
||||||
virtual int getResCnt()
|
virtual int getResCnt() {
|
||||||
{
|
if (!m_seq)
|
||||||
if (!m_seq)
|
return 0;
|
||||||
return 0;
|
return m_seq->getResCnt();
|
||||||
return m_seq->getResCnt();
|
|
||||||
}
|
}
|
||||||
virtual std::string title();
|
virtual std::string title();
|
||||||
private:
|
private:
|
||||||
@ -290,4 +276,4 @@ private:
|
|||||||
DocSeqSortSpec m_sspec;
|
DocSeqSortSpec m_sspec;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _DOCSEQ_H_INCLUDED_ */
|
#endif /* _DOCSEQ_H_ */
|
||||||
|
|||||||
@ -30,7 +30,7 @@ using std::list;
|
|||||||
|
|
||||||
DocSequenceDb::DocSequenceDb(std::shared_ptr<Rcl::Db> db,
|
DocSequenceDb::DocSequenceDb(std::shared_ptr<Rcl::Db> db,
|
||||||
std::shared_ptr<Rcl::Query> q, const string &t,
|
std::shared_ptr<Rcl::Query> q, const string &t,
|
||||||
std::shared_ptr<Rcl::SearchData> sdata)
|
std::shared_ptr<Rcl::SearchData> sdata)
|
||||||
: DocSequence(t), m_db(db), m_q(q), m_sdata(sdata), m_fsdata(sdata),
|
: DocSequence(t), m_db(db), m_q(q), m_sdata(sdata), m_fsdata(sdata),
|
||||||
m_rescnt(-1),
|
m_rescnt(-1),
|
||||||
m_queryBuildAbstract(true),
|
m_queryBuildAbstract(true),
|
||||||
@ -56,7 +56,7 @@ bool DocSequenceDb::getDoc(int num, Rcl::Doc &doc, string *sh)
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> locker(o_dblock);
|
std::unique_lock<std::mutex> locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
if (sh) sh->erase();
|
if (sh) sh->erase();
|
||||||
return m_q->getDoc(num, doc);
|
return m_q->getDoc(num, doc);
|
||||||
}
|
}
|
||||||
@ -65,9 +65,9 @@ int DocSequenceDb::getResCnt()
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> locker(o_dblock);
|
std::unique_lock<std::mutex> locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
if (m_rescnt < 0) {
|
if (m_rescnt < 0) {
|
||||||
m_rescnt= m_q->getResCnt();
|
m_rescnt= m_q->getResCnt();
|
||||||
}
|
}
|
||||||
return m_rescnt;
|
return m_rescnt;
|
||||||
}
|
}
|
||||||
@ -76,32 +76,33 @@ static const string cstr_mre("[...]");
|
|||||||
|
|
||||||
// This one only gets called to fill-up the snippets window
|
// This one only gets called to fill-up the snippets window
|
||||||
// We ignore most abstract/snippets preferences.
|
// We ignore most abstract/snippets preferences.
|
||||||
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs)
|
bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>& vpabs,
|
||||||
|
int maxlen, bool sortbypage)
|
||||||
{
|
{
|
||||||
LOGDEB("DocSequenceDb::getAbstract/pair\n" );
|
LOGDEB("DocSequenceDb::getAbstract/pair\n");
|
||||||
std::unique_lock<std::mutex> locker(o_dblock);
|
std::unique_lock<std::mutex> locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Have to put the limit somewhere.
|
// Have to put the limit somewhere.
|
||||||
int maxoccs = 1000;
|
|
||||||
int ret = Rcl::ABSRES_ERROR;
|
int ret = Rcl::ABSRES_ERROR;
|
||||||
if (m_q->whatDb()) {
|
if (m_q->whatDb()) {
|
||||||
ret = m_q->makeDocAbstract(doc, vpabs, maxoccs,
|
ret = m_q->makeDocAbstract(
|
||||||
m_q->whatDb()->getAbsCtxLen()+ 2);
|
doc, vpabs, maxlen, m_q->whatDb()->getAbsCtxLen() + 2, sortbypage);
|
||||||
}
|
}
|
||||||
LOGDEB("DocSequenceDb::getAbstract: got ret " << (ret) << " vpabs len " << (vpabs.size()) << "\n" );
|
LOGDEB("DocSequenceDb::getAbstract: got ret " << ret << " vpabs len " <<
|
||||||
|
vpabs.size() << "\n");
|
||||||
if (vpabs.empty()) {
|
if (vpabs.empty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the list was probably truncated, indicate it.
|
// If the list was probably truncated, indicate it.
|
||||||
if (ret & Rcl::ABSRES_TRUNC) {
|
if (ret & Rcl::ABSRES_TRUNC) {
|
||||||
vpabs.push_back(Rcl::Snippet(-1, cstr_mre));
|
vpabs.push_back(Rcl::Snippet(-1, cstr_mre));
|
||||||
}
|
}
|
||||||
if (ret & Rcl::ABSRES_TERMMISS) {
|
if (ret & Rcl::ABSRES_TERMMISS) {
|
||||||
vpabs.insert(vpabs.begin(),
|
vpabs.insert(vpabs.begin(),
|
||||||
Rcl::Snippet(-1, "(Words missing in snippets)"));
|
Rcl::Snippet(-1, "(Words missing in snippets)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -111,13 +112,13 @@ bool DocSequenceDb::getAbstract(Rcl::Doc &doc, vector<string>& vabs)
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> locker(o_dblock);
|
std::unique_lock<std::mutex> locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
if (m_q->whatDb() &&
|
if (m_q->whatDb() &&
|
||||||
m_queryBuildAbstract && (doc.syntabs || m_queryReplaceAbstract)) {
|
m_queryBuildAbstract && (doc.syntabs || m_queryReplaceAbstract)) {
|
||||||
m_q->makeDocAbstract(doc, vabs);
|
m_q->makeDocAbstract(doc, vabs);
|
||||||
}
|
}
|
||||||
if (vabs.empty())
|
if (vabs.empty())
|
||||||
vabs.push_back(doc.meta[Rcl::Doc::keyabs]);
|
vabs.push_back(doc.meta[Rcl::Doc::keyabs]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,9 +126,9 @@ int DocSequenceDb::getFirstMatchPage(Rcl::Doc &doc, string& term)
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> locker(o_dblock);
|
std::unique_lock<std::mutex> locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return false;
|
return false;
|
||||||
if (m_q->whatDb()) {
|
if (m_q->whatDb()) {
|
||||||
return m_q->getFirstMatchPage(doc, term);
|
return m_q->getFirstMatchPage(doc, term);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -136,7 +137,7 @@ list<string> DocSequenceDb::expand(Rcl::Doc &doc)
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> locker(o_dblock);
|
std::unique_lock<std::mutex> locker(o_dblock);
|
||||||
if (!setQuery())
|
if (!setQuery())
|
||||||
return list<string>();
|
return list<string>();
|
||||||
vector<string> v = m_q->expand(doc);
|
vector<string> v = m_q->expand(doc);
|
||||||
return list<string>(v.begin(), v.end());
|
return list<string>(v.begin(), v.end());
|
||||||
}
|
}
|
||||||
@ -145,58 +146,58 @@ string DocSequenceDb::title()
|
|||||||
{
|
{
|
||||||
string qual;
|
string qual;
|
||||||
if (m_isFiltered && !m_isSorted)
|
if (m_isFiltered && !m_isSorted)
|
||||||
qual = string(" (") + o_filt_trans + string(")");
|
qual = string(" (") + o_filt_trans + string(")");
|
||||||
else if (!m_isFiltered && m_isSorted)
|
else if (!m_isFiltered && m_isSorted)
|
||||||
qual = string(" (") + o_sort_trans + string(")");
|
qual = string(" (") + o_sort_trans + string(")");
|
||||||
else if (m_isFiltered && m_isSorted)
|
else if (m_isFiltered && m_isSorted)
|
||||||
qual = string(" (") + o_sort_trans + string(",") + o_filt_trans +
|
qual = string(" (") + o_sort_trans + string(",") + o_filt_trans +
|
||||||
string(")");
|
string(")");
|
||||||
return DocSequence::title() + qual;
|
return DocSequence::title() + qual;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
|
bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
|
||||||
{
|
{
|
||||||
LOGDEB("DocSequenceDb::setFiltSpec\n" );
|
LOGDEB("DocSequenceDb::setFiltSpec\n");
|
||||||
std::unique_lock<std::mutex> locker(o_dblock);
|
std::unique_lock<std::mutex> locker(o_dblock);
|
||||||
if (fs.isNotNull()) {
|
if (fs.isNotNull()) {
|
||||||
// We build a search spec by adding a filtering layer to the base one.
|
// We build a search spec by adding a filtering layer to the base one.
|
||||||
m_fsdata = std::shared_ptr<Rcl::SearchData>(
|
m_fsdata = std::shared_ptr<Rcl::SearchData>(
|
||||||
new Rcl::SearchData(Rcl::SCLT_AND, m_sdata->getStemLang()));
|
new Rcl::SearchData(Rcl::SCLT_AND, m_sdata->getStemLang()));
|
||||||
Rcl::SearchDataClauseSub *cl =
|
Rcl::SearchDataClauseSub *cl =
|
||||||
new Rcl::SearchDataClauseSub(m_sdata);
|
new Rcl::SearchDataClauseSub(m_sdata);
|
||||||
m_fsdata->addClause(cl);
|
m_fsdata->addClause(cl);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < fs.crits.size(); i++) {
|
for (unsigned int i = 0; i < fs.crits.size(); i++) {
|
||||||
switch (fs.crits[i]) {
|
switch (fs.crits[i]) {
|
||||||
case DocSeqFiltSpec::DSFS_MIMETYPE:
|
case DocSeqFiltSpec::DSFS_MIMETYPE:
|
||||||
m_fsdata->addFiletype(fs.values[i]);
|
m_fsdata->addFiletype(fs.values[i]);
|
||||||
break;
|
break;
|
||||||
case DocSeqFiltSpec::DSFS_QLANG:
|
case DocSeqFiltSpec::DSFS_QLANG:
|
||||||
{
|
{
|
||||||
if (!m_q)
|
if (!m_q)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
string reason;
|
string reason;
|
||||||
Rcl::SearchData *sd =
|
Rcl::SearchData *sd =
|
||||||
wasaStringToRcl(m_q->whatDb()->getConf(),
|
wasaStringToRcl(m_q->whatDb()->getConf(),
|
||||||
m_sdata->getStemLang(),
|
m_sdata->getStemLang(),
|
||||||
fs.values[i], reason);
|
fs.values[i], reason);
|
||||||
if (sd) {
|
if (sd) {
|
||||||
Rcl::SearchDataClauseSub *cl1 =
|
Rcl::SearchDataClauseSub *cl1 =
|
||||||
new Rcl::SearchDataClauseSub(
|
new Rcl::SearchDataClauseSub(
|
||||||
std::shared_ptr<Rcl::SearchData>(sd));
|
std::shared_ptr<Rcl::SearchData>(sd));
|
||||||
m_fsdata->addClause(cl1);
|
m_fsdata->addClause(cl1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_isFiltered = true;
|
m_isFiltered = true;
|
||||||
} else {
|
} else {
|
||||||
m_fsdata = m_sdata;
|
m_fsdata = m_sdata;
|
||||||
m_isFiltered = false;
|
m_isFiltered = false;
|
||||||
}
|
}
|
||||||
m_needSetQuery = true;
|
m_needSetQuery = true;
|
||||||
return true;
|
return true;
|
||||||
@ -204,14 +205,15 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
|
|||||||
|
|
||||||
bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec)
|
bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec)
|
||||||
{
|
{
|
||||||
LOGDEB("DocSequenceDb::setSortSpec: fld [" << (spec.field) << "] " << (spec.desc ? "desc" : "asc") << "\n" );
|
LOGDEB("DocSequenceDb::setSortSpec: fld [" << spec.field << "] " <<
|
||||||
|
(spec.desc ? "desc" : "asc") << "\n");
|
||||||
std::unique_lock<std::mutex> locker(o_dblock);
|
std::unique_lock<std::mutex> locker(o_dblock);
|
||||||
if (spec.isNotNull()) {
|
if (spec.isNotNull()) {
|
||||||
m_q->setSortBy(spec.field, !spec.desc);
|
m_q->setSortBy(spec.field, !spec.desc);
|
||||||
m_isSorted = true;
|
m_isSorted = true;
|
||||||
} else {
|
} else {
|
||||||
m_q->setSortBy(string(), true);
|
m_q->setSortBy(string(), true);
|
||||||
m_isSorted = false;
|
m_isSorted = false;
|
||||||
}
|
}
|
||||||
m_needSetQuery = true;
|
m_needSetQuery = true;
|
||||||
return true;
|
return true;
|
||||||
@ -220,14 +222,15 @@ bool DocSequenceDb::setSortSpec(const DocSeqSortSpec &spec)
|
|||||||
bool DocSequenceDb::setQuery()
|
bool DocSequenceDb::setQuery()
|
||||||
{
|
{
|
||||||
if (!m_needSetQuery)
|
if (!m_needSetQuery)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
m_needSetQuery = false;
|
m_needSetQuery = false;
|
||||||
m_rescnt = -1;
|
m_rescnt = -1;
|
||||||
m_lastSQStatus = m_q->setQuery(m_fsdata);
|
m_lastSQStatus = m_q->setQuery(m_fsdata);
|
||||||
if (!m_lastSQStatus) {
|
if (!m_lastSQStatus) {
|
||||||
m_reason = m_q->getReason();
|
m_reason = m_q->getReason();
|
||||||
LOGERR("DocSequenceDb::setQuery: rclquery::setQuery failed: " << (m_reason) << "\n" );
|
LOGERR("DocSequenceDb::setQuery: rclquery::setQuery failed: " <<
|
||||||
|
m_reason << "\n");
|
||||||
}
|
}
|
||||||
return m_lastSQStatus;
|
return m_lastSQStatus;
|
||||||
}
|
}
|
||||||
@ -236,9 +239,9 @@ bool DocSequenceDb::docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
|
|||||||
{
|
{
|
||||||
if (m_q->whatDb()) {
|
if (m_q->whatDb()) {
|
||||||
std::unique_lock<std::mutex> locker(o_dblock);
|
std::unique_lock<std::mutex> locker(o_dblock);
|
||||||
return m_q->whatDb()->docDups(doc, dups);
|
return m_q->whatDb()->docDups(doc, dups);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,9 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef _DOCSEQDB_H_INCLUDED_
|
#ifndef _DOCSEQDB_H_INCLUDED_
|
||||||
#define _DOCSEQDB_H_INCLUDED_
|
#define _DOCSEQDB_H_INCLUDED_
|
||||||
#include "docseq.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "docseq.h"
|
||||||
#include "searchdata.h"
|
#include "searchdata.h"
|
||||||
#include "rclquery.h"
|
#include "rclquery.h"
|
||||||
|
|
||||||
@ -26,21 +27,22 @@
|
|||||||
class DocSequenceDb : public DocSequence {
|
class DocSequenceDb : public DocSequence {
|
||||||
public:
|
public:
|
||||||
DocSequenceDb(std::shared_ptr<Rcl::Db> db,
|
DocSequenceDb(std::shared_ptr<Rcl::Db> db,
|
||||||
std::shared_ptr<Rcl::Query> q, const string &t,
|
std::shared_ptr<Rcl::Query> q, const std::string &t,
|
||||||
std::shared_ptr<Rcl::SearchData> sdata);
|
std::shared_ptr<Rcl::SearchData> sdata);
|
||||||
virtual ~DocSequenceDb() {}
|
virtual ~DocSequenceDb() {}
|
||||||
virtual bool getDoc(int num, Rcl::Doc &doc, string * = 0);
|
virtual bool getDoc(int num, Rcl::Doc &doc, std::string * = 0);
|
||||||
virtual int getResCnt();
|
virtual int getResCnt();
|
||||||
virtual void getTerms(HighlightData& hld);
|
virtual void getTerms(HighlightData& hld);
|
||||||
|
|
||||||
// Called to fill-up the snippets window. Ignoers
|
// Called to fill-up the snippets window. Ignoers
|
||||||
// buildabstract/replaceabstract and syntabslen
|
// buildabstract/replaceabstract and syntabslen
|
||||||
virtual bool getAbstract(Rcl::Doc &doc, vector<Rcl::Snippet>&);
|
virtual bool getAbstract(Rcl::Doc &doc, std::vector<Rcl::Snippet>&,
|
||||||
|
int maxlen, bool sortbypage) override;
|
||||||
|
|
||||||
virtual bool getAbstract(Rcl::Doc &doc, vector<string>&);
|
virtual bool getAbstract(Rcl::Doc &doc, std::vector<std::string>&);
|
||||||
virtual int getFirstMatchPage(Rcl::Doc&, std::string& term);
|
virtual int getFirstMatchPage(Rcl::Doc&, std::string& term);
|
||||||
virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups);
|
virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups);
|
||||||
virtual string getDescription();
|
virtual std::string getDescription();
|
||||||
virtual std::list<std::string> expand(Rcl::Doc &doc);
|
virtual std::list<std::string> expand(Rcl::Doc &doc);
|
||||||
virtual bool canFilter() {return true;}
|
virtual bool canFilter() {return true;}
|
||||||
virtual bool setFiltSpec(const DocSeqFiltSpec &filtspec);
|
virtual bool setFiltSpec(const DocSeqFiltSpec &filtspec);
|
||||||
@ -56,7 +58,7 @@ class DocSequenceDb : public DocSequence {
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual string title();
|
virtual std::string title();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::shared_ptr<Rcl::Db> getDb() {
|
virtual std::shared_ptr<Rcl::Db> getDb() {
|
||||||
|
|||||||
@ -138,12 +138,14 @@ public:
|
|||||||
if (maxtermcount && termcount++ > maxtermcount) {
|
if (maxtermcount && termcount++ > maxtermcount) {
|
||||||
LOGINF("Rclabsfromtext: stopping because maxtermcount reached: "<<
|
LOGINF("Rclabsfromtext: stopping because maxtermcount reached: "<<
|
||||||
maxtermcount << endl);
|
maxtermcount << endl);
|
||||||
|
retflags |= ABSRES_TRUNC;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Also limit the number of fragments (just in case safety)
|
// Also limit the number of fragments (just in case safety)
|
||||||
if (m_fragments.size() > maxtermcount / 100) {
|
if (m_fragments.size() > maxtermcount / 100) {
|
||||||
LOGINF("Rclabsfromtext: stopping because maxfragments reached: "<<
|
LOGINF("Rclabsfromtext: stopping because maxfragments reached: "<<
|
||||||
maxtermcount/100 << endl);
|
maxtermcount/100 << endl);
|
||||||
|
retflags |= ABSRES_TRUNC;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Remember recent past
|
// Remember recent past
|
||||||
@ -326,6 +328,10 @@ public:
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getretflags() {
|
||||||
|
return retflags;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Past terms because we need to go back for context before a hit
|
// Past terms because we need to go back for context before a hit
|
||||||
@ -364,6 +370,7 @@ private:
|
|||||||
|
|
||||||
unsigned int termcount{0};
|
unsigned int termcount{0};
|
||||||
unsigned int maxtermcount{0};
|
unsigned int maxtermcount{0};
|
||||||
|
int retflags{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
int Query::Native::abstractFromText(
|
int Query::Native::abstractFromText(
|
||||||
@ -375,7 +382,8 @@ int Query::Native::abstractFromText(
|
|||||||
int ctxwords,
|
int ctxwords,
|
||||||
unsigned int maxtotaloccs,
|
unsigned int maxtotaloccs,
|
||||||
vector<Snippet>& vabs,
|
vector<Snippet>& vabs,
|
||||||
Chrono& chron
|
Chrono& chron,
|
||||||
|
bool sortbypage
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
(void)chron;
|
(void)chron;
|
||||||
@ -423,13 +431,21 @@ int Query::Native::abstractFromText(
|
|||||||
// Sort the fragments by decreasing weight
|
// Sort the fragments by decreasing weight
|
||||||
const vector<MatchFragment>& res1 = splitter.getFragments();
|
const vector<MatchFragment>& res1 = splitter.getFragments();
|
||||||
vector<MatchFragment> result(res1.begin(), res1.end());
|
vector<MatchFragment> result(res1.begin(), res1.end());
|
||||||
std::sort(result.begin(), result.end(),
|
if (sortbypage) {
|
||||||
[](const MatchFragment& a,
|
std::sort(result.begin(), result.end(),
|
||||||
const MatchFragment& b) -> bool {
|
[](const MatchFragment& a,
|
||||||
return a.coef > b.coef;
|
const MatchFragment& b) -> bool {
|
||||||
}
|
return a.hitpos < b.hitpos;
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
std::sort(result.begin(), result.end(),
|
||||||
|
[](const MatchFragment& a,
|
||||||
|
const MatchFragment& b) -> bool {
|
||||||
|
return a.coef > b.coef;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
vector<int> vpbreaks;
|
vector<int> vpbreaks;
|
||||||
ndb->getPagePositions(docid, vpbreaks);
|
ndb->getPagePositions(docid, vpbreaks);
|
||||||
|
|
||||||
@ -464,7 +480,7 @@ int Query::Native::abstractFromText(
|
|||||||
if (count++ >= maxtotaloccs)
|
if (count++ >= maxtotaloccs)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ABSRES_OK;
|
return ABSRES_OK | splitter.getretflags();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -623,11 +623,12 @@ int Query::Native::abstractFromIndex(
|
|||||||
// @param[out] vabs the abstract is returned as a vector of snippets.
|
// @param[out] vabs the abstract is returned as a vector of snippets.
|
||||||
int Query::Native::makeAbstract(Xapian::docid docid,
|
int Query::Native::makeAbstract(Xapian::docid docid,
|
||||||
vector<Snippet>& vabs,
|
vector<Snippet>& vabs,
|
||||||
int imaxoccs, int ictxwords)
|
int imaxoccs, int ictxwords, bool sortbypage)
|
||||||
{
|
{
|
||||||
chron.restart();
|
chron.restart();
|
||||||
LOGABS("makeAbstract: docid " << docid << " imaxoccs " <<
|
LOGDEB("makeAbstract: docid " << docid << " imaxoccs " <<
|
||||||
imaxoccs << " ictxwords " << ictxwords << "\n");
|
imaxoccs << " ictxwords " << ictxwords << " sort by page " <<
|
||||||
|
sortbypage << "\n");
|
||||||
|
|
||||||
// The (unprefixed) terms matched by this document
|
// The (unprefixed) terms matched by this document
|
||||||
vector<string> matchedTerms;
|
vector<string> matchedTerms;
|
||||||
@ -675,7 +676,7 @@ int Query::Native::makeAbstract(Xapian::docid docid,
|
|||||||
if (ndb->m_storetext) {
|
if (ndb->m_storetext) {
|
||||||
return abstractFromText(ndb, docid, matchedTerms, byQ,
|
return abstractFromText(ndb, docid, matchedTerms, byQ,
|
||||||
totalweight, ctxwords, maxtotaloccs, vabs,
|
totalweight, ctxwords, maxtotaloccs, vabs,
|
||||||
chron);
|
chron, sortbypage);
|
||||||
} else {
|
} else {
|
||||||
return abstractFromIndex(ndb, docid, matchedTerms, byQ,
|
return abstractFromIndex(ndb, docid, matchedTerms, byQ,
|
||||||
totalweight, ctxwords, maxtotaloccs, vabs,
|
totalweight, ctxwords, maxtotaloccs, vabs,
|
||||||
|
|||||||
@ -267,7 +267,7 @@ bool Query::getQueryTerms(vector<string>& terms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Query::makeDocAbstract(const Doc &doc, vector<Snippet>& abstract,
|
int Query::makeDocAbstract(const Doc &doc, vector<Snippet>& abstract,
|
||||||
int maxoccs, int ctxwords)
|
int maxoccs, int ctxwords, bool sortbypage)
|
||||||
{
|
{
|
||||||
LOGDEB("makeDocAbstract: maxoccs " << maxoccs << " ctxwords " <<
|
LOGDEB("makeDocAbstract: maxoccs " << maxoccs << " ctxwords " <<
|
||||||
ctxwords << "\n");
|
ctxwords << "\n");
|
||||||
@ -276,7 +276,7 @@ int Query::makeDocAbstract(const Doc &doc, vector<Snippet>& abstract,
|
|||||||
return ABSRES_ERROR;
|
return ABSRES_ERROR;
|
||||||
}
|
}
|
||||||
int ret = ABSRES_ERROR;
|
int ret = ABSRES_ERROR;
|
||||||
XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords),
|
XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords, sortbypage),
|
||||||
m_db->m_ndb->xrdb, m_reason);
|
m_db->m_ndb->xrdb, m_reason);
|
||||||
if (!m_reason.empty()) {
|
if (!m_reason.empty()) {
|
||||||
LOGDEB("makeDocAbstract: makeAbstract: reason: " << m_reason << "\n");
|
LOGDEB("makeDocAbstract: makeAbstract: reason: " << m_reason << "\n");
|
||||||
|
|||||||
@ -107,7 +107,7 @@ public:
|
|||||||
bool makeDocAbstract(const Doc &doc, std::vector<std::string>& abstract);
|
bool makeDocAbstract(const Doc &doc, std::vector<std::string>& abstract);
|
||||||
// Returned as a vector of pair<page,snippet> page is 0 if unknown
|
// Returned as a vector of pair<page,snippet> page is 0 if unknown
|
||||||
int makeDocAbstract(const Doc &doc, std::vector<Snippet>& abst,
|
int makeDocAbstract(const Doc &doc, std::vector<Snippet>& abst,
|
||||||
int maxoccs= -1, int ctxwords = -1);
|
int maxoccs= -1, int ctxwords = -1, bool sortbypage=false);
|
||||||
/** Retrieve page number for first match for "significant" query term
|
/** Retrieve page number for first match for "significant" query term
|
||||||
* @param term returns the chosen term */
|
* @param term returns the chosen term */
|
||||||
int getFirstMatchPage(const Doc &doc, std::string& term);
|
int getFirstMatchPage(const Doc &doc, std::string& term);
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public:
|
|||||||
/** Return a list of terms which matched for a specific result document */
|
/** Return a list of terms which matched for a specific result document */
|
||||||
bool getMatchTerms(unsigned long xdocid, std::vector<std::string>& terms);
|
bool getMatchTerms(unsigned long xdocid, std::vector<std::string>& terms);
|
||||||
int makeAbstract(Xapian::docid id, std::vector<Snippet>&,
|
int makeAbstract(Xapian::docid id, std::vector<Snippet>&,
|
||||||
int maxoccs = -1, int ctxwords = -1);
|
int maxoccs, int ctxwords, bool sortbypage);
|
||||||
int getFirstMatchPage(Xapian::docid docid, std::string& term);
|
int getFirstMatchPage(Xapian::docid docid, std::string& term);
|
||||||
void setDbWideQTermsFreqs();
|
void setDbWideQTermsFreqs();
|
||||||
double qualityTerms(Xapian::docid docid,
|
double qualityTerms(Xapian::docid docid,
|
||||||
@ -109,7 +109,8 @@ public:
|
|||||||
int ctxwords,
|
int ctxwords,
|
||||||
unsigned int maxtotaloccs,
|
unsigned int maxtotaloccs,
|
||||||
vector<Snippet>& vabs,
|
vector<Snippet>& vabs,
|
||||||
Chrono& chron
|
Chrono& chron,
|
||||||
|
bool sortbypage
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user