Here is a patch that will allow Aspell to learn from users mistakes when
used with LyX. All it does is store the replacement pairs when it
detects that aspell is being used instead of Ispell.
The current version of Aspell only keeps a log of replacements however
the next version of aspell will actually learn from them.
I would appreciate it if you could apply the patch to the 1.0 branch
because the change is minor. However I will understand if you think it
is two major of a change.
The patch is the diff with spellchecker.C as provided with
lyx-1.0.0pre2.
Please CC me as I am not normally on this list.
---
Kevin Atkinson
[EMAIL PROTECTED]
http://metalab.unc.edu/kevina/
*** spellchecker.C Fri Jun 26 11:12:53 1998
--- spellchecker.C.mine Sun Dec 27 22:27:22 1998
***************
*** 73,78 ****
--- 73,82 ----
pid_t isp_pid = -1; // pid for the `ispell' process. Also used (RO) in
// lyx_cb.C
+ // the true spell checker program being used
+ enum ActualSpellChecker {ASC_ISPELL, ASC_ASPELL};
+ static ActualSpellChecker actual_spell_checker;
+
static int isp_fd;
static FD_form_spell_options *fd_form_spell_options = NULL;
***************
*** 320,325 ****
--- 324,331 ----
/* Parent process: Read ispells identification message */
// Hmm...what are we using this id msg for? Nothing? (Lgb)
+ // Actaully I used it to tell is its trully Ispell or if its
+ // aspell -- ([EMAIL PROTECTED])
char buf[2048];
#ifdef WITH_WARNINGS
#warning verify that this works.
***************
*** 338,343 ****
--- 344,356 ----
// Ok, do the reading. We don't have to FD_ISSET since
// there is only one fd in infds.
fgets(buf, 2048, in);
+
+ // determine if the spell checker is really Aspell
+ if (strstr(buf, "Aspell"))
+ actual_spell_checker = ASC_ASPELL;
+ else
+ actual_spell_checker = ASC_ISPELL;
+
} else if (retval == 0) {
// timeout. Give nice message to user.
fprintf(stderr, "Ispell read timed out, what now?\n");
***************
*** 426,431 ****
--- 439,449 ----
static
inline void ispell_terminate()
{
+ // Note: If you decide to optimize this out when it is not
+ // needed please note that when Aspell is used this command
+ // is also needed to save the replacement dictionary.
+ // -- Kevin Atkinson ([EMAIL PROTECTED])
+
fputs("#\n", out); // Save personal dictionary
fflush(out);
***************
*** 457,462 ****
--- 475,491 ----
fputc('\n', out);
}
+ static
+ inline void ispell_store_replacement(const char *mis, LString const & cor) {
+ if(actual_spell_checker == ASC_ASPELL) {
+ fputs("$$ra ", out);
+ fputs(mis, out);
+ fputc(',', out);
+ fputs(cor.c_str(), out);
+ fputc('\n', out);
+ }
+ }
+
void ShowSpellChecker()
{
***************
*** 665,670 ****
--- 694,700 ----
}
if (obj==fd_form_spell_check->replace ||
obj==fd_form_spell_check->input) {
+ ispell_store_replacement(word,
+fl_get_input(fd_form_spell_check->input));
ReplaceWord(fl_get_input(fd_form_spell_check->input));
break;
}
***************
*** 673,678 ****
--- 703,709 ----
// sent to lyx@via by Mark Burton
<[EMAIL PROTECTED]>
if (clickline ==
fl_get_browser(fd_form_spell_check->browser)) {
+ ispell_store_replacement(word,
+fl_get_input(fd_form_spell_check->input));
ReplaceWord(fl_get_input(fd_form_spell_check->input));
break;
}