From: <sk...@us...> - 2007-10-19 09:52:28
|
Revision: 249 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=249&view=rev Author: sknappe Date: 2007-10-19 02:52:23 -0700 (Fri, 19 Oct 2007) Log Message: ----------- new version Modified Paths: -------------- trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2007-10-19 09:47:16 UTC (rev 248) +++ trunk/src/dbpedia-navigator/index.php 2007-10-19 09:52:23 UTC (rev 249) @@ -7,37 +7,66 @@ ini_set('error_reporting',E_ALL); ini_set('max_execution_time',200); -$lastAction="View"; $content=""; -$possibleActions=""; -$instances=" "; -$left=""; -$right=""; -$middle=""; $search=""; -$system=""; +$examples=""; +$positiveAdd=""; +$negativeAdd=""; -$settings=new Settings(); +$settings=new Settings(); echo "<a href='index.php?clearsession=clear'>start from scratch</a>"; -if(isset($_GET['clearsession']))$_SESSION['State_ID'] =false; +if(isset($_GET['clearsession'])){ + unset($_SESSION['positive']); + unset($_SESSION['negative']); +} - - -if( (!isset($_SESSION['State_ID'] ) ) || ($_SESSION['State_ID']=="")) -{ - //get new ID - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); - $_SESSION['State_ID']=$sc->getID(); - -} - -else{ - //echo "Current ID is: ".$_SESSION['Learner_ID']."<br>"; - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['State_ID']); -} - - +$sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + +//add positives or negatives to session +if (@$_GET['action']=='AddPositive'){ + $_GET=$_SESSION["lastGet"]; + if (!isset($_SESSION['positive'])){ + $array=array($_GET['subject']); + $_SESSION['positive']=$array; + } + else{ + $array=$_SESSION['positive']; + $array[]=$_GET['subject']; + $_SESSION['positive']=$array; + } +} +if (@$_GET['action']=='AddNegative'){ + $_GET=$_SESSION["lastGet"]; + if (!isset($_SESSION['negative'])){ + $array=array($_GET['subject']); + $_SESSION['negative']=$array; + } + else{ + $array=$_SESSION['negative']; + $array[]=$_GET['subject']; + $_SESSION['negative']=$array; + } +} +if (@$_GET['action']=='ClearPositive'){ + $_GET=$_SESSION["lastGet"]; + unset($_SESSION['positive']); +} +if (@$_GET['action']=='ClearNegative'){ + $_GET=$_SESSION["lastGet"]; + unset($_SESSION['negative']); +} + +//learn a concept +if (@$_GET['action']=="GetConcept") +{ + $_GET=$_SESSION["lastGet"]; + $conc=$sc->getConceptFromExamples($_SESSION['positive'],$_SESSION['negative']); + $_SESSION['learnedConcept']=$conc; +} +if (isset($_SESSION['learnedConcept'])) $learnedConcept="<br/>Last learned Concept: ".$_SESSION['learnedConcept']; +else $learnedConcept=""; + //SearchBox $search="<form action=\"index.php\" method=\"GET\">\n". "<table border=\"0\">\n". @@ -70,17 +99,51 @@ foreach ($triples as $triple){ $content.="Subject: ".urldecode($triple[0])."<br/>Predicate: ".urldecode($triple[1])."<br/>Object: ".urldecode($triple[2])."<br/><br/>\n"; } - } + $positiveAdd="<input type=\"submit\" name=\"action\" value=\"AddPositive\">"; + $negativeAdd="<input type=\"submit\" name=\"action\" value=\"AddNegative\">"; + } + +//add box for adding articles to positive or negative + $examples.="<form action=\"index.php\" method=\"GET\">\n". + "Positive:<br/>\n"; + if (!isset($_SESSION['positive'])) $examples.="No positive example picked yet.<br/>\n"; + else{ + $pos=$_SESSION['positive']; + foreach ($pos as $p) + { + $examples.=$p."<br/>\n"; + } + } + $examples.="<br/>".$positiveAdd." <input type=\"submit\" name=\"action\" value=\"ClearPositive\">\n". + "</form>\n"; + + $examples.="<form action=\"index.php\" method=\"GET\">\n". + "<br/>Negative:<br/>\n"; + if (!isset($_SESSION['negative'])) $examples.="No negative example picked yet.<br/>\n"; + else{ + $neg=$_SESSION['negative']; + foreach ($neg as $n) + { + $examples.=$n."<br/>\n"; + } + } + $examples.="<br/>".$negativeAdd." <input type=\"submit\" name=\"action\" value=\"ClearNegative\">\n". + "</form>\n"; + +//fill concept box + $concept="<form action=\"index.php\" method=\"GET\">\n". + "<input type=\"submit\" name=\"action\" value=\"GetConcept\">\n". + "</form>\n"; + $concept.=$learnedConcept; - +//include master + $_SESSION['lastGet']=$_GET; include("master.php"); echo $masterContent; - - - - - + + + //make a box function makeBox($title,$content,$toggleBoxContent=true) { if($toggleBoxContent) @@ -97,14 +160,4 @@ </div> <!-- box -->"; return $ret; } - - - function shorten($a) - { - if(($strpos=strpos($a,'#'))>=4){ - return substr($a,$strpos); - } - else {return $a;} - } - ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |