|
1
|
|
|
<?php |
|
2
|
|
|
namespace Ezama\tests{ |
|
3
|
|
|
require($DIR = (($dir = dirname(__DIR__)).DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR)).'similar_text.php'; |
|
4
|
|
|
require $DIR.'simpleCommonTextSimilarities.php'; |
|
5
|
|
|
require $DIR.'complexCommonTextSimilaritiesHelper.php'; |
|
6
|
|
|
require $DIR.'complexCommonTextSimilarities.php'; |
|
7
|
|
|
require $DIR.'distance.php'; |
|
8
|
|
|
require $DIR.'diceDistance.php'; |
|
9
|
|
|
require $DIR.'jaroWinklerDistance.php'; |
|
10
|
|
|
require $DIR.'hammingDistance.php'; |
|
11
|
|
|
require $DIR.'levenshteinDistance.php'; |
|
12
|
|
|
require $dir.DIRECTORY_SEPARATOR.'similar_text.php'; |
|
13
|
|
|
|
|
14
|
|
|
use PHPUnit\Framework\TestCase; |
|
15
|
|
|
|
|
16
|
|
|
class similar_textTest extends TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
public function testSimilarText() |
|
19
|
|
|
{ |
|
20
|
|
|
$this->assertTrue(100.0 === similarText('qwerty', 'ytrewq')); |
|
21
|
|
|
$this->assertTrue(similarText('qwerty', 'ytreq') >= 80); |
|
22
|
|
|
$this->assertTrue(areAnagrams('qwerty', 'ytrewq')); |
|
23
|
|
|
$this->assertTrue(0.0 === similarText('qwerty', ';lkjhg')); |
|
24
|
|
|
$this->assertTrue(haveSameRoot('qwerty', 'qwertyuiop')); |
|
25
|
|
|
$this->assertTrue(wordsReorderOccured('joker is a clown.', 'a clown is joker')); |
|
26
|
|
|
$this->assertTrue(similarButNotEqual('qwerty', 'ytrewq')); |
|
27
|
|
|
$this->assertTrue(StrippedUrl('yahoo.com', 'yahoo')); |
|
28
|
|
|
$this->assertTrue(acronymorExpanded('pda', 'personal digital assistant')); |
|
29
|
|
|
$this->assertTrue(wordsAddedOrRemoved('personal digital', 'personal digital assistant')); |
|
30
|
|
|
$this->assertTrue(aIsSuperStringOfB('mum do you want to cook something', 'do you cook something mum')); |
|
31
|
|
|
$this->assertTrue(punctuationChangesOccured('mum do you want to cook something', 'mum, do you want to cook something?')); |
|
32
|
|
|
$this->assertTrue(0.8 <= jaroWinkler('martha', 'marhta')['jaro-winkler']); |
|
33
|
|
|
$this->assertTrue(0.8 <= jaroWinkler('dixon', 'dicksonx')['jaro-winkler']); |
|
34
|
|
|
$this->assertTrue(0.8 <= jaroWinkler('dwayne', 'duane')['jaro-winkler']); |
|
35
|
|
|
$this->assertTrue(3 === hamming('ramer', 'cases')); |
|
36
|
|
|
$this->assertTrue(0.5 >= dice('casest', 'casesta')); |
|
37
|
|
|
$this->assertTrue(2 === _levenshtein('casesat', 'casesta')); |
|
38
|
|
|
$this->assertTrue(1 === levenshteinDamerau('casest', 'casesta')); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|