From: <sk...@us...> - 2007-10-29 10:26:55
|
Revision: 263 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=263&view=rev Author: sknappe Date: 2007-10-29 03:26:51 -0700 (Mon, 29 Oct 2007) Log Message: ----------- added function to learn a concept to ajax version Modified Paths: -------------- trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php trunk/src/dbpedia-navigator/Ajax-Test/ajax.php trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php trunk/src/dbpedia-navigator/Ajax-Test/index.php Modified: trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php 2007-10-28 09:14:13 UTC (rev 262) +++ trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php 2007-10-29 10:26:51 UTC (rev 263) @@ -42,21 +42,12 @@ $this->client->init($id); - $learn_start = microtime(true); - $init = $learn_start - $start; - echo 'components initialised in '.$init.' seconds<br />'; - $threaded=true; if($threaded == false) { $concept = $this->client->learn($id); - $learn = microtime(true) - $learn_start; - echo 'concept learned in '.$learn.' seconds<br />'; - - echo 'result: '.$concept; - } else { $this->client->learnThreaded($id); @@ -74,12 +65,9 @@ $seconds = $i * $sleeptime; - echo 'result after '.$seconds.' seconds of sleep: '.$concept.'<br />'; - $i++; } while($running); - echo 'algorithm finished'; } return $concept; } Modified: trunk/src/dbpedia-navigator/Ajax-Test/ajax.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/ajax.php 2007-10-28 09:14:13 UTC (rev 262) +++ trunk/src/dbpedia-navigator/Ajax-Test/ajax.php 2007-10-29 10:26:51 UTC (rev 263) @@ -14,4 +14,8 @@ $xajax->registerFunction('addNegative'); $xajax->registerFunction('clearPositives'); $xajax->registerFunction('clearNegatives'); +$xajax->register(XAJAX_FUNCTION, 'learnConcept', array( + 'onResponseDelay' => 'showLoadingConcept', + 'beforeResponseProcessing' => 'hideLoadingConcept' + )); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php 2007-10-28 09:14:13 UTC (rev 262) +++ trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php 2007-10-29 10:26:51 UTC (rev 263) @@ -1,4 +1,5 @@ <?php +session_start(); function getsubjects($label, $limit) { include_once("Settings.php"); @@ -94,6 +95,25 @@ return $objResponse; } +function learnConcept() +{ + $concept=""; + if (isset($_SESSION['positive'])&&isset($_SESSION['negative'])) + { + require_once("Settings.php"); + require_once("SparqlConnection.php"); + $settings=new Settings(); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + + $concept.=$sc->getConceptFromExamples($_SESSION['positive'],$_SESSION['negative']); + } + else $concept.="You must choose at least one<br/> positive and one negative example."; + + $objResponse = new xajaxResponse(); + $objResponse->assign("conceptcontent", "innerHTML", $concept); + return $objResponse; +} + require("ajax.php"); $xajax->processRequest(); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/Ajax-Test/index.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/index.php 2007-10-28 09:14:13 UTC (rev 262) +++ trunk/src/dbpedia-navigator/Ajax-Test/index.php 2007-10-29 10:26:51 UTC (rev 263) @@ -1,6 +1,10 @@ <?php session_start(); +unset($_SESSION['positive']); +unset($_SESSION['negative']); + + require("ajax.php"); ini_set('error_reporting',E_ALL); ini_set('max_execution_time',200); @@ -29,6 +33,14 @@ hideLoadingArticle = function() { xajax.$('loadingArticle').style.display = 'none'; xajax.$('articlecontent').style.display = 'block'; + }; + showLoadingConcept = function() { + xajax.$('loadingConcept').style.display='block'; + xajax.$('conceptcontent').style.display = 'none'; + }; + hideLoadingConcept = function() { + xajax.$('loadingConcept').style.display = 'none'; + xajax.$('conceptcontent').style.display = 'block'; } </script> </head> @@ -64,6 +76,14 @@ </div> <!-- boxcontent --> </div> <!-- box --> +<div class="box" id="concept"> + <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left">Learned Concept</td><td class="right"><input type="button" value="Learn" class="button" onclick="xajax_learnConcept();return false;" /></td></tr></table></div> + <div class="boxcontent"> + <div id="conceptcontent" style="display:none"></div> + <div id="loadingConcept" style="display:none"><img src="ajax-loader.gif" alt="Loading..."/></div> + </div> <!-- boxcontent --> +</div> <!-- box --> + <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> </div><!-- END leftSidebar --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |