Server Side Spell Check - WordIgnoreOptions Bug?

3 posts, 0 answers
  1. Codey McCodesalot
    Codey McCodesalot avatar
    3 posts
    Member since:
    Jul 2009

    Posted 24 Oct 2009 Link to this post

    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. Codey McCodesalot
    Codey McCodesalot avatar
    3 posts
    Member since:
    Jul 2009

    Posted 26 Oct 2009 Link to this post

    Ironic that my function name has a spelling error...  can someone else confirm that this is a bug?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 27 Oct 2009 Link to this post

    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.
Back to Top