locutusjs / locutus

Bringing stdlibs of other programming languages to JavaScript for educational purposes
https://locutus.io
MIT License
3.72k stars 1.12k forks source link

php similar_text performance #459

Closed LordVersA closed 2 years ago

LordVersA commented 2 years ago

hi is there anyway to make this function's performance better? src/php/strings/similar_text.js

kukawski commented 2 years ago

I can check if I can squeeze some more microseconds out of the code, but it's going to be difficult because even the PHPs function has O(N**3) complexity.

LordVersA commented 2 years ago

thanks for your answer, is there any javascript function that work like this? and can get percentage of similarity? a more efficient way @kukawski

kukawski commented 2 years ago

Not exactly what you're looking for, but in this repository you will find function for calculating Levenshtein distance (src/php/strings/levenshtein.js). Otherwise you can try out Jaro-Winkler similarity (https://www.geeksforgeeks.org/jaro-and-jaro-winkler-similarity/) which is O(n*m).

LordVersA commented 2 years ago

Not exactly what you're looking for, but in this repository you will find function for calculating Levenshtein distance (src/php/strings/levenshtein.js). Otherwise you can try out Jaro-Winkler similarity (https://www.geeksforgeeks.org/jaro-and-jaro-winkler-similarity/) which is O(n*m).

thanks for your time <3