/**
  * Checks whether the word is misspelled, by performing a series of checks according to properties
  * of the dictionary.
  *
  * <p>If the flag <code>fsa.dict.speller.ignore-punctuation</code> is set, then all non-alphabetic
  * characters are considered to be correctly spelled.
  *
  * <p>If the flag <code>fsa.dict.speller.ignore-numbers</code> is set, then all words containing
  * decimal digits are considered to be correctly spelled.
  *
  * <p>If the flag <code>fsa.dict.speller.ignore-camel-case</code> is set, then all CamelCase words
  * are considered to be correctly spelled.
  *
  * <p>If the flag <code>fsa.dict.speller.ignore-all-uppercase</code> is set, then all alphabetic
  * words composed of only uppercase characters are considered to be correctly spelled.
  *
  * <p>Otherwise, the word is checked in the dictionary. If the test fails, and the dictionary does
  * not perform any case conversions (as set by <code>fsa.dict.speller.convert-case</code> flag),
  * then the method returns false. In case of case conversions, it is checked whether a non-mixed
  * case word is found in its lowercase version in the dictionary, and for all-uppercase words,
  * whether the word is found in the dictionary with the initial uppercase letter.
  *
  * @param word - the word to be checked
  * @return true if the word is misspelled
  */
 public boolean isMisspelled(final String word) {
   // dictionaries usually do not contain punctuation
   String wordToCheck = word;
   if (!dictionaryMetadata.getInputConversionPairs().isEmpty()) {
     wordToCheck =
         DictionaryLookup.applyReplacements(word, dictionaryMetadata.getInputConversionPairs());
   }
   boolean isAlphabetic = wordToCheck.length() != 1 || isAlphabetic(wordToCheck.charAt(0));
   return wordToCheck.length() > 0
       && (!dictionaryMetadata.isIgnoringPunctuation() || isAlphabetic)
       && (!dictionaryMetadata.isIgnoringNumbers() || containsNoDigit(wordToCheck))
       && !(dictionaryMetadata.isIgnoringCamelCase() && isCamelCase(wordToCheck))
       && !(dictionaryMetadata.isIgnoringAllUppercase()
           && isAlphabetic
           && isAllUppercase(wordToCheck))
       && !isInDictionary(wordToCheck)
       && (!dictionaryMetadata.isConvertingCase()
           || !(!isMixedCase(wordToCheck)
               && (isInDictionary(wordToCheck.toLowerCase(dictionaryMetadata.getLocale()))
                   || isAllUppercase(wordToCheck)
                       && isInDictionary(initialUppercase(wordToCheck)))));
 }