mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-22 13:05:10 +00:00
946fbbc521
* tests: update to PHPUnit 6.0 with rector * [cs] clean empty docs * composer: bump to PHPUnit 6.4 * tests: use class references over strings * cleanup
56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace tests\Phpml\FeatureExtraction;
|
|
|
|
use Phpml\Exception\InvalidArgumentException;
|
|
use Phpml\FeatureExtraction\StopWords;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class StopWordsTest extends TestCase
|
|
{
|
|
public function testCustomStopWords(): void
|
|
{
|
|
$stopWords = new StopWords(['lorem', 'ipsum', 'dolor']);
|
|
|
|
$this->assertTrue($stopWords->isStopWord('lorem'));
|
|
$this->assertTrue($stopWords->isStopWord('ipsum'));
|
|
$this->assertTrue($stopWords->isStopWord('dolor'));
|
|
|
|
$this->assertFalse($stopWords->isStopWord('consectetur'));
|
|
$this->assertFalse($stopWords->isStopWord('adipiscing'));
|
|
$this->assertFalse($stopWords->isStopWord('amet'));
|
|
}
|
|
|
|
public function testThrowExceptionOnInvalidLanguage(): void
|
|
{
|
|
$this->expectException(InvalidArgumentException::class);
|
|
StopWords::factory('Lorem');
|
|
}
|
|
|
|
public function testEnglishStopWords(): void
|
|
{
|
|
$stopWords = StopWords::factory('English');
|
|
|
|
$this->assertTrue($stopWords->isStopWord('again'));
|
|
$this->assertFalse($stopWords->isStopWord('strategy'));
|
|
}
|
|
|
|
public function testPolishStopWords(): void
|
|
{
|
|
$stopWords = StopWords::factory('Polish');
|
|
|
|
$this->assertTrue($stopWords->isStopWord('wam'));
|
|
$this->assertFalse($stopWords->isStopWord('transhumanizm'));
|
|
}
|
|
|
|
public function testFrenchStopWords(): void
|
|
{
|
|
$stopWords = StopWords::factory('French');
|
|
|
|
$this->assertTrue($stopWords->isStopWord('alors'));
|
|
$this->assertFalse($stopWords->isStopWord('carte'));
|
|
}
|
|
}
|