This is a migrated thread and some comments may be shown as answers.

Server Side Spell Check - WordIgnoreOptions Bug?

2 Answers 45 Views
Spell
This is a migrated thread and some comments may be shown as answers.
Codey McCodesalot
Top achievements
Rank 1
Codey McCodesalot asked on 24 Oct 2009, 11:13 PM
RadSpell Version: 2009.2.701.20

I use a simple function to determine if any misspellings exist:

        public bool MispellingsExist()  
        {  
            SpellChecker spell = new SpellChecker(Server.MapPath("~/App_Data/RadSpell"));  
            spell.Text = Editor.Text;  
            spell.WordIgnoreOptions = WordIgnoreOptions.WordsWithNumbers | WordIgnoreOptions.RepeatedWords | WordIgnoreOptions.UPPERCASE;  
            spell.CheckText();  
            SpellCheckErrors errors = spell.Errors;  
            return errors.Count > 0;  
        } 

Using the code snippet above, consider the scenario where Editor.Text is equal to "We can meet on the 10th" without the quotes.  In this case the Errors collection is not empty.  It considers the "10th" as a misspelling.  Shouldn't this word be ignored based on my WordIgnoreOptions?

2 Answers, 1 is accepted

Sort by
0
Codey McCodesalot
Top achievements
Rank 1
answered on 27 Oct 2009, 12:17 AM
Ironic that my function name has a spelling error...  can someone else confirm that this is a bug?
0
Lini
Telerik team
answered on 27 Oct 2009, 09:11 AM
Hi,

The problem is that you set the text before you set the WordIgnoreOptions property. The spell checker will tokenize (split the text into words) as soon as you set the Text property. Since WordIgnoreOptions.WordsWithNumbers is not set then, it will also count the "10th" as a word. To fix the problem, reorder your code like this:

public bool MispellingsExist() 
    SpellChecker spell = new SpellChecker(Server.MapPath("~/App_Data/RadSpell")); 
    spell.WordIgnoreOptions = WordIgnoreOptions.WordsWithNumbers | WordIgnoreOptions.RepeatedWords | WordIgnoreOptions.UPPERCASE; 
    spell.Text = Editor.Text; 
    spell.CheckText(); 
    SpellCheckErrors errors = spell.Errors; 
    return errors.Count > 0; 
}

Best wishes,
Lini
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Spell
Asked by
Codey McCodesalot
Top achievements
Rank 1
Answers by
Codey McCodesalot
Top achievements
Rank 1
Lini
Telerik team
Share this question
or