From: <sk...@us...> - 2008-09-16 00:09:56
|
Revision: 1216 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1216&view=rev Author: sknappe Date: 2008-09-16 07:09:53 +0000 (Tue, 16 Sep 2008) Log Message: ----------- changed some files to work with the new way natural language description is called and put old files into a folder Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajax_learn_concepts.php Added Paths: ----------- trunk/src/dbpedia-navigator/database.sql trunk/src/dbpedia-navigator/old/ trunk/src/dbpedia-navigator/old/NaturalConcepts.php trunk/src/dbpedia-navigator/old/ajax.php trunk/src/dbpedia-navigator/old/ajaxfunctions.php trunk/src/dbpedia-navigator/old/index-old.php Removed Paths: ------------- trunk/src/dbpedia-navigator/NaturalConcepts.php trunk/src/dbpedia-navigator/ajax.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index-old.php trunk/src/dbpedia-navigator/localhost.sql Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-09-16 07:08:33 UTC (rev 1215) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-09-16 07:09:53 UTC (rev 1216) @@ -113,6 +113,11 @@ return json_decode($this->client->getCurrentlyBestEvaluatedDescriptions($this->id,3),true); } + function getNaturalDescription($concept) + { + return $this->client->getNaturalDescription($concept); + } + function getConceptDepth() { return $this->client->getConceptDepth($this->id,3)->item; Deleted: trunk/src/dbpedia-navigator/NaturalConcepts.php =================================================================== --- trunk/src/dbpedia-navigator/NaturalConcepts.php 2008-09-16 07:08:33 UTC (rev 1215) +++ trunk/src/dbpedia-navigator/NaturalConcepts.php 2008-09-16 07:09:53 UTC (rev 1216) @@ -1,121 +0,0 @@ -<?php - -class NaturalConcepts -{ - private $concept; - - function NaturalConcepts($conc){ - $this->concept=$conc; - } - - function getNaturalConcept(){ - $identifiedConcepts=$this->identifyConcepts(); - $labels=$this->getLabels($identifiedConcepts); - return $identifiedConcepts; - } - - function identifyConcepts() - { - $temp=$this->concept; - $ret=array(); - $offset=0; - while (true){ - $nextpos=strpos($temp,"http",$offset); - if (!$nextpos) break; - $nextend=preg_match("/\040|.TOP|.BOTTOM|.EXISTS|.ALL|.\(/",$temp,$treffer,PREG_OFFSET_CAPTURE,$nextpos); - if (!$nextend){ - $uri=substr($temp,$nextpos,strlen($temp)-$nextpos); - $ret[]=$uri; - break; - } - $uri=substr($temp,$nextpos,$treffer[0][1]-$nextpos); - $ret[]=$uri; - $offset=$treffer[0][1]; - } - - return $ret; - } - - function getLabels($conc) - { - $query="SELECT DISTINCT "; - for ($i=0;$i<count($conc)-1;$i++) - $query.="?obj".$i.", "; - $query.="?obj".$i."\n"; - $query.="WHERE {\n"; - foreach ($conc as $key=>$con){ - $query.="<".$con."> <http://www.w3.org/2000/01/rdf-schema#label> ?obj".$key.".\n"; - } - $query.="}"; - 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.(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->isExistsConstruct($conc); -//print_r($ic); -?> \ No newline at end of file Deleted: trunk/src/dbpedia-navigator/ajax.php =================================================================== --- trunk/src/dbpedia-navigator/ajax.php 2008-09-16 07:08:33 UTC (rev 1215) +++ trunk/src/dbpedia-navigator/ajax.php 2008-09-16 07:09:53 UTC (rev 1216) @@ -1,33 +0,0 @@ -<?php -require_once ("xajax/xajax_core/xajax.inc.php"); -$sid = session_id(); -if (isset($_GET['path'])) $path=$_GET['path']; -else $path=""; - -$xajax = new xajax($path."ajaxfunctions.php?sid=$sid&path=".$path); -$xajax->configureMany(array('debug'=>true)); - -$xajax->register(XAJAX_FUNCTION, 'getsubjects', array( - 'onResponseDelay' => 'showLoading', - 'beforeResponseProcessing' => 'hideLoading' - )); -$xajax->register(XAJAX_FUNCTION,'getarticle', array( - 'onResponseDelay' => 'showLoading', - 'beforeResponseProcessing' => 'hideLoading' - )); -$xajax->register(XAJAX_FUNCTION,'learnConcept', array( - 'onResponseDelay' => 'showLoading', - 'beforeResponseProcessing' => 'hideLoading' - )); -$xajax->register(XAJAX_FUNCTION,'getSubjectsFromConcept', array( - 'onResponseDelay' => 'showLoading', - 'beforeResponseProcessing' => 'hideLoading' - )); - $xajax->registerFunction('toPositive'); -$xajax->registerFunction('toNegative'); -$xajax->registerFunction('clearPositives'); -$xajax->registerFunction('clearNegatives'); -$xajax->registerFunction('removePosInterest'); -$xajax->registerFunction('removeNegInterest'); -$xajax->registerFunction('stopServerCall'); -?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_learn_concepts.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_learn_concepts.php 2008-09-16 07:08:33 UTC (rev 1215) +++ trunk/src/dbpedia-navigator/ajax_learn_concepts.php 2008-09-16 07:09:53 UTC (rev 1216) @@ -29,7 +29,8 @@ $concept.="<table border=0>\n"; $concept.="<tr><td>You could also be interested in articles matching these descriptions:</td></tr>"; foreach ($concepts as $con){ - $concept.="<tr><td><a href=\"\" onclick=\"getSubjectsFromConcept('manchester=".htmlentities($con['descriptionManchesterSyntax'])."&kb=".htmlentities($con['descriptionKBSyntax'])."');return false;\" />".$con['NaturalLanguage']."</a> (Accuracy: ".(floatVal($con['accuracy'])*100)."%)</td></tr>"; + $label=$sc->getNaturalDescription($con['descriptionKBSyntax']); + $concept.="<tr><td><a href=\"\" onclick=\"getSubjectsFromConcept('manchester=".htmlentities($con['descriptionManchesterSyntax'])."&kb=".htmlentities($con['descriptionKBSyntax'])."');return false;\" />".$label."</a> (Accuracy: ".(floatVal($con['accuracy'])*100)."%)</td></tr>"; } $concept.="</table>"; } Deleted: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-09-16 07:08:33 UTC (rev 1215) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-09-16 07:09:53 UTC (rev 1216) @@ -1,616 +0,0 @@ -<?php -ini_set('max_execution_time',200); - -require("ajax.php"); -$xajax->processRequest(); - -function getsubjects($label,$list) -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - $id=$_SESSION['id']; - $ksID=$_SESSION['ksID']; - session_write_close(); - - setRunning($id,"true"); - - //get parts of the list - $checkedInstances=preg_split("[,]",$list,-1,PREG_SPLIT_NO_EMPTY); - - //initialise content - $content=""; - try{ - require_once("DLLearnerConnection.php"); - $sc=new DLLearnerConnection($id,$ksID); - - $subjects=$sc->getSubjects($label,$checkedInstances); - - $content.=getTagCloud($subjects['tagcloud'],$subjects['tagcloudlabel']); - $content.=getResultsTable($subjects['subjects']); - } catch (Exception $e){ - $content=$e->getMessage(); - } - - $objResponse = new xajaxResponse(); - $objResponse->assign("articlecontent", "innerHTML", $content); - $objResponse->assign("ArticleTitle","innerHTML","Searchresult for ".$label); - return $objResponse; -} - -function getarticle($subject,$fromCache) -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - if (isset($_SESSION['articles'])) $articles=$_SESSION['articles']; - $id=$_SESSION['id']; - $ksID=$_SESSION['ksID']; - session_write_close(); - setRunning($id,"true"); - - //get first Letter of label big - $uri=subjectToURI($subject); - - //if article is in session, get it out of the session - if (isset($articles)){ - foreach ($articles as $key => $value) - { - if ($value['subject']==$subject){ - $fromCache=$key; - break; - } - } - } - - //initialize the content variables - $content=""; - $searchResult=""; - $lastArticles=""; - $artTitle=""; - - $objResponse = new xajaxResponse(); - - //get the article - //if $fromCache is -2, no new SearchResults should be processed - //if $fromCache is -1, everything is normal - //if $fromCache is >=0, the article is taken out of the cache - if ($fromCache<0) { - //if there are errors see catch block - try{ - require_once("DLLearnerConnection.php"); - $sc=new DLLearnerConnection($id,$ksID); - $triples=$sc->getTriples($uri); - - //BUILD ARTICLE - // goal: display the data in a nice (DBpedia specific way), maybe similar to - // dbpedia.org/search - - // display a picture if there is one - if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) - $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0]['value'].'" alt="Picture of '.$subject.'" style="float:right; max-width:200px;" \>'; - - //display where it was redirected from, if it was redirected - $redirect=""; - if (isset($triples['http://dbpedia.org/property/redirect'])){ - $content.="<span id=\"redirectedFrom\">redirected from '$subject'</span>"; - $redirect=$triples['http://dbpedia.org/property/redirect'][0]['value']; - } - - // add short description in english - $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0]['value'])."</p>"; - - // give the link to the corresponding Wikipedia article - if(isset($triples['http://xmlns.com/foaf/0.1/page'])) - $content .= '<p><img src="'.$_GET['path'].'images/wikipedia_favicon.png" alt="Wikipedia" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0]['value'].'">view Wikipedia article</a>, '; - $content .= '<a href="'.$uri.'">view DBpedia resource description</a></p>'; - - // display a list of classes - if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) - $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; - - if(isset($triples['http://dbpedia.org/property/reference'])) { - $content .= '<p>references: <ul>'; - foreach($triples['http://dbpedia.org/property/reference'] as $reference) - $content .= '<li><a href="'.$reference['value'].'">'.$reference['value'].'</a></li>'; - $content .= '</ul></p>'; - } - - //display a Google Map if Geo-koordinates are available - if (isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'])&&isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'])){ - $content.="<br/><img src=\"".$_GET['path']."images/mobmaps_googlemapsicon.jpg\" alt=\"Google Maps\" style=\"max-width:25px;\" /> <a href=\"\" onClick=\"loadGoogleMap(".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0]['value'].",".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0]['value'].",'".$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']."');return false;\">Toggle a map of the location</a><br/><br/><div id=\"map\" style=\"width: 500px; height: 300px;display:none;\"></div>"; - } - - //display photo collection, if there is one - if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])){ - $content.="<br/><img src=\"".$_GET['path']."images/flickr.jpg\" alt=\"Flickr\" style=\"max-width:25px;\" /> <a href=\"".$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value']."\">view a photo collection</a><br/>"; - } - - //skos-subjects - if (isset($triples['http://www.w3.org/2004/02/skos/core#subject'])){ - $content .= '<br/><p>skos subjects: <ul>'; - foreach($triples['http://www.w3.org/2004/02/skos/core#subject'] as $skos) - $content .= '<li><a href="'.$skos['value'].'">'.$skos['value'].'</a></li>'; - $content .= '</ul></p>'; - } - - //BUILD ARTICLE TITLE - $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']; - - // filter out uninteresting properties and properties which - // have already been displayed - unset($triples['http://xmlns.com/foaf/0.1/page']); - unset($triples['http://xmlns.com/foaf/0.1/depiction']); - unset($triples['http://dbpedia.org/property/abstract']); - unset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']); - unset($triples['http://dbpedia.org/property/redirect']); - unset($triples['http://dbpedia.org/property/reference']); - unset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long']); - unset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat']); - unset($triples['http://dbpedia.org/property/hasPhotoCollection']); - unset($triples['http://www.w3.org/2004/02/skos/core#subject']); - unset($triples['http://www.w3.org/2000/01/rdf-schema#label']); - - // display the remaining properties as list which can be used for further navigation - $content .= '<br/><br/><br/>'.get_triple_table($triples); - - //Restart the Session - session_start(); - - //store article in session, to navigate between last 5 articles quickly - $contentArray=array('content' => $content,'subject' => $artTitle); - if (!isset($_SESSION['nextArticle'])){ - $_SESSION['nextArticle']=0; - $_SESSION['articles']=array(); - } - if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; - $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; - $_SESSION['currentArticle']=$_SESSION['nextArticle']; - $_SESSION['nextArticle']++; - - //Add Positives to Session - if (!isset($_SESSION['positive'])){ - if ($redirect!=""){ - $array=array($redirect => $redirect); - } - else $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); - $_SESSION['positive']=$array; - } - else{ - $array=$_SESSION['positive']; - if ($redirect!="") $array[$redirect] = $redirect; - else $array["http://dbpedia.org/resource/".str_replace(" ","_",$subject)]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); - $_SESSION['positive']=$array; - } - - } catch (Exception $e) - { - $content=$e->getMessage(); - $artTitle="No Result"; - $objResponse->call('xajax_getsubjects',$subject); - } - } - else { - session_start(); - //Article is in session - $content=$_SESSION['articles'][$fromCache]['content']; - $artTitle=$_SESSION['articles'][$fromCache]['subject']; - } - - //Build lastArticles - if (isset($_SESSION['articles'])){ - foreach ($_SESSION['articles'] as $key => $value) - { - $lastArticles.="<a href=\"\" onclick=\"xajax_getarticle('',".$key.");return false;\">".$value['subject']."</a><br/>"; - } - } - - //add Positives and Negatives to Interests - $posInterests=""; - if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ - $posInterests.=urldecode(substr (strrchr ($pos, "/"), 1))." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"".$_GET['path']."images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - $negInterests=""; - if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ - $negInterests.=urldecode(substr (strrchr ($neg, "/"), 1))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"".$_GET['path']."images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - - $objResponse->assign("articlecontent", "innerHTML", $content); - $objResponse->assign("ArticleTitle","innerHTML",$artTitle); - $objResponse->assign("lastarticles","innerHTML",$lastArticles); - $objResponse->assign('Positives','innerHTML',$posInterests); - $objResponse->assign('Negatives','innerHTML',$negInterests); - $objResponse->call('xajax_learnConcept'); - return $objResponse; -} - -function toPositive($subject) -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - unset($_SESSION['negative'][$subject]); - if (!isset($_SESSION['positive'])){ - $array=array($subject => $subject); - $_SESSION['positive']=$array; - } - else{ - $array=$_SESSION['positive']; - $array[$subject]=$subject; - $_SESSION['positive']=$array; - } - - //add Positives and Negatives to Interests - $posInterests=""; - if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ - $posInterests.=urldecode(substr (strrchr ($pos, "/"), 1))." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"".$_GET['path']."images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - $negInterests=""; - if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ - $negInterests.=urldecode(substr (strrchr ($neg, "/"), 1))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"".$_GET['path']."images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - - $objResponse = new xajaxResponse(); - $objResponse->assign('Positives','innerHTML',$posInterests); - $objResponse->assign('Negatives','innerHTML',$negInterests); - return $objResponse; -} - -function toNegative($subject) -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - unset($_SESSION['positive'][$subject]); - if (!isset($_SESSION['negative'])){ - $array=array($subject => $subject); - $_SESSION['negative']=$array; - } - else{ - $array=$_SESSION['negative']; - $array[$subject]=$subject; - $_SESSION['negative']=$array; - } - - //add Positives and Negatives to Interests - $posInterests=""; - if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ - $posInterests.=urldecode(substr (strrchr ($pos, "/"), 1))." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"".$_GET['path']."images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - $negInterests=""; - if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ - $negInterests.=urldecode(substr (strrchr ($neg, "/"), 1))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"".$_GET['path']."images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - - $objResponse = new xajaxResponse(); - $objResponse->assign('Positives','innerHTML',$posInterests); - $objResponse->assign('Negatives','innerHTML',$negInterests); - return $objResponse; -} - -function clearPositives() -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - unset($_SESSION['positive']); - - $objResponse = new xajaxResponse(); - $objResponse->assign("Positives", "innerHTML", ""); - return $objResponse; -} - -function clearNegatives() -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - unset($_SESSION['negative']); - - $objResponse = new xajaxResponse(); - $objResponse->assign("Negatives", "innerHTML", ""); - return $objResponse; -} - -function removePosInterest($subject) -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - unset($_SESSION['positive'][$subject]); - - //add Positives and Negatives to Interests - $posInterests=""; - if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ - $posInterests.=urldecode(substr (strrchr ($pos, "/"), 1))." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"".$_GET['path']."images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - $negInterests=""; - if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ - $negInterests.=urldecode(substr (strrchr ($neg, "/"), 1))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"".$_GET['path']."images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - - $objResponse = new xajaxResponse(); - $objResponse->assign('Positives','innerHTML',$posInterests); - $objResponse->assign('Negatives','innerHTML',$negInterests); - return $objResponse; -} - -function removeNegInterest($subject) -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - unset($_SESSION['negative'][$subject]); - - //add Positives and Negatives to Interests - $posInterests=""; - if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ - $posInterests.=urldecode(substr (strrchr ($pos, "/"), 1))." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"".$_GET['path']."images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - $negInterests=""; - if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ - $negInterests.=urldecode(substr (strrchr ($neg, "/"), 1))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"".$_GET['path']."images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; - } - - $objResponse = new xajaxResponse(); - $objResponse->assign('Positives','innerHTML',$posInterests); - $objResponse->assign('Negatives','innerHTML',$negInterests); - return $objResponse; -} - -function learnConcept() -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - - if (isset($_SESSION['positive'])) $positives=$_SESSION['positive']; - if (isset($_SESSION['negative'])) $negatives=$_SESSION['negative']; - $id=$_SESSION['id']; - $ksID=$_SESSION['ksID']; - session_write_close(); - setRunning($id,"true"); - $concept=""; - $conceptinformation=""; - if (isset($positives)) - { - $posArray=array(); - foreach ($positives as $pos) - $posArray[]=$pos; - $negArray=array(); - if (isset($negatives)) - foreach ($negatives as $neg) - $negArray[]=$neg; - - require_once("DLLearnerConnection.php"); - $sc=new DLLearnerConnection($id, $ksID); - try{ - $concepts=$sc->getConceptFromExamples($posArray,$negArray); - $conceptDepth=$sc->getConceptDepth(); - $conceptArity=$sc->getConceptArity(); - - $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>"; - //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++; - } - $concept.="</table>"; - } catch(Exception $e){ - $concept.=$e->getMessage(); - } - } - else $concept="You must choose at least one positive example."; - - $objResponse = new xajaxResponse(); - $objResponse->assign("conceptlink", "innerHTML", $concept); - $objResponse->assign("ConceptInformation", "innerHTML", $conceptinformation); - return $objResponse; -} - -function getSubjectsFromConcept($concept) -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - $id=$_SESSION['id']; - $ksID=$_SESSION['ksID']; - session_write_close(); - - setRunning($id,"true"); - - $concept=html_entity_decode($concept); - $content=""; - try{ - require_once("DLLearnerConnection.php"); - $sc=new DLLearnerConnection($id,$ksID); - $subjects=$sc->getSubjectsFromConcept($concept); - $content.=getResultsTable($subjects); - } catch (Exception $e){ - $content=$e->getMessage(); - } - - $objResponse = new xajaxResponse(); - $objResponse->assign("articlecontent", "innerHTML", $content); - $objResponse->assign("ArticleTitle", "innerHTML", "Search Results"); - return $objResponse; -} - -function stopServerCall() -{ - $sid = $_GET['sid']; - session_id($sid); - session_start(); - $id=$_SESSION['id']; - session_write_close(); - setRunning($id,"false"); - $objResponse=new xajaxResponse(); - return $objResponse; -} - -/////////////////////// -// Helper Functions. // -/////////////////////// - -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 - $subject=ucfirst($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); - $min=min($tags); - $diff=$max-$min; - $distribution=$diff/3; - - $ret="<p>"; - foreach ($tags as $tag=>$count){ - if ($count==$min) $style="font-size:xx-small;"; - else if ($count==$max) $style="font-size:xx-large;"; - else if ($count>($min+2*$distribution)) $style="font-size:large;"; - else if ($count>($min+$distribution)) $style="font-size:medium;"; - else $style="font-size:small;"; - - $tag_with_entities=htmlentities("\"".$tag."\""); - $ret.='<a style="'.$style.'" href="#" onclick="xajax_getSubjectsFromConcept(\''.$tag_with_entities.'\');">'.$label[$tag].'</a>'; - } - $ret.="</p>"; - return $ret; -} - -function getResultsTable($results) -{ - $ret="<p>Your search brought ".count($results)." results.</p><br/>"; - $i=0; - $display="block"; - while($i*30<count($results)) - { - $ret.="<div id='results".$i."' style='display:".$display."'>Seite ".($i+1)."<br/><br/>"; - for ($j=0;($j<30)&&(($i*30+$j)<count($results));$j++) - { - $result=$results[$i*30+$j]; - $ret.=" <a href=\"\" onclick=\"xajax_getarticle('".$result."',-1);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."</a><br/>"; - } - $ret.="</div>"; - $i++; - $display="none"; - } - $ret.="<br/><p style='width:100%;text-align:center;'>"; - for ($k=0;$k<$i;$k++){ - $ret.="<a href=\"\" onClick=\"showdiv('results".($k)."');"; - for ($l=0;$l<$i;$l++) - { - if ($l!=$k) $ret.="hidediv('results".$l."');"; - } - $ret.="return false;\">".($k+1)."</a>"; - if ($k!=($i-1)) $ret.=" | "; - } - $ret.="</p>"; - return $ret; -} - -function setRunning($id,$running) -{ - if(!is_dir("temp")) mkdir("temp"); - $file=fopen("./temp/".$id.".temp","w"); - fwrite($file, $running); - fclose($file); -} - -function get_triple_table($triples) { - - $table = '<table border="0"><tr><td>predicate</td><td>object</td></tr>'; - $i=1; - foreach($triples as $predicate=>$object) { - if ($i>0) $backgroundcolor="eee"; - else $backgroundcolor="ffffff"; - $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'">'.nicePredicate($predicate).'</a></td>'; - $table .= '<td><ul>'; - foreach($object as $element) { - if ($element['type']=="uri") $table .= '<li><a href="'.$element['value'].'">'.$element['value'].'</a></li>'; - else $table .= '<li>'.$element['value'].'</li>'; - } - $table .= '</ul></td>'; - $i*=-1; - } - $table .= '</table>'; - return $table; -} - -function nicePredicate($predicate) -{ - if (strripos ($predicate, "#")>strripos ($predicate, "/")){ - $namespace=substr ($predicate,0,strripos ($predicate, "#")); - $name=substr ($predicate,strripos ($predicate, "#")+1); - } - else{ - $namespace=substr ($predicate,0,strripos ($predicate, "/")); - $name=substr ($predicate,strripos ($predicate, "/")+1); - } - - switch ($namespace){ - case "http://www.w3.org/2000/01/rdf-schema": $namespace="rdfs"; - break; - case "http://www.w3.org/2002/07/owl": $namespace="owl"; - break; - case "http://xmlns.com/foaf/0.1": $namespace="foaf"; - break; - case "http://dbpedia.org/property": $namespace="p"; - break; - case "http://www.w3.org/2003/01/geo/wgs84_pos": $namespace="geo"; - break; - case "http://www.w3.org/2004/02/skos/core": $namespace="skos"; - break; - } - - return $namespace.':'.$name; -} - -function formatClassArray($ar) { - $string = formatClass($ar[0]['value']); - for($i=1; $i<count($ar); $i++) { - $string .= ', ' . formatClass($ar[$i]['value']); - } - return $string; -} - -// format a class nicely, i.e. link to it and possibly display -// it in a better way -function formatClass($className) { - $yagoPrefix = 'http://dbpedia.org/class/yago/'; - if(substr($className,0,30)==$yagoPrefix) { - return '<a href="'.$className.'">'.substr($className,30).'</a>'; - // DBpedia is Linked Data, so it makes always sense to link it - // ToDo: instead of linking to other pages, the resource should better - // be openened within DBpedia Navigator - } else if(substr($className,0,14)=='http://dbpedia') { - return '<a href="'.$className.'">'.$className.'</a>'; - } else { - return $className; - } -} - -function arrayToCommaSseparatedList($ar) { - $string = $ar[0]; - for($i=1; $i<count($ar); $i++) { - $string .= ', ' . $ar[$i]; - } - return $string; -} - -?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/database.sql (from rev 1124, trunk/src/dbpedia-navigator/localhost.sql) =================================================================== --- trunk/src/dbpedia-navigator/database.sql (rev 0) +++ trunk/src/dbpedia-navigator/database.sql 2008-09-16 07:09:53 UTC (rev 1216) @@ -0,0 +1,90 @@ +-- phpMyAdmin SQL Dump +-- version 2.9.1 +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Erstellungszeit: 20. August 2008 um 12:05 +-- Server Version: 5.0.67 +-- PHP-Version: 5.2.5 +-- +-- Datenbank: `navigator_db` +-- +CREATE DATABASE `navigator_db` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +USE `navigator_db`; + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `articlecategories` +-- + +CREATE TABLE `articlecategories` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(330) NOT NULL, + `category` varchar(330) NOT NULL, + `number` int(8) default '0', + PRIMARY KEY (`id`), + KEY `Category` (`category`), + KEY `Names` (`name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Daten für Tabelle `articlecategories` +-- + + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `categories` +-- + +CREATE TABLE `categories` ( + `category` varchar(330) NOT NULL, + `label` varchar(330) NOT NULL, + PRIMARY KEY (`category`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Daten für Tabelle `categories` +-- + + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `classhierarchy` +-- + +CREATE TABLE `classhierarchy` ( + `id` int(11) NOT NULL auto_increment, + `father` varchar(330) NOT NULL, + `child` varchar(330) NOT NULL, + PRIMARY KEY (`id`), + KEY `Father` (`father`), + KEY `Child` (`child`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Daten für Tabelle `classhierarchy` +-- + + +-- -------------------------------------------------------- + +-- +-- Tabellenstruktur für Tabelle `rank` +-- + +CREATE TABLE `rank` ( + `name` varchar(330) NOT NULL, + `label` varchar(330) default NULL, + `number` int(8) NOT NULL default '0', + PRIMARY KEY (`name`), + FULLTEXT KEY `Label` (`label`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- +-- Daten für Tabelle `rank` +-- + Deleted: trunk/src/dbpedia-navigator/index-old.php =================================================================== --- trunk/src/dbpedia-navigator/index-old.php 2008-09-16 07:08:33 UTC (rev 1215) +++ trunk/src/dbpedia-navigator/index-old.php 2008-09-16 07:09:53 UTC (rev 1216) @@ -1,255 +0,0 @@ -<?php - -ini_set('error_reporting',E_ALL); -ini_set('max_execution_time',200); -ini_set("soap.wsdl_cache_enabled","1"); - -session_start(); -require_once('DLLearnerConnection.php'); -$sc=new DLLearnerConnection(); -$ids=$sc->getIDs(); -$_SESSION['id']=$ids[0]; -$_SESSION['ksID']=$ids[1]; - -if (isset($_GET['path'])) $path=$_GET['path']; -else $path=""; - -require_once 'Settings.php'; -$settings=new Settings(); - -//what happens onLoad -$onLoad="onLoad=\""; -if (isset($_GET['resource'])){ - $onLoad.="xajax_getarticle('".$_GET['resource']."',-1);"; - unset($_GET['resource']); -} -else if (isset($_SESSION['currentArticle'])){ - $onLoad.="xajax_getarticle('',".$_SESSION['currentArticle'].");"; -} -$onLoad.="\""; - -require("ajax.php"); - -echo '<?xml version="1.0" encoding="UTF-8"?>'; -?> -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - <head> - <title>DBpedia Navigator</title> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> - <link rel="stylesheet" href="<?php print $path;?>default.css"/> - <link rel="stylesheet" type="text/css" href="<?php print $path;?>treemenu/dhtmlxtree.css"> - <?php $xajax->printJavascript($path.'xajax/'); ?> - <script src="http://maps.google.com/maps?file=api&v=2&key=<?php print $settings->googleMapsKey;?>" - type="text/javascript"></script> - <script src="<?php print $path;?>treemenu/dhtmlxcommon.js"></script> - <script src="<?php print $path;?>treemenu/dhtmlxtree.js"></script> - <script type="text/javascript"> - showLoading = function() { - xajax.$('Loading').style.display='inline'; - }; - hideLoading = function() { - xajax.$('Loading').style.display = 'none'; - //xajax.$('SearchResultBox').style.display = 'block'; - xajax.$('LastArticlesBox').style.display = 'block'; - }; - - function showdiv(id){ - document.getElementById(id).style.display='block'; - } - - function hidediv(id) { - document.getElementById(id).style.display='none'; - } - - function loadGoogleMap(Lat,Lng,Label) { - if (document.getElementById("map").style.display=="none"){ - document.getElementById("map").style.display='block'; - if (GBrowserIsCompatible()) { - // Create and Center a Map - var map = new GMap2(document.getElementById("map")); - map.setCenter(new GLatLng(Lat, Lng), 12); - map.addControl(new GLargeMapControl()); - map.addControl(new GMapTypeControl()); - var marker=new GMarker(new GLatLng(Lat, Lng)); - GEvent.addListener(marker, "click", function() { - marker.openInfoWindowHtml(Label); - }); - map.addOverlay(marker); - } - } - else { - document.getElementById("map").style.display='none'; - } - } - </script> - </head> - <body <?php print $onLoad;?>> - -<!-- <h1>DBpedia Navigator</h1> --> -<div><table border="0" width="100%"><tr><td width="35%"><img src="<?php print $path;?>images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /></td><td width="50%"><span id="conceptlink"></span></td><td width="15%"><span id="Loading" style="display:none">Server Call... <img src="<?php print $path;?>images/remove.png" onclick="xajax_stopServerCall();return false;" /></span></td></tr></table></div> -<div id="layer" style="display:none"> - <div id="layerContent" style="display:none"></div> -</div> - -<div id="wrapper"> - <div id="leftSidebar"> - - <div class="box"> - <div class="boxtitle">Search DBpedia</div> - <div class="boxcontent" id="search"> - <!-- Search:<br/> --> - <form onSubmit="xajax_getarticle(document.getElementById('label').value,-1);return false;"> - <input type="text" name="label" id="label" /><br/> - <input type="button" value="Article" class="button" onclick="xajax_getarticle(document.getElementById('label').value,-1);return false;" /> <input type="button" value="Search" class="button" onclick="var list=tree.getAllChecked();xajax_getsubjects(document.getElementById('label').value,list);return false;" /> - <!-- <input type="button" value="Fulltext" class="button" onclick=""/> --> - </form> - </div> <!-- boxcontent --> - </div> <!-- box --> - - <div class="box" id="SearchResultBox" style="display:none"> - <div class="boxtitle">Search Results</div> - <div class="boxcontent"> - <div id="searchcontent" style="display:block"></div> - </div> <!-- boxcontent --> - </div> <!-- box --> - - <div class="box" id="NavigationBox"> - <div class="boxtitle">Navigate</div> - <div class="boxcontent"> - <div id="treeboxbox_tree" style="height:218px;overflow:auto;"> - </div> - </div> <!-- boxcontent --> - </div> <!-- box --> - <script> - tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); - tree.setImagePath("<?php print $path;?>images/csh_bluebooks/"); - tree.enableCheckBoxes(1); - tree.setOnClickHandler(doOnClick); - function doOnClick(nodeId){ - var myUrl = tree.getUserData(nodeId,"myurl"); - xajax_getSubjectsFromConcept(myUrl); - } - tree.setXMLAutoLoading("processTreeMenu.php"); - tree.loadXML("processTreeMenu.php?id=0"); - </script> - - - <div class="box" id="credits"> - <p>DBpedia Navigator is powered by ... <br /> - <a href="http://dl-learner.org">DL-Learner</a><br /> - <a href="http//dbpedia.org">DBpedia</a><br/> - <a href="http://virtuoso.openlinksw.com/wiki/main/">OpenLink Virtuoso</a><br /> - ... and implemented by <a href="http://jens-lehmann.org">Jens Lehmann</a> and - Sebastian Knappe at the <a href="http:/aksw.org">AKSW</a> research group (University of Leipzig).</p> - - <a href="http://www.w3.org/2004/OWL/"><img src="<?php print $path;?>images/sw-owl-green.png" alt="OWL logo" /></a> - <a href="http://www.w3.org/2001/sw/DataAccess/"><img src="<?php print $path;?>images/sw-sparql-green.png" alt="SPARQL logo"/></a> - </div> - - </div><!-- END leftSidebar --> - - <div id="content"> - <div class="box"> - <div class="boxtitle" id="ArticleTitle">Welcome</div> - <div class="boxcontent" id="article"> - <div id="articlecontent" style="display:block"> - <br /><br /> - Welcome to the DBpedia Navigator interface! DBpedia Navigator allows you to search DBpedia - and uses the background knowledge in DBpedia to suggest possible interesting navigation - links. - </div> - </div> <!-- boxcontent --> - </div> <!-- box --> - </div><!-- content --> - - <div id="rightSidebar"> - - <div class="box"> - <div class="boxtitlewithbutton" id="positivesboxtitle">search relevant <img src="<?php print $path;?>images/remove.png" onclick="xajax_clearPositives()" /> </div> - <div class="boxcontent" id="Positives"> - </div> <!-- boxcontent --> - </div> <!-- box --> - - <div class="box"> - <div class="boxtitlewithbutton" id="negativesboxtitle">not relevant <img src="<?php print $path;?>images/remove.png" onclick="xajax_clearNegatives()" /> </div> - <div class="boxcontent" id="Negatives"> - </div> <!-- boxcontent --> - </div> <!-- box --> - - <div class="box" id="LastArticlesBox" style="display:none"> - <div class="boxtitle">Articles Last Viewed</div> - <div class="boxcontent" id="lastarticles"> - </div> <!-- boxcontent --> - </div> <!-- box --> - - </div><!-- rightSidebar --> - - <!-- <div id="clear"></div> --> - -</div><!-- wrapper --> -<div id="footer"> - <p>Licensed under the GNU General Public License (GPL) 3 as part of the DL-Learner open source - project.<br />Copyright © Jens Lehmann 2007-2008 </p> - <div id="validation"> - <?php - $uri = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; - - echo '<div><a href="http://validator.w3.org/check?uri='.$uri.'"'; - echo '><img src="'.$path.'images/valid-xhtml10.png" alt="valid XHTML 1.0" /></a>'."\n"; - echo '<a href="http://jigsaw.w3.org/css-validator/validator?uri='.$uri.'"'; - echo '><img src="'.$path.'images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; - ?> - </div> - <p><a href='<?php print $path;?>rebuild.php'>rebuild [restart session and redownload WSDL file (for debugging)]</a></p> -</div> - -<div id="todo"> -<b>ToDo:</b> -<ul style="float:left"> - <li>Get learning component fast.</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>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>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>Allow to disable caching functionality (in Settings.php).</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 - also be given, e.g. $base/search/$phrase?positives=[$URL1,$URL2,$URL3]&negatives=[$URL4]. The supported - URI design should be briefly documented (e.g. on a dbpedia.org wiki page). A good URI design allows - easier external access (just give someone a link instead of saying exactly which actions have to be done to - get to a state), simplifies debugging the application, and may be of use for creating further - 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>[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 - some way to abandon these if the user has already switched to doing something else. Example: The user - has added 3 positive and 1 negative examples. This is executed as a learning problem, but has no solution (so - DL-Learner would run forever unless we pose some internal time limit). The user adds another negative example a - second later, so instead of letting the previous learning problem run for a long time (and needing much resources), - it should be stopped by DBpedia Navigator.</li> - <li>[if possible] Find an easy way to validate HTML/JS in AJAX applications.</li> - <li>[maybe] Would be interesting to somehow view the Wikipedia article (without the left navigation part, - tabs etc.) as an overlay, because the Wikipedia article will almost always be a human-friendlier - description of an object compared to the extracted one.</li> -</ul> -</div> - - <div class="box" id="ConceptBox" style="position:absolute;top:15px;right:15px;width:18%;opacity:0.90;display:none;z-index:5;"> - <div class="boxtitle">Detailed Concept Information</div> - <div class="boxcontent" id="ConceptInformation"></div> - </div> - - </body> -</html> - \ No newline at end of file Deleted: trunk/src/dbpedia-navigator/localhost.sql =================================================================== --- trunk/src/dbpedia-navigator/localhost.sql 2008-09-16 07:08:33 UTC (rev 1215) +++ trunk/src/dbpedia-navigator/localhost.sql 2008-09-16 07:09:53 UTC (rev 1216) @@ -1,90 +0,0 @@ --- phpMyAdmin SQL Dump --- version 2.9.1 --- http://www.phpmyadmin.net --- --- Host: localhost --- Erstellungszeit: 20. August 2008 um 12:05 --- Server Version: 5.0.67 --- PHP-Version: 5.2.5 --- --- Datenbank: `navigator_db` --- -CREATE DATABASE `navigator_db` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; -USE `navigator_db`; - --- -------------------------------------------------------- - --- --- Tabellenstruktur für Tabelle `articlecategories` --- - -CREATE TABLE `articlecategories` ( - `id` int(11) NOT NULL auto_increment, - `name` varchar(330) NOT NULL, - `category` varchar(330) NOT NULL, - `number` int(8) default '0', - PRIMARY KEY (`id`), - KEY `Category` (`category`), - KEY `Names` (`name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Daten für Tabelle `articlecategories` --- - - --- -------------------------------------------------------- - --- --- Tabellenstruktur für Tabelle `categories` --- - -CREATE TABLE `categories` ( - `category` varchar(330) NOT NULL, - `label` varchar(330) NOT NULL, - PRIMARY KEY (`category`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Daten für Tabelle `categories` --- - - --- -------------------------------------------------------- - --- --- Tabellenstruktur für Tabelle `classhierarchy` --- - -CREATE TABLE `classhierarchy` ( - `id` int(11) NOT NULL auto_increment, - `father` varchar(330) NOT NULL, - `child` varchar(330) NOT NULL, - PRIMARY KEY (`id`), - KEY `Father` (`father`), - KEY `Child` (`child`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- --- Daten für Tabelle `classhierarchy` --- - - --- -------------------------------------------------------- - --- --- Tabellenstruktur für Tabelle `rank` --- - -CREATE TABLE `rank` ( - `name` varchar(330) NOT NULL, - `label` varchar(330) default NULL, - `number` int(8) NOT NULL default '0', - PRIMARY KEY (`name`), - FULLTEXT KEY `Label` (`label`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Daten für Tabelle `rank` --- - Copied: trunk/src/dbpedia-navigator/old/NaturalConcepts.php (from rev 1124, trunk/src/dbpedia-navigator/NaturalConcepts.php) =================================================================== --- trunk/src/dbpedia-navigator/old/NaturalConcepts.php (rev 0) +++ trunk/src/dbpedia-navigator/old/NaturalConcepts.php 2008-09-16 07:09:53 UTC (rev 1216) @@ -0,0 +1,121 @@ +<?php + +class NaturalConcepts +{ + private $concept; + + function NaturalConcepts($conc){ + $this->concept=$conc; + } + + function getNaturalConcept(){ + $identifiedConcepts=$this->identifyConcepts(); + $labels=$this->getLabels($identifiedConcepts); + return $identifiedConcepts; + } + + function identifyConcepts() + { + $temp=$this->concept; + $ret=array(); + $offset=0; + while (true){ + $nextpos=strpos($temp,"http",$offset); + if (!$nextpos) break; + $nextend=preg_match("/\040|.TOP|.BOTTOM|.EXISTS|.ALL|.\(/",$temp,$treffer,PREG_OFFSET_CAPTURE,$nextpos); + if (!$nextend){ + $uri=substr($temp,$nextpos,strlen($temp)-$nextpos); + $ret[]=$uri; + break; + } + $uri=substr($temp,$nextpos,$treffer[0][1]-$nextpos); + $ret[]=$uri; + $offset=$treffer[0][1]; + } + + return $ret; + } + + function getLabels($conc) + { + $query="SELECT DISTINCT "; + for ($i=0;$i<count($conc)-1;$i++) + $query.="?obj".$i.", "; + $query.="?obj".$i."\n"; + $query.="WHERE {\n"; + foreach ($conc as $key=>$con){ + $query.="<".$con."> <http://www.w3.org/2000/01/rdf-schema#label> ?obj".$key.".\n"; + } + $query.="}"; + 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.(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->isExistsConstruct($conc); +//print_r($ic); +?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/old/ajax.php (from rev 1124, trunk/src/dbpedia-navigator/ajax.php) =================================================================== --- trunk/src/dbpedia-navigator/old/ajax.php (rev 0) +++ trunk/src/dbpedia-navigator/old/ajax.php 2008-09-16 07:09:53 UTC (rev 1216) @@ -0,0 +1,33 @@ +<?php +require_once ("xajax/xajax_core/xajax.inc.php"); +$sid = session_id(); +if (isset($_GET['path'])) $path=$_GET['path']; +else $path=""; + +$xajax = new xajax($path."ajaxfunctions.php?sid=$sid&path=".$path); +$xajax->configureMany(array('debug'=>true)); + +$xajax->register(XAJAX_FUNCTION, 'getsubjects', array( + 'onResponseDelay' => 'showLoading', + 'beforeResponseProcessing' => 'hideLoading' + )); +$xajax->register(XAJAX_FUNCTION,'getarticle', array( + 'onResponseDelay' => 'showLoading', + 'beforeResponseProcessing' => 'hideLoading' + )); +$xajax->register(XAJAX_FUNCTION,'learnConcept', array( + 'onResponseDelay' => 'showLoading', + 'beforeResponseProcessing' => 'hideLoading' + )); +$xajax->register(XAJAX_FUNCTION,'getSubjectsFromConcept', array( + 'onResponseDelay' => 'showLoading', + 'beforeResponseProcessing' => 'hideLoading' + )); + $xajax->registerFunction('toPositive'); +$xajax->registerFunction('toNegative'); +$xajax->registerFunction('clearPositives'); +$xajax->registerFunction('clearNegatives'); +$xajax->registerFunction('removePosInterest'); +$xajax->registerFunction('removeNegInterest'); +$xajax->registerFunction('stopServerCall'); +?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/old/ajaxfunctions.php (from rev 1124, trunk/src/dbpedia-navigator/ajaxfunctions.php) =================================================================== --- trunk/src/dbpedia-navigator/old/ajaxfunctions.php (rev 0) +++ trunk/src/dbpedia-navigator/old/ajaxfunctions.php 2008-09-16 07:09:53 UTC (rev 1216) @@ -0,0 +1,616 @@ +<?php +ini_set('max_execution_time',200); + +require("ajax.php"); +$xajax->processRequest(); + +function getsubjects($label,$list) +{ + $sid = $_GET['sid']; + session_id($sid); + session_start(); + $id=$_SESSION['id']; + $ksID=$_SESSION['ksID']; + session_write_close(); + + setRunning($id,"true"); + + //get parts of the list + $checkedInstances=preg_split("[,]",$list,-1,PREG_SPLIT_NO_EMPTY); + + //initialise content + $content=""; + try{ + require_once("DLLearnerConnection.php"); + $sc=new DLLearnerConnection($id,$ksID); + + $subjects=$sc->getSubjects($label,$checkedInstances); + + $content.=getTagCloud($subjects['tagcloud'],$subjects['tagcloudlabel']); + $content.=getResultsTable($subjects['subjects']); + } catch (Exception $e){ + $content=$e->getMessage(); + } + + $objResponse = new xajaxResponse(); + $objResponse->assign("articlecontent", "innerHTML", $content); + $objResponse->assign("ArticleTitle","innerHTML","Searchresult for ".$label); + return $objResponse; +} + +function getarticle($subject,$fromCache) +{ + $sid = $_GET['sid']; + session_id($sid); + session_start(); + if (isset($_SESSION['articles'])) $articles=$_SESSION['articles']; + $id=$_SESSION['id']; + $ksID=$_SESSION['ksID']; + session_write_close(); + setRunning($id,"true"); + + //get first Letter of label big + $uri=subjectToURI($subject); + + //if article is in session, get it out of the session + if (isset($articles)){ + foreach ($articles as $key => $value) + { + if ($value['subject']==$subject){ + $fromCache=$key; + break; + } + } + } + + //initialize the content variables + $content=""; + $searchResult=""; + $lastArticles=""; + $artTitle=""; + + $objResponse = new xajaxResponse(); + + //get the article + //if $fromCache is -2, no new SearchResults should be processed + //if $fromCache is -1, everything is normal + //if $fromCache is >=0, the article is taken out of the cache + if ($fromCache<0) { + //if there are errors see catch block + try{ + require_once("DLLearnerConnection.php"); + $sc=new DLLearnerConnection($id,$ksID); + $triples=$sc->getTriples($uri); + + //BUILD ARTICLE + // goal: display the data in a nice (DBpedia specific way), maybe similar to + // dbpedia.org/search + + // display a picture if there is one + if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) + $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0]['value'].'" alt="Picture of '.$subject.'" style="float:right; max-width:200px;" \>'; + + //display where it was redirected from, if it was redirected + $redirect=""; + if (isset($triples['http://dbpedia.org/property/redirect'])){ + $content.="<span id=\"redirectedFrom\">redirected from '$subject'</span>"; + $redirect=$triples['http://dbpedia.org/property/redirect'][0]['value']; + } + + // add short description in english + $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0]['value'])."</p>"; + + // give the link to the corresponding Wikipedia article + if(isset($triples['http://xmlns.com/foaf/0.1/page'])) + $content .= '<p><img src="'.$_GET['path'].'images/wikipedia_favicon.png" alt="Wikipedia" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0]['value'].'">view Wikipedia article</a>, '; + $content .= '<a href="'.$uri.'">view DBpedia resource description</a></p>'; + + // display a list of classes + if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) + $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; + + if(isset($triples['http://dbpedia.org/property/reference'])) { + $content .= '<p>references: <ul>'; + foreach($triples['http://dbpedia.org/property/reference'] as $reference) + $content .= '<li><a href="'.$reference['value'].'">'.$reference['value'].'</a></li>'; + $content .= '</ul></p>'; + } + + //display a Google Map if Geo-koordinates are available + if (isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'])&&isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'])){ + $content.="<br/><img src=\"".$_GET['path']."images/mobmaps_googlemapsicon.jpg\" alt=\"Google Maps\" style=\"max-width:25px;\" /> <a href=\"\" onClick=\"loadGoogleMap(".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0]['value'].",".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0]['value'].",'".$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']."');return false;\">Toggle a map of the location</a><br/><br/><div id=\"map\" style=\"width: 500px; height: 300px;display:none;\"></div>"; + } + + //display photo collection, if there is one + if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])){ + $content.="<br/><img src=\"".$_GET['path']."images/flickr.jpg\" alt=\"Flickr\" style=\"max-width:25px;\" /> <a href=\"".$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value']."\">view a photo collection</a><br/>"; + } + + //skos-subjects + if (isset($triples['http://www.w3.org/2004/02/skos/core#subject'])){ + $content .= '<br/><p>skos subjects: <ul>'; + foreach($triples['http://www.w3.org/2004/02/skos/core#subject'] as $skos) + $content .= '<li><a href="'.$skos['value'].'">'.$skos['value'].'</a></li>'; + $content .= '</ul></p>'; + } + + //BUILD ARTICLE TITLE + $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']; + + // filter out uninteresting properties and properties which + // have already been displayed + unset($triples['http://xmlns.com/foaf/0.1/page']); + unset($triples['http://xmlns.com/foaf/0.1/depiction']); + unset($triples['http://dbpedia.org/property/abstract']); + unset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']); + unset($triples['http://dbpedia.org/property/redirect']); + unset($triples['http://dbpedia.org/property/reference']); + unset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long']); + ... [truncated message content] |