PHP code example of webd / language

1. Go to this page and download the library: Download webd/language 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/ */

    

webd / language example snippets


use webd\language\StringDistance;

$string1 = "You won 10000$";
$string2 = "You won 15500$";

echo "Edit distance : " . StringDistance::EditDistance($string1, $string2);
echo "Levenshtein : " . StringDistance::Levenshtein($string1, $string2);
echo "Jaro-Winkler : " . StringDistance::JaroWinkler($string1, $string2);
echo "Jaro-Winkler (prefix scale = 0.2) : " . StringDistance::JaroWinkler($string1, $string2, 0.2);

use webd\language\PorterStemmer;
echo "analyzing => " . PorterStemmer::Stem("analyzing");
echo "abandoned => " . PorterStemmer::Stem("abandoned");
echo "inclination => " . PorterStemmer::Stem("inclination");

$lcs = new \webd\language\LCS($str1, $str2);
echo $lcs->value();
echo $lcs->length();
echo $lcs->distance();

// SpamSum, aka ssdeep, aka Context-Triggered Piecewize Hashing (CTPH):
$s = new \webd\language\SpamSum;
echo $s->HashString(file_get_contents($f));