UltimateSpell Class Library

Speller Constructor ()

Initializes a new instance of the Speller class without specifying a dictionary file.

[Visual Basic]
Overloads Public Sub New()
[C#]
public Speller();

Example

This sample shows how to instantiate this class without specifying a physical path to the dictionary file.

  // Create array lists for spell errors
  ArrayList spellErrors = new ArrayList();
  StringBuilder sbSpellErrors = new StringBuilder();
  
  // Create spell checker
  Speller speller = new Speller();
  
  // Check whether dictionary is in cache
  if (!speller.DictionaryInCache("your dictionary file"))
  {
      // Get words from your own dictionary source
      DataTable dt = GetWords("your dictionary file");
      foreach (DataRow dr in dt.Rows)
      {
          string word = dr[0].ToString();
          speller.AddWord(word);
      }
      
      // Write dictionary into cache
      speller.CacheDictionary("your dictionary file");
  }
  
  // Call spell check
  spellErrors = speller.SpellCheck("text to spell check");
  
  // Create a string in the form of misspelledWord,textIndex,type,suggestion1,suggestion2,...|misspelledWord,textIndex,type,suggestion1,suggestion2,...
  foreach (SpellError spellError in spellErrors)
  {
        sbSpellErrors.Append(spellError.MisspelledWord);
        sbSpellErrors.Append(",");
        sbSpellErrors.Append(spellError.TextIndex);
        sbSpellErrors.Append(",");
        sbSpellErrors.Append(Convert.ToInt32(spellError.Type).ToString());
        foreach (string suggestion in spellError.Suggestions)
        {
            sbSpellErrors.Append(",");
            sbSpellErrors.Append(suggestion);
        }
        sbSpellErrors.Append("|");
  }
  sbSpellErrors.Remove(sbSpellErrors.Length - 1, 1);

See Also

Speller Class | Karamasoft.WebControls.UltimateSpell Namespace | Speller Constructor Overload List