Example #1
0
// load WSDL files (has to be done due to a Java web service bug)
ini_set("soap.wsdl_cache_enabled", "0");
$wsdluri = "http://127.0.0.1:8181/services?wsdl";
if (!file_exists('main.wsdl')) {
    include 'Utilities.php';
    Utilities::loadWSDLfiles($wsdluri);
}
$examples = array('http://dbpedia.org/resource/Leipzig', 'http://dbpedia.org/resource/Dresden');
$client = new SoapClient("main.wsdl", array('features' => SOAP_SINGLE_ELEMENT_ARRAYS));
$id = $client->generateID();
$ksID = $client->addKnowledgeSource($id, "sparqlfrag", "http://dbpedia.org/sparql");
$client->applyConfigEntryInt($id, $ksID, "recursionDepth", 2);
$filterClasses = array("http://xmlns.com/foaf/", "http://dbpedia.org/class/yago/", "http://dbpedia.org/ontology/Resource");
$relatedInstances = array('http://dbpedia.org/resource/Berlin', 'http://dbpedia.org/resource/London');
$instances = array_merge($examples, $relatedInstances);
$client->applyConfigEntryStringArray($id, $ksID, "instances", $instances);
$client->applyConfigEntryString($id, $ksID, "predefinedFilter", "DBPEDIA-NAVIGATOR");
$client->applyConfigEntryString($id, $ksID, "predefinedEndpoint", "DBPEDIA");
$client->applyConfigEntryBoolean($id, $ksID, "saveExtractedFragment", true);
$client->applyConfigEntryBoolean($id, $ksID, "propertyInformation", true);
$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>';
Example #2
0
// Utilities::loadWSDLfiles($wsdluri);
// specifiy ontology
$ontology = 'file:' . realpath("../../examples/family/father.owl");
// create DL-Learner client
$client = new SoapClient("main.wsdl");
// $client = new SoapClient($wsdluri);
// load owl file in DIG reasoner (you need a running DIG reasoner)
$id = $client->generateID();
$ksID = $client->addKnowledgeSource($id, "owlfile", $ontology);
$rID = $client->setReasoner($id, "fastInstanceChecker");
// create a learning problem
$posExamples = array('http://example.com/father#stefan', 'http://example.com/father#markus', 'http://example.com/father#martin');
$negExamples = array('http://example.com/father#heinz', 'http://example.com/father#anna', 'http://example.com/father#michelle');
$client->setLearningProblem($id, "posNegLPStandard");
$client->setPositiveExamples($id, $posExamples);
$client->setNegativeExamples($id, $negExamples);
// choose refinement operator approach
$la_id = $client->setLearningAlgorithm($id, "refexamples");
// you can add the following to apply a config option to a component, e.g. ignore a concept
$client->applyConfigEntryStringArray($id, $la_id, "ignoredConcepts", array('http://example.com/father#female'));
$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->learnDescriptionsEvaluatedLimit($id, 5);
echo 'OK <br />';
echo 'solution: <pre>';
var_dump(json_decode($concept, true));
echo '</pre>';