A library that implements the php-score-interface package

4.0.0 2022-05-31 06:59 UTC


A library that implements the php-score-interface package

coverage build status


The installation of this library is made via composer. Download composer.phar from their website. Then add to your composer.json :

	"require": {
		"php-extended/php-score-object": "^3",

Then run php composer.phar update to install this library. The autoloading of all classes of this library is made through composer's autoloader.

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();

// 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 (See license file).