PHP code example of itk-dev / sentence-similarity-metrics

1. Go to this page and download the library: Download itk-dev/sentence-similarity-metrics library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

itk-dev / sentence-similarity-metrics example snippets


use ItkDev\SentenceSimilarityMetrics\WordErrorRate;

$wordErrorRate = new WordErrorRate();

$reference = 'I am 32 years old and I am a software developer';
$prediction = 'I am a 32 year old and I am as a developer';

$wer = $wordErrorRate->wer($reference, $prediction); // 0.36363636363636365

use ItkDev\SentenceSimilarityMetrics\CharacterErrorRate;

$characterErrorRate = new CharacterErrorRate();

$reference = 'I am 32 years old and I am a software developer';
$prediction = 'I am a 32 year old and I am as a developer';

$cer = $characterErrorRate->cer($reference, $prediction); // 0.2127659574468085