Do you know any strictly equivalent implementation of the PHP similar_text function in Java?
A:
As for Java, your best bet might be the StringUtils class from the Apache Commons Lang library, which contains the LevensteinDistance method that the other SO posts mention.
Roman Stolper
2010-01-04 16:14:00
So you could take the longest strings length and subtract the LevensteinDistance in order to get the same number that similar_text would produce. and for the percentage result you would devide the result by the length.
smokeysonora
2010-01-04 17:23:36
A:
- Download the source code for PHP (http://php.net/downloads.php)
- Uncompress it.
- Convert the similar_text() function in ext\standard\string.c to Java.
- Then eat some ice-cream for tea :D
Mike
2010-05-15 10:33:35
OK so I've converted the C similar_text() to Java. I have a love / hate relationship with C lol. Converting slightly hacky pointer code (obviously to make it efficient for PHP) to Java wasn't easy (for me anyway hehe).Unfortunately the code won't fit here... now just point 4) to finish :)
Mike
2010-05-15 13:38:12
+1
A:
Have a look at http://www.merriampark.com/ldjava.htm
Method: getLevenshteinDistance
.
MasterGaurav
2010-05-15 10:53:29