SpellCorrectWord - Maple Help

Home : Support : Online Help : Education : EssayTools : SpellCorrectWord

EssayTools

 SpellCorrectWord
 correct the spelling of a given word

 Calling Sequence SpellCorrectWord( word ) SpellCorrectWord( word, wordlist )

Parameters

 word - string wordlist - (optional) ordered list or array of strings

Description

 • The SpellCorrectWord command will try to return a word that closely matches the spelling of the given word.   If it cannot find a close match it will return the given word; otherwise, the word returned will be from the internal word list or from the wordlist provided.
 • In many cases there are many candidates for a misspelled word that are equally good.  This command picks the first of these candidates to be returned.  Priority will be given to the first equal candidate found in the wordlist when provided.
 • The optional wordlist is a group of words that either extends the dictionary or provides context as to which words are likely to appear. For example, "snak" will normally be corrected to "sank", but if the context is a group of essays on wild animals in which the word "snake" frequently appears, an ordered list generated from those essays will lead to a more appropriate correction.
 • A near match is found if a single character deletion, character replacement, character insertion, or transposition of characters results in a word found in the internal word list.  Matching when an optional short-list of words is provided is done by computing the Levenshtein distance between the given word to each word in the short-list, and returning the best match provided it is a sufficiently close match.
 • This function is part of the EssayTools package, so it can be used in the short form SpellCorrectWord(..) only after executing the command with(EssayTools). However, it can always be accessed through the long form of the command by using EssayTools[SpellCorrectWord](..).

Examples

 > $\mathrm{with}\left(\mathrm{EssayTools}\right)$
 $\left[{\mathrm{AppendToWordList}}{,}{\mathrm{BinaryCosineCoefficient}}{,}{\mathrm{BinaryDiceCoefficient}}{,}{\mathrm{BinaryJaccardCoefficient}}{,}{\mathrm{BuildScoreModel}}{,}{\mathrm{CosineCoefficient}}{,}{\mathrm{CountMisspellings}}{,}{\mathrm{CountUseOfAllWords}}{,}{\mathrm{CountUseOfEachWord}}{,}{\mathrm{DetectPlagiarism}}{,}{\mathrm{DiceCoefficient}}{,}{\mathrm{GetWordList}}{,}{\mathrm{GetWordTable}}{,}{\mathrm{IsAdjective}}{,}{\mathrm{IsAdverb}}{,}{\mathrm{IsConjunction}}{,}{\mathrm{IsDefiniteArticle}}{,}{\mathrm{IsIndefiniteArticle}}{,}{\mathrm{IsInterjection}}{,}{\mathrm{IsIntransitiveVerb}}{,}{\mathrm{IsNominative}}{,}{\mathrm{IsNoun}}{,}{\mathrm{IsNounPhrase}}{,}{\mathrm{IsPlural}}{,}{\mathrm{IsPreposition}}{,}{\mathrm{IsPronoun}}{,}{\mathrm{IsTransitiveVerb}}{,}{\mathrm{IsUsuallyParticipleVerb}}{,}{\mathrm{IsVerb}}{,}{\mathrm{JaccardCoefficient}}{,}{\mathrm{Lemma}}{,}{\mathrm{Misspellings}}{,}{\mathrm{PartOfSpeech}}{,}{\mathrm{QuadraticWeightedKappa}}{,}{\mathrm{Reduce}}{,}{\mathrm{Score}}{,}{\mathrm{SetWordList}}{,}{\mathrm{SimilarityScore}}{,}{\mathrm{SpellCorrectWord}}{,}{\mathrm{WordUse}}\right]$ (1)
 > $\mathrm{SpellCorrectWord}\left("snak"\right)$
 ${"sank"}$ (2)
 > $\mathrm{SpellCorrectWord}\left("snak",\left["animal","river","snake"\right]\right)$
 ${"snake"}$ (3)
 > $\mathrm{SpellCorrectWord}\left("nothingclose"\right)$
 ${"nothingclose"}$ (4)
 > $\mathrm{sentence}≔"It is rahter dangeros to automagically appli corections"$
 ${\mathrm{sentence}}{≔}{"It is rahter dangeros to automagically appli corections"}$ (5)
 > $\mathrm{mwords}≔\mathrm{Misspellings}\left(\mathrm{sentence}\right)$
 ${\mathrm{mwords}}{≔}\left[{"rahter"}{,}{"dangeros"}{,}{"automagically"}{,}{"appli"}{,}{"corections"}\right]$ (6)
 > $\mathrm{corrections}≔\left[\mathrm{seq}\left(w=\mathrm{SpellCorrectWord}\left(w\right),w\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{mwords}\right)\right]$
 ${\mathrm{corrections}}{≔}\left[{"rahter"}{=}{"rafter"}{,}{"dangeros"}{=}{"dangers"}{,}{"automagically"}{=}{"automatically"}{,}{"appli"}{=}{"apple"}{,}{"corections"}{=}{"corrections"}\right]$ (7)
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}c\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{corrections}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{sentence}≔\mathrm{StringTools}:-\mathrm{SubstituteAll}\left(\mathrm{sentence},\mathrm{lhs}\left(c\right),\mathrm{rhs}\left(c\right)\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{print}\left(\mathrm{sentence}\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$
 ${"It is rafter dangeros to automagically appli corections"}$
 ${"It is rafter dangers to automagically appli corections"}$
 ${"It is rafter dangers to automatically appli corections"}$
 ${"It is rafter dangers to automatically apple corections"}$
 ${"It is rafter dangers to automatically apple corrections"}$ (8)
 > $\mathrm{sentence}$
 ${"It is rafter dangers to automatically apple corrections"}$ (9)

Compatibility

 • The EssayTools[SpellCorrectWord] command was introduced in Maple 17.