suggest alternate spellings if no results

This commit is contained in:
dockes
2009-11-26 14:03:02 +00:00
parent 203e8a9f9d
commit f554960b9b
12 changed files with 248 additions and 66 deletions
+9
View File
@@ -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;
+5
View File
@@ -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();
+1
View File
@@ -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();
+16
View File
@@ -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) {
+3
View File
@@ -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()
{