Am 22.07.2011 um 11:02 schrieb Stephan Witt:

> Am 22.07.2011 um 04:10 schrieb Richard Heck:
> 
>> On 07/21/2011 09:01 PM, Uwe Stöhr wrote:
>>> Am 21.07.2011 17:33, schrieb sw...@lyx.org:
>>> 
>>>> only aspell is using spellchecker_accept_compound rc variable
>>> 
>>> This should also be backported to branch. Richard?
>>> 
>> OK.
> 
> I'll do that. But I'm doing several changes in small steps currently.
> So, I'll want to discuss them at once.
> 
> The issues with aspell are:
> * accept_compound handling (r39360, r39361 and r39363)
> * misbehavior when hard hyphens are used
>  We changed LyX's word delimiter set - now hard hyphens are part of a word.
>  But aspell cannot work that way. It's impossible to add these words to the
>  list of valid words. See ticket 7660. I'll post a patch to discuss it later.

This patch works for me. But I'm not sure if it's too pragmatic.
It breaks up the word with hard hyphens and checks them separately.
If the check fails it is done again with hard hyphens removed.
That way one can add the word-conglomerate to personal dictionary.
Does anyone has another proposal?

Stephan

Index: src/AspellChecker.cpp
===================================================================
--- src/AspellChecker.cpp       (Revision 39363)
+++ src/AspellChecker.cpp       (Arbeitskopie)
@@ -19,6 +19,7 @@
 
 #include "support/lassert.h"
 #include "support/debug.h"
+#include "support/lstrings.h"
 #include "support/docstring_list.h"
 
 #include "support/filetools.h"
@@ -311,17 +312,36 @@
        return addSpeller(lang);
 }
 
- 
+
 string AspellChecker::Private::toAspellWord(docstring const & word) const
 {
-       return to_utf8(word);
+       size_t mpos;
+       string word_str = to_utf8(word);
+       while ((mpos = word_str.find('-')) != word_str.npos) {
+               word_str.erase(mpos, 1);
+       }
+       return word_str;
 }
 
- 
+
 SpellChecker::Result AspellChecker::Private::check(
        AspellSpeller * m, WordLangTuple const & word) 
        const
 {
+       SpellChecker::Result result = WORD_OK;
+       docstring w1;
+       docstring rest = split(word.word(), w1, '-');
+       for (; result == WORD_OK;) {
+               string const word_str = toAspellWord(w1);
+               int const word_ok = aspell_speller_check(m, word_str.c_str(), 
-1);
+               LASSERT(word_ok != -1, /**/);
+               result = (word_ok) ? WORD_OK : UNKNOWN_WORD;
+               if (rest.empty())
+                       break;
+               rest = split(rest,w1,'-');
+       }
+       if (result == WORD_OK)
+               return result;
        string const word_str = toAspellWord(word.word());
        int const word_ok = aspell_speller_check(m, word_str.c_str(), -1);
        LASSERT(word_ok != -1, /**/);

Reply via email to