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. |