getKeywords($text); $i = 0; foreach ($expected as $word) { if ($word[0] == '*') { $word = substr($word, 1); } if (!empty($keywords[$word])) { $i++; } } $this->AssertTrue($i > 0); } /** @dataProvider provider */ public function testSentences($text, $expected, $esummary) { $config = new \crodas\TextRank\Config; $config->addListener(new \crodas\TextRank\Stopword); $analizer = new \crodas\TextRank\Summary($config); $summary = $analizer->getSummary($text); $this->assertTrue(strpos($summary, $esummary) !== false, "Expected: $summary"); } /** * @dataProvider provider */ public function testGetkeywords($text, $expected) { $config = new \crodas\TextRank\Config; $config->addListener(new \crodas\TextRank\Stopword); $analizer = new \crodas\TextRank\TextRank($config); $keywords = $analizer->getKeywords($text); foreach ($expected as $word) { $catch = false; if ($word[0] == '*') { $catch = true; $word = substr($word, 1); } try { $this->assertTrue(!empty($keywords[$word]), "cannot find \"$word\""); } catch (\Exception $e) { if (!$catch) throw $e; } } } }