From: <sk...@us...> - 2008-10-01 08:50:07
|
Revision: 1333 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1333&view=rev Author: sknappe Date: 2008-10-01 08:49:57 +0000 (Wed, 01 Oct 2008) Log Message: ----------- algorithm with ordering concepts is working now Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajax_learn_concepts.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-10-01 07:48:46 UTC (rev 1332) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-10-01 08:49:57 UTC (rev 1333) @@ -44,7 +44,7 @@ return array(0 => $id, 1 => $ksID); } - function getConceptFromExamples($posExamples,$negExamples) + function getConceptFromExamples($posExamples,$negExamples,$number) { require_once("Settings.php"); $settings=new Settings(); @@ -53,7 +53,7 @@ $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedFilter", "DBPEDIA-NAVIGATOR"); $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedEndpoint", $this->endpoint); $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedManipulator", "DBPEDIA-NAVIGATOR"); - $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "useCache", $settings->useCache); + $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "useCache", true); if(empty($negExamples)){ $negExamples=$this->client->getNegativeExamples($this->id,$this->ksID,$posExamples,count($posExamples),"http://dbpedia.org/resource/"); $negExamples=$negExamples->item; @@ -69,6 +69,10 @@ $this->client->setNegativeExamples($this->id, $negExamples); $algorithmID=$this->client->setLearningAlgorithm($this->id, "dbpediaNavigationSuggestor"); $this->client->applyConfigEntryBoolean($this->id, $algorithmID, "forceRefinementLengthIncrease", true); + $this->client->applyConfigEntryBoolean($this->id, $algorithmID, "useHasValueConstructor", true); + $this->client->applyConfigEntryInt($this->id, $algorithmID, "valueFrequencyThreshold", 2); + $this->client->applyConfigEntryBoolean($this->id, $algorithmID, "useNegation", false); + $this->client->applyConfigEntryBoolean($this->id, $algorithmID, "useAllConstructor", false); $start = microtime(true); $this->client->initAll($this->id); @@ -112,7 +116,7 @@ fclose($file); if ($run=="false"){ $this->client->stop($this->id); - return json_decode($this->client->getCurrentlyBestEvaluatedDescriptionsFiltered($this->id,3,0.8,true),true); + return json_decode($this->client->getCurrentlyBestEvaluatedDescriptionsFiltered($this->id,$number,0.8,true),true); } } while($seconds<$this->learnttl&&$running); @@ -120,7 +124,7 @@ } //return $concepts->item; - return json_decode($this->client->getCurrentlyBestEvaluatedDescriptionsFiltered($this->id,3,0.8,true),true); + return json_decode($this->client->getCurrentlyBestEvaluatedDescriptionsFiltered($this->id,$number,0.8,true),true); } function getNaturalDescription($concept) Modified: trunk/src/dbpedia-navigator/ajax_learn_concepts.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_learn_concepts.php 2008-10-01 07:48:46 UTC (rev 1332) +++ trunk/src/dbpedia-navigator/ajax_learn_concepts.php 2008-10-01 08:49:57 UTC (rev 1333) @@ -78,7 +78,7 @@ } } } - $groups[]=$noclass; + if (count($noclass)>0) $groups[]=$noclass; $problems=array(); foreach ($groups as $group){ $pos=array(); @@ -92,24 +92,29 @@ require_once("DLLearnerConnection.php"); $sc=new DLLearnerConnection($id, $ksID); + if (count($problems)==1) $number=3; + else if (count($problems)==2) $number=2; + else $number=1; try{ $concepts=array(); - foreach ($problems as $problem) - $concepts=array_merge($concepts,@$sc->getConceptFromExamples($problem['pos'],$problem['neg'])); - - + foreach ($problems as $problem){ + $concepts[]=@$sc->getConceptFromExamples($problem['pos'],$problem['neg'],$number); + } + if (count($concepts)>0){ $concept.="<table border=0>\n"; $concept.="<tr><td>You could also be interested in articles matching these descriptions:</td></tr>"; - foreach ($concepts as $con){ - $label=$sc->getNaturalDescription($con['descriptionKBSyntax']); - $concept.="<tr><td><a href=\"\" onclick=\"getSubjectsFromConcept('kb=".htmlentities($con['descriptionKBSyntax'])."&number=10');return false;\" />".$label."</a> (Accuracy: ".(floatVal($con['accuracy'])*100)."%)</td></tr>"; + foreach ($concepts as $conc){ + foreach ($conc as $con){ + $label=$sc->getNaturalDescription($con['descriptionKBSyntax']); + $concept.="<tr><td><a href=\"\" onclick=\"getSubjectsFromConcept('kb=".htmlentities($con['descriptionKBSyntax'])."&number=10');return false;\" />".$label."</a> (Accuracy: ".(floatVal($con['accuracy'])*100)."%)</td></tr>"; + } } $concept.="</table>"; } else $concept="-"; } catch(Exception $e){ - $concept.=$e->getMessage(); + $concept.="-"; } } else $concept="-"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |