From: <sk...@us...> - 2008-10-23 14:17:41
|
Revision: 1417 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1417&view=rev Author: sknappe Date: 2008-10-23 14:17:31 +0000 (Thu, 23 Oct 2008) Log Message: ----------- bugfixes Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php trunk/src/dbpedia-navigator/helper_functions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-23 08:44:58 UTC (rev 1416) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-10-23 14:17:31 UTC (rev 1417) @@ -65,7 +65,8 @@ $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']; else $artTitle=urldecode(str_replace("_"," ",substr (strrchr ($uri, "/"), 1))); - + if (strpos($artTitle,'"')==strlen($artTitle)-1) $artTitle=substr($artTitle,0,strlen($artTitle)-1); + // display a picture if there is one if (isset($triples['http://dbpedia.org/property/imageCaption'])&&$triples['http://dbpedia.org/property/imageCaption'][0]['type']!='uri') $alt=$triples['http://dbpedia.org/property/imageCaption'][0]['value']; else if (isset($triples['http://dbpedia.org/property/caption'])&&$triples['http://dbpedia.org/property/caption'][0]['type']!='uri') $alt=$triples['http://dbpedia.org/property/caption'][0]['value']; @@ -96,11 +97,11 @@ // give the link to the corresponding Wikipedia article if(isset($triples['http://xmlns.com/foaf/0.1/page'])) - $content .= '<p><img src="images/wikipedia_favicon.png" alt="Wikipedia" style="max-width:20px;" /> <a href="#" onclick="window.open(\''.getPrintableURL($triples['http://xmlns.com/foaf/0.1/page'][0]['value']).'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view Wikipedia article</a>, '; - $content .= '<img src="images/dbpedia-favicon.ico" alt="DBpedia" style="max-width:20px;"/> <a href="#" onclick="window.open(\''.$uri.'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view DBpedia resource description</a>'; + $content .= '<p><img src="images/wikipedia_favicon.png" alt="Wikipedia" style="max-width:20px;" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0]['value'].'" onclick="window.open(\''.getPrintableURL($triples['http://xmlns.com/foaf/0.1/page'][0]['value']).'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view Wikipedia article</a>, '; + $content .= '<img src="images/dbpedia-favicon.ico" alt="DBpedia" style="max-width:20px;"/> <a href="'.$uri.'" onclick="window.open(\''.$uri.'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view DBpedia resource description</a>'; //display photo collection, if there is one if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])){ - $content.=', <img src="images/flickr.png" alt="Flickr" style="max-width:20px;" /> <a href="#" onclick="window.open(\''.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view photo collection</a></p>'; + $content.=', <img src="images/flickr.png" alt="Flickr" style="max-width:20px;" /> <a href="'.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'" onclick="window.open(\''.$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value'].'\',\'Wikiwindow\',\'width=800,height=500,top=50,left=50,scrollbars=yes\');">view photo collection</a></p>'; } //display owl:sameAs properties Modified: trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php 2008-10-23 08:44:58 UTC (rev 1416) +++ trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php 2008-10-23 14:17:31 UTC (rev 1417) @@ -22,6 +22,7 @@ $query="SELECT label FROM rank WHERE name='$pos' LIMIT 1"; $res=$databaseConnection->query($query); $result=$databaseConnection->nextEntry($res); + if (strlen($result['label'])<=0) $ptemp[$pos]=urldecode(str_replace("_"," ",substr (strrchr ($pos, "/"), 1))); $ptemp[$pos]=$result['label']; } @@ -30,6 +31,7 @@ $query="SELECT label FROM rank WHERE name='$neg' LIMIT 1"; $res=$databaseConnection->query($query); $result=$databaseConnection->nextEntry($res); + if (strlen($result['label'])<=0) $ntemp[$neg]=urldecode(str_replace("_"," ",substr (strrchr ($neg, "/"), 1))); $ntemp[$neg]=$result['label']; } Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 08:44:58 UTC (rev 1416) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-10-23 14:17:31 UTC (rev 1417) @@ -30,8 +30,10 @@ function subjectToURI($subject) { //if the subject is already a URI return it - if (strpos($subject,"http://dbpedia.org/resource/")===0) - return $subject; + if (strpos($subject,"http://dbpedia.org/resource/")===0){ + $part=substr (strrchr ($subject, "/"), 1); + return substr($subject,0,strlen($subject)-strlen($part)).urlencode($part); + } //delete whitespaces at beginning and end $subject=trim($subject); //get first letters big @@ -260,87 +262,90 @@ function get_triple_table($triples,$subjecttriples) { - $table = '<table border="0" style="width:100%;overflow:hidden"><tr><td><b>Predicate</b></td><td><b>Object/Subject</b></td></tr>'; - $i=1; - foreach($triples as $predicate=>$object) { - $number=count($object); - if ($i>0) $backgroundcolor="eee"; - else $backgroundcolor="ffffff"; - $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'" target="_blank">'.nicePredicate($predicate).'</a></td>'; - $table .= '<td>'; - if ($number>1) $table.='<ul>'; - $k=1; - foreach($object as $element) { - if ($k>3) $display=" style=\"display:none\""; - else $display=""; - if ($element['type']=="uri"){ - if (strpos($element['value'],"http://dbpedia.org/resource/")===0&&substr_count($element['value'],"/")==4&&strpos($element['value'],"Template:")!=28){ - $label=str_replace('_',' ',substr($element['value'],28)); - if (strlen($label)>60) $label=substr($label,0,60).'...'; - if ($number>1) $table.='<li'.$display.'>'; - $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; - if ($number>1) $table.='</li>'; + if ((is_array($triples)&&count($triples)>0)||(is_array($subjecttriples)&&count($subjecttriples)>0){ + $table = '<table border="0" style="width:100%;overflow:hidden"><tr><td><b>Predicate</b></td><td><b>Object/Subject</b></td></tr>'; + $i=1; + if (is_array($triples)&&count($triples)>0) foreach($triples as $predicate=>$object) { + $number=count($object); + if ($i>0) $backgroundcolor="eee"; + else $backgroundcolor="ffffff"; + $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'" target="_blank">'.nicePredicate($predicate).'</a></td>'; + $table .= '<td>'; + if ($number>1) $table.='<ul>'; + $k=1; + foreach($object as $element) { + if ($k>3) $display=" style=\"display:none\""; + else $display=""; + if ($element['type']=="uri"){ + if (strpos($element['value'],"http://dbpedia.org/resource/")===0&&substr_count($element['value'],"/")==4&&strpos($element['value'],"Template:")!=28){ + $label=str_replace('_',' ',substr($element['value'],28)); + if (strlen($label)>60) $label=substr($label,0,60).'...'; + if ($number>1) $table.='<li'.$display.'>'; + $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; + if ($number>1) $table.='</li>'; + } + else{ + if ($number>1) $table.='<li'.$display.'>'; + $label=urldecode($element['value']); + if (strlen($label)>60) $label=substr($label,0,60).'...'; + $table .= '<a href="'.$element['value'].'" target="_blank">'.$label.'</a>'; + if ($number>1) $table.='</li>'; + } } else{ if ($number>1) $table.='<li'.$display.'>'; - $label=urldecode($element['value']); - if (strlen($label)>60) $label=substr($label,0,60).'...'; - $table .= '<a href="'.$element['value'].'" target="_blank">'.$label.'</a>'; + $table .= $element['value']; if ($number>1) $table.='</li>'; } + $k++; } - else{ - if ($number>1) $table.='<li'.$display.'>'; - $table .= $element['value']; - if ($number>1) $table.='</li>'; - } - $k++; + if ($number>3) $table.='<a href="javascript:none()" onclick="toggleAttributes(this)"><img src="images/arrow_down.gif"/> show</a>'; + if ($number>1) $table.='</ul>'; + $table .= '</td>'; + $i*=-1; } - if ($number>3) $table.='<a href="javascript:none()" onclick="toggleAttributes(this)"><img src="images/arrow_down.gif"/> show</a>'; - if ($number>1) $table.='</ul>'; - $table .= '</td>'; - $i*=-1; - } - foreach($subjecttriples as $predicate=>$object) { - $number=count($object); - if ($i>0) $backgroundcolor="eee"; - else $backgroundcolor="ffffff"; - $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'" target="_blank">is '.nicePredicate($predicate).' of </a></td>'; - $table .= '<td>'; - if ($number>1) $table.='<ul>'; - $k=1; - foreach($object as $element) { - if ($k>3) $display=" style=\"display:none\""; - else $display=""; - if ($element['type']=="uri"){ - if (strpos($element['value'],"http://dbpedia.org/resource/")===0&&substr_count($element['value'],"/")==4&&strpos($element['value'],"Template:")!=28){ - $label=str_replace('_',' ',substr($element['value'],28)); - if (strlen($label)>60) $label=substr($label,0,60).'...'; - if ($number>1) $table.='<li'.$display.'>'; - $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; - if ($number>1) $table.='</li>'; + if (is_array($subjecttriples)&&count($subjecttriples)>0) foreach($subjecttriples as $predicate=>$object) { + $number=count($object); + if ($i>0) $backgroundcolor="eee"; + else $backgroundcolor="ffffff"; + $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'" target="_blank">is '.nicePredicate($predicate).' of </a></td>'; + $table .= '<td>'; + if ($number>1) $table.='<ul>'; + $k=1; + foreach($object as $element) { + if ($k>3) $display=" style=\"display:none\""; + else $display=""; + if ($element['type']=="uri"){ + if (strpos($element['value'],"http://dbpedia.org/resource/")===0&&substr_count($element['value'],"/")==4&&strpos($element['value'],"Template:")!=28){ + $label=str_replace('_',' ',substr($element['value'],28)); + if (strlen($label)>60) $label=substr($label,0,60).'...'; + if ($number>1) $table.='<li'.$display.'>'; + $table .= '<a href="#" onclick="get_article(\'label='.$element['value'].'&cache=-1\');">'.urldecode($label).'</a>'; + if ($number>1) $table.='</li>'; + } + else{ + if ($number>1) $table.='<li'.$display.'>'; + $label=urldecode($element['value']); + if (strlen($label)>60) $label=substr($label,0,60).'...'; + $table .= '<a href="'.$element['value'].'" target="_blank">'.$label.'</a>'; + if ($number>1) $table.='</li>'; + } } else{ if ($number>1) $table.='<li'.$display.'>'; - $label=urldecode($element['value']); - if (strlen($label)>60) $label=substr($label,0,60).'...'; - $table .= '<a href="'.$element['value'].'" target="_blank">'.$label.'</a>'; + $table .= $element['value']; if ($number>1) $table.='</li>'; } + $k++; } - else{ - if ($number>1) $table.='<li'.$display.'>'; - $table .= $element['value']; - if ($number>1) $table.='</li>'; - } - $k++; + if ($number>3) $table.='<a href="javascript:none()" onclick="toggleAttributes(this)"><img src="images/arrow_down.gif"/> show</a>'; + if ($number>1) $table.='</ul>'; + $table .= '</td>'; + $i*=-1; } - if ($number>3) $table.='<a href="javascript:none()" onclick="toggleAttributes(this)"><img src="images/arrow_down.gif"/> show</a>'; - if ($number>1) $table.='</ul>'; - $table .= '</td>'; - $i*=-1; + $table .= '</table>'; } - $table .= '</table>'; + else $table="No Tripel left."; return $table; } Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-10-23 08:44:58 UTC (rev 1416) +++ trunk/src/dbpedia-navigator/index.php 2008-10-23 14:17:31 UTC (rev 1417) @@ -18,11 +18,26 @@ $onLoad="onLoad=\"document.getElementById('label').focus();"; if (isset($_GET['positives'])||isset($_GET['negatives'])) $onLoad.="setPositivesAndNegatives('positives=".@$_GET['positives']."&negatives=".@$_GET['negatives']."');"; else if (isset($_SESSION['positives'])||isset($_SESSION['negatives'])) $onLoad.="setPositivesAndNegatives('positives=".$_SESSION['positives']."&negatives=".$_SESSION['negatives']."');"; -if (isset($_GET['showArticle'])) $onLoad.="get_article('label=".$_GET['showArticle']."&cache=-1');"; -else if (isset($_GET['search'])) $onLoad.="search_it('label=".$_GET['search']."&number=10');"; -else if (isset($_GET['showClass'])) $onLoad.="get_class('class=http://dbpedia.org/class/yago/".$_GET['showClass']."&cache=-1');"; -else if (isset($_GET['searchInstances'])) $onLoad.="getSubjectsFromCategory('category=http://dbpedia.org/class/yago/".$_GET['searchInstances']."&number=10');"; -else if (isset($_GET['searchConceptInstances'])) $onLoad.="getSubjectsFromConcept('kb=".htmlentities(urldecode($_GET['concept']))."&number=10');"; +if (isset($_GET['showArticle'])){ + session_unset(); + $onLoad.="get_article('label=".$_GET['showArticle']."&cache=-1');"; +} +else if (isset($_GET['search'])){ + session_unset(); + $onLoad.="search_it('label=".$_GET['search']."&number=10');"; +} +else if (isset($_GET['showClass'])){ + session_unset(); + $onLoad.="get_class('class=http://dbpedia.org/class/yago/".$_GET['showClass']."&cache=-1');"; +} +else if (isset($_GET['searchInstances'])){ + session_unset(); + $onLoad.="getSubjectsFromCategory('category=http://dbpedia.org/class/yago/".$_GET['searchInstances']."&number=10');"; +} +else if (isset($_GET['searchConceptInstances'])){ + session_unset(); + $onLoad.="getSubjectsFromConcept('kb=".htmlentities(urldecode($_GET['concept']))."&number=10');"; +} else if (isset($_SESSION['currentArticle'])){ $onLoad.="get_article('label=&cache=".$_SESSION['currentArticle']."');"; } @@ -86,14 +101,14 @@ <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://dl-learner.org" target="_blank">DL-Learner</a><br /> + <a href="http//dbpedia.org" target="_blank">DBpedia</a><br/> + <a href="http://virtuoso.openlinksw.com/wiki/main/" target="_blank">OpenLink Virtuoso</a><br /> + ... and implemented by <a href="http://jens-lehmann.org" target="_blank">Jens Lehmann</a> and + Sebastian Knappe at the <a href="http:/aksw.org" target="_blank">AKSW</a> research group (University of Leipzig).</p> - <a href="http://www.w3.org/2004/OWL/"><img src="images/sw-owl-green.png" alt="OWL logo" /></a> - <a href="http://www.w3.org/2001/sw/DataAccess/"><img src="images/sw-sparql-green.png" alt="SPARQL logo"/></a> + <a href="http://www.w3.org/2004/OWL/" target="_blank"><img src="images/sw-owl-green.png" alt="OWL logo" /></a> + <a href="http://www.w3.org/2001/sw/DataAccess/" target="_blank"><img src="images/sw-sparql-green.png" alt="SPARQL logo"/></a> </div> </div><!-- END leftSidebar --> @@ -152,45 +167,12 @@ $uri = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; echo '<div><a href="http://validator.w3.org/check?uri='.$uri.'"'; - echo '><img src="images/valid-xhtml10.png" alt="valid XHTML 1.0" /></a>'."\n"; + echo ' target="_blank"><img src="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="images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; + echo ' target="_blank"><img src="images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; ?> - </div> - <p><a href='rebuild.php'>rebuild [restart session and redownload WSDL file (for debugging)]</a></p> + </div> </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>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>[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> -</ul> -</div> - </body> </html> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |