| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 6:00 AM | XQuery & XSLT Built-In & Modules Function Reference
Module: Spelling Dictionary Management
The spelling functions are designed to help you manage dictionary documents in MarkLogic Server. 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. To use the `spell.xqy` module in your own XQuery modules, include the following line in your XQuery prolog: `import module namespace spell = "http://marklogic.com/xdmp/spell" at "/MarkLogic/spell.xqy";` The library uses the `spell:` namespace, predefined in the server. 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. There are also Spell Built-In functions, which you use to check if words are spelled correctly according to the dictionaries and to suggest alternate spellings.
Function Summary
spell:add-word | Add the word $word to the dictionary at $uri.
spell:insert | Load the words in $dict into the dictionary at $uri.
spell:load | Add the words from the file specified in $path to the dictionary at $uri.
spell:make-dictionary | Creates a dictionary node from a sequence of words.
spell:remove-word | Remove the word $word from the dictionary at $uri.
Function Detail
spell:add-word(
| $uri as xs:string,
| $word as xs:string
) as empty-sequence()
Summary: Add the word $word to the dictionary at $uri. If the word is already in the dictionary (case-sensitive), then this function throws an exception.
Parameters:
$uri : The URI of the dictionary.
$word : The word to add.
Example:
      xquery version "1.0-ml";
      import module namespace spell = "http://marklogic.com/xdmp/spell"
    		  at "/MarkLogic/spell.xqy";

      spell:add-word("/mySpell/spell.xml", "WebDAV")

      => adds the word "WebDAV" to the specifed dictionary
spell:insert(
| $uri as xs:string,
| $dict as element(spell:dictionary)
) as empty-sequence()
Summary: Load the words in $dict into the dictionary at $uri. If there is no document at $uri a new one will be created. If there is a document at $uri it will be overwritten.
Parameters:
$uri : The URI of the dictionary.
$dict : A dictionary document.
Example:
      xquery version "1.0-ml";
      import module namespace spell = "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:load(
| $path as xs:string,
| $uri as xs:string
) as empty-sequence()
Summary: Add the words from the file specified in $path to the dictionary at $uri. If a document exists with the specified URI, it is replaced with this one. Note that words that are 64 characters or greater will never be returned as suggestions from `spell:suggest` or `spell:suggest-detailed`.
Parameters:
$path : The path to a file containing the dictionary.
$uri : The URI of the dictionary.
Usage Notes: Dictionaries loaded with the `spell:load` function are automatically added to the following collections: http://marklogic.com/xdmp/documents http://marklogic.com/xdmp/spell
Example:
      xquery version "1.0-ml";
      import module namespace spell = "http://marklogic.com/xdmp/spell"
    		  at "/MarkLogic/spell.xqy";

      spell:load("c:\dictionaries\spell.xml", "/mySpell/spell.xml")
spell:make-dictionary(
| $words as xs:string*
) as element(spell:dictionary)
Summary: Creates a dictionary node from a sequence of words. Use `spell:load` to load the dictionary node into the database as a dictionary.
Parameters:
$words : The words from which to construct a dictionary.
Example:
      xquery version "1.0-ml";
      import module namespace spell = "http://marklogic.com/xdmp/spell"
    		  at "/MarkLogic/spell.xqy";

      let $words := ("words", "to", "go", "in", "the", "dictionary")
      return
      spell:make-dictionary($words)

      =>
      <dictionary xmlns="http://marklogic.com/xdmp/spell">
        <word>words</word>
        <word>to</word>
        <word>go</word>
        <word>in</word>
        <word>the</word>
        <word>dictionary</word>
      </dictionary>
Example:
      xquery version "1.0-ml";
      import module namespace spell = "http://marklogic.com/xdmp/spell"
    		  at "/MarkLogic/spell.xqy";

      spell:make-dictionary(cts:words())

      => A spell:dictionary element containing all the words in the database.
         Use spell:load to load this into the database as a dictionary.
         This example requires a word lexicon on the database.  You can
         construct the sequence of words any way you like.
spell:remove-word(
| $uri as xs:string,
| $word as xs:string
) as empty-sequence()
Summary: Remove the word $word from the dictionary at $uri.
Parameters:
$uri : The URI of the dictionary.
$word : The word to remove.
Example:
      xquery version "1.0-ml";
      import module namespace spell = "http://marklogic.com/xdmp/spell"
    		  at "/MarkLogic/spell.xqy";

      spell:remove-word("/mySpell/spell.xml", "Fiat")

      => removes the word "Fiat" from the specified dictionary

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.