I am looking for a PHP library which does more or less the same thing as this webpage: http://textalyser.net/
I know that there are popular libraries in python and java, but I am looking for a PHP version. Thanks for your help!
As far as I'm aware there's isn't one, or at least not a well-known / well-distributed one.
The closes de-facto code I've come across is php-text-statistics by Dave
Child (since the PEAR version has been unmaintained for years) but
that only takes care of readability and sentence, word and syllable counting.
Any other data you'd have to get yourself with count_chars
,
str_word_count
, substr_count
,
preg_match_all
and the like. And of course some math
skills to calculate all the percentages.
That said, I'm not sure exactly what is it you'd want the library to do, or
what http://textalyser.net/ does...
(I mean what is a stoplist anyway? Or an exhaustive polyword phrase, for that
matter...?)
Pretty old question...
Anyways, if you want to find the the similarity between two given strings, PHP ha a built-in function similar_text
.
SYNTAX: similar_text ($first, $second, &$percent = null);
//*Find the similarity/difference between two strings in percentage
$pc = 0;
similar_text('You rock!', 'I Rock too!!',$pc);
print $pc;
OUTPUT: 57.142857142857
As noted above this value is the percentage two strings are similar.
Note: This function is case sensitive
$pc = 0;
similar_text('you', 'YOU',$pc);
print $pc;
will give 0!
Two more such functions I came across are:
Levenshtein Distance & Soundex
For more information please check official documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With