From: <sk...@us...> - 2008-09-23 18:37:22
|
Revision: 1242 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1242&view=rev Author: sknappe Date: 2008-09-23 18:35:57 +0000 (Tue, 23 Sep 2008) Log Message: ----------- design changes, filters, bugfixes, resource as object, etc. Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajax_generate_URL.php trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/ajax_get_subjects_from_concept.php trunk/src/dbpedia-navigator/ajax_learn_concepts.php trunk/src/dbpedia-navigator/helper_functions.php trunk/src/dbpedia-navigator/index.php trunk/src/dbpedia-navigator/js/navigator.js Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-09-23 10:46:20 UTC (rev 1241) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-09-23 18:35:57 UTC (rev 1242) @@ -135,14 +135,18 @@ function getTriples($uri) { //i am filtering the references out at the moment, because they are causing errors with URL with ...&profile=bla, the XMLParser thinks &profile is a HTML-Entitie and misses the ; - $query="SELECT ?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'))}}"; + $query="SELECT ?pred ?obj ?sub ". + "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'))}UNION{?sub ?pred <".$uri.">}UNION{<".$uri."> <http://dbpedia.org/property/redirect> ?Conc.?sub ?pred ?Conc}}"; $result=json_decode($this->getSparqlResultThreaded($query),true); if (count($result['results']['bindings'])==0) throw new Exception("An article with that name does not exist. The 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; + if (isset($results['obj'])) $value=$results['obj']; + else if (isset($results['sub'])) $value=$results['sub']; + if (!(isset($value['xml:lang'])&&($value['xml:lang']!=$this->lang))){ + if (isset($results['obj'])) $ret[0][$results['pred']['value']][]=$value; + else if (isset($results['sub'])) $ret[1][$results['pred']['value']][]=$value; + } } return $ret; @@ -256,7 +260,7 @@ } return $ret; } - + /*not used at the moment function getYagoSubCategories($category) { $query="SELECT ?subject ?label count(?subclass) as ?numberOfSubclasses\n". @@ -272,7 +276,7 @@ if (strlen($res['label'])>0) $ret[]=$res; } return $ret; - } + }*/ public function loadWSDLfiles($wsdluri){ $main=DLLearnerConnection::getwsdl($wsdluri); Modified: trunk/src/dbpedia-navigator/ajax_generate_URL.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_generate_URL.php 2008-09-23 10:46:20 UTC (rev 1241) +++ trunk/src/dbpedia-navigator/ajax_generate_URL.php 2008-09-23 18:35:57 UTC (rev 1242) @@ -3,6 +3,7 @@ $positives=$_SESSION['positive']; $negatives=$_SESSION['negative']; + $attr=array(); $pos=""; $i=1; if (isset($_SESSION['positive'])) foreach ($positives as $key=>$value){ @@ -10,7 +11,10 @@ else $pos.=$key; $i++; } - if (strlen($pos)>0) $pos='positives=['.$pos.']'; + if (strlen($pos)>0){ + $pos='positives=['.$pos.']'; + $attr[]=$pos; + } $neg=""; $i=1; if (isset($_SESSION['negative'])) foreach ($negatives as $key=>$value){ @@ -18,12 +22,19 @@ else $neg.=$key; $i++; } - if (strlen($neg)>0) $neg='negatives=['.$neg.']'; - - if (strlen($pos)>0||strlen($neg)>0) $interests='?'.$pos.$neg; - else $interests=""; + if (strlen($neg)>0){ + $neg.='negatives=['.$neg.']'; + $attr[]=$neg; + } - $url='http://'.$_SERVER['HTTP_HOST'].'/dbpedia-navigator/'.$_SESSION['lastAction'].$interests; + $last_action=$_SESSION['lastAction']; + if (strpos($last_action,'searchConceptInstances')===0){ + $attr[]='concept='.substr($last_action,strpos($last_action, "/")+1); + $last_action='searchConceptInstances/Concept'; + } + $attributes='?'.implode('&',$attr); + $url='http://'.$_SERVER['HTTP_HOST'].'/dbpedia-navigator/'.$last_action.$attributes; + print $url.'<br/><br/>'; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-09-23 10:46:20 UTC (rev 1241) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-09-23 18:35:57 UTC (rev 1242) @@ -46,7 +46,9 @@ try{ require_once("DLLearnerConnection.php"); $sc=new DLLearnerConnection($id,$ksID); - $triples=$sc->getTriples($uri); + $alltriples=$sc->getTriples($uri); + $triples=$alltriples[0]; + $subjecttriples=$alltriples[1]; //BUILD ARTICLE // goal: display the data in a nice (DBpedia specific way), maybe similar to @@ -83,7 +85,8 @@ $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>'; } - if (isset($triples['http://www.w3.org/2002/07/owl#sameAs'])){ + //display owl:sameAs properties + if (isset($triples['http://www.w3.org/2002/07/owl#sameAs'])||isset($subjecttriples['http://www.w3.org/2002/07/owl#sameAs'])){ $content.='<br/><hr><h4>Same as</h4><br/>'; $content.='<ul>'; foreach ($triples['http://www.w3.org/2002/07/owl#sameAs'] as $same){ @@ -91,12 +94,18 @@ $content .= '<li><a href="'.$same['value'].'" target="_blank">'.urldecode($same['value']).'</a></li>'; else $content.= '<li>'.urldecode($same['value']).'</li>'; } + if (isset($subjecttriples['http://www.w3.org/2002/07/owl#sameAs'])) foreach ($subjecttriples['http://www.w3.org/2002/07/owl#sameAs'] as $same){ + if ($same['type']=="uri") + $content .= '<li><a href="'.$same['value'].'" target="_blank">'.urldecode($same['value']).'</a></li>'; + else $content.= '<li>'.urldecode($same['value']).'</li>'; + } $content.='</ul>'; } + // display a list of classes $content.='<br/><hr><h4>YAGO Classes</h4><br/>'; - // display a list of classes + if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) $content .= '<p>'.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; @@ -137,7 +146,7 @@ $birthuri=false; foreach ($birthdates as $dates){ if ($birthdate!=false){ - unset($triples[$dates]); + if (isset($triples[$dates])) unset($triples[$dates]); continue; } if (isset($triples[$dates])&&$triples[$dates][0]['type']!='uri'){ @@ -148,7 +157,7 @@ $birthuri=$dates; $characteristics['Birthdate']=$triples[$dates]; } - else unset($triples[$dates]); + else if (isset($triples[$dates])) unset($triples[$dates]); } //display only one deathdate @@ -157,7 +166,7 @@ $deathuri=false; foreach ($deathdates as $dates){ if ($deathdate!=false){ - unset($triples[$dates]); + if (isset($triples[$dates])) unset($triples[$dates]); continue; } if (isset($triples[$dates])&&$triples[$dates][0]['type']!='uri'){ @@ -168,7 +177,7 @@ $deathuri=$dates; $characteristics['Deathdate']=$triples[$dates]; } - else unset($triples[$dates]); + else if (isset($triples[$dates])) unset($triples[$dates]); } //display a small characteristics of a person, if at least the birth date is given @@ -179,15 +188,13 @@ if (isset($triples['http://dbpedia.org/property/birthPlace'])) $characteristics['Birthplace']=$triples['http://dbpedia.org/property/birthPlace']; if (isset($triples['http://dbpedia.org/property/deathPlace'])) $characteristics['Deathplace']=$triples['http://dbpedia.org/property/deathPlace']; if (isset($triples['http://dbpedia.org/property/spouse'])) $characteristics['Spouse']=$triples['http://dbpedia.org/property/spouse']; - if (isset($triples['http://dbpedia.org/property/shortDescription'])) $characteristics['Short Description']=$triples['http://dbpedia.org/property/shortDescription']; if (isset($triples['http://dbpedia.org/property/alternativeNames'])) $characteristics['Alternative Names']=$triples['http://dbpedia.org/property/alternativeNames']; $content.=createCharacteristics($characteristics); - unset($triples['http://dbpedia.org/property/birthname']); - unset($triples['http://dbpedia.org/property/birthPlace']); - unset($triples['http://dbpedia.org/property/deathPlace']); - unset($triples['http://dbpedia.org/property/spouse']); - unset($triples['http://dbpedia.org/property/shortDescription']); - unset($triples['http://dbpedia.org/property/alternativeNames']); + if (isset($triples['http://dbpedia.org/property/birthname'])) unset($triples['http://dbpedia.org/property/birthname']); + if (isset($triples['http://dbpedia.org/property/birthPlace'])) unset($triples['http://dbpedia.org/property/birthPlace']); + if (isset($triples['http://dbpedia.org/property/deathPlace'])) unset($triples['http://dbpedia.org/property/deathPlace']); + if (isset($triples['http://dbpedia.org/property/spouse'])) unset($triples['http://dbpedia.org/property/spouse']); + if (isset($triples['http://dbpedia.org/property/alternativeNames'])) unset($triples['http://dbpedia.org/property/alternativeNames']); if ($birthdate!=false) unset($triples[$birthdate]); if ($birthuri!=false) unset($triples[$birthuri]); if ($deathdate!=false) unset($triples[$deathdate]); @@ -224,54 +231,70 @@ // filter out uninteresting properties and properties which // have already been displayed - unset($triples['http://www.w3.org/2002/07/owl#sameAs']); - 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']); - unset($triples['http://www.w3.org/2000/01/rdf-schema#comment']); - unset($triples['http://dbpedia.org/property/latSec']); - unset($triples['http://dbpedia.org/property/lonSec']); - unset($triples['http://dbpedia.org/property/lonDeg']); - unset($triples['http://dbpedia.org/property/latMin']); - unset($triples['http://dbpedia.org/property/lonMin']); - unset($triples['http://dbpedia.org/property/latDeg']); - unset($triples['http://dbpedia.org/property/lonMin']); - unset($triples['http://www.georss.org/georss/point']); - unset($triples['http://dbpedia.org/property/audioProperty']); - unset($triples['http://dbpedia.org/property/wikiPageUsesTemplate']); - unset($triples['http://dbpedia.org/property/relatedInstance']); - unset($triples['http://dbpedia.org/property/boxWidth']); - unset($triples['http://dbpedia.org/property/pp']); - unset($triples['http://dbpedia.org/property/caption']); - unset($triples['http://dbpedia.org/property/s']); - unset($triples['http://dbpedia.org/property/lifetimeProperty']); - unset($triples['http://dbpedia.org/property/imagesize']); - unset($triples['http://dbpedia.org/property/id']); - unset($triples['http://dbpedia.org/property/issue']); - if ($triples['http://dbpedia.org/property/hips'][0]['type']=='uri') unset($triples['http://dbpedia.org/property/hips']); - if ($triples['http://dbpedia.org/property/weight'][0]['type']=='uri') unset($triples['http://dbpedia.org/property/weight']); - if ($triples['http://dbpedia.org/property/waist'][0]['type']=='uri') unset($triples['http://dbpedia.org/property/waist']); - if ($triples['http://dbpedia.org/property/height'][0]['type']=='uri') unset($triples['http://dbpedia.org/property/height']); - unset($triples['http://www.geonames.org/ontology#featureCode']); - unset($triples['http://www.geonames.org/ontology#featureClass']); - unset($triples['http://dbpedia.org/property/dmozProperty']); - unset($triples['http://dbpedia.org/property/color']); - unset($triples['http://dbpedia.org/property/imageCaption']); - unset($triples['http://dbpedia.org/property/name']); + if (isset($triples['http://www.w3.org/2002/07/owl#sameAs'])) unset($triples['http://www.w3.org/2002/07/owl#sameAs']); + if (isset($subjecttriples['http://www.w3.org/2002/07/owl#sameAs'])) unset($subjecttriples['http://www.w3.org/2002/07/owl#sameAs']); + if (isset($triples['http://xmlns.com/foaf/0.1/page'])) unset($triples['http://xmlns.com/foaf/0.1/page']); + if (isset($triples['http://xmlns.com/foaf/0.1/depiction'])) unset($triples['http://xmlns.com/foaf/0.1/depiction']); + if (isset($triples['http://dbpedia.org/property/abstract'])) unset($triples['http://dbpedia.org/property/abstract']); + if (isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) unset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']); + if (isset($triples['http://dbpedia.org/property/redirect'])) unset($triples['http://dbpedia.org/property/redirect']); + if (isset($triples['http://dbpedia.org/property/reference'])) unset($triples['http://dbpedia.org/property/reference']); + if (isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'])) unset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long']); + if (isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'])) unset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat']); + if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])) unset($triples['http://dbpedia.org/property/hasPhotoCollection']); + if (isset($triples['http://www.w3.org/2004/02/skos/core#subject'])) unset($triples['http://www.w3.org/2004/02/skos/core#subject']); + if (isset($triples['http://www.w3.org/2000/01/rdf-schema#label'])) unset($triples['http://www.w3.org/2000/01/rdf-schema#label']); + if (isset($triples['http://www.w3.org/2000/01/rdf-schema#comment'])) unset($triples['http://www.w3.org/2000/01/rdf-schema#comment']); + if (isset($triples['http://dbpedia.org/property/latSec'])) unset($triples['http://dbpedia.org/property/latSec']); + if (isset($triples['http://dbpedia.org/property/lonSec'])) unset($triples['http://dbpedia.org/property/lonSec']); + if (isset($triples['http://dbpedia.org/property/lonDeg'])) unset($triples['http://dbpedia.org/property/lonDeg']); + if (isset($triples['http://dbpedia.org/property/latMin'])) unset($triples['http://dbpedia.org/property/latMin']); + if (isset($triples['http://dbpedia.org/property/lonMin'])) unset($triples['http://dbpedia.org/property/lonMin']); + if (isset($triples['http://dbpedia.org/property/latDeg'])) unset($triples['http://dbpedia.org/property/latDeg']); + if (isset($triples['http://dbpedia.org/property/lonMin'])) unset($triples['http://dbpedia.org/property/lonMin']); + if (isset($triples['http://www.georss.org/georss/point'])) unset($triples['http://www.georss.org/georss/point']); + if (isset($triples['http://dbpedia.org/property/audioProperty'])) unset($triples['http://dbpedia.org/property/audioProperty']); + if (isset($triples['http://dbpedia.org/property/wikiPageUsesTemplate'])) unset($triples['http://dbpedia.org/property/wikiPageUsesTemplate']); + if (isset($triples['http://dbpedia.org/property/relatedInstance'])) unset($triples['http://dbpedia.org/property/relatedInstance']); + if (isset($triples['http://dbpedia.org/property/boxWidth'])) unset($triples['http://dbpedia.org/property/boxWidth']); + if (isset($triples['http://dbpedia.org/property/pp'])) unset($triples['http://dbpedia.org/property/pp']); + if (isset($triples['http://dbpedia.org/property/caption'])) unset($triples['http://dbpedia.org/property/caption']); + if (isset($subjecttriples['http://dbpedia.org/property/caption'])) unset($subjecttriples['http://dbpedia.org/property/caption']); + if (isset($triples['http://dbpedia.org/property/s'])) unset($triples['http://dbpedia.org/property/s']); + if (isset($triples['http://dbpedia.org/property/lifetimeProperty'])) unset($triples['http://dbpedia.org/property/lifetimeProperty']); + if (isset($triples['http://dbpedia.org/property/imagesize'])) unset($triples['http://dbpedia.org/property/imagesize']); + if (isset($triples['http://dbpedia.org/property/id'])) unset($triples['http://dbpedia.org/property/id']); + if (isset($triples['http://dbpedia.org/property/issue'])) unset($triples['http://dbpedia.org/property/issue']); + if (isset($triples['http://dbpedia.org/property/hips'][0]['type']=='uri')) unset($triples['http://dbpedia.org/property/hips']); + if (isset($triples['http://dbpedia.org/property/weight'][0]['type']=='uri')) unset($triples['http://dbpedia.org/property/weight']); + if (isset($triples['http://dbpedia.org/property/waist'][0]['type']=='uri')) unset($triples['http://dbpedia.org/property/waist']); + if (isset($triples['http://dbpedia.org/property/height'][0]['type']=='uri')) unset($triples['http://dbpedia.org/property/height']); + if (isset($triples['http://www.geonames.org/ontology#featureCode'])) unset($triples['http://www.geonames.org/ontology#featureCode']); + if (isset($triples['http://www.geonames.org/ontology#featureClass'])) unset($triples['http://www.geonames.org/ontology#featureClass']); + if (isset($triples['http://dbpedia.org/property/dmozProperty'])) unset($triples['http://dbpedia.org/property/dmozProperty']); + if (isset($triples['http://dbpedia.org/property/color'])) unset($triples['http://dbpedia.org/property/color']); + if (isset($triples['http://dbpedia.org/property/imageCaption'])) unset($triples['http://dbpedia.org/property/imageCaption']); + if (isset($triples['http://dbpedia.org/property/name'])) unset($triples['http://dbpedia.org/property/name']); + if (isset($triples['http://dbpedia.org/property/audioIpaProperty'])) unset($triples['http://dbpedia.org/property/audioIpaProperty']); + if (isset($subjecttriples['http://dbpedia.org/property/redirect'])) unset($subjecttriples['http://dbpedia.org/property/redirect']); + if (isset($triples['http://dbpedia.org/property/audioDeProperty'])) unset($triples['http://dbpedia.org/property/audioDeProperty']); + if (isset($triples['http://dbpedia.org/property/art'])) unset($triples['http://dbpedia.org/property/art']); + if (isset($subjecttriples['http://dbpedia.org/property/babAsProperty'])) unset($subjecttriples['http://dbpedia.org/property/babAsProperty']); + if (isset($triples['http://dbpedia.org/property/babAsProperty'])) unset($triples['http://dbpedia.org/property/babAsProperty']); + if (isset($triples['http://dbpedia.org/property/imageWidth'])) unset($triples['http://dbpedia.org/property/imageWidth']); + if (isset($triples['http://dbpedia.org/property/rangeMapWidth'])) unset($triples['http://dbpedia.org/property/rangeMapWidth']); + if (isset($triples['http://dbpedia.org/property/rangeMapCaption'])) unset($triples['http://dbpedia.org/property/rangeMapCaption']); + if (isset($subjecttriples['http://dbpedia.org/property/nihongoProperty'])) unset($subjecttriples['http://dbpedia.org/property/nihongoProperty']); + if (isset($triples['http://dbpedia.org/property/shortDescription'])) unset($triples['http://dbpedia.org/property/shortDescription']); + if (isset($triples['http://dbpedia.org/property/refLabelProperty'])) unset($triples['http://dbpedia.org/property/refLabelProperty']); + if (isset($triples['http://dbpedia.org/property/noteLabelProperty'])) unset($triples['http://dbpedia.org/property/noteLabelProperty']); + if (isset($triples['http://dbpedia.org/property/wikisourcelangProperty'])) unset($triples['http://dbpedia.org/property/wikisourcelangProperty']); if (count($triples)>0){ $content.='<br/><hr><h4>Remaining Triples</h4><br/>'; // display the remaining properties as list which can be used for further navigation - $content .= get_triple_table($triples); + $content .= get_triple_table($triples,$subjecttriples); } //Restart the Session Modified: trunk/src/dbpedia-navigator/ajax_get_subjects_from_concept.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_subjects_from_concept.php 2008-09-23 10:46:20 UTC (rev 1241) +++ trunk/src/dbpedia-navigator/ajax_get_subjects_from_concept.php 2008-09-23 18:35:57 UTC (rev 1242) @@ -3,20 +3,25 @@ include_once('Settings.php'); include_once('DatabaseConnection.php'); - $manchester=html_entity_decode($_POST['manchester']); $kb=html_entity_decode($_POST['kb']); $number=$_POST['number']; - $label=$_POST['label']; - + session_start(); $id=$_SESSION['id']; $ksID=$_SESSION['ksID']; + //write last action into session + $actionuri=urlencode($kb); + $_SESSION['lastAction']='searchConceptInstances/'.$actionuri; session_write_close(); setRunning($id,"true"); - $test=preg_match("/^([\(]*http:\/\/dbpedia\.org\/class\/yago\/[^\040]+[\)]*(\040(AND|OR)\040)?)+$/",$manchester); + require_once("DLLearnerConnection.php"); + $sc=new DLLearnerConnection($id,$ksID); + $label=$sc->getNaturalDescription($kb); + $test=preg_match("/^([\(]*\"http:\/\/dbpedia\.org\/class\/yago\/[^\040]+\"[\)]*(\040(AND|OR)\040)?)+$/",$kb); + $content=""; if ($test){ //connect to the database @@ -25,24 +30,24 @@ $databaseConnection->connect($settings->database_server,$settings->database_user,$settings->database_pass); $databaseConnection->select_database($settings->database_name); - preg_match_all("/http:\/\/dbpedia\.org\/class\/yago\/[^\040()]+/",$manchester,$treffer,PREG_OFFSET_CAPTURE); + preg_match_all("/\"http:\/\/dbpedia\.org\/class\/yago\/[^\040()]+\"/",$kb,$treffer,PREG_OFFSET_CAPTURE); $final=''; $i=1; $pos=0; foreach ($treffer[0] as $tref){ - $final.=substr($manchester,$pos,$tref[1]-$pos).'('; - $category=substr($manchester,$tref[1],strlen($tref[0])); - $query='SELECT child FROM classhierarchy WHERE father=\''.$category.'\''; + $final.=substr($kb,$pos,$tref[1]-$pos).'('; + $category=substr($kb,$tref[1],strlen($tref[0])); + $query='SELECT child FROM classhierarchy WHERE father='.$category.''; $res=$databaseConnection->query($query); while ($result=$databaseConnection->nextEntry($res)){ - $final.='cat'.$i.'.category=\''.$result['child'].'\' OR '; + $final.='cat'.$i.'.category="'.$result['child'].'" OR '; } - $final.='cat'.$i.'.category=\''.$category.'\')'; + $final.='cat'.$i.'.category='.$category.')'; $i++; $pos=$tref[1]+strlen($tref[0]); } - $final.=substr($manchester,$pos); + $final.=substr($kb,$pos); $temp='SELECT cat1.name FROM '; for ($j=0;$j<$i-1;$j++) if ($j!=$i-2) $temp.='articlecategories as cat'.($j+1).','; @@ -65,7 +70,7 @@ $result2=$databaseConnection->nextEntry($res2); $labels[]=$result2['label']; } - $content.=getConceptResultsTable($names,$labels,htmlentities($manchester),htmlentities($kb),$label,$number); + $content.=getConceptResultsTable($names,$labels,htmlentities($kb),$label,$number); $bestsearches=getBestSearches($names,$labels); } else Modified: trunk/src/dbpedia-navigator/ajax_learn_concepts.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_learn_concepts.php 2008-09-23 10:46:20 UTC (rev 1241) +++ trunk/src/dbpedia-navigator/ajax_learn_concepts.php 2008-09-23 18:35:57 UTC (rev 1242) @@ -30,7 +30,7 @@ $concept.="<tr><td>You could also be interested in articles matching these descriptions:</td></tr>"; foreach ($concepts as $con){ $label=$sc->getNaturalDescription($con['descriptionKBSyntax']); - $concept.="<tr><td><a href=\"\" onclick=\"getSubjectsFromConcept('manchester=".htmlentities($con['descriptionManchesterSyntax'])."&kb=".htmlentities($con['descriptionKBSyntax'])."&label=".$label."&number=10');return false;\" />".$label."</a> (Accuracy: ".(floatVal($con['accuracy'])*100)."%)</td></tr>"; + $concept.="<tr><td><a href=\"\" onclick=\"getSubjectsFromConcept('kb=".htmlentities($con['descriptionKBSyntax'])."&number=10');return false;\" />".$label."</a> (Accuracy: ".(floatVal($con['accuracy'])*100)."%)</td></tr>"; } $concept.="</table>"; } Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-09-23 10:46:20 UTC (rev 1241) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-09-23 18:35:57 UTC (rev 1242) @@ -10,10 +10,11 @@ $subject=ucfirst($subject); //replace spaces with _ $subject=str_replace(' ','_',$subject); + $subject=urlencode($subject); //add the uri $subject="http://dbpedia.org/resource/".$subject; - return urldecode($subject); + return $subject; } function getTagCloud($tags,$label) @@ -104,6 +105,9 @@ $string=str_replace("u00F6","ö",$string); $string=str_replace("u00FC","ü",$string); $string=str_replace("u0161","š",$string); + $string=str_replace("u00FA","ú",$string); + $string=str_replace("u00F0","ð",$string); + $string=str_replace("u00E6","æ",$string); return $string; } @@ -150,11 +154,11 @@ return $ret; } -function getConceptResultsTable($names,$labels,$manchester,$kb,$label,$number) +function getConceptResultsTable($names,$labels,$kb,$label,$number) { $ret="<p>These are your results. Show best "; for ($k=10;$k<125;){ - $ret.="<a href=\"#\" onclick=\"getSubjectsFromConcept('manchester=".$manchester."&kb=".$kb."&label=".$label."number=".$k."');return false;\""; + $ret.="<a href=\"#\" onclick=\"getSubjectsFromConcept('kb=".$kb."&number=".$k."');return false;\""; if ($k==$number) $ret.=" style=\"text-decoration:none;\""; else $ret.=" style=\"text-decoration:underline;\""; $ret.=">".($k)."</a>"; @@ -220,9 +224,9 @@ fclose($file); } -function get_triple_table($triples) { +function get_triple_table($triples,$subjecttriples) { - $table = '<table border="0"><tr><td><b>Predicate</b></td><td><b>Object</b></td></tr>'; + $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); @@ -231,30 +235,77 @@ $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 ($number>1) $table.='<li>'; + 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\');return false;">'.urldecode($label).'</a>'; if ($number>1) $table.='</li>'; } else{ - if ($number>1) $table.='<li>'; - $table .= '<a href="'.$element['value'].'" target="_blank">'.urldecode($element['value']).'</a>'; + 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>'; + 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; } + 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\');return false;">'.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.'>'; + $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; + } $table .= '</table>'; return $table; } @@ -367,7 +418,7 @@ $ret.='<tr style="height:20px"><td><hr/></td></tr>'; $ret.='<tr><td style="font-size:14px;"><b>Current class</b></td></tr>'; $ret.='<tr style="height:10px"><td></td></tr>'; - $ret.='<tr><td><b>'.$title.'</b></td></tr>'; + $ret.='<tr><td><b>'.$title.'</b> ('.urldecode(str_replace("_"," ",substr (strrchr ($class, "/"), 1))).')</td></tr>'; $ret.='<tr style="height:10px"><td></td></tr>'; $ret.='<tr><td>'; $ret.='<input style="width:70px" type="button" value="Instances" class="button" onclick="getSubjectsFromCategory(\'category='.$class.'&number=10\');" title="Search Instances of Shown class."/>'; Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-09-23 10:46:20 UTC (rev 1241) +++ trunk/src/dbpedia-navigator/index.php 2008-09-23 18:35:57 UTC (rev 1242) @@ -21,6 +21,7 @@ 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');"; else if (isset($_SESSION['currentArticle'])){ $onLoad.="get_article('label=&cache=".$_SESSION['currentArticle']."');"; } @@ -75,7 +76,7 @@ </div> <!-- box --> <div class="box" id="SearchResultBox" style="display:none"> - <div class="boxtitle" style="cursor:help;" title="The best 10 Search Results are shown here.">Search Results</div> + <div class="boxtitle" style="cursor:help;" title="The best 10 Search Results are shown here.">Best Search Results</div> <div class="boxcontent"> <div id="searchcontent" style="display:block"></div> </div> <!-- boxcontent --> Modified: trunk/src/dbpedia-navigator/js/navigator.js =================================================================== --- trunk/src/dbpedia-navigator/js/navigator.js 2008-09-23 10:46:20 UTC (rev 1241) +++ trunk/src/dbpedia-navigator/js/navigator.js 2008-09-23 18:35:57 UTC (rev 1242) @@ -60,4 +60,22 @@ else sitenumbers[i].style.display='inline'; } -} \ No newline at end of file +} + +function toggleAttributes(element) +{ + var list=element.parentNode.getElementsByTagName('li'); + if (element.innerHTML.match('hide'+'$')=='hide'){ + element.innerHTML='<img src="images/arrow_down.gif"> show'; + for (var i=3;i<list.length;i++) + list[i].style.display='none'; + } + else { + element.innerHTML='<img src="images/arrow_up.gif"> hide'; + for (var i=3;i<list.length;i++) + list[i].style.display='list-item'; + } +} + +function none() +{} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |