Am 27.09.2010 um 13:58 schrieb Stephan Witt:

> Am 27.09.2010 um 13:50 schrieb Jürgen Spitzmüller:
> 
>> Stephan Witt wrote:
>>> As JMarc said we should try to strip the apostrophes ourself somehow.
>>> I'll think about it and propose a patch later.
>> 
>> But note that this is not correct in all cases (and we should look at what 
>> the 
>> spellcheckers really do before proceeding).
>> 
>> For example, a spell checker could, at least in theory, decide that the word 
>> rollin' is correct, while rollin is not. You might say that this is non-
>> standard English spelling, but I'm not sure you can say that a preceeding 
>> (or 
>> leading) apostrophe is non-standard in all languages we support.
> 
> Good point. It's similar to "ggf" and "ggf." in German.
> The problem is you cannot know how a spell checker implements this.
> Even more it may change from version to version of the engine.
> 
> Perhaps, the strategy with the "2nd try when failing" helps here too.

Like the attached patch. Would that be acceptable?

But this doesn't solve the "Ignore all" problem. The "Ignore all" button
calls Spellchecker::accept() and restarts at the current position. I think
it could help to go on like the "Ignore" button after adding the word to
the personal dictionary.

Stephan

Index: src/Paragraph.cpp
===================================================================
--- src/Paragraph.cpp   (Revision 35518)
+++ src/Paragraph.cpp   (Arbeitskopie)
@@ -3313,6 +3313,12 @@
 }
 
 
+bool Paragraph::isApostrophe(pos_type pos) const
+{
+       return pos >= 0 && pos < size() && d->text_[pos] == '\'';
+}
+
+
 void Paragraph::deregisterWords()
 {
        Private::LangWordsMap::const_iterator itl = d->words_.begin();
@@ -3527,6 +3533,18 @@
                                           word << "\" [" <<
                                           from << ".." << to << "]");
                                }
+                       } else if (SpellChecker::misspelled(result) &&
+                               (isApostrophe(from) || isApostrophe(to - 1)))
+                       {
+                               pos_type s1 = isApostrophe(from) ? 1 : 0;
+                               pos_type s2 = word.length() - (isApostrophe(to 
- 1) ? 1 : 0);
+                               wl = WordLangTuple(word.substr(s1, s2 - s1), 
lang);
+                               result = speller->check(wl);
+                               if (!SpellChecker::misspelled(result)) {
+                                       LYXERR(Debug::GUI, "misspelled word is 
correct without apostrophe: \"" <<
+                                                  word << "\" [" <<
+                                                  from << ".." << to << "]");
+                               }
                        }
                }
                d->setMisspelled(from, to, result);
Index: src/Paragraph.h
===================================================================
--- src/Paragraph.h     (Revision 35518)
+++ src/Paragraph.h     (Arbeitskopie)
@@ -379,6 +379,8 @@
        bool isNewline(pos_type pos) const;
        /// return true if the char is a word separator
        bool isSeparator(pos_type pos) const;
+       /// return true if the char is a apostrophe
+       bool isApostrophe(pos_type pos) const;
        ///
        bool isLineSeparator(pos_type pos) const;
        /// True if the character/inset at this point is a word separator.

Reply via email to