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

31 lines
No EOL
1.2 KiB
PHP
Executable file

<?php
namespace Tests\TextAnalysis\Tokenizers;
use TextAnalysis\Tokenizers\SentenceTokenizer;
/**
* @author yooper
*/
class SentenceTokenizerTest extends \PHPUnit\Framework\TestCase
{
public function testSentenceTokenizer()
{
$tokenizer = new SentenceTokenizer();
$this->assertCount(2, $tokenizer->tokenize("This has some words. Why only 4 words?"));
$this->assertCount(2, $tokenizer->tokenize("My name is Yooper. I like programming!"));
$this->assertCount(2, $tokenizer->tokenize("My name is Yooper!? I like programming!! !!"));
$this->assertCount(3, $tokenizer->tokenize($this->getArticle()));
$this->assertCount(1, $tokenizer->tokenize("The U.S.A. recently dropped out of the T.P.P."));
}
private function getArticle()
{
return <<<TEXT
The Freshwater is the new incarnation of the well-known Terrace Restaurant which, along with the Terrace Bay Inn, were recently purchased by Jarred and Jen Drown.
Located in the Terrace Bay Hotel between Escanaba and Gladstone, the restaurant offers comfort food with a twist. The menu is the creation of head chef Ken Coates.
TEXT;
}
}