The spelling functions are designed to help you manage dictionary documents in MarkLogic Server, to use those dictionaries to check if words are spelled correctly, and to suggest possible spellings for words that are not spelled correctly. The spelling function module is installed as the following file:
install_dir/Modules/MarkLogic/spell.xqy
where install_dir is the directory in which MarkLogic Server is installed.
install_dir
To use the spell.xqy module in your own XQuery modules, include the following line in your XQuery prolog:
spell.xqy
import module "http://marklogic.com/xdmp/spell" at "/MarkLogic/spell.xqy"
The library uses the spell: namespace, predefined in the server.
spell:
The spelling correction functions (spell:is-correct and spell:suggest) are built-in functions and do not require the import module statement in the XQuery prolog.
spell:is-correct
spell:suggest
import module
xquery version "0.9-ml" import module "http://marklogic.com/xdmp/spell" at "/MarkLogic/spell.xqy" spell:add-word("/mySpell/spell.xml", "WebDAV") => adds the word "WebDAV" to the specifed dictionary
xquery version "0.9-ml" import module "http://marklogic.com/xdmp/spell" at "/MarkLogic/spell.xqy" spell:insert("/mySpell/special.xml", <dictionary xmlns="http://marklogic.com/xdmp/spell"> <word>WebDAV</word> </dictionary> ) => Creates a dictionary with only the word "WebDAV" at the specifed URI
spell:is-correct("en-utf8.xml","occasionally") => true()
spell:load
xquery version "0.9-ml" import module "http://marklogic.com/xdmp/spell" at "/MarkLogic/spell.xqy" spell:load("c:\dictionaries\spell.xml", "/mySpell/spell.xml")
xquery version "0.9-ml" import module "http://marklogic.com/xdmp/spell" at "/MarkLogic/spell.xqy" spell:remove-word("/mySpell/spell.xml", "Fiat") => removes the word "Fiat" from the specified dictionary
spell:suggest("myDictionary.xml","occasionally") => ()
spell:suggest("spell.xml", "albetros") => albatross abettors alders alters Albert's Elbert's allegros alder's Walters abettor's