Changes

Jump to navigation Jump to search
260 bytes added ,  17:52, 21 November 2017
no edit summary
=Conventions=
All functions and errors in this module and errors are assigned to the <code><nowiki>http://basex.org/modules/strings</nowiki></code> namespace, which is statically bound to the {{Code|strings}} prefix.<br/>
=Functions=
|-
| '''Summary'''
|Computes the [https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance Damerau-Levenshtein Distance] for two strings and returns a double value ({{Code|0.0}} - {{Code|1.0}}). The distance returned value is computed as follows:<br/>* <code>1.0 - </code> – distance / max(length of strings)</code>
* <code>1.0</code> is returned if the strings are equal; <code>0.0</code> is returned if the strings are too different.
|-
|
* {{Code|strings:levenshtein("flower", "flower")}} returns {{Code|1}}
* {{Code|strings:levenshtein("flower", "floewrlewes")}} returns {{Code|0.835}}* In the following query, the input is first normalized (words are stemmed, converted to lower case, and diacritics are removed). It returns {{Code|1}}:<pre class="brush:xquery">let $norm := ft:normalize(?, map { 'stemming': true() })return strings:levenshtein($norm("flowerHOUSES"), $norm("rewolfhouse")}} returns {{Code|0.16}})</pre>
|}
| '''Examples'''
|
* <code>strings:soundex("Michael")</code> returns {{Code|M240}}.* <code>strings:soundex("OBrien") = strings:soundex("O'Brien")</code> returns {{Code|true}}.
|}
|-
| '''Summary'''
|Computes the [https://de.wikipedia.org/wiki/K%C3%B6lner_Phonetik Kölner Phonetik] value for the specified string. The algorithm was published by Hans Joachim Postel in 1969. Similar to Soundex, it the algorithm is used to find similarly pronounced words in , but for the German language. As the first returned digit can be {{Code|0}}, the value is returned as string.
|-
| '''Examples'''
|
* <code>strings:cologne-phonetic("Michael")</code> returns {{Code|645}}.* <code>every $s in ("Mayr", "Maier", "Meier") satisfies strings:cologne-phonetic($s) = "67"</code> returns {{Code|true}}.
|}
The Module was introduced with Version 8.3.
 
[[Category:XQuery]]
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu