This commit is contained in:
Jean-Francois Dockes
2017-04-18 14:39:12 +02:00
parent 9d8ce3df62
commit 9661a4431e
12 changed files with 147 additions and 141 deletions
-19
View File
@@ -40,9 +40,6 @@
#include "rclmain_w.h"
#include "ssearch_w.h"
#include "guiutils.h"
#ifdef RCL_USE_ASPELL
#include "rclaspell.h"
#endif
#include "smallut.h"
#include "readfile.h"
@@ -83,9 +80,6 @@ void deleteAllTempFiles()
Rcl::Db *rcldb;
#ifdef RCL_USE_ASPELL
Aspell *aspell;
#endif
int recollNeedsExit;
RclMain *mainWindow;
@@ -158,10 +152,6 @@ static void recollCleanup()
deleteAllTempFiles();
#ifdef RCL_USE_ASPELL
deleteZ(aspell);
#endif
LOGDEB2("recollCleanup: done\n" );
}
@@ -322,15 +312,6 @@ int main(int argc, char **argv)
// fprintf(stderr, "Translations installed\n");
#ifdef RCL_USE_ASPELL
aspell = new Aspell(theconfig);
aspell->init(reason);
if (!aspell || !aspell->ok()) {
LOGDEB("Aspell speller creation failed " << (reason) << "\n" );
aspell = 0;
}
#endif
string historyfile = path_cat(theconfig->getConfDir(), "history");
g_dynconf = new RclDynConf(historyfile);
if (!g_dynconf || !g_dynconf->ok()) {
-5
View File
@@ -46,11 +46,6 @@ extern void startManual(const string& helpindex);
extern void applyStyleSheet(const QString&);
#ifdef RCL_USE_ASPELL
class Aspell;
extern Aspell *aspell;
#endif
inline std::string qs2utf8s(const QString& qs)
{
return std::string((const char *)qs.toUtf8());
+1 -1
View File
@@ -2,7 +2,7 @@ TEMPLATE = app
LANGUAGE = C++
VPATH = @srcdir@
DEFINES += BUILDING_RECOLL
DEFINES += BUILDING_RECOLL TESTING_XAPIAN_SPELL
@QMAKE_ENABLE_WEBKIT@ QT += webkit
@QMAKE_DISABLE_WEBKIT@ QMAKE_CXXFLAGS += -DRESLIST_TEXTBROWSER -DSNIPPETS_TEXTBROWSER
+10 -30
View File
@@ -55,9 +55,6 @@
#include "reslist.h"
#include "moc_reslist.cpp"
#include "rclhelp.h"
#ifdef RCL_USE_ASPELL
#include "rclaspell.h"
#endif
#include "appformime.h"
#include "respopup.h"
@@ -201,53 +198,36 @@ void QtGuiResListPager::suggest(const vector<string>uterms,
map<string, vector<string> >& sugg)
{
sugg.clear();
#ifdef RCL_USE_ASPELL
bool noaspell = false;
theconfig->getConfParam("noaspell", &noaspell);
if (noaspell)
return;
if (!aspell) {
LOGERR("QtGuiResListPager:: aspell not initialized\n" );
return;
}
bool issimple = m_reslist && m_reslist->m_rclmain &&
m_reslist->m_rclmain->lastSearchSimple();
for (vector<string>::const_iterator uit = uterms.begin();
uit != uterms.end(); uit++) {
list<string> asuggs;
string reason;
for (const auto& uit : uterms) {
vector<string> tsuggs;
// If the term is in the dictionary, Aspell::suggest won't
// list alternatives. In fact we may want to check the
// frequencies and propose something anyway if a possible
// variation is much more common (as google does) ?
if (!aspell->suggest(*rcldb, *uit, asuggs, reason)) {
LOGERR("QtGuiResListPager::suggest: aspell failed: " << (reason) << "\n" );
if (!rcldb->getSpellingSuggestions(uit, tsuggs)) {
continue;
}
// We should check that the term stems differently from the
// base word (else it's not useful to expand the search). Or
// is it ? This should depend if stemming is turned on or not
if (!asuggs.empty()) {
sugg[*uit] = vector<string>(asuggs.begin(), asuggs.end());
if (sugg[*uit].size() > 5)
sugg[*uit].resize(5);
if (!tsuggs.empty()) {
sugg[uit] = vector<string>(tsuggs.begin(), tsuggs.end());
if (sugg[uit].size() > 5)
sugg[uit].resize(5);
// Set up the links as a <href="Sold|new">.
for (vector<string>::iterator it = sugg[*uit].begin();
it != sugg[*uit].end(); it++) {
for (auto& it : sugg[uit]) {
if (issimple) {
*it = string("<a href=\"S") + *uit + "|" + *it + "\">" +
*it + "</a>";
it = string("<a href=\"S") + uit + "|" + it + "\">" +
it + "</a>";
}
}
}
}
#endif
}
string QtGuiResListPager::iconUrl(RclConfig *config, Rcl::Doc& doc)
+10 -39
View File
@@ -47,10 +47,6 @@
#include "execmd.h"
#include "indexer.h"
#ifdef RCL_USE_ASPELL
#include "rclaspell.h"
#endif
using std::list;
using std::multimap;
using std::string;
@@ -64,14 +60,8 @@ void SpellW::init()
m_c2t.push_back(TYPECMB_REG);
expTypeCMB->addItem(tr("Stem expansion"));
m_c2t.push_back(TYPECMB_STEM);
#ifdef RCL_USE_ASPELL
bool noaspell = false;
theconfig->getConfParam("noaspell", &noaspell);
if (!noaspell) {
expTypeCMB->addItem(tr("Spelling/Phonetic"));
m_c2t.push_back(TYPECMB_ASPELL);
}
#endif
expTypeCMB->addItem(tr("Spelling/Phonetic"));
m_c2t.push_back(TYPECMB_SPELL);
expTypeCMB->addItem(tr("Show index statistics"));
m_c2t.push_back(TYPECMB_STATS);
@@ -189,37 +179,19 @@ void SpellW::doExpand()
break;
#ifdef RCL_USE_ASPELL
case TYPECMB_ASPELL:
case TYPECMB_SPELL:
{
LOGDEB("SpellW::doExpand: aspelling\n" );
if (!aspell) {
QMessageBox::warning(0, "Recoll",
tr("Aspell init failed. "
"Aspell not installed?"));
LOGDEB("SpellW::doExpand: aspell init error\n" );
return;
LOGDEB("SpellW::doExpand: spelling [" << expr << "]\n" );
vector<string> suggs;
if (!rcldb->getSpellingSuggestions(expr, suggs)) {
QMessageBox::warning(0, "Recoll", tr("Spell expansion error. "));
}
list<string> suggs;
if (!aspell->suggest(*rcldb, expr, suggs, reason)) {
QMessageBox::warning(0, "Recoll",
tr("Aspell expansion error. "));
LOGERR("SpellW::doExpand:suggest failed: " << (reason) << "\n" );
}
for (list<string>::const_iterator it = suggs.begin();
it != suggs.end(); it++)
res.entries.push_back(Rcl::TermMatchEntry(*it));
#ifdef TESTING_XAPIAN_SPELL
string rclsugg = rcldb->getSpellingSuggestion(expr);
if (!rclsugg.empty()) {
res.entries.push_back(Rcl::TermMatchEntry("Xapian spelling:"));
res.entries.push_back(Rcl::TermMatchEntry(rclsugg));
}
#endif // TESTING_XAPIAN_SPELL
for (const auto& it : suggs) {
res.entries.push_back(Rcl::TermMatchEntry(it));
}
statsLBL->setText(tr("%1 results").arg(res.entries.size()));
}
break;
#endif // RCL_USE_ASPELL
case TYPECMB_STATS:
{
@@ -229,7 +201,6 @@ void SpellW::doExpand()
break;
}
if (res.entries.empty()) {
resTW->setItem(0, 0, new QTableWidgetItem(tr("No expansion found")));
} else {
+4 -4
View File
@@ -14,8 +14,8 @@
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _ASPELL_W_H_INCLUDED_
#define _ASPELL_W_H_INCLUDED_
#ifndef _SPELL_W_H_INCLUDED_
#define _SPELL_W_H_INCLUDED_
#include <vector>
@@ -36,7 +36,7 @@ public:
virtual bool eventFilter(QObject *target, QEvent *event );
enum comboboxchoice {TYPECMB_NONE, TYPECMB_WILD, TYPECMB_REG, TYPECMB_STEM,
TYPECMB_ASPELL, TYPECMB_STATS};
TYPECMB_SPELL, TYPECMB_STATS};
public slots:
virtual void doExpand();
virtual void wordChanged(const QString&);
@@ -62,4 +62,4 @@ private:
void setModeCommon(comboboxchoice mode);
};
#endif /* _ASPELL_W_H_INCLUDED_ */
#endif /* _SPELL_W_H_INCLUDED_ */