|
a/src/aspell/rclaspell.cpp |
|
b/src/aspell/rclaspell.cpp |
1 |
#ifndef TEST_RCLASPELL
|
1 |
#ifndef TEST_RCLASPELL
|
2 |
#ifndef lint
|
2 |
#ifndef lint
|
3 |
static char rcsid[] = "@(#$Id: rclaspell.cpp,v 1.3 2006-10-11 14:16:25 dockes Exp $ (C) 2006 J.F.Dockes";
|
3 |
static char rcsid[] = "@(#$Id: rclaspell.cpp,v 1.4 2006-10-11 16:09:45 dockes Exp $ (C) 2006 J.F.Dockes";
|
4 |
#endif
|
4 |
#endif
|
5 |
#ifdef HAVE_CONFIG_H
|
5 |
#ifdef HAVE_CONFIG_H
|
6 |
#include "autoconfig.h"
|
6 |
#include "autoconfig.h"
|
7 |
#endif
|
7 |
#endif
|
8 |
|
8 |
|
|
... |
|
... |
172 |
{
|
172 |
{
|
173 |
return path_cat(m_config->getConfDir(),
|
173 |
return path_cat(m_config->getConfDir(),
|
174 |
string("aspdict.") + m_lang + string(".rws"));
|
174 |
string("aspdict.") + m_lang + string(".rws"));
|
175 |
}
|
175 |
}
|
176 |
|
176 |
|
|
|
177 |
|
|
|
178 |
class AspExecPv : public ExecCmdProvide {
|
|
|
179 |
public:
|
|
|
180 |
string *m_input; // pointer to string used as input buffer to command
|
|
|
181 |
Rcl::TermIter *m_tit;
|
|
|
182 |
Rcl::Db &m_db;
|
|
|
183 |
AspExecPv(string *i, Rcl::TermIter *tit, Rcl::Db &db)
|
|
|
184 |
: m_input(i), m_tit(tit), m_db(db)
|
|
|
185 |
{}
|
|
|
186 |
void newData() {
|
|
|
187 |
while (m_db.termWalkNext(m_tit, *m_input)) {
|
|
|
188 |
// Filter out terms beginning with upper case (special stuff) and
|
|
|
189 |
// containing numbers
|
|
|
190 |
if (m_input->empty())
|
|
|
191 |
continue;
|
|
|
192 |
if ('A' <= m_input->at(0) && m_input->at(0) <= 'Z')
|
|
|
193 |
continue;
|
|
|
194 |
if (m_input->find_first_of("0123456789+-._@") != string::npos)
|
|
|
195 |
continue;
|
|
|
196 |
// Got a non-empty sort-of appropriate term, let's send it to
|
|
|
197 |
// aspell
|
|
|
198 |
m_input->append("\n");
|
|
|
199 |
return;
|
|
|
200 |
}
|
|
|
201 |
// End of data. Tell so. Exec will close cmd.
|
|
|
202 |
m_input->erase();
|
|
|
203 |
}
|
|
|
204 |
};
|
|
|
205 |
|
|
|
206 |
|
177 |
bool Aspell::buildDict(Rcl::Db &db, string &reason)
|
207 |
bool Aspell::buildDict(Rcl::Db &db, string &reason)
|
178 |
{
|
208 |
{
|
179 |
if (!ok())
|
209 |
if (!ok())
|
180 |
return false;
|
210 |
return false;
|
181 |
|
211 |
|
|
... |
|
... |
192 |
Rcl::TermIter *tit = db.termWalkOpen();
|
222 |
Rcl::TermIter *tit = db.termWalkOpen();
|
193 |
if (tit == 0) {
|
223 |
if (tit == 0) {
|
194 |
reason = "termWalkOpen failed\n";
|
224 |
reason = "termWalkOpen failed\n";
|
195 |
return false;
|
225 |
return false;
|
196 |
}
|
226 |
}
|
197 |
string allterms, term;
|
227 |
|
198 |
while (db.termWalkNext(tit, term)) {
|
228 |
string termbuf;
|
199 |
// Filter out terms beginning with upper case (special stuff) and
|
229 |
AspExecPv pv(&termbuf, tit, db);
|
200 |
// containing numbers
|
230 |
aspell.setProvide(&pv);
|
201 |
if (term.empty())
|
231 |
|
202 |
continue;
|
232 |
if (aspell.doexec(m_data->m_exec, args, &termbuf)) {
|
203 |
if ('A' <= term.at(0) && term.at(0) <= 'Z')
|
233 |
reason = string("aspell dictionary creation command failed. Check the language data files for lang = ") + m_lang;
|
204 |
continue;
|
234 |
return false;
|
205 |
if (term.find_first_of("0123456789+-._@") != string::npos)
|
|
|
206 |
continue;
|
|
|
207 |
allterms += term + "\n";
|
|
|
208 |
// std::cout << "[" << term << "]" << std::endl;
|
|
|
209 |
}
|
235 |
}
|
210 |
db.termWalkClose(tit);
|
236 |
db.termWalkClose(tit);
|
211 |
if (aspell.doexec(m_data->m_exec, args, &allterms)) {
|
|
|
212 |
reason = string("aspell dictionary creation command failed. Check the language data files for lang = ") + m_lang;
|
|
|
213 |
return false;
|
|
|
214 |
}
|
|
|
215 |
return true;
|
237 |
return true;
|
216 |
}
|
238 |
}
|
217 |
|
239 |
|
218 |
|
240 |
|
219 |
bool Aspell::suggest(Rcl::Db &db,
|
241 |
bool Aspell::suggest(Rcl::Db &db,
|