GUI snippets window: add options for the max list length and for sorting the snippets by page number
This commit is contained in:
parent
049ba1e7e4
commit
736051fcd6
@ -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="text">
|
|
||||||
<string>Activate links in preview.</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Make links inside the preview window clickable, and start an external browser when they are clicked.</string>
|
<string>Make links inside the preview window clickable, and start an external browser when they are clicked.</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Activate links in preview.</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,7 +50,7 @@ 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) {
|
||||||
@ -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() {}
|
||||||
|
|
||||||
@ -101,19 +101,16 @@ class DocSequence {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,10 +152,11 @@ class DocSequence {
|
|||||||
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -186,63 +184,53 @@ public:
|
|||||||
{}
|
{}
|
||||||
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);
|
return m_seq->getAbstract(doc, abs, maxlen, bypage);
|
||||||
}
|
}
|
||||||
/** 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,14 +257,12 @@ public:
|
|||||||
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();
|
||||||
@ -290,4 +276,4 @@ private:
|
|||||||
DocSeqSortSpec m_sspec;
|
DocSeqSortSpec m_sspec;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _DOCSEQ_H_INCLUDED_ */
|
#endif /* _DOCSEQ_H_ */
|
||||||
|
|||||||
@ -76,21 +76,22 @@ 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;
|
||||||
}
|
}
|
||||||
@ -156,7 +157,7 @@ string DocSequenceDb::title()
|
|||||||
|
|
||||||
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.
|
||||||
@ -204,7 +205,8 @@ 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);
|
||||||
@ -227,7 +229,8 @@ bool DocSequenceDb::setQuery()
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
@ -327,6 +329,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
|
||||||
deque<pair<int,int>> m_prevterms;
|
deque<pair<int,int>> m_prevterms;
|
||||||
@ -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());
|
||||||
|
if (sortbypage) {
|
||||||
|
std::sort(result.begin(), result.end(),
|
||||||
|
[](const MatchFragment& a,
|
||||||
|
const MatchFragment& b) -> bool {
|
||||||
|
return a.hitpos < b.hitpos;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
std::sort(result.begin(), result.end(),
|
std::sort(result.begin(), result.end(),
|
||||||
[](const MatchFragment& a,
|
[](const MatchFragment& a,
|
||||||
const MatchFragment& b) -> bool {
|
const MatchFragment& b) -> bool {
|
||||||
return a.coef > b.coef;
|
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