public function testContainNull() { $this->assertTrue(SpiderAsserts::containKeywords('Somewhere in her smile she knows', null)); $this->assertTrue(SpiderAsserts::containKeywords('Somewhere in her smile she knows', [])); $this->assertFalse(SpiderAsserts::containKeywords('Somewhere in her smile she knows', null, false)); $this->assertFalse(SpiderAsserts::containKeywords('Somewhere in her smile she knows', [], false)); }
/** * Faz query no documento, de acordo com os parâmetros definidos * na assinatura e define a relevância, sendo que esta relevância * pode ser: * 1) Possivelmente contém conteúdo * 2) Contém conteúdo e contém uma ou mais palavras chave desejadas * pela assinatura ou não contém palavras indesejadas * 3) Contém conteúdo, contém palavras desejadas e não contém * palavras indesejadas. **/ protected function setRelevancy() { if (!$this->bigger) { $this->logger('Content too short', 'info', 5); return false; } $this->addRelevancy(); //+1 cause text exist $txt = $this->getTitle() . "\n" . $this->getText(); $this->logger("Text to be verified:\n" . $txt . "\n", 'info', 5); //diseribles keywords filter if (is_null($this->subscription->getFilter('contain'))) { $this->addRelevancy(); $this->logger('ignore keywords filter', 'info', 5); } else { //Contain? $this->logger('Check for keywords[' . implode(',', $this->subscription->getFilter('contain')) . ']', 'info', 4); $containTest = SpiderAsserts::containKeywords($txt, (array) $this->subscription->getFilter('contain'), true); if ($containTest) { $this->addRelevancy(); } else { $this->logger('Document not contain keywords', 'info', 5); } } //Bad words if (is_null($this->subscription->getFilter('notContain'))) { $this->addRelevancy(); $this->logger('ignore Bad keywords filter', 'info', 5); } else { //Not Contain? $this->logger('Check for BAD keywords[' . implode(',', $this->subscription->getFilter('notContain')) . ']', 'info', 5); if (!SpiderAsserts::containKeywords($txt, $this->subscription->getFilter('notContain'), false)) { $this->addRelevancy(); } else { $this->logger('Document contain BAD keywords', 'info', 5); } } }