cii-text-analysis/vendor/yooper/php-text-analysis/tests/TextAnalysis/Tokenizers/RegexTokenizerTest.php
Jéremy Munsch f68d2ac333
premier poc
2026-02-11 08:24:04 +01:00

27 lines
No EOL
749 B
PHP
Executable file

<?php
namespace Tests\TextAnalysis\Tokenizers;
use TextAnalysis\Tokenizers\RegexTokenizer;
/**
* @author yooper
*/
class RegexTokenizerTest extends \PHPUnit\Framework\TestCase
{
public function testDefaultRegex()
{
//uses default regex
$tokenizer = new RegexTokenizer();
$tokens = $tokenizer->tokenize("Good muffins cost $3.88\nin New York. Please buy me\ntwo of them.\nThanks.");
$this->assertCount(17, $tokens);
}
public function testMatchWordsOnly()
{
$tokenizer = new RegexTokenizer("/[A-Za-z]+/");
$tokens = $tokenizer->tokenize("Good muffins cost $3.88\nin New York. Please buy me\ntwo of them.\nThanks.");
$this->assertCount(13, $tokens);
}
}