From: <sk...@us...> - 2008-09-16 03:18:53
|
Revision: 1218 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1218&view=rev Author: sknappe Date: 2008-09-16 10:18:49 +0000 (Tue, 16 Sep 2008) Log Message: ----------- had to change the separation symbol between texts and also changed the way instances of concepts for some special concepts are found, cant test now, because I only get bad concepts Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/ajax_get_class.php trunk/src/dbpedia-navigator/ajax_get_subjects_from_category.php trunk/src/dbpedia-navigator/ajax_get_subjects_from_concept.php trunk/src/dbpedia-navigator/ajax_learn_concepts.php trunk/src/dbpedia-navigator/ajax_remove_neg_interest.php trunk/src/dbpedia-navigator/ajax_remove_pos_interest.php trunk/src/dbpedia-navigator/ajax_search.php trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php trunk/src/dbpedia-navigator/ajax_to_negative.php trunk/src/dbpedia-navigator/ajax_to_positive.php trunk/src/dbpedia-navigator/helper_functions.php trunk/src/dbpedia-navigator/js/ajax.js Modified: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -232,16 +232,16 @@ $interests=show_Interests($_SESSION); print $content; - print '$$'; + print '$$$'; print $artTitle; - print '$$'; + print '$$$'; print $lastArticles; - print '$$'; + print '$$$'; print $interests[0]; - print '$$'; + print '$$$'; print $interests[1]; - print '$$'; + print '$$$'; print $lat; - print '$$'; + print '$$$'; print $long; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_get_class.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_class.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_get_class.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -116,8 +116,8 @@ } print $content; - print '$$'; + print '$$$'; print "Class: ".$title; - print '$$'; + print '$$$'; print $lastClasses; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_get_subjects_from_category.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_subjects_from_category.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_get_subjects_from_category.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -48,8 +48,8 @@ $content.="Your Search brought no results."; print $content; - print '$$'; + print '$$$'; print "Searchresult for Category \"".$label."\""; - print '$$'; + print '$$$'; print $bestsearches; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_get_subjects_from_concept.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_subjects_from_concept.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_get_subjects_from_concept.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -1,8 +1,12 @@ <?php - include('helper_functions.php'); + include_once('helper_functions.php'); + include_once('Settings.php'); + include_once('DatabaseConnection.php'); - $manchester=$_POST['manchester']; - $kb=$_POST['kb']; + $manchester=html_entity_decode($_POST['manchester']); + $kb=html_entity_decode($_POST['kb']); + $number=$_POST['number']; + $label=$_POST['label']; session_start(); $id=$_SESSION['id']; @@ -13,12 +17,57 @@ $concept=html_entity_decode($concept); - $test=preg_match("/(http:\/\/dbpedia\.org\/class\/yago\/[^\040]+(\040)*(AND|OR)*)+/",$manchester); + $test=preg_match("/^([\(]*http:\/\/dbpedia\.org\/class\/yago\/[^\040]+[\)]*(\040(AND|OR)\040)?)+$/",$such); + $content=""; if ($test){ + preg_match_all("/http:\/\/dbpedia\.org\/class\/yago\/[^\040()]+/",$such,$treffer,PREG_OFFSET_CAPTURE); + + $final=''; + $i=1; + $pos=0; + foreach ($treffer[0] as $tref){ + $final.=substr($such,$pos,$tref[1]-$pos); + $final.='cat'.$i.'.category=\''.substr($such,$tref[1],strlen($tref[0])).'\''; + $i++; + $pos=$tref[1]+strlen($tref[0]); + } + $final.=substr($such,$pos); + $temp='SELECT cat1.name FROM '; + for ($j=0;$j<$i-1;$j++) + if ($j!=$i-2) $temp.='articlecategories as cat'.($j+1).','; + else $temp.='articlecategories as cat'.($j+1); + $temp.=' WHERE '; + for ($j=1;$j<$i-1;$j++) + $temp.='cat'.$j.'.name=cat'.($j+1).'.name AND '; + $query=$temp.'('.$final.') LIMIT '.$number; + + //connect to the database + $settings=new Settings(); + $databaseConnection=new DatabaseConnection($settings->database_type); + $databaseConnection->connect($settings->database_server,$settings->database_user,$settings->database_pass); + $databaseConnection->select_database($settings->database_name); + + $res=$databaseConnection->query($query); + $bestsearches=""; + if ($databaseConnection->numberOfEntries($res)>0){ + $names=array(); + $labels=array(); + while ($result=$databaseConnection->nextEntry($res)){ + $names[]=$result['name']; + $query="SELECT label FROM rank WHERE name='".$result['name']."' LIMIT 1"; + $res2=$databaseConnection->query($query); + $result2=$databaseConnection->nextEntry($res2); + $labels[]=$result2['label']; + } + $content.=getConceptResultsTable($names,$labels,htmlentities($manchester),htmlentities($kb),$label,$number); + $bestsearches=getBestSearches($names,$labels); + } + else + $content.="Your Search brought no results."; } - $content=""; + else{ /*try{ require_once("DLLearnerConnection.php"); $sc=new DLLearnerConnection($id,$ksID); @@ -27,8 +76,11 @@ } catch (Exception $e){ $content=$e->getMessage(); }*/ + } - print $test."ho"; - print '$$'; - print "Instances for Concept ".$concept; + print $content; + print '$$$'; + print "Instances for Concept \"".$label."\""; + print '$$$'; + print $bestsearches; ?> \ 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:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_learn_concepts.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -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'])."');return false;\" />".$label."</a> (Accuracy: ".(floatVal($con['accuracy'])*100)."%)</td></tr>"; + $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.="</table>"; } Modified: trunk/src/dbpedia-navigator/ajax_remove_neg_interest.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_remove_neg_interest.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_remove_neg_interest.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -10,6 +10,6 @@ $interests=show_Interests($_SESSION); print $interests[0]; - print '$$'; + print '$$$'; print $interests[1]; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_remove_pos_interest.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_remove_pos_interest.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_remove_pos_interest.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -10,6 +10,6 @@ $interests=show_Interests($_SESSION); print $interests[0]; - print '$$'; + print '$$$'; print $interests[1]; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_search.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_search.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_search.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -65,8 +65,8 @@ $content.="Your Search brought no results."; print $content; - print '$$'; + print '$$$'; print "Searchresult for \"".$label."\""; - print '$$'; + print '$$$'; print $bestsearches; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_set_positives_and_negatives.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -42,6 +42,6 @@ $interests=show_Interests($_SESSION); print $interests[0]; - print '$$'; + print '$$$'; print $interests[1]; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_to_negative.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_to_negative.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_to_negative.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -20,6 +20,6 @@ $interests=show_Interests($_SESSION); print $interests[0]; - print '$$'; + print '$$$'; print $interests[1]; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajax_to_positive.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_to_positive.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/ajax_to_positive.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -20,6 +20,6 @@ $interests=show_Interests($_SESSION); print $interests[0]; - print '$$'; + print '$$$'; print $interests[1]; ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-09-16 10:18:49 UTC (rev 1218) @@ -150,6 +150,48 @@ return $ret; } +function getConceptResultsTable($names,$labels,$manchester,$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;\""; + if ($k==$number) $ret.=" style=\"text-decoration:none;\""; + else $ret.=" style=\"text-decoration:underline;\""; + $ret.=">".($k)."</a>"; + if ($k!=100) $ret.=" | "; + if($k==10) $k=25; + else $k=$k+25; + } + $ret.="</p><br/>"; + $i=0; + $display="block"; + $ret.="<div id=\"results\">"; + while($i*25<count($names)) + { + for ($j=0;($j<25)&&(($i*25+$j)<count($names));$j++) + { + $name=$names[$i*25+$j]; + $label=$labels[$i*25+$j]; + if (strlen($label)==0) $label=urldecode(str_replace("_"," ",substr (strrchr ($name, "/"), 1))); + $ret.='<p style="display:'.$display.'"> '.($i*25+$j+1).'. <a class="all" href="" onclick="get_article(\'label='.$name.'&cache=-1\');return false;">'.utf8_to_html($label).'</a></p>'; + } + $i++; + $display="none"; + } + $ret.='<input type="hidden" id="hidden_class" value="all"/><input type="hidden" id="hidden_number" value="0"/></div><br/><p style="width:100%;text-align:center;" id="sitenumbers">'; + for ($k=0;$k<$i;$k++){ + $ret.="<span>"; + if ($k!=0) $ret.=" | "; + $ret.="<a href=\"#\" onclick=\"document.getElementById('hidden_number').value='".(25*$k)."';show_results(document.getElementById('hidden_class').value,".(25*$k).");\""; + if ($k==0) $ret.=" style=\"text-decoration:none;\""; + else $ret.=" style=\"text-decoration:underline;\""; + $ret.=">".($k+1)."</a>"; + $ret.="</span>"; + } + $ret.="</p>"; + return $ret; +} + function getBestSearches($names,$labels) { $ret="<div id=\"best-results\">"; Modified: trunk/src/dbpedia-navigator/js/ajax.js =================================================================== --- trunk/src/dbpedia-navigator/js/ajax.js 2008-09-16 07:19:01 UTC (rev 1217) +++ trunk/src/dbpedia-navigator/js/ajax.js 2008-09-16 10:18:49 UTC (rev 1218) @@ -14,7 +14,7 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('articlecontent').innerHTML=response[0]; document.getElementById('ArticleTitle').innerHTML=response[1]; if (response[2].length>0){ @@ -45,7 +45,7 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('articlecontent').innerHTML=response[0]; document.getElementById('ArticleTitle').innerHTML=response[1]; document.getElementById('lastarticles').innerHTML=response[2]; @@ -83,7 +83,7 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('articlecontent').innerHTML=response[0]; document.getElementById('ArticleTitle').innerHTML=response[1]; document.getElementById('lastclasses').innerHTML=response[2]; @@ -111,7 +111,7 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('Positives').innerHTML=response[0]; document.getElementById('Negatives').innerHTML=response[1]; } @@ -137,7 +137,7 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('Positives').innerHTML=response[0]; document.getElementById('Negatives').innerHTML=response[1]; } @@ -211,7 +211,7 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('Positives').innerHTML=response[0]; document.getElementById('Negatives').innerHTML=response[1]; } @@ -237,7 +237,7 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('Positives').innerHTML=response[0]; document.getElementById('Negatives').innerHTML=response[1]; } @@ -315,9 +315,13 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('articlecontent').innerHTML=response[0]; document.getElementById('ArticleTitle').innerHTML=response[1]; + if (response[2].length>0){ + document.getElementById('searchcontent').innerHTML=response[2]; + document.getElementById('SearchResultBox').style.display='block'; + } } } @@ -341,7 +345,7 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('articlecontent').innerHTML=response[0]; document.getElementById('ArticleTitle').innerHTML=response[1]; if (response[2].length>0){ @@ -371,7 +375,7 @@ XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200){ - var response = XhrObj.responseText.split('$$'); + var response = XhrObj.responseText.split('$$$'); document.getElementById('Positives').innerHTML=response[0]; document.getElementById('Negatives').innerHTML=response[1]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |