Example #1
0
 */
include 'Utilities.php';
// load WSDL files (has to be done due to a Java web service bug)
ini_set("soap.wsdl_cache_enabled", "0");
$wsdluri = "http://localhost:8181/services?wsdl";
// Utilities::loadWSDLfiles($wsdluri);
// specifiy ontology
$ontology = 'file:' . realpath("../../examples/swore/swore.rdf");
// create DL-Learner client
$client = new SoapClient("main.wsdl");
// $client = new SoapClient($wsdluri);
$id = $client->generateID();
$ksID = $client->addKnowledgeSource($id, "owlfile", $ontology);
$rID = $client->setReasoner($id, "fastInstanceChecker");
// create a learning problem
$lp = $client->setLearningProblem($id, "classLearning");
$client->applyConfigEntryURL($id, $lp, "classToDescribe", "http://ns.softwiki.de/req/CustomerRequirement");
$la_id = $client->setLearningAlgorithm($id, "celoe");
$client->applyConfigEntryInt($id, $la_id, "maxExecutionTimeInSeconds", 5);
$client->initAll($id);
// learn concept
echo 'start learning ... ';
// get only concept
// $concept = $client->learn($id, "manchester");
// get concept and additional information in JSON syntax
$concept = $client->learnDescriptionsEvaluated($id);
echo 'OK <br />';
// echo htmlspecialchars($concept);
echo 'solution: <pre>';
var_dump(json_decode($concept, true));
echo '</pre>';
Example #2
0
$rID = $client->setReasoner($id, "cwr");
$client->setLearningProblem($id, "posonlylp");
$client->setPositiveExamples($id, $examples);
$laID = $client->setLearningAlgorithm($id, "celoe");
$client->applyConfigEntryInt($id, $laID, "maxExecutionTimeInSeconds", 1);
$client->initAll($id);
echo '<p>Positive examples:<br />';
foreach ($examples as $example) {
    echo $example . '<br />';
}
echo '</p>';
echo '<p>Additional instances:<br />';
foreach ($relatedInstances as $related) {
    echo $related . '<br />';
}
echo '</p>';
echo '<p>start learning ... ';
$startTime = microtime(true);
$concepts = $client->learnDescriptionsEvaluated($id, 10);
$runTime = microtime(true) - $startTime;
echo 'OK (' . $runTime . ' seconds)</p>';
$concepts = json_decode($concepts);
echo '<table border="1px"><tr><td><i>Manchester OWL Syntax</i></td><td><i>accuracy</i></td></tr>';
foreach ($concepts as $concept) {
    // echo $natural . '(Manchester: ' . $concept->descriptionManchesterSyntax . ', acc. ' . $concept->scoreValue . ')<br />'; ;
    echo '<tr><td>' . $concept->descriptionManchesterSyntax . '</td><td>' . $concept->scoreValue . '</td></tr>';
}
echo '</table>';
?>