Created
October 22, 2015 19:33
-
-
Save grtjn/e7bd6f0a86631a88d0bd to your computer and use it in GitHub Desktop.
Spell suggestions driven from lexicon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
let $term := "werld" | |
let $start-char := substring($term,1,1) | |
let $limit := 10 | |
let $threshold := 100 | |
return ( | |
for $candidate in cts:field-words("meta-content",$start-char) | |
let $distance := | |
if (starts-with($candidate, $start-char) and string-length($candidate) le 64) then | |
spell:levenshtein-distance($term, $candidate) | |
else 9999999 | |
where $distance le $threshold | |
order by $distance | |
return concat($candidate, ' - ', $distance) | |
)[1 to $limit] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment