Beispiel #1
0
 public function testSanitizeByStopwords()
 {
     $instance = new Sanitizer('Foo bar foobar');
     $stopwordAnalyzer = new StopwordAnalyzer();
     $stopwordAnalyzer->setCustomStopwordList(array('zh' => array('bar')));
     $this->assertEquals('Foo foobar', $instance->sanitizeBy($stopwordAnalyzer));
 }
Beispiel #2
0
 public function testToLoadFromCache()
 {
     $cache = $this->getMockBuilder('\\Onoi\\Cache\\Cache')->disableOriginalConstructor()->setMethods(array('contains', 'fetch'))->getMockForAbstractClass();
     $cache->expects($this->once())->method('contains')->with($this->stringContains('onoi:tesa:stopword'))->will($this->returnValue(true));
     $cache->expects($this->once())->method('fetch');
     $instance = new StopwordAnalyzer($cache);
     $instance->loadListByLanguage('foo');
 }
 /**
  * @dataProvider textByLanguageProvider
  */
 public function testByLanguage($languageCode, $text, $expected)
 {
     $stopwordAnalyzer = new StopwordAnalyzer();
     $stopwordAnalyzer->loadListByLanguage($languageCode);
     $sanitizer = new Sanitizer($text);
     $sanitizer->toLowercase();
     $string = $sanitizer->sanitizeBy($stopwordAnalyzer);
     $this->assertEquals($expected, $string);
 }