edu.northwestern.at.utils.spellcheck

## Interface SpellingChecker

- All Known Implementing Classes:
    SimpleMindedSpellingChecker, TernaryTrieBasedSpellingChecker

      public interface SpellingChecker

  SpellingChecker -- interface for spelling checkers.

  This interface defines methods useful when constructing a spelling checker in an application. The interface provides for looking up words in two persistent dictionaries, a global dictionary shared among many users, and a local dictionary specific to an individual. An individual use can also add words to a transient "ignore" cache which contains words which should be ignored during the course of spell checking a specific document.

  A typical SpellingChecker implementation might store the dictionaries in a file or a database. Usually some kind of hash code is stored along with each word in the dictionary to support the notion of spelling correction. For example, an English dictionary might store the soundex or metaphone code for each word in the dictionary to ease production of a list of correctly spelled alternatives to a misspelled word.

  Assuming an implementation called "MySpellingChecker", a sample sequence to spelling check a word might go as follows.

  `MySpellingChecker myChecker = new MySpellingChecker( new FileBasedSpellingDictionary( "global.english" ) , new FileBasedSpellingDictionary( "user.english" ) ); ... if ( !myChecker.checkSpelling( someWord ) ) { String[] suggestions = myChecker.suggest( someWord ); // Show list of suggestions, etc. }`

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addWordToGlobalDictionary(java.lang.String word)` Add a word to the global dictionary.
    `boolean` | `addWordToIgnoreList(java.lang.String word)` Add word to ignore list.
    `boolean` | `addWordToLocalDictionary(java.lang.String word)` Add a word to the local dictionary.
    `boolean` | `checkSpelling(java.lang.String word)` Check spelling of word.
    `void` | `emptyIgnoreList()` Empties the ignore list.
    `java.lang.String[]` | `suggest(java.lang.String word)` Suggest alternative words for misspelled item.
    `void` | `useGlobalDictionary(SpellingDictionary dictionary)` Select global dictionary to use to check spelling.
    `void` | `useLocalDictionary(SpellingDictionary dictionary)` Select local dictionary to use to check spelling.

- - ### Method Detail

    - #### useGlobalDictionary

          void useGlobalDictionary(SpellingDictionary dictionary)

      Select global dictionary to use to check spelling.
      Parameters:
        `dictionary` - Identifies global dictionary, a class implementing the SpellingDictionary interface. If the name is null, no global dictionary is used.

        The global dictionary is usually shared among many users. Typically it is created by a system administrator as a shareable resource.

    - #### useLocalDictionary

          void useLocalDictionary(SpellingDictionary dictionary)

      Select local dictionary to use to check spelling.
      Parameters:
        `dictionary` - Identifies local dictionary, a class implementing the SpellingDictionary interface. If the name is null, no local dictionary is used.

        The local dictionary is usually limited to access by a single individual. The local dictionary generally contains words added by an individual while checking the spelling of one or more documents.

    - #### checkSpelling

          boolean checkSpelling(java.lang.String word)

      Check spelling of word.
      Parameters:
        `word` - The word whose spelling should be checked.
      Returns:
        True if the word was found in the global or local dictionaries.

    - #### suggest

          java.lang.String[] suggest(java.lang.String word)

      Suggest alternative words for misspelled item.
      Parameters:
        `word` - The misspelled word for which possible alternatives are desired.
      Returns:
        String array of correctly spelled words which are similar in some sense to the misspelled word.

        The suggested words are typically words which are similar in sound or spelling to the misspelled word. For English, an implementation might return all words with the same soundex or metaphone code as the misspelled word.

    - #### addWordToLocalDictionary

          boolean addWordToLocalDictionary(java.lang.String word)

      Add a word to the local dictionary.
      Parameters:
        `word` - The word to add to the local dictionary.
      Returns:
        True if word added successfully.

    - #### addWordToGlobalDictionary

          boolean addWordToGlobalDictionary(java.lang.String word)

      Add a word to the global dictionary.
      Parameters:
        `word` - The word to add to the global dictionary.
      Returns:
        True if word added successfully.

        Typically this function is retricted to system administrators.

    - #### addWordToIgnoreList

          boolean addWordToIgnoreList(java.lang.String word)

      Add word to ignore list.
      Parameters:
        `word` - Word to ignore.
      Returns:
        True if word successfully added to ignore list.

        The ignore list contains words which an individual marks as ignorable while checking the spelling of one of more documents. The ignore list is transient. If an ignored word is to persist across multiple spelling check sessions, the word should be added to the local dictionary.

    - #### emptyIgnoreList

          void emptyIgnoreList()

      Empties the ignore list.

      Removes all words from the ignore list. Typically this is invoked at the start of a spelling checker session for a new document.