MarkLogic Server 11.0 Product Documentation
spell:suggest

spell:suggest(
   $uri as xs:string*,
   $word as xs:string,
   [$options as (element()|map:map)?]
) as xs:string*

Summary

Suggests a list of spellings for a word. Returns a sequence of 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. You can specify options as either an options XML element in the http://marklogic.com/xdmp/spell namespace, or as a map:map. The options names below are XML element localnames. When using a map, replace the hyphens with camel casing. For example, "an-option" becomes "anOption" when used as a map:map key. This function supports the following options:
maximum
Specifies the maximum number of suggestions to be returned. The default is 10.
distance-threshold
Specifies a cut off threshold for suggestions having a distance less than the given number. The default is 100. When passing a map option, the name of the key is distanceThreshold.

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

xquery version "1.0-ml";
spell:suggest("myDictionary.xml","occasionally")
 
(: Returns a sequence of suggestions such as the following, from the
 : dictionary with URI "myDictionary.xml":
 : 
 : ("occasionally", "occasional", "occasion", "occasions", "occasion's",
 :  "occasioned", "optionally", "educationally", "irrationally")
 :)

Example

xquery version "1.0-ml";
spell:suggest("spell.xml", "albetros")
  
(: Returns a sequence of suggestions such as the following, from the dictionary
 : with the URI "/dictionary.xml":
 :
 : ("albatross", "abettors", "alders", "alters", "Albert's", "Elbert's",
 :  "allegros", "alder's", "Walters", "abettor's")
 :)

Example

xquery version "1.0-ml";
spell:suggest("/dictionary.xml", "occasionally", 
  <options xmlns="http://marklogic.com/xdmp/spell">
    <distance-threshold>200</distance-threshold>
    <maximum>4</maximum>
  </options>)

(: Returns a sequence of suggestions such as: 
 :   ("occasionally", "occasional", "occasion", "occasions")
 :)

Example

(: pass options using a map :)
xquery version "1.0-ml";
spell:suggest(
  "/my/dictionary.xml", "occasionally", 
  map:map() => map:with("distanceThreshold", 200)
            => map:with("maximum", 4)
)

(: Returns a sequence of suggestions such as the following from the dictionary
 : with the URI "/my/dictionary.xml":
 :
 : ("occasionally", "occasional", "occasion", "occasions")
 :)
Powered by MarkLogic Server | Terms of Use | Privacy Policy