<apidoc:module name="SearchBuiltins" category="SpellBuiltins" xmlns:apidoc="http://marklogic.com/xdmp/apidoc"><apidoc:summary access="public">
<p xmlns="http://www.w3.org/1999/xhtml">The spelling correction built-in functions are used with dictionary documents
to compare words with words in the dictionary.  These functions use the 
double metaphone algorithm, which uses the way words sound to try and
suggest spelling alternatives for incorrectly-spelled words.</p>
<p xmlns="http://www.w3.org/1999/xhtml">There is also a Spelling Dictionary Management XQuery module, which 
is used to load and manage dictionary documents, and is complimentary 
to the spelling built-in functions.</p>
</apidoc:summary><apidoc:function name="is-correct" type="builtin" lib="spell" category="SpellBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Returns true() if the specified word is spelled correctly, 
  otherwise returns false().  A word is considered to be spelled 
  correctly if it is in the specified dictionary.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="uri" type="xs:string*" optional="false">
    The URIs of the dictionarys to use.
  </apidoc:param>
      <apidoc:param name="word" type="xs:string" optional="false">
    The word to check.
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>xs:boolean</apidoc:return>
    <apidoc:usage>
   The <code xmlns="http://www.w3.org/1999/xhtml">spell:is-correct</code> function is a built-in function and 
   does not require the <code xmlns="http://www.w3.org/1999/xhtml">import module</code> statement in the XQuery
   prolog.
</apidoc:usage>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  spell:is-correct("en-utf8.xml","occasionally")
  
  =&gt; true()
</pre></apidoc:example>
    <algorithm xmlns="http://www.w3.org/1999/xhtml"></algorithm>
  </apidoc:function><apidoc:function name="suggest" type="builtin" lib="spell" category="SpellBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Suggests a list of spellings for a word. Returns a sequence of the most 
  likely spellings for the specified word.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="uri" type="xs:string*" optional="false">
    The URIs of the dictionarys to use.
  </apidoc:param>
      <apidoc:param name="word" type="xs:string" optional="false">
    The word for which you get spelling suggestions.
  </apidoc:param>
      <apidoc:param name="options" type="node()?" optional="true">
    The options node for this suggest operation. The default is ().  
    The node for the spell:suggest options must be in the
    <code xmlns="http://www.w3.org/1999/xhtml">http://marklogic.com/xdmp/spell</code> namespace. 
    <p xmlns="http://www.w3.org/1999/xhtml">The <code>spell:suggest</code> options include:</p> 
    <blockquote xmlns="http://www.w3.org/1999/xhtml"><dl>
    <dt><p>&lt;maximum&gt;</p></dt>
    <dd>Specifies the maximum number of suggestions to be returned.
    The default is 10.</dd>
    <dt><p>&lt;distance-threshold&gt;</p></dt>
    <dd>Specifies a cut off threshold for suggestions having a distance
    less than the gven number.  The default is 100.</dd>
    </dl></blockquote> 
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>xs:string*</apidoc:return>
    <apidoc:usage>
   <p xmlns="http://www.w3.org/1999/xhtml">The <code>spell:suggest</code> function is a built-in function and 
   does not require the <code>import module</code> statement in the XQuery
   prolog.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">The <code>spell:suggest</code> function only provides suggestions
   to words that are less than 64 characters in length; words 64 characters
   or longer return no suggestions.  Also, it removes any dictionary entries
   that are 64 characters or more, so it will never return a suggestion with
   greater than 64 characters.</p>
</apidoc:usage>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  spell:suggest("myDictionary.xml","occasionally")
  <br/>
  =&gt; occasionally occasional occasion occasions occasion's 
     occasioned optionally educationally irrationally
</pre></apidoc:example>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  spell:suggest("spell.xml", "albetros")
  <br/>
  =&gt; albatross abettors alders alters Albert's Elbert's 
     allegros alder's Walters abettor's
</pre></apidoc:example>
    <algorithm xmlns="http://www.w3.org/1999/xhtml"></algorithm>
  </apidoc:function><apidoc:function name="levenshtein-distance" type="builtin" lib="spell" category="SpellBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Given two strings, returns the Levenshtein distance between those strings. 
  The Levenshtein distance is a measure of how many operations it takes to 
  transform a string into another string, and it is useful in determining
  if a word is spelled correctly, or in simply comparing how "different" two
  words are.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="str1" type="xs:string" optional="false">
    The first input string.
  </apidoc:param>
      <apidoc:param name="str2" type="xs:string" optional="false">
    The second input string.
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>xs:integer?</apidoc:return>
    <apidoc:usage>
   <p xmlns="http://www.w3.org/1999/xhtml">The <code>spell:levenshtein-distance</code> function is a built-in 
   function and does not require the <code>import module</code> statement 
   in the XQuery prolog.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">The <code>spell:levenshtein-distance</code> function throws an exception
   if one of the strings is 64 or more characters in length and the other
   is at least 1 character in length.</p>
