/** * Funkce pro načtení základu pravidel z PMML (jen text pravidla, IDčka a míry zajímavosti) * @param string|\SimpleXMLElement $pmml * @param int &$rulesCount = null - informace o počtu importovaných pravidel * @throws \Exception */ public function basicParseRulesPMML($pmml, &$rulesCount = null) { if ($pmml instanceof \SimpleXMLElement) { $xml = $pmml; } else { $xml = simplexml_load_string($pmml); } $xml->registerXPathNamespace('guha', 'http://keg.vse.cz/ns/GUHA0.1rev1'); $guhaAssociationModel = $xml->xpath('//guha:AssociationModel'); $rulesCount = (string) $guhaAssociationModel[0]['numberOfRules']; $associationRules = $xml->xpath('//guha:AssociationModel/AssociationRules/AssociationRule'); if (empty($associationRules)) { return; } //pokud nejsou vrácena žádná pravidla, nemá smysl zpracovávat cedenty... $rulesArr = []; foreach ($associationRules as $associationRule) { $rule = new Rule(); $rule->task = $this->task; $rule->text = (string) $associationRule->Text; $rule->pmmlRuleId = (string) $associationRule['id']; $fourFtTable = $associationRule->FourFtTable; $rule->a = (string) $fourFtTable['a']; $rule->b = (string) $fourFtTable['b']; $rule->c = (string) $fourFtTable['c']; $rule->d = (string) $fourFtTable['d']; $rulesArr[] = $rule; } $this->rulesFacade->saveRulesHeads($rulesArr); $this->rulesFacade->calculateMissingInterestMeasures($this->task); }