Package Data | |
---|---|
Maintainer Username: | jpmurray |
Maintainer Contact: | jp@atomescroch.us (Jean-Philippe Murray) |
Package Create Date: | 2017-01-08 |
Package Last Update: | 2022-10-27 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 15:25:15 |
Package Statistics | |
---|---|
Total Downloads: | 91,149 |
Monthly Downloads: | 3,365 |
Daily Downloads: | 121 |
Total Stars: | 70 |
Total Watchers: | 5 |
Total Forks: | 20 |
Total Open Issues: | 0 |
Compare two string and get a similarity percentage. Note that I did not write the algorithms myself, see down this document for the full credits.
Some methods are usable in production, some are not, see usage for informations. Pull requests are more than welcomed!
You can install this package via composer:
$ composer require atomescrochus/laravel-string-similarities
Then you have to install the package' service provider, unless you are running Laravel >=5.5 (it'll use package auto-discovery) :
// config/app.php
'providers' => [
...
Atomescrochus\StringSimilarities\StringSimilaritiesServiceProvider::class,
];
$comparison = new \Atomescrochus\StringSimilarities\Compare();
// the functions returns similarity percentage between strings
$jaroWinkler = $comparison->jaroWinkler('first string', 'second string'); // JaroWinkler comparison
$levenshtein = $comparison->levenshtein('first string', 'second string'); // Levenshtein comparison
$smg = $comparison->smg('first string', 'second string'); // Smith Waterman Gotoh comparison
$similar = $comparison->similarText('first string', 'second string'); // Using "similar_text()"
// This next one will return an array containing the results of all working comparison methods
// plus an array of 'data' that includes the first and second string, and the time in second it took to run all
// comparison. BE AWARE that comparing long string can results in really long compute time!
$all = $comparison->all('first string', 'second string');
Please see CHANGELOG for more information on what has changed recently.
Coming.
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email jp@atomescroch.us instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.