From: <jen...@us...> - 2008-01-10 16:34:02
|
Revision: 362 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=362&view=rev Author: jenslehmann Date: 2008-01-10 08:30:32 -0800 (Thu, 10 Jan 2008) Log Message: ----------- - enabled lazy ReasoningService initialisation - fixed some learning bugs in DBpedia Navigator (learning still not working) Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/php-client/testnew.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-10 09:12:48 UTC (rev 361) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-10 16:30:32 UTC (rev 362) @@ -1,11 +1,23 @@ <?php +/** + * Encapsulates all functions, which require communication with DL-Learner. + * + * @author Jens Lehmann + * @author Sebastian Knappe + */ class DLLearnerConnection { private $DBPediaUrl; private $DLLearnerUri; + + // private $client; + + // ID given to this client by the web service private $id; + + // ID of the DBpedia knowledge source private $ksID; function DLLearnerConnection($DBPediaUrl,$DLLearnerUri,$id=0,$ksID=0) @@ -33,9 +45,9 @@ function getConceptFromExamples($ttl,$posExamples,$negExamples) { - $this->client->applyConfigEntryInt($this->id, $this->ksID, "numberOfRecursions", 2); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth", 2); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); - $this->client->applyConfigEntryInt($this->id, $this->ksID, "filterMode", 0); + // $this->client->applyConfigEntryInt($this->id, $this->ksID, "filterMode", 0); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "predList", array()); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "objList", array()); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "classList", array()); @@ -43,9 +55,13 @@ $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "dumpToFile", true); $this->client->setReasoner($this->id, "dig"); - $this->client->setLearningProblem($this->id, "posNegDefinition"); + if(!isset($negExamples)) + $this->client->setLearningProblem($this->id, "posOnlyDefinition"); + else + $this->client->setLearningProblem($this->id, "posNegDefinition"); $this->client->setPositiveExamples($this->id, $posExamples); - $this->client->setNegativeExamples($this->id, $negExamples); + if(isset($negExamples)) + $this->client->setNegativeExamples($this->id, $negExamples); $this->client->setLearningAlgorithm($this->id, "refinement"); $start = microtime(true); Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-10 09:12:48 UTC (rev 361) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-10 16:30:32 UTC (rev 362) @@ -181,7 +181,7 @@ function learnConcept() { - if (isset($_SESSION['positive'])&&isset($_SESSION['negative'])) + if (isset($_SESSION['positive'])) { require_once("Settings.php"); require_once("DLLearnerConnection.php"); @@ -192,7 +192,7 @@ $_SESSION['lastLearnedConcept']=$concept; if (strlen(substr (strrchr ($concept, "/"), 1))>0) $concept=urldecode(substr (strrchr ($concept, "/"), 1)); } - else $concept="You must choose at least one<br/> positive and one negative example."; + else $concept="You must choose at least one<br/> positive example."; $objResponse = new xajaxResponse(); $objResponse->assign("conceptcontent", "innerHTML", $concept); Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-01-10 09:12:48 UTC (rev 361) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-01-10 16:30:32 UTC (rev 362) @@ -92,9 +92,12 @@ public ReasoningService(ReasonerComponent reasoner) { this.reasoner = reasoner; - // list view - atomicConceptsList = new LinkedList<AtomicConcept>(getAtomicConcepts()); - atomicRolesList = new LinkedList<AtomicRole>(getAtomicRoles()); + // list view: the following two lines are commented out, because otherwise the ReasonerComponent + // already has to be initialised when a ReasoningService instance is created; this is problematic + // e.g. for the web service interface, which does not expose the ReasoningService + // (because it is not a component itself) + // atomicConceptsList = new LinkedList<AtomicConcept>(getAtomicConcepts()); + // atomicRolesList = new LinkedList<AtomicRole>(getAtomicRoles()); resetStatistics(); } @@ -428,10 +431,12 @@ } public List<AtomicConcept> getAtomicConceptsList() { + // not working, see message in constructor return atomicConceptsList; } public List<AtomicRole> getAtomicRolesList() { + // not working, see message in constructor return atomicRolesList; } Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-10 09:12:48 UTC (rev 361) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-10 16:30:32 UTC (rev 362) @@ -239,7 +239,7 @@ * @param id Session ID. */ @WebMethod - public void init(int id) throws ClientNotKnownException { + public void initAll(int id) throws ClientNotKnownException { ClientState state = getState(id); for(KnowledgeSource ks : state.getKnowledgeSources()) ks.init(); @@ -249,6 +249,20 @@ } /** + * Initialise the specified component. + * @param id Session-ID. + * @param componentID Component-ID. + * @throws ClientNotKnownException Thrown if the client ID is nor registered. + * @throws UnknownComponentException Thrown if the component is unknown. + */ + @WebMethod + public void init(int id, int componentID) throws ClientNotKnownException, UnknownComponentException { + ClientState state = getState(id); + Component component = state.getComponent(componentID); + component.init(); + } + + /** * Starts the learning algorithm and returns the best concept found. This * method will block until learning is completed. * Modified: trunk/src/php-client/testnew.php =================================================================== --- trunk/src/php-client/testnew.php 2008-01-10 09:12:48 UTC (rev 361) +++ trunk/src/php-client/testnew.php 2008-01-10 16:30:32 UTC (rev 362) @@ -6,6 +6,7 @@ $wsdluri="http://localhost:8181/services?wsdl"; $ontology="file:/home/jl/promotion/dl-learner-svn/trunk/examples/father.owl"; +// $ontology="file:/home/jl/programmierung/eclipse_workspace/DL-Learner-SVN/examples/father.owl"; $posExamples = array('http://example.com/father#stefan', 'http://example.com/father#markus', @@ -53,7 +54,7 @@ $start = microtime(true); -$client->init($id); +$client->initAll($id); $learn_start = microtime(true); $init = $learn_start - $start; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |