php-extended / php-score-object
实现 php-score-interface 包的库
7.0.6
2024-07-31 13:33 UTC
Requires
- php: >=8.0
- php-extended/php-score-interface: ^7
- php-extended/polyfill-str-levenshtein: ^1
Requires (Dev)
- dev-master
- 7.0.6
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.0.7
- 6.0.6
- 6.0.5
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.0.1
- 5.0.0
- 4.0.1
- 4.0.0
- 3.2.8
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.16
- 3.1.15
- 3.1.14
- 3.1.13
- 3.1.12
- 3.1.11
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-08-31 11:38:01 UTC
README
实现 php-score-interface 包的库
安装
此库的安装是通过 composer 完成的,并且所有类的自动加载都通过它们的自动加载器来完成。
- 从他们的网站下载
composer.phar
。 - 然后运行以下命令将此库作为依赖项安装
php composer.phar require php-extended/php-score-object ^7
基本用法
您可以使用以下方式使用此库
use PhpExtended\Score\StringLevenshteinScore;
use PhpExtended\Score\ScoreCollection;
use PhpExtended\Score\PresumptionGuiltPolicy;
// First, let's image you have three strings and a reference string, and you
// want to know which is the global distance of the three strings from the
// reference
$reference = '<put your reference string here>';
$test1 = '<put your first test string here>';
$test2 = '<put your second test string here>';
$test3 = '<put your third test string here>';
$score1 = new StringLevenshteinScore($reference, $test1);
$score2 = new StringLevenshteinScore($reference, $test2);
$score3 = new StringLevenshteinScore($reference, $test3);
// Next, concatenate the results
$collection = new ScoreCollection();
$collection->add($score1);
$collection->add($score2);
$collection->add($score3);
// Finally, get the mean value
$result = $collection->resolve(new PresumptionGuiltPolicy());
// To get the result as a number between 0 and 1, use the getNormalizedValue()
// of the IScore object $result.
许可证
MIT (见许可证文件)。