Loading TOC...

MarkLogic 12 EA 2 Product Documentation
spell.suggest

spell.suggest(
   uri as String[],
   word as String,
   [options as Object?]
) as Sequence

Summary

Suggests a list of spellings for a word. Returns a Sequence containing the most likely spellings for the specified word.

Parameters
uri The URIs of the dictionaries to use.
word The word for which you get spelling suggestions.
options Options with which to customize this operation. This function supports the following options:
maximum
Specifies the maximum number of suggestions to be returned. The default is 10.
distanceThreshold
Specifies a cut off threshold for suggestions having a distance less than the given number. The default is 100.

Usage Notes

This function is a built-in function, so you need not import a library module to use it.

This function only provides suggestions to words that are less than 256 characters in length; words 256 characters or longer return no suggestions. Also, it removes any dictionary entries that are 256 characters or more, so it will never return a suggestion with greater than 256 characters.

Example

spell.suggest('myDictionary.xml','occasionally');

// Returns a Sequence containing suggestions such as the following,
// from the dictionary with URI "myDictionary.xml":
//
//   occasionally occasional occasion occasions occasion's
//   occasioned optionally educationally irrationally

Example

// Options usage
spell.suggest(
  '/my/dictionary.xml', 'occasionally', 
  { distanceThreshold: 200, maximum: 4}
);

// Returns a Sequence containing suggestions such as the following, from
// the dictionary with the URI "/my/dictionary.xml":
//
// "occasionally", "occasional", "occasion", "occasions"

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.