/** * * @param $article * @param $additional */ function onIndexPmml($rule, array $additional) { $index = JuceneHelper::getIndex(); //var_dump($index); $pk = $additional['pk']; JuceneHelper::removeFromIndex('pk:' . $pk); $app = JFactory::getApplication(); try { $zendDoc = Zend_Search_Lucene_Document_Pmml::addPmml($rule, $additional, 'UTF-8'); $index->addDocument($zendDoc); } catch (Exception $e) { $app->enqueueMessage(JText::_($e->getMessage()), 'error'); } }
/** * Function to update rating of the association rule by the Sewebar domain experts. It should be * in the format +/- 1. * @param $docId reference of the document id - e.g. db primary key id, pk field of the lucene record * @param $rating value of the rating +/- 1 * @param $rulePosition position in the document */ function updateRating($docId, $userRating, $rulePosition) { $index = JuceneHelper::getIndex(); $results = $index->find("pk:'.{$docId}.' AND position:" . $rulePosition); if (count($results) > 0) { foreach ($results as $result) { $del = $index->delete($result->id); } $ruleRating = $result->rating; if ($userRating == -1 || $userRating == 1) { $newRating = $ruleRating + $userRating; $zendDoc = Zend_Search_Lucene_Document_Pmml::addPmml($result, array(), false); $index->addDocument($zendDoc); } } }