</apidoc:usage>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  spell:levenshtein-distance("albatros","albetros")
  <br/>
  =&gt; 1
</pre></apidoc:example>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  spell:levenshtein-distance("cat", "cats")
  <br/>
  =&gt; 1
</pre></apidoc:example>
    <algorithm xmlns="http://www.w3.org/1999/xhtml"></algorithm>
  </apidoc:function><apidoc:function name="double-metaphone" type="builtin" lib="spell" category="SpellBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Given a word returns the two metaphone keys. 
  The primary and secondary metaphone keys which represent 
  the phonetic encoding of two words 
  are returned as a sequence of two strings.  Double metaphone is an algorithm
  based on phonetic sounds useful in providing data to spelling correction
  suggestions.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="word" type="xs:string" optional="false">
    The word for phonetic matching.
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>xs:string*</apidoc:return>
    <apidoc:usage>
   The <code xmlns="http://www.w3.org/1999/xhtml">spell:double-metaphone</code> function is a built-in function and 
   does not require the <code xmlns="http://www.w3.org/1999/xhtml">import module</code> statement in the XQuery
   prolog.
</apidoc:usage>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  spell:double-metaphone("smith")
  <br/>
  =&gt; smo xmt
</pre></apidoc:example>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  spell:double-metaphone("jones")
  <br/>
  =&gt; jns ans
</pre></apidoc:example>
    <algorithm xmlns="http://www.w3.org/1999/xhtml"></algorithm>
  </apidoc:function><apidoc:function name="suggest-detailed" type="builtin" lib="spell" category="SpellBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Suggests a list of spellings for a word. Returns a sequence of elements
  describing each suggestion, including the suggested word, the distance,
  the key distance, the word distance, and the levenshtein distance.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="uri" type="xs:string*" optional="false">
    The URIs of the dictionarys to use.
  </apidoc:param>
      <apidoc:param name="word" type="xs:string" optional="false">
    The word for which you get spelling suggestions.
  </apidoc:param>
      <apidoc:param name="options" type="node()?" optional="true">
    The options node for this suggest operation. The default is ().  
    The node for the <code xmlns="http://www.w3.org/1999/xhtml">spell:suggest-detailed</code> options must be in the
    <code xmlns="http://www.w3.org/1999/xhtml">http://marklogic.com/xdmp/spell</code> namespace. 
    <p xmlns="http://www.w3.org/1999/xhtml">The <code>spell:suggest-detailed</code> options include:</p> 
    <blockquote xmlns="http://www.w3.org/1999/xhtml"><dl>
    <dt><p>&lt;maximum&gt;</p></dt>
    <dd>Specifies the maximum number of suggestions to be returned.
    The default is 10.</dd>
    <dt><p>&lt;distance-threshold&gt;</p></dt>
    <dd>Specifies a cut off threshold for suggestions having a distance
    less than the gven number.  The default is 100.</dd>
    </dl></blockquote> 
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>spell:suggestion*</apidoc:return>
    <apidoc:usage>
   <p xmlns="http://www.w3.org/1999/xhtml">The <code>spell:suggest-detailed</code> function is a built-in 
   function and does not require the <code>import module</code> statement 
   in the XQuery prolog.</p>
   <p xmlns="http://www.w3.org/1999/xhtml">The <code>spell:suggest-detailed</code> function only provides suggestions
   to words that are less than 64 characters in length; words 64 characters
   or longer return no suggestions.  Also, it removes any dictionary entries
   that are 64 characters or more, so it will never return a suggestion with
   greater than 64 characters.</p>
</apidoc:usage>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  spell:suggest-detailed("myDictionary.xml","occasionally")
  <br/>
  =&gt; ()
</pre></apidoc:example>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  spell:suggest("spell.xml", "albetros")
  
  =&gt; 
&lt;spell:suggestion original="albetros" dictionary="spell.xml"&gt;
  &lt;spell:word 
         distance="26" 
         key-distance="0" 
         word-distance="95" 
         levenshtein-distance="2"&gt;
    albatross
  &lt;/spell:word&gt;
&lt;/spell:suggestion&gt;
</pre></apidoc:example>
    <algorithm xmlns="http://www.w3.org/1999/xhtml"></algorithm>
  </apidoc:function></apidoc:module>