From: <sk...@us...> - 2008-04-02 16:13:41
|
Revision: 757 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=757&view=rev Author: sknappe Date: 2008-04-02 09:13:35 -0700 (Wed, 02 Apr 2008) Log Message: ----------- get examples for concept works, but not yet perfect Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/NaturalConcepts.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-04-02 16:02:52 UTC (rev 756) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-04-02 16:13:35 UTC (rev 757) @@ -227,8 +227,7 @@ function getSubjectsFromConcept($concept) { - $query="SELECT DISTINCT ?subject\n". - "WHERE { ?subject a <".$concept.">}\n"; + $query=$this->client->SparqlRetrieval($concept); $result=json_decode($this->getSparqlResultThreaded($query),true); if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result."); $ret=array(); Modified: trunk/src/dbpedia-navigator/NaturalConcepts.php =================================================================== --- trunk/src/dbpedia-navigator/NaturalConcepts.php 2008-04-02 16:02:52 UTC (rev 756) +++ trunk/src/dbpedia-navigator/NaturalConcepts.php 2008-04-02 16:13:35 UTC (rev 757) @@ -50,10 +50,72 @@ print $query; return $query; } + + function getSparqlQuery() + { + $temp=$this->concept; + $andOrParts=$this->getAndOrParts($temp); + print_r($andOrParts); + } + + function getAndOrParts($temp) + { + $split=preg_split("/(OR)|(AND)/",$temp,-1,PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); + $bracket=0; + $arr=array(); + $temppart=""; + foreach ($split as $part){ + $part=trim($part); + if (strpos($part,"(")===0){ + $bracket+=substr_count($part,"("); + } + if ($bracket>0){ + if (($part=="AND")||($part=="OR")) $temppart.=" ".$part." "; + else $temppart.=$part; + } + else{ + if ((!strpos($part,"AND"))&&(!strpos($part,"OR"))) $arr[]=$part; + else $arr[]=$this->getAndOrParts($part); + } + if ((strrpos($part,')')==(strlen($part)-1))&&($bracket>0)){ + $bracket-=substr_count($part,")"); + if ($bracket==0){ + if ((!strpos($temppart,"AND"))&&(!strpos($temppart,"OR"))) $arr[]=substr($temppart,1,strlen($temppart)-2); + else $arr[]=$this->getAndOrParts(substr($temppart,1,strlen($temppart)-2)); + $temppart=""; + } + } + } + return $arr; + } + + function isExistsConstruct($construct) + { + if (!(strpos($construct,"EXISTS")===0)) return false; + $split=preg_split("/(EXISTS \".*\")\./",$construct,-1,PREG_SPLIT_NO_EMPTY); + $afterdot=$split[0]; + print $afterdot; + $bracket=0; + $offset=0; + do{ + $nextBracketOn=strpos($afterdot,"(",$offset); + $nextBracketOff=strpos($afterdot,")",$offset); + print "On: ".$nextBracketOn+1; + print "Off: ".$nextBracketOff+1; + $min=min($nextBracketOn,$nextBracketOff); + print $min+1; + if ($nextBracketOn==$min) $bracket++; + if ($nextBracketOff==$min) $bracket--; + $offset=$min; + } while(($bracket>0)||($offset>=strlen($afterdot)-1)); + print ($offset); + return true; + } } -$conc="EXISTS http://dbpedia.org/property/website.TOP AND http://dbpedia.org/resource/Berlin"; +//$conc="(EXISTS http://dbpedia.org/property/website.(http://dbpedia.org/resource/Berlin AND http://dbpedia.org/resource/Berlin) OR (http://dbpedia.org/resource/Berlin AND http://dbpedia.org/resource/Berlin)) OR http://dbpedia.org/resource/Berlin"; +$conc="EXISTS \"http://dbpedia.org/property/website\".(http://dbpedia.org/resource/Berlin AND http://dbpedia.org/resource/Berlin)"; $nc=new NaturalConcepts($conc); -$ic=$nc->getNaturalConcept(); +$ic=$nc->isExistsConstruct($conc); //print_r($ic); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-04-02 16:02:52 UTC (rev 756) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-04-02 16:13:35 UTC (rev 757) @@ -392,7 +392,7 @@ $concept.="<table border=0>\n"; $i=1; foreach ($concepts as $con){ - $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".$con."');return false;\" onMouseOver=\"showdiv('div".$i."');showdiv('ConceptBox');\" onMouseOut=\"hidediv('div".$i."');hidediv('ConceptBox');\" />".$con."</a></td></tr>"; + $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".urlencode($con)."');return false;\" onMouseOver=\"showdiv('div".$i."');showdiv('ConceptBox');\" onMouseOut=\"hidediv('div".$i."');hidediv('ConceptBox');\" />".$con."</a></td></tr>"; //put information about concepts in divs $conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."<br/>Concept Length: ".$sc->getConceptLength($con)."</div>"; $i++; @@ -421,6 +421,7 @@ setRunning($id,"true"); + $concept=urldecode($concept); $content=""; try{ require_once("DLLearnerConnection.php"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-05-14 15:17:01
|
Revision: 841 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=841&view=rev Author: sknappe Date: 2008-05-14 08:16:00 -0700 (Wed, 14 May 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-05-14 14:26:34 UTC (rev 840) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-05-14 15:16:00 UTC (rev 841) @@ -44,9 +44,9 @@ { $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); - $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedFilter", 1); - $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedEndpoint", 1); - + $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedFilter", "YAGO"); + $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedEndpoint", "DBPEDIA"); + $this->client->setReasoner($this->id, "dig"); if(empty($negExamples)) $this->client->setLearningProblem($this->id, "posOnlyDefinition"); Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-05-14 14:26:34 UTC (rev 840) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-05-14 15:16:00 UTC (rev 841) @@ -220,7 +220,8 @@ $objResponse->assign("ArticleTitle","innerHTML",$artTitle); $objResponse->assign("lastarticles","innerHTML",$lastArticles); $objResponse->assign('Positives','innerHTML',$posInterests); - $objResponse->assign('Negatives','innerHTML',$negInterests); + $objResponse->assign('Negatives','innerHTML',$negInterests); + $objResponse->call('xajax_learnConcept'); return $objResponse; } @@ -394,7 +395,7 @@ foreach ($concepts as $con){ $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".urlencode($con)."');return false;\" onMouseOver=\"showdiv('div".$i."');showdiv('ConceptBox');\" onMouseOut=\"hidediv('div".$i."');hidediv('ConceptBox');\" />".$con."</a></td></tr>"; //put information about concepts in divs - $conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."<br/>Concept Length: ".$sc->getConceptLength($con)."</div>"; + //$conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."<br/>Concept Length: ".$sc->getConceptLength($con)."</div>"; $i++; } $concept.="</table>"; @@ -486,7 +487,7 @@ for ($j=0;($j<30)&&(($i*30+$j)<count($results));$j++) { $result=$results[$i*30+$j]; - $ret.=" <a href=\"\" onclick=\"xajax_getarticle('".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."',-1);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."</a><br/>"; + $ret.=" <a href=\"\" onclick=\"xajax_getarticle('".str_replace("_"," ",substr (strrchr ($result, "/"), 1))."',-1);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."</a><br/>"; } $ret.="</div>"; $i++; Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-05-14 14:26:34 UTC (rev 840) +++ trunk/src/dbpedia-navigator/index.php 2008-05-14 15:16:00 UTC (rev 841) @@ -149,8 +149,6 @@ <a href="http://www.w3.org/2001/sw/DataAccess/"><img src="<?php print $path;?>images/sw-sparql-green.png" alt="SPARQL logo"/></a> </div> - <input type="button" value="Learn" class="button" onclick="xajax_learnConcept();return false;" /> - </div><!-- END leftSidebar --> <div id="content"> @@ -212,25 +210,16 @@ <b>ToDo:</b> <ul style="float:left"> <li>Get learning component fast.</li> - <li>Learning as a Thread.</li> <li>Get local DBpedia SPARQL endpoint working (next DBpedia release expected at the endof January and then every two months, so it would be nice to have a script based partly automated or at least documented solution for creating a DBpedia mirror).</li> <li>Improve stability: Fix sometimes occurring PHP errors and warnings (check PHP error log).</li> - <li>Automatically learn concepts whenever an example has been added (and there is at least one - positive example present).</li> <li>For each result, display a "+" which shows more information about the concept in an overlay box, e.g. its Description Logic or OWL syntax, its classification accuracy on the examples, and which examples it classifies (in-)correctly.</li> - <li>Move the "Learned Concepts" box above the main box in the center.</li> - <li>Remove the "Subjects from Concept" box and instead change the learned concepts to links (clicking - on a link shows instances of the concept).</li> <li>Create a small number of test cases (e.g. 3), which can be used to verify that DBpedia Navigator is working in typical scenarios (in particular cases where concepts with length greater one are learned).</li> - <li>Display "server call" in progress (or "n server calls in progress") in the top right corner - of the screen whenever AJAX queries are executed.</li> <li>Allow to disable caching functionality (in Settings.php).</li> - <li>Fix the rebuild.php script such that PHP replaces the cached WSDL file by the new one.</li> <li>Make DBpedia Navigator RESTful, e.g. URLs $base/showArticle/$URL for displaying an article; $base/search/$phrase for searching; $base/listInstances/$complexClass for listing the instances of a learned. Maybe session variables (in particuar the selected positive and negative examples) can @@ -241,8 +230,6 @@ features.</li> <li>Improve search functionality [we will probably get feedback from Georgi in February].</li> <li>[maybe] Display a tag cloud similar to <a href="http://dbpedia.org/search/">DBpedia search</a>.</li> - <li>Get a nice DBpedia Navigator logo (preferrably in SVG format) [currently in contact with Matt, but not - sure he has time to help].</li> <li>[maybe] Instead of only allowing a search as entry point to the application, also display a navigatable class tree.</li> <li>[if possible] When expensive SPARQL queries or learning problems have been posed, there should be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-06-10 15:48:44
|
Revision: 953 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=953&view=rev Author: sknappe Date: 2008-06-10 08:48:27 -0700 (Tue, 10 Jun 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/Settings.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-06-10 15:08:22 UTC (rev 952) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-06-10 15:48:27 UTC (rev 953) @@ -124,8 +124,8 @@ if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result. The Label-Search is started."); $ret=array(); foreach ($result['results']['bindings'] as $results){ - $value=$results['obj']; - if (!(isset($value['xml:lang'])&&($value['xml:lang']!=$this->lang))) $ret[$results['pred']['value']][]=$value; + $value=$results['obj']; + if (!(isset($value['xml:lang'])&&($value['xml:lang']!=$this->lang))) $ret[$results['pred']['value']][]=$value; } return $ret; Modified: trunk/src/dbpedia-navigator/Settings.php =================================================================== --- trunk/src/dbpedia-navigator/Settings.php 2008-06-10 15:08:22 UTC (rev 952) +++ trunk/src/dbpedia-navigator/Settings.php 2008-06-10 15:48:27 UTC (rev 953) @@ -35,7 +35,7 @@ public $dbpediauri='http://dbpedia.openlinksw.com:8890/sparql'; // public DBpedia mirror // public $dbpediauri='http://dbpedia2.openlinksw.com:8890/isparql'; - + //in mikrosekunden public $sparqlttl=60000000; public $language="en"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-06-10 16:57:05
|
Revision: 956 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=956&view=rev Author: sknappe Date: 2008-06-10 09:56:59 -0700 (Tue, 10 Jun 2008) Log Message: ----------- modified learn to use format cache is now configurable in settings Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/Settings.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-06-10 16:51:06 UTC (rev 955) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-06-10 16:56:59 UTC (rev 956) @@ -42,11 +42,14 @@ function getConceptFromExamples($posExamples,$negExamples) { + require_once("Settings.php"); + $settings=new Settings(); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedFilter", "YAGO"); $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedEndpoint", "DBPEDIA"); - + $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "useCache", $settings->useCache); $this->client->setReasoner($this->id, "fastInstanceChecker"); if(empty($negExamples)) $this->client->setLearningProblem($this->id, "posOnlyDefinition"); @@ -65,7 +68,7 @@ if($threaded == false) { - $concept = $this->client->learn($this->id); + $concept = $this->client->learn($this->id,'kb'); } else { Modified: trunk/src/dbpedia-navigator/Settings.php =================================================================== --- trunk/src/dbpedia-navigator/Settings.php 2008-06-10 16:51:06 UTC (rev 955) +++ trunk/src/dbpedia-navigator/Settings.php 2008-06-10 16:56:59 UTC (rev 956) @@ -41,6 +41,8 @@ public $language="en"; public $googleMapsKey="ABQIAAAAWwHG9WuZ8hxFSPjRX2-D-hSOxlJeL3USfakgDtFzmQkGhQTW0xTFM1Yr38ho8qREnjt-6oLs37o4xg"; + + public useCache=true; } ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-06-11 16:33:19
|
Revision: 958 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=958&view=rev Author: sknappe Date: 2008-06-11 09:30:50 -0700 (Wed, 11 Jun 2008) Log Message: ----------- the article search was a bit changed Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-06-10 17:22:21 UTC (rev 957) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-06-11 16:30:50 UTC (rev 958) @@ -119,10 +119,10 @@ return $this->client->getConceptLength($concept); } - function getTriples($label) + function getTriples($uri) { $query="SELECT ?pred ?obj ". - "WHERE {{<http://dbpedia.org/resource/".str_replace(' ','_',$label)."> ?pred ?obj}UNION{<http://dbpedia.org/resource/".str_replace(' ','_',$label)."> <http://dbpedia.org/property/redirect> ?Conc.?Conc ?pred ?obj}}"; + "WHERE {{<".$uri."> ?pred ?obj}UNION{<".$uri."> <http://dbpedia.org/property/redirect> ?Conc.?Conc ?pred ?obj}}"; $result=json_decode($this->getSparqlResultThreaded($query),true); if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result. The Label-Search is started."); $ret=array(); Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-06-10 17:22:21 UTC (rev 957) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-06-11 16:30:50 UTC (rev 958) @@ -50,8 +50,7 @@ setRunning($id,"true"); //get first Letter of label big - $subject=ucfirst($subject); - $uri="http://dbpedia.org/resource/".str_replace(' ','_',$subject); + $uri=subjectToURI($subject); //if article is in session, get it out of the session if (isset($articles)){ @@ -81,7 +80,7 @@ try{ require_once("DLLearnerConnection.php"); $sc=new DLLearnerConnection($id,$ksID); - $triples=$sc->getTriples($subject); + $triples=$sc->getTriples($uri); //BUILD ARTICLE // goal: display the data in a nice (DBpedia specific way), maybe similar to @@ -455,6 +454,20 @@ // Helper Functions. // /////////////////////// +function subjectToURI($subject) +{ + //delete whitespaces at beginning and end + $subject=trim($subject); + //get first letters big + $subject=ucwords($subject); + //replace spaces with _ + $subject=str_replace(' ','_',$subject); + //add the uri + $subject="http://dbpedia.org/resource/".$subject; + + return $subject; +} + function getTagCloud($tags,$label) { $max=max($tags); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-06-17 16:33:41
|
Revision: 965 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=965&view=rev Author: sknappe Date: 2008-06-17 09:33:03 -0700 (Tue, 17 Jun 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-06-17 10:56:39 UTC (rev 964) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-06-17 16:33:03 UTC (rev 965) @@ -176,6 +176,7 @@ function getSubjects($label,$checkedInstances) { $offset=1; + $steps=100; $ret=array(); $labels=preg_split("[\040]",$label,-1,PREG_SPLIT_NO_EMPTY); //TODO if instances are checked the offset no longer works @@ -191,7 +192,7 @@ $i=1; } $query.="'@en.?subject a ?cat.?cat <http://www.w3.org/2000/01/rdf-schema#label> ?label}\n". - "LIMIT 100 OFFSET ".$offset."}}"; + "LIMIT ".$steps." OFFSET ".$offset."}}"; }else { $query="SELECT DISTINCT ?subject ?cat ?label\n". "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '"; @@ -202,7 +203,7 @@ $i=1; } $query.="'@en.?subject a ?cat.?cat <http://www.w3.org/2000/01/rdf-schema#label> ?label}". - "LIMIT 100 OFFSET ".$offset; + "LIMIT ".$steps." OFFSET ".$offset; } $result=json_decode($this->getSparqlResultThreaded($query),true); $count=count($result['results']['bindings']); @@ -217,8 +218,8 @@ else $tagcloud[$results['cat']['value']]++; } - $offset+=100; - } while($count==100); + $offset+=$steps; + } while($count==$steps); //have to do this, because distinct doesn't work, and i use the key to eliminate doubles unset($tagcloud['http://www.w3.org/2004/02/skos/core#Concept']); foreach ($ret as $r) Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-06-17 10:56:39 UTC (rev 964) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-06-17 16:33:03 UTC (rev 965) @@ -456,6 +456,9 @@ function subjectToURI($subject) { + //if the subject is already a URI return it + if (strpos($subject,"http://dbpedia.org/resource/")===0) + return $subject; //delete whitespaces at beginning and end $subject=trim($subject); //get first letters big @@ -483,7 +486,7 @@ else if ($count>($min+$distribution)) $style="font-size:medium;"; else $style="font-size:small;"; - $ret.="<a style='".$style."' href='".$tag."'>".$label[$tag]."</a> "; + $ret.="<a style='".$style."' href='javascript:xajax_getSubjectsFromConcept('".$tag."');>".$label[$tag]."</a> "; } $ret.="</p>"; return $ret; @@ -500,7 +503,7 @@ for ($j=0;($j<30)&&(($i*30+$j)<count($results));$j++) { $result=$results[$i*30+$j]; - $ret.=" <a href=\"\" onclick=\"xajax_getarticle('".str_replace("_"," ",substr (strrchr ($result, "/"), 1))."',-1);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."</a><br/>"; + $ret.=" <a href=\"\" onclick=\"xajax_getarticle('".$result."',-1);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."</a><br/>"; } $ret.="</div>"; $i++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-07-05 14:21:14
|
Revision: 998 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=998&view=rev Author: sknappe Date: 2008-07-05 07:21:07 -0700 (Sat, 05 Jul 2008) Log Message: ----------- modified to work with changes in the ws Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-07-05 14:20:26 UTC (rev 997) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-07-05 14:21:07 UTC (rev 998) @@ -51,10 +51,14 @@ $this->client->applyConfigEntryString($this->id, $this->ksID, "predefinedEndpoint", "DBPEDIA"); $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "useCache", $settings->useCache); $this->client->setReasoner($this->id, "fastInstanceChecker"); - if(empty($negExamples)) + /*if(empty($negExamples)) $this->client->setLearningProblem($this->id, "posOnlyDefinition"); else - $this->client->setLearningProblem($this->id, "posNegDefinition"); + $this->client->setLearningProblem($this->id, "posNegDefinition");*/ + $this->client->setLearningProblem($this->id, "posNegDefinition"); + if(empty($negExamples)){ + $negExamples=$this->client->getNegativeExamples($this->id,$this->ksID,$posExamples,count($posExamples),"http://dbpedia.org/resource/"); + } $this->client->setPositiveExamples($this->id, $posExamples); if(!empty($negExamples)) $this->client->setNegativeExamples($this->id, $negExamples); @@ -82,7 +86,7 @@ sleep($sleeptime); // see what we have learned so far - $concepts=$this->client->getCurrentlyBestConcepts($this->id,3); + $concepts=$this->client->getCurrentlyBestConcepts($this->id,3,"kb"); $running=$this->client->isAlgorithmRunning($this->id); $seconds = $i * $sleeptime; @@ -122,7 +126,7 @@ function getTriples($uri) { $query="SELECT ?pred ?obj ". - "WHERE {{<".$uri."> ?pred ?obj}UNION{<".$uri."> <http://dbpedia.org/property/redirect> ?Conc.?Conc ?pred ?obj}}"; + "WHERE {{<".$uri."> ?pred ?obj.Filter(!regex(str(?pred),'http://dbpedia.org/property/reference'))}UNION{<".$uri."> <http://dbpedia.org/property/redirect> ?Conc.?Conc ?pred ?obj.Filter(!regex(str(?pred),'http://dbpedia.org/property/reference'))}}"; $result=json_decode($this->getSparqlResultThreaded($query),true); if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result. The Label-Search is started."); $ret=array(); Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-07-05 14:20:26 UTC (rev 997) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-07-05 14:21:07 UTC (rev 998) @@ -220,7 +220,7 @@ $objResponse->assign("lastarticles","innerHTML",$lastArticles); $objResponse->assign('Positives','innerHTML',$posInterests); $objResponse->assign('Negatives','innerHTML',$negInterests); - //$objResponse->call('xajax_learnConcept'); + $objResponse->call('xajax_learnConcept'); return $objResponse; } @@ -392,7 +392,7 @@ $concept.="<table border=0>\n"; $i=1; foreach ($concepts as $con){ - $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".urlencode($con)."');return false;\" onMouseOver=\"showdiv('div".$i."');showdiv('ConceptBox');\" onMouseOut=\"hidediv('div".$i."');hidediv('ConceptBox');\" />".$con."</a></td></tr>"; + $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".htmlentities($con)."');return false;\" onMouseOver=\"showdiv('div".$i."');showdiv('ConceptBox');\" onMouseOut=\"hidediv('div".$i."');hidediv('ConceptBox');\" />".$con."</a></td></tr>"; //put information about concepts in divs //$conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."<br/>Concept Length: ".$sc->getConceptLength($con)."</div>"; $i++; @@ -421,7 +421,7 @@ setRunning($id,"true"); - $concept=urldecode($concept); + $concept=html_entity_decode($concept); $content=""; try{ require_once("DLLearnerConnection.php"); @@ -462,7 +462,7 @@ //delete whitespaces at beginning and end $subject=trim($subject); //get first letters big - $subject=ucwords($subject); + $subject=ucfirst($subject); //replace spaces with _ $subject=str_replace(' ','_',$subject); //add the uri @@ -486,7 +486,8 @@ else if ($count>($min+$distribution)) $style="font-size:medium;"; else $style="font-size:small;"; - $ret.='<a style="'.$style.'" href="#" onclick="xajax_getSubjectsFromConcept(\''.$tag.'\');">'.$label[$tag].'</a>'; + $tag_with_entities=htmlentities("\"".$tag."\""); + $ret.='<a style="'.$style.'" href="#" onclick="xajax_getSubjectsFromConcept(\''.$tag_with_entities.'\');">'.$label[$tag].'</a>'; } $ret.="</p>"; return $ret; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |