PHP Classes

File: similar_text.php

Recommend this page to a friend!
  Classes of zinsou A.A.E.Mose  >  PHP Similar Text Percentage  >  similar_text.php  >  Download  
File: similar_text.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Similar Text Percentage
Compare two strings to compute a similarity score
Author: By
Last change: Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
refactoring
refactoring
implemented common distance algorithms with some custom behavior so it won't do as good as original

-levenshtein without string length limit
-levenshtein damerau
-dice
-hamming
-jaroWinkler

Also improved existing methods
Date: 3 years ago
Size: 3,013 bytes
 

Contents

Class file image Download
<?php

/**
*
* @Name : similar-text
* @Programmer : Akp Aurelle Emmanuel Mose Zinsou
* @Date : 2019-04-01
* @Released under : https://github.com/manuwhat/similar-text/blob/master/LICENSE
* @Repository : https://github.com/manuwhat/similar
*
**/
namespace{
    use
EZAMA\similar_text;
    use
EZAMA\simpleCommonTextSimilarities;
    use
EZAMA\complexCommonTextSimilaritiesHelper;
    use
EZAMA\complexCommonTextSimilarities;
    use
EZAMA\distance;
    use
EZAMA\diceDistance;
    use
EZAMA\levenshteinDistance;
    use
EZAMA\jaroWinklerDistance;
    use
EZAMA\hammingDistance;

    function
SimilarText(
       
$firstString,
       
$secondString,
       
$round = 2,
       
$insensitive = true,
        &
$stats = false,
       
$getParts = false,
       
$checkposition = false
                       
) {
        return
similar_text::similarText(
           
$firstString,
           
$secondString,
           
$round,
           
$insensitive,
           
$stats,
           
$getParts,
           
$checkposition
                                       
);
    }
   
    function
areAnagrams($a, $b)
    {
        return
simpleCommonTextSimilarities::areAnagrams($a, $b);
    }
   
    function
similarButNotEqual($a, $b)
    {
        return
simpleCommonTextSimilarities::similarButNotEqual($a, $b);
    }
   
    function
aIsSuperStringOfB($a, $b)
    {
        return
simpleCommonTextSimilarities::aIsSuperStringOfB($a, $b);
    }
       
    function
haveSameRoot($a, $b)
    {
        return
simpleCommonTextSimilarities::haveSameRoot($a, $b);
    }
   
    function
wordsReorderOccured($a, $b, $considerPunctuation = true)
    {
        return
complexCommonTextSimilarities::wordsReorderOccured($a, $b, $considerPunctuation);
    }
   
    function
punctuationChangesOccured($a, $b, $considerSpace = true)
    {
        return
complexCommonTextSimilarities::punctuationChangesOccured($a, $b, $considerSpace);
    }
   
    function
areStems($a, $b)
    {
        return
complexCommonTextSimilarities::areStems($a, $b);
    }
   
    function
strippedUrl($a, $b)
    {
        return
complexCommonTextSimilarities::strippedUrl($a, $b);
    }
   
    function
acronymOrExpanded($a, $b)
    {
        return
complexCommonTextSimilarities::acronymOrExpanded($a, $b);
    }
   
    function
wordsAddedOrRemoved($a, $b)
    {
        return
complexCommonTextSimilarities::wordsAddedOrRemoved($a, $b);
    }
   
    function
_levenshtein($a, $b)
    {
        return
levenshteinDistance::levenshtein($a, $b);
    }
   
   
    function
levenshteinDamerau($a, $b)
    {
        return
levenshteinDistance::levenshteinDamerau($a, $b);
    }
   
   
    function
dice($a, $b, $round = 2)
    {
        return
diceDistance::dice($a, $b, $round);
    }
   
   
    function
hamming($a, $b)
    {
        return
hammingDistance::hamming($a, $b);
    }
   
   
    function
jaroWinkler($a, $b, $round = 2)
    {
        return
jaroWinklerDistance::jaroWinkler($a, $b, $round);
    }
   
}

For more information send a message to info at phpclasses dot org.