php-extended / php-score-object
A library that implements the php-score-interface package
9.0.7
2026-05-20 01:05 UTC
Requires
- php: >=8.2
- php-extended/php-score-interface: ^9
- php-extended/polyfill-str-levenshtein: ^1
Requires (Dev)
This package is auto-updated.
Last update: 2026-06-19 23:18:56 UTC
README
A library that implements the php-score-interface package
Installation
The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.
- Download
composer.pharfrom their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-score-object ^9
Basic Usage
You may use this library the following way :
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.
License
MIT (See license file).