suggest alternate spellings if no results
This commit is contained in:
@@ -123,6 +123,11 @@ class DocSequence {
|
||||
{
|
||||
terms.clear(); groups.clear(); gslks.clear(); return true;
|
||||
}
|
||||
/** Get user-input terms (before stemming etc.) */
|
||||
virtual void getUTerms(vector<string>& terms)
|
||||
{
|
||||
terms.clear();
|
||||
}
|
||||
virtual list<string> expand(Rcl::Doc &) {return list<string>();}
|
||||
|
||||
/** Optional functionality. Yeah, not nice */
|
||||
@@ -159,6 +164,10 @@ public:
|
||||
{
|
||||
return m_seq->getTerms(terms, groups, gslks);
|
||||
}
|
||||
virtual void getUTerms(vector<string>& terms)
|
||||
{
|
||||
m_seq->getUTerms(terms);
|
||||
}
|
||||
|
||||
protected:
|
||||
RefCntr<DocSequence> m_seq;
|
||||
|
||||
@@ -45,6 +45,11 @@ bool DocSequenceDb::getTerms(vector<string>& terms,
|
||||
return m_fsdata->getTerms(terms, groups, gslks);
|
||||
}
|
||||
|
||||
void DocSequenceDb::getUTerms(vector<string>& terms)
|
||||
{
|
||||
m_sdata->getUTerms(terms);
|
||||
}
|
||||
|
||||
string DocSequenceDb::getDescription()
|
||||
{
|
||||
return m_fsdata->getDescription();
|
||||
|
||||
@@ -35,6 +35,7 @@ class DocSequenceDb : public DocSequence {
|
||||
virtual bool getTerms(vector<string>& terms,
|
||||
vector<vector<string> >& groups,
|
||||
vector<int>& gslks);
|
||||
virtual void getUTerms(vector<string>& terms);
|
||||
virtual string getAbstract(Rcl::Doc &doc);
|
||||
virtual bool getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc);
|
||||
virtual string getDescription();
|
||||
|
||||
@@ -98,6 +98,22 @@ void ResListPager::displayPage()
|
||||
|
||||
if (pageEmpty()) {
|
||||
chunk += trans("<p><b>No results found</b><br>");
|
||||
vector<string>uterms;
|
||||
m_docSource->getUTerms(uterms);
|
||||
if (!uterms.empty()) {
|
||||
vector<string> spellings;
|
||||
suggest(uterms, spellings);
|
||||
if (!spellings.empty()) {
|
||||
chunk +=
|
||||
trans("<p><i>Alternate spellings (accents suppressed): </i>");
|
||||
for (vector<string>::iterator it = spellings.begin();
|
||||
it != spellings.end(); it++) {
|
||||
chunk += *it;
|
||||
chunk += " ";
|
||||
}
|
||||
chunk += "</p>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unsigned int resCnt = m_docSource->getResCnt();
|
||||
if (m_winfirst + m_respage.size() < resCnt) {
|
||||
|
||||
@@ -67,6 +67,9 @@ public:
|
||||
virtual string prevUrl();
|
||||
virtual string pageTop() {return string();}
|
||||
virtual string iconPath(const string& mtype);
|
||||
virtual void suggest(const vector<string>, vector<string>&sugg) {
|
||||
sugg.clear();
|
||||
}
|
||||
private:
|
||||
void initall()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user