kacythed / laravel-string-similarities
比较两个字符串并获取相似度百分比
2.0.1
2021-11-30 10:15 UTC
Requires
- php: ~8.0
Requires (Dev)
- phpunit/phpunit: ~4.0||~5.0
- squizlabs/php_codesniffer: ^2.3
This package is not auto-updated.
Last update: 2024-09-18 22:31:06 UTC
README
比较两个字符串并获取相似度百分比。请注意,算法不是我写的,请参阅文档下方以获取完整的致谢信息。
某些方法可用于生产,某些则不可,请参阅使用说明以获取更多信息。欢迎提交拉取请求!
安装
您可以通过composer安装此包
$ composer require atomescrochus/laravel-string-similarities
然后您需要安装包的服务提供者,除非您正在运行 Laravel >=5.5(它将使用包自动发现)
// 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');
变更日志
请参阅 CHANGELOG 以获取有关最近更改的更多信息。
测试
需要帮助。
贡献
请参阅 CONTRIBUTING 和 CONDUCT 以获取详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件 jp@atomescroch.us 而不是使用问题跟踪器。
致谢
- Jean-Philippe Murray
- joshweir over StackOverflow 指引我找到了Jaro Winkler和Smith Waterman Gotoh比较的解决方案和算法
- 所有贡献者
许可证
MIT许可证(MIT)。请参阅 许可证文件 以获取更多信息。