cii-text-analysis/vendor/yooper/php-text-analysis/tests/TextAnalysis/Tokenizers/RegexTokenizerTest.php

27 lines
749 B
PHP
Raw Permalink Normal View History

2026-02-10 16:19:59 +01:00
<?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);
}
}