SpellCorrect
SpellCorrect(speller, word)
Returns a list of correct alternates for a word.
DISCUSSION
- speller
- The frame returned by the *
SpellDocBegin
function.
- word
- A string containing a word to correct.
- return value
- An array of strings containing correct alternates for word. The value
nil
or an empty array might also be returned if there are no alternates found.
This function first processes the word as described in "Processing of Words Passed to the Spell Checker". It then uses the resulting word to generate a list of possible correct alternates for the word. If it finds no alternates, it returns either
nil
or an empty array.The returned list contains up to 7 alternates, ordered by their similarity to the original word. Each alternate is punctuated as was the original word, and it is also capitalized like the original (unless fixing the capitalization was part of the problem), so the returned alternates can be directly substituted for the original word.
Note that *
SpellCorrect
can suggest alternates for correctly spelled words, even though it is normally used only for words that *SpellCheck
flagged as incorrect.The following examples provide an indication of the types of corrections that
*SpellCorrect
makes:
SpellCorrect(s, "bxnd") => ["band", "bend"...] // letter substitution
SpellCorrect(s, "baxnd") => ["band"] // letter deletion SpellCorrect(s, "bnd") => ["bond", "band"...] // letter insertion SpellCorrect(s, "ernie") => ["Ernie", "Renie"...] // capitalization SpellCorrect(s, "hisn't") => ["hasn't", "isn't"] // curly apostrophe preserved SpellCorrect(s, "(and.)") => ["(and.)", "(end.)"...] // punctuation preserved SpellCorrect(s, "looseends") => ["loose ends"] // words split SpellCorrect(s, "unfourtaneatly") => ["unfortunately"] // phonetic substitution SpellCorrect(s, "Shes") => ["She's", "Shoes"...] // case preserved SpellCorrect(s, "SHEP") => ["SHEEP", "SHIP"...] // case preserved
Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help