Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any open source text analysis library for PHP? [closed]

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!

like image 441
Marc Avatar asked Dec 12 '09 20:12

Marc


2 Answers

Short Answer

As far as I'm aware there's isn't one, or at least not a well-known / well-distributed one.

Long Answer

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...?)

like image 197
Potherca Avatar answered Nov 05 '22 11:11

Potherca


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

like image 24
Junaid Qadir Shekhanzai Avatar answered Nov 05 '22 10:11

Junaid Qadir Shekhanzai