spell:suggest( $uri as xs:string*, $word as xs:string, [$options as (element()|map:map)?] ) as xs:string*
Suggests a list of spellings for a word. Returns a sequence of the most likely spellings for the specified word.
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.
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") :)
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") :)
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") :)
(: 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") :)
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.