can this be run in text editor or only as an addon?
This works from Text Editor and from addon system.
In the last line of the code, you will see main() called, which means its entry point is main() function. So if you want to run it by your own, you can get the idea to how to run the script by reading the code in main() function.
Also you can set your own parameters manually in #41 to #44 in the code where you will find the code like ui[“DistForSearch”] = 1.0.