1

So I am trying to devise a spin off of the Levenshtein algorithm, where I keep track of what transformations I did in the string(insert a, replace a for b, or delete) in strictly XQuery only.

Example:

Basically, say I am computing the edit distance of "cat" and "cbt", and am trying to transform "cbt" into "cat."

The edit distance will be 1 and the transformation will be "replace (letter at index 1) for a"

P.S. This same post was made 5 years ago, but I wish to have a solution in XQuery instead of Python, and I am finding it quite hard to do so as I am unable to use 2-D arrays (sequences).

Andy Chan
  • 133
  • 7
  • XQuery 3.1 has arrays you can nest, not sure if Marklogic supports them. – Martin Honnen Feb 06 '20 at 15:16
  • 1
    Can you link to that previous question, for reference? – Mads Hansen Feb 06 '20 at 15:25
  • Sure, here are two links: https://stackoverflow.com/questions/24190003/how-to-modify-levenshtein-algorithm-to-know-if-it-inserted-deleted-or-substit https://stackoverflow.com/questions/44640570/modify-damerau-levenshtein-algorithm-to-track-transformations-insertions-delet – Andy Chan Feb 06 '20 at 15:30
  • 1
    There are several ways to create "real" arrays in MarkLogic, but the simplest is via node constructors, i.e. `array-node { 1, 2, 3 }`. See: https://docs.marklogic.com/10.0/guide/app-dev/json#id_98451 (@MartinHonnen they're supported, but don't conform to the spec) – wst Feb 06 '20 at 15:48
  • 1
    You can also use map:map, or json:array data types in MarkLogic. That gives you mutable objects.. – grtjn Feb 06 '20 at 19:58

0 Answers0