Levenshtein distance


#1

Hi there! I’m trying to do something where Levenshtein distance could help, UIpath have something like that?


#2

Nothing built-in that I know of, but it shouldn’t be hard to build a custom code activity for it.


#3

thank you!


#4

Hello, @carmen! I need an activity that computes Levenshtein distance. Did you make it?

Thanks,
Bernardo


#5

Hi @Bernardo_Ferreira, I’m sorry I didn’t.


#6

@Bernardo_Ferreira, if you can settle for what I think is Damerau-Levenshtein instead of Levenshtein, try this workflow below.
You’ll need a “Run Auto Hot Key Script”, so that means installing UiPath.Script.Activities if you don’t already have it.
The results of 'wordIn = “tset”, 'listIn = "“random,task,test,text,toast” are:

Damerau-Levenshtein\

I think true Levenshtein would be:

Levenshtein

but I may well have it backwards. Either way, if you fiddle with the script you can use either, I suppose.
I think if you want to pass in a collection as anything but a string you’ll have to convert this to an “Invoke Code” activity or “AHKActivities”.

There’s a link in the script “Fuzzy Test Function.ahk” to the AutoHotkey forum, or here, where I got the script that I modified for the workflow. The original “Fuzzy Test.ahk” is included also, as is the “LDistance.ahk” library itself.

Regards,
burque505
Levenshtein.zip (4.3 KB)

EDIT: Okay, here’s two workflows, L3 is Damerau-Levenshtein, L4 is Levenshtein.

Levenshtein_and_Damerau-Levenshtein.zip (15.8 KB)

Levenshtein screenshot confirming my suspicions above:

Levenshtein2


#7

Thank you @burque505. I will try to see if I can solve my issue with this.

Best Regards,
Bernardo Ferreira


#8

Good luck with it, Bernardo. If it works for you please let me know. Thanks!

Regards,

burque505


#9

I got it working in my colleague’s computer, but when i tried to execute it in mine, I found out that I don’t have UiPath.Script.Activities. Can you help me installing it, please?

Best Regards,
Bernardo Ferreira


#10

I got it working, just for future reference, here is the link for the UiPath.Script.Activities package:

https://www.myget.org/F/workflow/api/v2/package/UiPath.Script.Activities/1.0.6068.29800

If you need help installing a package, use this:

Best Regards,
Bernardo Ferreira


#11

@Bernardo_Ferreira, glad to hear it!
Regards,
burque505


#12

You could also try this in the Code activity


#13

Updated to reflect changes in code at the AHK link above.
Regards,
burque505

Levenshtein_and_Damerau_Levenshtein_updated.zip (7.5 KB)


#14

Very interested in this, company content restrictions don’t let me download zip files though. Could you upload the .xamls separately please?