* Spellcheck against multiple dictionaries? @ 2009-03-14 16:04 cmr.Pent 2009-03-18 19:36 ` cmr.Pent 0 siblings, 1 reply; 7+ messages in thread From: cmr.Pent @ 2009-03-14 16:04 UTC (permalink / raw To: help-gnu-emacs Hello Emacsists! I use Emacs almost daily, and one of the features I use frequently is ispell-word (M-$). I find the feature very nice, except for one thing: it seems to use only one (the "current") dictionary at a time. So, every time I'm spellchecking a word I must make sure the correct dictionary is selected, and if not, actually select it before hitting M-$. It is very inconvinient when working with multilingual text. Is there a nice way to let Emacs use multiple dictionaries for spellchecking? I think it is a very practical approach, especially if language character sets do not intersect (English/Russian for example). Thanks, Andrey Paramonov ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Spellcheck against multiple dictionaries? 2009-03-14 16:04 Spellcheck against multiple dictionaries? cmr.Pent @ 2009-03-18 19:36 ` cmr.Pent 0 siblings, 0 replies; 7+ messages in thread From: cmr.Pent @ 2009-03-18 19:36 UTC (permalink / raw To: help-gnu-emacs 2009/3/18 martin rudalics <rudalics@gmx.at>: > Privet, Andrey! > >> Is there a nice way to let Emacs use multiple dictionaries for >> spellchecking? I think it is a very practical approach, especially if >> language character sets do not intersect (English/Russian for >> example). > > I once wrote a mode to handle multiple dictionaries which you should be > able to find here > > http://www.emacswiki.org/emacs/SpeckMode > > Note, however, that it provides only flyspell-like behavior which means > it will eagerly check all text displayed in a window and not just > individual words in the lazy manner of ispell. Please give it a try, in > particular because I never had any feedback from Russian users ;-). If > it works and the flyspell-type behavior annoys you sufficiently, we can > think about implementing a more ispell-like behavior. > > Sincerely, martin. > Grüß Gott! I've downloaded speck.el file, but I'm not sure how do I use it. I've created a test file containing mixed correct and incorrect words, in Russian and English: Test тест correct очепятка incorect верно Then I've done M-x speck-mode. Emacs said that Speck-mode has been activated and is using "ru_RU" dictionary, but nothing has changed in the test buffer. From your description I was expecting that the incorrect words would be highlighted somehow. Am I missing something? I think that the ispell-ish behavior would indeed be nice. I've looked through the ispell code, and it looks like Emacs raises some kind of exception if the ispell process returns "invalid" status. Do you think it is possible to fallback to another dictionary on such an event? Andrey ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <49C09110.9010105@gmx.at>]
[parent not found: <5f0660120903181236g3714f647ia568e3d02ae4fe56@mail.gmail.com>]
* Re: Spellcheck against multiple dictionaries? [not found] ` <5f0660120903181236g3714f647ia568e3d02ae4fe56@mail.gmail.com> @ 2009-03-19 8:17 ` martin rudalics [not found] ` <mailman.3552.1237450712.31690.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 7+ messages in thread From: martin rudalics @ 2009-03-19 8:17 UTC (permalink / raw To: Андрей Парамонов Cc: help-gnu-emacs > I've downloaded speck.el file, but I'm not sure how do I use it. > > I've created a test file containing mixed correct and incorrect words, > in Russian and English: > > Test тест correct очепятка incorect верно > > Then I've done M-x speck-mode. Emacs said that Speck-mode has been > activated and is using ru_RU dictionary, but nothing has changed in > the test buffer. From your description I was expecting that the > incorrect words would be highlighted somehow. Am I missing something? I don't have a Russian spell-checking engine installed so I can't comment your example directly. Suppose I have a file with the line Test Test correct Duckfehler incorect richtig Doing M-x speck-mode here starts an Aspell process checking with my default language which is English, flagging the last three words as incorrect. I can now set the region around the word "Duckfehler" and type C-2 C-? to set the speck language text property of that word to German, which will still flag the word as incorrect but now with the appropriate German suggestions how to correct it. > I think that the ispell-ish behavior would indeed be nice. I've looked > through the ispell code, and it looks like Emacs raises some kind of > exception if the ispell process returns "invalid" status. Do you think > it is possible to fallback to another dictionary on such an event? With my Aspell engine I can write (and bind) a trivial command like (defun ispell-check-word (arg) (interactive "p") (if (= arg 2) (ispell-change-dictionary "de_DE") (ispell-change-dictionary "en_US")) (ispell-word)) here and probably get what you want. Note, however, that each time you change the language with this command, Emacs kills an old and spawns a new process of the Aspell engine. Changing `ispell-word' as you say seems hardly possible because in general there's no way to distinguish a word written incorrectly in language A from a word written correctly in language B. For the special English/Russian case you could probably investigate the character properties at `point' and spark the appropriate word-checking process. martin ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.3552.1237450712.31690.help-gnu-emacs@gnu.org>]
* Re: Spellcheck against multiple dictionaries? [not found] ` <mailman.3552.1237450712.31690.help-gnu-emacs@gnu.org> @ 2009-03-19 9:30 ` Sergei 2009-03-19 14:29 ` Miles Bader 0 siblings, 1 reply; 7+ messages in thread From: Sergei @ 2009-03-19 9:30 UTC (permalink / raw To: help-gnu-emacs ---- martin: >> I've downloaded speck.el file, but I'm not sure how do I use it. >> I've created a test file containing mixed correct and incorrect >> words, in Russian and English: >> Test тест correct очепятка incorect верно >> Then I've done M-x speck-mode. Emacs said that Speck-mode has been >> activated and is using ru_RU dictionary, but nothing has changed in >> the test buffer. From your description I was expecting that the >> incorrect words would be highlighted somehow. Am I missing >> something? I do not know about speck-mode, but at least ispell.el would pick up only what looks like a word in the currently enabled language; only such words are recoded according to the current ispell dictionary requirements and passed to the ispell process. This means that "Test" is skipped in the Russian mode (just like =%==!!.... etc); and conversely, очепятка and верно are skipped in a Latin-alphabet context. And this is really convenient. (While the users of Latin-alphabet languages should stumble at any foreign word.) > I don't have a Russian spell-checking engine installed so I can't > comment your example directly. Suppose I have a file with the line > Test Test correct Duckfehler incorect richtig > Doing M-x speck-mode here starts an Aspell process checking with my > default language which is English, flagging the last three words as > incorrect. I can now set the region around the word "Duckfehler" > and type C-2 C-? to set the speck language text property of that > word to German, which will still flag the word as incorrect but now > with the appropriate German suggestions how to correct it. There are some formal text (like html or xml) which allow for a language markup. Something like ,---- | correct <i lang="de">Duckfehler</i> incorect <i lang="de">richtig</ i> `---- >> I think that the ispell-ish behavior would indeed be nice. I've >> looked through the ispell code, and it looks like Emacs raises some >> kind of exception if the ispell process returns "invalid" >> status. Do you think it is possible to fallback to another >> dictionary on such an event? > With my Aspell engine I can write (and bind) a trivial command like > (defun ispell-check-word (arg) > (interactive "p") > (if (= arg 2) > (ispell-change-dictionary "de_DE") > (ispell-change-dictionary "en_US")) > (ispell-word)) > here and probably get what you want. Note, however, that each time you > change the language with this command, Emacs kills an old and spawns a > new process of the Aspell engine. Yes, because everything has to be changed: the filtering rules, the affix grammar, the word provision. > Changing `ispell-word' as you say seems hardly possible because in > general there's no way to distinguish a word written incorrectly in > language A from a word written correctly in language B. For the > special English/Russian case you could probably investigate the > character properties at `point' and spark the appropriate > word-checking process. In principle one could create a combined grammar for Russian and English; actually it would be a "direct sum" of the two grammars, as the word spaces are completely disjoint because the alphabets are disjoint. Such a combined processor exists in TeX for a combined English-Russian hyphenation. It would be more efficient too, because there would be no need to spawn a new process at every change from Russian to English. But presently it would be easier to use a two-pass approach: 1. check the Russian spelling (ignoring all Latin characters); 2. check the English spelling (ignoring all Cyrillic characters) Both passes are faster then in a switching mode -- and no extra work is required. Besides, you could spellcheck the Russian+French or Russian+German combinations (but not Russian+French+English, of course; while Russian+German+Armenian is still possible). -- Sergei ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Spellcheck against multiple dictionaries? 2009-03-19 9:30 ` Sergei @ 2009-03-19 14:29 ` Miles Bader 2009-03-19 15:34 ` Lennart Borgman [not found] ` <mailman.3577.1237476870.31690.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 7+ messages in thread From: Miles Bader @ 2009-03-19 14:29 UTC (permalink / raw To: help-gnu-emacs Potentially, it seems that you could keep multiple ispell processes around, and feed each word to _all_ active processes. To handle the results: If any process returns "correct", then a word would be considered correct, otherwise, perhaps the smallest correction list from any process would be presented to the user. -Miles -- Neighbor, n. One whom we are commanded to love as ourselves, and who does all he knows how to make us disobedient. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Spellcheck against multiple dictionaries? 2009-03-19 14:29 ` Miles Bader @ 2009-03-19 15:34 ` Lennart Borgman [not found] ` <mailman.3577.1237476870.31690.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 7+ messages in thread From: Lennart Borgman @ 2009-03-19 15:34 UTC (permalink / raw To: Miles Bader; +Cc: help-gnu-emacs On Thu, Mar 19, 2009 at 3:29 PM, Miles Bader <miles@gnu.org> wrote: > Potentially, it seems that you could keep multiple ispell processes > around, and feed each word to _all_ active processes. I think Peter Heslin implemented something like that here: http://www.dur.ac.uk/p.j.heslin/Software/Emacs/ (Wasn't there a discussion about getting this into Emacs? Or am I just dreaming?) ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.3577.1237476870.31690.help-gnu-emacs@gnu.org>]
* Re: Spellcheck against multiple dictionaries? [not found] ` <mailman.3577.1237476870.31690.help-gnu-emacs@gnu.org> @ 2009-03-20 19:54 ` cmr.Pent 0 siblings, 0 replies; 7+ messages in thread From: cmr.Pent @ 2009-03-20 19:54 UTC (permalink / raw To: help-gnu-emacs Hello! I'm the original thread starter. Thanks for your feedback. On 19 мар, 18:34, Lennart Borgman <lennart.borg...@gmail.com> wrote: > On Thu, Mar 19, 2009 at 3:29 PM, Miles Bader <mi...@gnu.org> wrote: > > Potentially, it seems that you could keep multiple ispell processes > > around, and feed each word to _all_ active processes. > > I think Peter Heslin implemented something like that here: > > http://www.dur.ac.uk/p.j.heslin/Software/Emacs/ > > (Wasn't there a discussion about getting this into Emacs? Or am I just > dreaming?) I've looked though ispell-multi.el, and indeed keeping several ispell processes would be nice for the approach I've tried to describe. But this is ultimately just details of implementation and not the feature I'm looking for. I've created a sketch of the desired functionality. Hope the code speaks better: (defun ispell-word-with-dictionary (dict) "Spellcheck word with given dictionary." (ispell-change-dictionary dict) (ispell-word)) (defun ispell-word-smart () "Spellcheck word with British or, if that failed, with Russian dictionary." (interactive) (condition-case nil (ispell-word-with-dictionary "british") (error (ispell-word-with-dictionary "russian")))) It required me to tweak the code in ispell.el for the feature to actually work: *** /home/pent/emacs/emacs/lisp/textmodes/ispell.el 2009-02-27 21:48:23.000000000 +0300 --- /home/pent/ispell.el 2009-03-20 22:16:25.000000000 +0300 *************** *** 1689,1695 **** (extent-at start) (and (fboundp 'delete-extent) (delete-extent (extent-at start))))) ! ((null poss) (message "Error in ispell process")) (ispell-check-only ; called from ispell minor mode. (if (fboundp 'make-extent) (if (fboundp 'set-extent-property) --- 1689,1695 ---- (extent-at start) (and (fboundp 'delete-extent) (delete-extent (extent-at start))))) ! ((null poss) (error "Error in ispell process")) (ispell-check-only ; called from ispell minor mode. (if (fboundp 'make-extent) (if (fboundp 'set-extent-property) Please note that the code above is just a prototype (i.e. it doesn't restore the original dictionary, the dictionaries are not customisable, ...). Do you think the idea is reasonable? Andrey Paramonov P.S: Perhaps I should post to emacs-devel? ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-03-20 19:54 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-03-14 16:04 Spellcheck against multiple dictionaries? cmr.Pent 2009-03-18 19:36 ` cmr.Pent [not found] <49C09110.9010105@gmx.at> [not found] ` <5f0660120903181236g3714f647ia568e3d02ae4fe56@mail.gmail.com> 2009-03-19 8:17 ` martin rudalics [not found] ` <mailman.3552.1237450712.31690.help-gnu-emacs@gnu.org> 2009-03-19 9:30 ` Sergei 2009-03-19 14:29 ` Miles Bader 2009-03-19 15:34 ` Lennart Borgman [not found] ` <mailman.3577.1237476870.31690.help-gnu-emacs@gnu.org> 2009-03-20 19:54 ` cmr.Pent
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.