Recommend this page to a friend! |
Classes of zinsou A.A.E.Moïse | PHP Similar Text Percentage | README.md | Download |
|
DownloadPHP Similar Text Percentage: Compare two strings to compute a similarity scoreLibrary which help to Compare two strings to compute a similarity score and get stats on how linked are the strings.Requires: PHP 5.3+ What this library exactly does?this library can compare two strings to compute a similarity score. It takes the text of two strings and analyze them using pure PHP code to evaluate how equal they are. The class returns a number that represents a percentage of the two strings to tell the level of similarity. Based on the stats provided It actually can help to detect similarity even if these cases occurred : WORD REORDER,WHITESPACE AND PUNCTUATION,REMOVE WORDS,ADD WORDS,URL STRIPPING, FORM ACRONYM,EXPAND ACRONYM,STEMMING,SUBSTRING ,SUPERSTRING,ABBREVIATION ,ANAGRAM How to use itRequire the library by issuing this command:
Add Next, use it in your script, just like this:
This is an example of how to use the stats to check a special case.Here we will use them to check about anagrams (note that this has already been implemented in the library check the file similar_text.php to know more about all available implementations)
Nb: some functions and methods are more subtle than one can think. For example the method simpleCommonTextSimilarities::aIsSuperStringOfB and its helper aIsSuperStringOfB are not at all equal to the usual checking functions built on top of preg_match ,stripos and PHP similar functions a simple example is :
The library also contains common distance algorithms such unlimited string length levenshtein ,levenshtein-damerau ,jaro ,jaro-winkler ,hamming ,dice implementation How To run unit tests
|