From: <sk...@us...> - 2007-10-19 09:53:19
|
Revision: 250 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=250&view=rev Author: sknappe Date: 2007-10-19 02:53:14 -0700 (Fri, 19 Oct 2007) Log Message: ----------- new version Modified Paths: -------------- trunk/src/dbpedia-navigator/SparqlConnection.php trunk/src/dbpedia-navigator/master.php Modified: trunk/src/dbpedia-navigator/SparqlConnection.php =================================================================== --- trunk/src/dbpedia-navigator/SparqlConnection.php 2007-10-19 09:52:23 UTC (rev 249) +++ trunk/src/dbpedia-navigator/SparqlConnection.php 2007-10-19 09:53:14 UTC (rev 250) @@ -7,50 +7,39 @@ private $DBPediaUrl; private $DLLearnerUri; private $client; - private $id; - - public function getID(){ - return $this->id; - } - - function SparqlConnection($DBPediaUrl,$DLLearnerUri,$getID=0) + + function SparqlConnection($DBPediaUrl,$DLLearnerUri) { ini_set("soap.wsdl_cache_enabled","0"); $this->DBPediaUrl=$DBPediaUrl; $this->DLLearnerUri=$DLLearnerUri; $this->loadWSDLfiles($DLLearnerUri); $this->client=new SoapClient("main.wsdl"); - if($getID==0) - { - $this->id=$this->client->generateID(); - } - else - { - $this->id=$getID; - } } function getConceptFromExamples($posExamples,$negExamples) { - $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); - $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 2); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array_merge($posExamples,$negExamples)); - $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 0); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); - $this->client->applyConfigEntryString($this->id, $ksID, "format", "KB"); - $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); + $id=$this->client->generateID(); - $this->client->setReasoner($this->id, "dig"); - $this->client->setLearningProblem($this->id, "posNegDefinition"); - $this->client->setPositiveExamples($this->id, $posExamples); - $this->client->setNegativeExamples($this->id, $negExamples); - $this->client->setLearningAlgorithm($this->id, "refinement"); + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 2); + $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array_merge($posExamples,$negExamples)); + $this->client->applyConfigEntryInt($id, $ksID, "filterMode", 0); + $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($id, $ksID, "format", "KB"); + $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", true); + $this->client->setReasoner($id, "dig"); + $this->client->setLearningProblem($id, "posNegDefinition"); + $this->client->setPositiveExamples($id, $posExamples); + $this->client->setNegativeExamples($id, $negExamples); + $this->client->setLearningAlgorithm($id, "refinement"); + $start = microtime(true); - $this->client->init($this->id); + $this->client->init($id); $learn_start = microtime(true); $init = $learn_start - $start; @@ -96,18 +85,20 @@ function getTriples($individual) { - $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); - $this->client->applyConfigEntryInt($this->id, $ksID, "numberOfRecursions", 1); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "instances", array($individual)); - $this->client->applyConfigEntryInt($this->id, $ksID, "filterMode", 3); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "predList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "objList", array()); - $this->client->applyConfigEntryStringArray($this->id, $ksID, "classList", array()); - $this->client->applyConfigEntryString($this->id, $ksID, "format", "Array"); - $this->client->applyConfigEntryBoolean($this->id, $ksID, "dumpToFile", false); - $this->client->applyConfigEntryBoolean($this->id,$ksID,"useLits",true); + $id=$this->client->generateID(); - $object=$this->client->getTriples($this->id,$ksID); + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 1); + $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array($individual)); + $this->client->applyConfigEntryInt($id, $ksID, "filterMode", 3); + $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($id, $ksID, "format", "Array"); + $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", false); + $this->client->applyConfigEntryBoolean($id,$ksID,"useLits",true); + + $object=$this->client->getTriples($id,$ksID); $array=$object->item; $ret=array(); foreach ($array as $element) @@ -121,8 +112,10 @@ function getSubjects($label,$limit) { - $ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); - $object=$this->client->getSubjects($this->id,$ksID,$label,$limit); + $id=$this->client->generateID(); + + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $object=$this->client->getSubjects($id,$ksID,$label,$limit); return $object->item; } @@ -198,18 +191,4 @@ } } - -$positive=array("http://dbpedia.org/resource/Pythagoras", - "http://dbpedia.org/resource/Philolaus", - "http://dbpedia.org/resource/Archytas"); -$negative=array("http://dbpedia.org/resource/Socrates", - "http://dbpedia.org/resource/Zeno_of_Elea", - "http://dbpedia.org/resource/Plato"); - -$sparqlConnection=new SparqlConnection("http://dbpedia.openlinksw.com:8890/sparql","http://localhost:8181/services?wsdl"); -//$sparqlConnection->getConceptFromExamples($positive,$negative); -//$triples=$sparqlConnection->getTriples("http://dbpedia.org/resource/Leipzig"); -//print_r($triples); -//$subjects=$sparqlConnection->getSubjects("Leipzig",5); -//print_r($subjects); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/master.php =================================================================== --- trunk/src/dbpedia-navigator/master.php 2007-10-19 09:52:23 UTC (rev 249) +++ trunk/src/dbpedia-navigator/master.php 2007-10-19 09:53:14 UTC (rev 250) @@ -26,8 +26,22 @@ </div> <!-- box --> -".$left." +<div class=\"box\" id=\"examples\"> + <div class=\"boxtitle\">Examples<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> + <div class=\"boxcontent\"> + ".$examples." + </div> <!-- boxcontent --> + +</div> <!-- box --> +<div class=\"box\" id=\"examples\"> + <div class=\"boxtitle\">Concept<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> + <div class=\"boxcontent\"> + ".$concept." + </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 --> @@ -38,7 +52,7 @@ ".$content." </div> <!-- boxcontent --> </div> <!-- box --> -".$middle." + <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> </div><!-- content --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2007-10-22 18:35:41
|
Revision: 257 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=257&view=rev Author: sknappe Date: 2007-10-22 11:35:37 -0700 (Mon, 22 Oct 2007) Log Message: ----------- added Ajax-Test, an Ajax enhanced dbpedia navigator Modified Paths: -------------- trunk/src/dbpedia-navigator/Settings.php trunk/src/dbpedia-navigator/SparqlConnection.php trunk/src/dbpedia-navigator/index.php Added Paths: ----------- trunk/src/dbpedia-navigator/Ajax-Test/ trunk/src/dbpedia-navigator/Ajax-Test/Settings.php trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php trunk/src/dbpedia-navigator/Ajax-Test/ajax-loader.gif trunk/src/dbpedia-navigator/Ajax-Test/ajax.php trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php trunk/src/dbpedia-navigator/Ajax-Test/default.css trunk/src/dbpedia-navigator/Ajax-Test/index.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/LICENSE.txt trunk/src/dbpedia-navigator/Ajax-Test/xajax/README.txt trunk/src/dbpedia-navigator/Ajax-Test/xajax/copyright.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/copyright-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/helloworld-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/multiply/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/multiply/multiply-common-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/multiply/multiply-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/multiply/multiply-server-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/signup/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/signup/signup-common-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/signup/signup-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/signup/signup-server-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/thewall/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/thewall/thewall-common-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/thewall/thewall-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/thewall/thewall-server-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/xul/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/xul/xulApplication-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/examples/xul/xulServer-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/errorHandlingTest-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/index-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/legacy_tests/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/legacy_tests/catchAllFunctionTest-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/legacy_tests/index-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/legacy_tests/jsLoadingTest-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/legacy_tests/preFunctionTest-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/registerObjectTest-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/searchReplaceTest-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/alert_confirm-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/assign_append-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/callScriptTest-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/controls_html_401_transitional-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/controls_xhtml_10_transitional-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/css-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/delayEvents-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/events-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/functions-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/index-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/scriptContext-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/server_events-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/suite/theFrame-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/tests/xajaxResponseTest-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_controls/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_controls/content-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_controls/document-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_controls/form-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_controls/group-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_controls/misc-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_controls/structure-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/support/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/support/xajaxCallableObject-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/support/xajaxEvent-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/support/xajaxUserFunction-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/xajaxCallableObjectPlugin-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/xajaxDefaultIncludePlugin-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/xajaxEventPlugin-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/xajaxFunctionPlugin-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/plugin_layer/xajaxScriptPlugin-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajax-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxArgumentManager-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxCall-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxCompress-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxControl-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxLanguageManager-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxPlugin-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxPluginManager-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxRequest-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxResponse-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajaxResponseManager-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_core/xajax_lang_de-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_js/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_js/xajax_core_uncompressed-js.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_js/xajax_debug_uncompressed-js.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_js/xajax_lang_de_uncompressed-js.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_js/xajax_legacy_uncompressed-js.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_js/xajax_verbose_uncompressed-js.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_plugins/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_plugins/response/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_plugins/response/googleMap-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/xajax_plugins/response/tableUpdater-inc-php.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Classes.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Constants.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Files.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Functions.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Functions2.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Functions3.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Functions4.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Functions5.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General10.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General2.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General3.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General4.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General5.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General6.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General7.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General8.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/General9.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Variables.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index/Variables2.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/index.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/javascript/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/javascript/main.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/styles/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/styles/main.css trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/helloworld.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/multiply/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/multiply/multiply.common.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/multiply/multiply.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/multiply/multiply.server.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/signup/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/signup/signup.common.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/signup/signup.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/signup/signup.server.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/thewall/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/thewall/brick.jpg trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/thewall/thewall.common.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/thewall/thewall.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/thewall/thewall.server.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/xul/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/xul/xulApplication.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/xul/xulClient.xul trunk/src/dbpedia-navigator/Ajax-Test/xajax/examples/xul/xulServer.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/release_notes.txt trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/HTTPStatusTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/basicPluginTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/callScriptTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/callTechniquesTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/catchAllFunctionTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/changeEventTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/charEncodingTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/createFormInputTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/customResponseClassTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/disabledFormElementsTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/errorHandlingTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/eventHandlerTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/fluentInterfaceTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/formSubmissionTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/includeExternalScriptTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/index.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/largeResponseTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/legacy_tests/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/legacy_tests/catchAllFunctionTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/legacy_tests/index.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/legacy_tests/jsLoadingTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/legacy_tests/preFunctionTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/myExternalFunction.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/myExternalFunction.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/nonXajaxResponseTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/performance.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/phpWhitespaceTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/preFunctionTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/redirectTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/registerExternalFunctionTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/registerObjectTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/searchReplaceTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/alert_confirm.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/alert_confirm_external.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/assign_append.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/callScriptTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/controls_html_401_transitional.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/controls_xhtml_10_transitional.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/css.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/css1.css trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/css2.css trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/delayEvents.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/events.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/frame_left.htm trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/frame_right.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/frameset.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/functions.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/googleMap.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/iframe.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/iframe.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/index.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/none.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/options.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/pluginTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/scriptContext.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/server_events.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/tables.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/theFrame.html trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/theFrame.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/suite/transport.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/tests/xajaxResponseTest.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_controls/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_controls/content.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_controls/document.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_controls/form.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_controls/group.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_controls/misc.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_controls/structure.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_controls/validate_HTML401TRANSITIONAL.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_controls/validate_XHTML10TRANSITIONAL.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/legacy.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/support/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/support/xajaxCallableObject.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/support/xajaxEvent.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/support/xajaxUserFunction.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/xajaxCallableObjectPlugin.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/xajaxDefaultIncludePlugin.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/xajaxEventPlugin.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/xajaxFunctionPlugin.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/plugin_layer/xajaxScriptPlugin.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajax.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxArgumentManager.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxCall.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxCompress.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxControl.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxLanguageManager.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxPlugin.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxPluginManager.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxRequest.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxResponse.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajaxResponseManager.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_core/xajax_lang_de.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_core.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_core_uncompressed.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_debug.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_debug_uncompressed.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_lang_de.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_lang_de_uncompressed.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_legacy.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_legacy_uncompressed.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_verbose.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_js/xajax_verbose_uncompressed.js trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_plugins/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_plugins/request/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_plugins/response/ trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_plugins/response/googleMap.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_plugins/response/tableUpdater.inc.php trunk/src/dbpedia-navigator/Ajax-Test/xajax/xajax_plugins/response/tableUpdater.js Added: trunk/src/dbpedia-navigator/Ajax-Test/Settings.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/Settings.php (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/Settings.php 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,7 @@ +<?php + +class Settings{ + public $wsdluri="http://localhost:8181/services?wsdl"; + public $dbpediauri="http://dbpedia.openlinksw.com:8890/sparql"; +} +?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,195 @@ +<?php + +//require_once 'pear/HTTP_Request.php'; + +class SparqlConnection +{ + private $DBPediaUrl; + private $DLLearnerUri; + private $client; + + function SparqlConnection($DBPediaUrl,$DLLearnerUri) + { + ini_set("soap.wsdl_cache_enabled","0"); + ini_set('default_socket_timeout',200); + $this->DBPediaUrl=$DBPediaUrl; + $this->DLLearnerUri=$DLLearnerUri; + //$this->loadWSDLfiles($DLLearnerUri); + $this->client=new SoapClient("main.wsdl"); + } + + function getConceptFromExamples($posExamples,$negExamples) + { + $id=$this->client->generateID(); + + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 2); + $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array_merge($posExamples,$negExamples)); + $this->client->applyConfigEntryInt($id, $ksID, "filterMode", 0); + $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($id, $ksID, "format", "KB"); + $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", true); + + $this->client->setReasoner($id, "dig"); + $this->client->setLearningProblem($id, "posNegDefinition"); + $this->client->setPositiveExamples($id, $posExamples); + $this->client->setNegativeExamples($id, $negExamples); + $this->client->setLearningAlgorithm($id, "refinement"); + + $start = microtime(true); + + $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); + + $i = 1; + $sleeptime = 1; + + do { + // sleep a while + sleep($sleeptime); + + // see what we have learned so far + $concept=$this->client->getCurrentlyBestConcept($id); + $running=$this->client->isAlgorithmRunning($id); + + $seconds = $i * $sleeptime; + + echo 'result after '.$seconds.' seconds of sleep: '.$concept.'<br />'; + + $i++; + } while($running); + + echo 'algorithm finished'; + } + return $concept; + } + + function getTriples($individual) + { + $id=$this->client->generateID(); + + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 1); + $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array($individual)); + $this->client->applyConfigEntryInt($id, $ksID, "filterMode", -1); + $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); + $this->client->applyConfigEntryString($id, $ksID, "format", "Array"); + $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", false); + $this->client->applyConfigEntryBoolean($id,$ksID,"useLits",true); + + $object=$this->client->getTriples($id,$ksID); + $array=$object->item; + $ret=array(); + foreach ($array as $element) + { + $items=preg_split("[<]",$element,-1, PREG_SPLIT_NO_EMPTY); + $ret[]=$items; + } + + return $ret; + } + + function getSubjects($label='Leipzig',$limit=5) + { + $id=$this->client->generateID(); + + $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); + $object=$this->client->getSubjects($id,$ksID,$label,$limit); + return $object->item; + } + + private function loadWSDLfiles($wsdluri){ + $main=$this->getwsdl($wsdluri); + $other=$this->getOtherWSDL($main); + $newMain=$this->changeWSDL($main); + $this->writeToFile("main.wsdl",$newMain); + $x=0; + foreach ($other as $o){ + $this->writeToFile("def".($x++).".xsd",$this->getwsdl($o)); + } + + } + + private function changeWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $newWSDL=""; + $desca="def"; + $descb=".xsd"; + $x=0; + while($posstart= strpos ( $wsdl, $before )){ + + $posstart+=strlen($before); + $newWSDL.=substr($wsdl,0,$posstart); + $wsdl=substr($wsdl,$posstart); + $newWSDL.=$desca.($x++).$descb; + $posend= strpos ( $wsdl, $after ); + $wsdl=substr($wsdl,$posend); + + } + return $newWSDL.$wsdl; + + } + + private function getOtherWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $ret=array(); + while($posstart= strpos ( $wsdl, $before )){ + $posstart+=strlen($before); + $wsdl=substr($wsdl,$posstart); + $posend= strpos ( $wsdl, $after ); + $tmp=substr($wsdl,0,$posend); + $ret[]=$tmp; + $wsdl=substr($wsdl,$posend+strlen($after)); + } + return $ret; + } + + + + + private function getwsdl($wsdluri){ + // this is copied from the Pear example + // please don't ask me how it works + $req = &new HTTP_Request($wsdluri); + $message=""; + $req->setMethod(HTTP_REQUEST_METHOD_GET); + $req->sendRequest(); + $ret=$req->getResponseBody(); + return $ret; + } + + + + private function writeToFile($filename,$content){ + + $fp=fopen($filename,"w"); + fwrite($fp,$content); + fclose($fp); + + } +} +?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/Ajax-Test/ajax-loader.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/Ajax-Test/ajax-loader.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/Ajax-Test/ajax.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/ajax.php (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/ajax.php 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,10 @@ +<?php +require_once ("xajax/xajax_core/xajax.inc.php"); + +$xajax = new xajax("ajaxfunctions.php"); +$xajax->register(XAJAX_FUNCTION, 'getsubjects', array( + 'onResponseDelay' => 'showLoading', + 'onComplete' => 'hideLoading' + )); +$xajax->registerFunction("getarticle"); +?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,40 @@ +<?php +function getsubjects($label, $limit) +{ + include_once("Settings.php"); + require_once("SparqlConnection.php"); + $settings=new Settings(); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + + $content=""; + $subjects=$sc->getSubjects($label,$limit); + foreach ($subjects as $subject) + { + $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subject."');return false;\">".urldecode($subject)."</a><br/>"; + } + + $objResponse = new xajaxResponse(); + $objResponse->assign("searchcontent", "innerHTML", $content); + return $objResponse; +} + +function getarticle($subject) +{ + include_once("Settings.php"); + require_once("SparqlConnection.php"); + $settings=new Settings(); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + $triples=$sc->getTriples($subject); + $content=""; + foreach ($triples as $triple){ + $content.="Subject: ".urldecode($triple[0])."<br/>Predicate: ".urldecode($triple[1])."<br/>Object: ".urldecode($triple[2])."<br/><br/>\n"; + } + + $objResponse = new xajaxResponse(); + $objResponse->assign("article", "innerHTML", $content); + return $objResponse; +} + +require("ajax.php"); +$xajax->processRequest(); +?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/Ajax-Test/default.css =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/default.css (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/default.css 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,478 @@ +/** + * default.css + * main Ontowiki style sheet + * @author: Norman Heino + * @version: $Id: default.css 751 2007-02-14 19:20:17Z nheino $ + */ + +/* remove browser specific margins */ +* { + margin: 0; + padding: 0; +} + +html { + font: 80%/1.2 "Lucida Grande", Helvetica, Arial, sans-serif; +} + +p { + margin: 8px 0; +} + +h2 { + margin: 0.5em 0 0.1em 0; +/* background-color: #eee;*/ + font-size: 110%; +} + + +/* + * Main site structure + */ + +#wrapper { + position: relative; + max-width: 100%; + padding: 15px; +/* margin: 15px;*/ +} + +#content { + margin: 0 19em; + overflow: hidden; +/* border-left: 1px solid #bbb; + border-right: 1px solid #bbb; + padding: 0 5px;*/ +} + +/* + * Side bars are positioned absolutely due to several reasons: + * (1)Internet Explorer has problems displaying float elements, + * (2) the content's position in html is irrelevant, + * (3) positioning the content div is more straightforward. + */ +#leftSidebar { + position: absolute; + width: 18em; +} + +#rightSidebar { + position: absolute; + width: 18em; + top: 15px; + right: 15px; +} + +#clear { + clear: both; +} + + +/* + * sidebar content (boxes) + */ + +.box { + color: #666; + margin-bottom: 20px; + border: 1px solid #bbb; + font-size: 85%; +} + +/*.box td { + font-size: 100%; +}*/ + +.box .boxtitle { + color: #666; + background-color: #eee; + padding: 3px 0.4em; + font-weight: bold; + white-space: nowrap; +} + +.box .boxtitle .boxtitle_string { + width: 80%; + overflow: hidden; +/* display: none;*/ +} + +.box .boxcontent { + padding: 0.6em; + border-top: 1px solid #bbb; +} + +/* restrict content of certain boxes */ +.box#predicates .boxcontent, +.box#classes .boxcontent { + overflow: hidden; +} + +.box p { + margin: 0 2px 4px 0; +} + +.box ul, .box ol { + margin: 0px; +/* padding-left: 15px;*/ + list-style-position: inside; +} + +.box ul.no_bullet, .box ul.no_bullet { + list-style-type: none; +} + +.box ul li.horizontal, .box ol li.horizontal, +.box ul.horizontal, .box ol.horizontal { + display: inline; +} + +.box a.title_switch { + position: absolute; + right: 0.5em; + margin: auto 0; + color: #666; + border: 1px solid #bbb; + width: 1em; + height: 1em; + background-color: #fff; + text-align: center; +} + +.box a.title_switch:hover { + color: #02a; + text-decoration: none; + background-color: #eee; +} + +.box hr { + margin: 0.5em 0; + border: none; + border-top: 1px dotted #bbb; + height: 0; +} + +.box#classes .boxcontent a { + display: block; +} + +/*.box select { + width: 250px; /* TODO remove absolute size */ +}*/ + +.box input { + width: auto; +} + +.box td input { + width: 100%; +} + +.box img.rating { + position: relative; + top: 1px; +} + +.hidden { + display: none; +} + + +/* + * Links + */ + +a, a:link, a:visited { + color: #02a; + text-decoration: none; + cursor: pointer; +} + +a:hover { + text-decoration: underline; +} + + +/* + * Tabs + */ + +/* all the tabs */ +.tabs { + float: left; + width: 100%; + background: #fff url("../images/tabs_back.png") repeat-x bottom; +} + +.tabs ul { + list-style: none; +} + +.tabs li { + float: left; + margin-right: 1px; +} + +.tabs a { + display: block; + margin-top: 1px; + padding: 0.35em 1.35em; + background-image: url("../images/tab_back.png"); + background-repeat: repeat-x; + background-color: #cbcbcb; + border: 1px solid #bbb; +} + +.tabs a:hover { + background: #fff; + text-decoration: none; +} + +.tabs a.current { + background: #fff; + border-bottom: 1px solid #fff; +} + +/* horizontal line underneath the tabs */ +#tab-line { + height: 1em; + clear: both; +} + +#instances { + float: right; +} + +.selected { + background-color: #bde; /*#b4d5fe;*/ +} + +.button { + border: solid black 1px; + padding: 0px 1px; + background-color: #eee; +} + +/* + * Tables + */ + +tr.odd { + background-color: #ccc; +} + +tr.even { + background-color: #eee; +} + +table.instanceTable th { + text-align: left; +/* background-color: #eee;*/ +} + +table.instanceTable > tbody > tr > td { + padding-top: 0.5em; +} + +table.instanceTable td.property { + text-align: right; + font-style: italic; + padding-right: 5px; +} + +table.instanceTable ul { + margin: 0px; + padding-left: 20px; +} + +table.instanceTable { + width: 100%; +} + +.searchHighlight { + background-color: orange; +} + +table.tripletable { + width: 100%; + font-size: 90%; +} + +.tripletable td { + padding: 0.4em; +} + +table.blind tr td { + padding-top: 0.4em; +} + +/* + * Instances + */ + +.instance .instance { + margin-left: 13px; + background-color: #ddd; +} +.instance .instance td { + font-size: 90%; +} +.instance .instance .instance { + background-color: #eee; +} + +.instance .instance .instance .instance { + background-color: #fff; +} + +#instanceEdit { + border-spacing: 0px; + width: 100%; +} + +#instanceEdit input, #instanceEdit textarea { +/* width: 250px;*/ + background-color: #fff; + font-size: 95%; + font-family: "Lucida Grande", Helvetica, Arial, sans-serif; + padding: 0.1em 0; +} + +#instanceEdit > tbody > tr > td, #instanceEdit > tr > td { + background-color: #eee; + padding: 5px; + border-bottom: 2px solid #fdfdfd; +} + +/* + * Calendar + */ + +table.calendar { + margin-top: 1em; + width: 100%; + height: 730px; + table-layout: fixed; + font-size: 90%; +} + +.calendar .weekday0 { + background-color: #eee; + padding: 0.4em; +} +.calendar .weekday1 { + background-color: #f5f5f5; + padding: 0.4em; +} +.calendar .weekend0 { + background-color: #ddd; + padding: 0.4em; +} +.calendar .weekend1 { + background-color: #eaeaea; + padding: 0.4em; +} + +#map { + margin-top: 0.5em; + width: 100%; + height: 750px; + font-size: 90%; +} + +#map .instance td { + font-size: 80%; + padding: 0 3px; + border-bottom: 5px solid white; +} + +#superClassPath { + margin-bottom: 0.5em; +} + +img { + border: none; +} + +span.submit { + float: right; + padding-right: 100px; +} + +/* + * Autosuggest box + */ +div.autosuggest { + font-size: 85%; + position: absolute; + background-color: #fff; + border: 1px solid #bbb; +} + +div.autosuggest ul { + list-style-type: none; + list-style-position: inside; + padding-left: 0px; +} + +div.autosuggest ul li.selected { + background-color: #bde; +} + +div.autosuggest ul li { + display: block; + padding: 0.2em; +/* height: 22px;*/ + cursor: pointer; +} + +span.formal { + display: none; +} + +/* + * Layer + */ +#layer { + width: 100%; + height: 100%; + position: absolute; + background-image: url("../images/black_50.png"); + background-repeat: repeat; + z-index: 98; +} + +#layerContent { + margin-top: 100px; + margin: auto; + width: 500px; + height: 300px; + background-color: #ffb; + border: 2px solid #bbb; + z-index: 99; +} + +/* + * Buttons + */ +input.button { + border: 1px solid #bbb; + color: #666; + background-color: #eee; + padding: 3px 0.4em; + font-weight: bold; + white-space: nowrap; + font-size: 85%; +} + +/* + * Loading + */ +#loading { + padding: 20px; + display: none; /* hidden */ + left: 50%; + top: 25%; + font-weight: bold; + font-size: large; +} \ No newline at end of file Added: trunk/src/dbpedia-navigator/Ajax-Test/index.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/index.php (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/index.php 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,68 @@ +<?php +require("ajax.php"); + ini_set('error_reporting',E_ALL); + ini_set('max_execution_time',200); + +echo '<?xml version="1.0" encoding="UTF-8"?>' +?> +<html> + <head> + <title>DL Learner</title> + <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\"/> + <link rel="stylesheet" href="default.css"/> + <?php $xajax->printJavascript('xajax/'); ?> + <script type="text/javascript"> + showLoading = function() { + xajax.$('loading').style.display='block'; + }; + hideLoading = function() { + xajax.$('loading').style.display = 'none'; + } + </script> + </head> + <body> +<h3>DBPedia-Navigator-Test</h3> +<div id="wrapper"> +<div id="leftSidebar"> + +<div class="box" id="search"> + <div class="boxtitle">Search</div> + <div class="boxcontent"> + <form action="index.php" method="GET" id="searchForm"> + <table border="0"> + <tr><tb>Search:<br/></tb></tr> + <tr><tb><input type="textfield" name="label" id="label"><select name="limit" size="1" id="limit"> + <option>1</option> + <option selected="selected">5</option> + <option>10</option> + <option>15</option> + </select><br/></tb></tr> + <tr><tb><input type="button" value="Calculate" class="button" onclick="xajax_getsubjects(document.getElementById('label').value,document.getElementById('limit').value);return false;" /></tb></tr> + </table> + </form> + </div> <!-- boxcontent --> +</div> <!-- box --> + +<div class="box" id="search"> + <div class="boxtitle">Searchresults</div> + <div class="boxcontent" id="searchcontent"> + <div id="loading"><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 --> + +<div id="content"> +<div class="box" id="search"> + <div class="boxtitle">Content</div> + <div class="boxcontent" id="article"> + </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><!-- content --> +</div> + </body> +</html> + \ No newline at end of file Added: trunk/src/dbpedia-navigator/Ajax-Test/xajax/LICENSE.txt =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/xajax/LICENSE.txt (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/xajax/LICENSE.txt 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,11 @@ +Copyright (c) 2006 - 2007, Jared White & J. Max Wilson +Portions Copyright (c) 2007, Joseph Woolley +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of xajax nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file Added: trunk/src/dbpedia-navigator/Ajax-Test/xajax/README.txt =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/xajax/README.txt (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/xajax/README.txt 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,149 @@ +=============================================================================== + + xajax PHP & Javascript Library + The easiest way to develop powerful Ajax applications with PHP + + Version 0.5 (Beta 4) + README Text File + September 5, 2007 + + ------------------------------------------------------ + | ** Release Notes: | + | See release_notes.txt in this download archive | + | | + | ** Project Managers: | + | Joseph Woolley (jo...@ca...) | + | J. Max Wilson (jma...@us...) | + | | + | ** Developers: | + | Steffen Konerow (st...@nr...) | + | Jared White (ja...@in...) | + | Eion Robb (ei...@bi...) | + ------------------------------------------------------ + +=============================================================================== + + :: To find out what's changed since the 0.5 Beta 3 release of xajax, :: + :: view the Release Notes in the file listed above. :: + +=============================================================================== + +xajax 0.5 is leaps and bounds forward from the last stable release, however, +xajax 0.2.5 was released to help bridge the gap. xajax 0.5 has an +extensible and flexible plugin interface so both the php and javascript +engines can be adapted to fit your needs. With xajax 0.5 beta 3, we've added +an HTML control library with built in support for both plain and xajax based +javascript and added new features that will give you a development platform +to build on for years to come. In this release, we've added the ability +to customize debug, warning and error messages, thus allowing for easier +development and debugging for non-english speaking programmers. + +Beta 4 represents a solidification of the xajax php and javascript code, so +from this point, the xajax interface will remain mostly unchanged until stable +release. We have greatly improved the documentation that is available for +the xajax api. In addition, we will continue to work hard to resolve any +issues that are discovered in the code, the documentation, wiki and to answer +questions in the forum. + +We published an updated website at http://xajaxproject.com Thanks to Jared and +Steffen for putting together a great looking site with a lot of functionality +and flexibility! The forums continue to be active and interesting, so be sure +to check in from time to time to keep current with all things xajax at +http://community.xajaxproject.com and visit sourceforge for posting feature +requests, bug fix requests and patches at http://www.sourceforge.net/projects/xajax + +Thank you for downloading xajax 0.5 beta 4! + +____________________________________________________________________ + + +"it's safer, better, faster and even more bright and shiny" - Steffen + +____________________________________________________________________ + +1. Introduction + +xajax is a PHP library that you can include in your PHP scripts +to provide an easy way for Web pages to call PHP functions or +object methods using Ajax (Asynchronous Javascript And XML). Simply +register one or more functions/methods with the xajax object that +return a proper XML response using the supplied response class, add +a statement in your HTML header to print the Javascript include, +and run a request processor prior to outputting any HTML. Then add +some simple Javascript function calls to your HTML, and xajax takes +care of the rest! + +xajax includes a Javascript object to facilitate the communication +between the browser and the server, and it can also be used as a +Javascript library directly to simplify certain DOM and event +manipulations. However, you can definitely choose to use a +dedicated Javascript "engine" of your liking and integrate it with +xajax's client/server communication features. Since xajax is moving +towards a highly modular, plugin-based system, you can alter and extend +its behavior in a number of ways. + +2. For More Information + +The official xajax Web site is located at: +http://www.xajaxproject.org + +Visit the xajax Forums at: +http://community.xajaxproject.org +to keep track of the latest news and participate in the community +discussion. + +There is also a wiki with documentation, tips & tricks, and other +information located at: +http://wiki.xajaxproject.org + +3. Installation + +To run xajax, you need: +* Apache Web Server or IIS for Windows XP/2003 Server + (other servers may or may not work and are not supported at this + time) +* PHP 4.3.x or PHP 5.x +* Minimum supported browsers: Internet Explorer 5.5, Firefox 1.0 (or + equivalent Gecko-based browser), Safari 1.3, Opera 8.5 (older + versions only work with GET requests) + +To install xajax: +Unpack the contents of this archive and copy them to your main Web +site folder. Or if you wish, you can put all of the files in a +dedicated "xajax" folder on your Web server (make sure that you +know what that URL is relative your site pages so you can provide +xajax with the correct installed folder URL). Note that the +"thewall" folder in the "examples" folder needs to be writable by +the Web server for that example to function. + +Within the main xajax folder there are four folders: "examples", +"tests", "xajax_js", and "xajax_core". Only "xajax_js" and +"xajax_core" are required to use xajax. + +You should be able to view the PHP pages in "tests" from your +Web browser and see xajax working in action. If you can view the +pages but the AJAX calls are not working, there may be something +wrong with your server setup or perhaps your browser is not +supported or configured correctly. If worst comes to worst, post +a message in our forums and someone may be able to help you. + +4. Documentation + +Detailed documentation for the xajax PHP classes is available on +our wiki (URL listed above in section 2), and more is on the way +(particularly in regards to the Javascript component of xajax). +Another good way of learning xajax is to look at the code for the +examples and tests. If you need any help, pop in the forums and +ask for assistance (and the more specific your questions are, +the better the answers will be). + +5. Contributing to xajax + +xajax is released under the BSD open source license. If you wish +to contribute to the project or suggest new features, introduce +yourself on the forums or you can e-mail the project managers +and developers at the addresses listed at the top of this README. + +6. Good luck and enjoy! + +==================================================================== Added: trunk/src/dbpedia-navigator/Ajax-Test/xajax/copyright.inc.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/xajax/copyright.inc.php (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/xajax/copyright.inc.php 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,54 @@ +<?php +/* + File: copyright.inc.php + + This file contains detailed information regarding the xajax project, + current version, copyrights, licnese and documentation. + + You do not need to include this file in your project for xajax to + function properly. +*/ + +/* + Section: Current Version + + xajax version 0.5 (beta 4) +*/ + +/* + Section: Copyright + + - copyright (c) 2005-2007 by Jared White & J. Max Wilson + - portions copyright (c) 2006-2007 by Joseph Woolley +*/ + +/* + Section: Description + + xajax is an open source PHP class library for easily creating powerful + PHP-driven, web-based Ajax Applications. Using xajax, you can asynchronously + call PHP functions and update the content of your your webpage without + reloading the page. +*/ + +/* + Section: License + + xajax is released under the terms of the BSD license + http://www.xajaxproject.org/bsd_license.txt +*/ + +/* + @package xajax + @version $Id: copyright.inc.php 327 2007-02-28 16:55:26Z calltoconstruct $ + @copyright Copyright (c) 2005-2006 by Jared White & J. Max Wilson + @license http://www.xajaxproject.org/bsd_license.txt BSD License +*/ + +/* + Section: Online documentation + + Online documentation for this class is available on the xajax wiki at: + http://wiki.xajaxproject.org/Documentation:xajax.inc.php +*/ + Added: trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/copyright-inc-php.html =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/copyright-inc-php.html (rev 0) +++ trunk/src/dbpedia-navigator/Ajax-Test/xajax/documentation/files/copyright-inc-php.html 2007-10-22 18:35:37 UTC (rev 257) @@ -0,0 +1,33 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + +<html><head><title>copyright.inc.php</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script></head><body class=UnframedPage onLoad="NDOnLoad()"><script language=JavaScript><!-- +if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script> + +<!-- Generated by Natural Docs, version 1.35 --> +<!-- http://www.naturaldocs.org --> + +<!-- saved from url=(0026)http://www.naturaldocs.org --> + +<table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td class=MenuSection valign=top><!--START_ND_MENU--><div class=MEntry><div class=MFile id=MSelected>copyright.<span class=HB> </span>inc.php</div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent4')">Examples</a><div class=MGroupContent id=MGroupContent4><div class=MEntry><div class=MFile><a href="examples/helloworld-php.html">helloworld.php</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Multiply</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MFile><a href="examples/multiply/multiply-common-php.html">common.php</a></div></div><div class=MEntry><div class=MFile><a href="examples/multiply/multiply-php.html">php</a></div></div><div class=MEntry><div class=MFile><a href="examples/multiply/multiply-server-php.html">server.php</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent2')">Signup</a><div class=MGroupContent id=MGroupContent2><div class=MEntry><div class=MFile><a href="examples/signup/signup-common-php.html">common.php</a></div></div><div class=MEntry><div class=MFile><a href="examples/signup/signup-php.html">php</a></div></div><div class=MEntry><div class=MFile><a href="examples/signup/signup-server-php.html">server.php</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent3')">Thewall</a><div class=MGroupContent id=MGroupContent3><div class=MEntry><div class=MFile><a href="examples/thewall/thewall-common-php.html">common.php</a></div></div><div class=MEntry><div class=MFile><a href="examples/thewall/thewall-php.html">php</a></div></div><div class=MEntry><div class=MFile><a href="examples/thewall/thewall-server-php.html">server.php</a></div></div></div></div></div><div class=MEntry><div class=MFile><a href="examples/xul/xulApplication-php.html">xulApplication.php</a></div></div><div class=MEntry><div class=MFile><a href="examples/xul/xulServer-php.html">xulServer.php</a></div></div></div></div></div><div class=MEntry><div class=MFile><a href="xajax_plugins/response/googleMap-inc-php.html">googleMap.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MFile><a href="xajax_plugins/response/tableUpdater-inc-php.html">tableUpdater.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent7')">Tests</a><div class=MGroupContent id=MGroupContent7><div class=MEntry><div class=MFile><a href="tests/errorHandlingTest-php.html">errorHandlingTest.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/index-php.html">index.php</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent5')">Legacy_tests</a><div class=MGroupContent id=MGroupContent5><div class=MEntry><div class=MFile><a href="tests/legacy_tests/catchAllFunctionTest-php.html">catchAllFunctionTest.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/legacy_tests/index-php.html">index.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/legacy_tests/jsLoadingTest-php.html">jsLoadingTest.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/legacy_tests/preFunctionTest-php.html">preFunctionTest.php</a></div></div></div></div></div><div class=MEntry><div class=MFile><a href="tests/registerObjectTest-php.html">registerObjectTest.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/searchReplaceTest-php.html">searchReplaceTest.php</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent6')">Suite</a><div class=MGroupContent id=MGroupContent6><div class=MEntry><div class=MFile><a href="tests/suite/alert_confirm-php.html">alert_confirm.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/assign_append-php.html">assign_append.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/callScriptTest-php.html">callScriptTest.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/controls_html_401_transitional-php.html">controls_html_401_transitional.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/controls_xhtml_10_transitional-php.html">controls_xhtml_10_transitional.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/css-php.html">css.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/delayEvents-php.html">delayEvents.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/events-php.html">events.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/functions-php.html">functions.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/index-php.html">index.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/scriptContext-php.html">scriptContext.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/server_events-php.html">server_events.php</a></div></div><div class=MEntry><div class=MFile><a href="tests/suite/theFrame-php.html">theFrame.php</a></div></div></div></div></div><div class=MEntry><div class=MFile><a href="tests/xajaxResponseTest-php.html">xajaxResponseTest.php</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent10')">Xajax_core</a><div class=MGroupContent id=MGroupContent10><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent9')">Plugin_layer</a><div class=MGroupContent id=MGroupContent9><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent8')">Support</a><div class=MGroupContent id=MGroupContent8><div class=MEntry><div class=MFile><a href="xajax_core/plugin_layer/support/xajaxCallableObject-inc-php.html">xajaxCallableObject.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MFile><a href="xajax_core/plugin_layer/support/xajaxEvent-inc-php.html">xajaxEvent.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MFile><a href="xajax_core/plugin_layer/support/xajaxUserFunction-inc-php.html">xajaxUserFunction.<span class=HB> </span>inc.php</a></div></div></div></div></div><div class=MEntry><div class=MFile><a href="xajax_core/plugin_layer/xajaxCallableObjectPlugin-inc-php.html">xajaxCallableObjectPlugin.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MFile><a href="xajax_core/plugin_layer/xajaxDefaultIncludePlugin-inc-php.html">xajaxDefaultIncludePlugin.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MFile><a href="xajax_core/plugin_layer/xajaxEventPlugin-inc-php.html">xajaxEventPlugin.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MFile><a href="xajax_core/plugin_layer/xajaxFunctionPlugin-inc-php.html">xajaxFunctionPlugin.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MFile><a href="xajax_core/plugin_layer/xajaxScriptPlugin-inc-php.html">xajaxScriptPlugin.<span class=HB> </span>inc.php</a></div></div></div></div></div><div class=MEntry><div class=MFile><a href="xajax_core/xajax-inc-php.html">xajax.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MFile><a href="xajax_core/xajax_lang_de-inc-php.html">xajax_lang_de.<span class=HB> </span>inc.php</a></div></div><div class=MEntry><div class=MFile><a href="xajax_core/xajaxA... [truncated message content] |
From: <sk...@us...> - 2007-11-20 08:42:34
|
Revision: 284 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=284&view=rev Author: sknappe Date: 2007-11-20 00:42:28 -0800 (Tue, 20 Nov 2007) Log Message: ----------- deleted old files 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 Removed Paths: ------------- trunk/src/dbpedia-navigator/Settings.php trunk/src/dbpedia-navigator/SparqlConnection.php trunk/src/dbpedia-navigator/default.css trunk/src/dbpedia-navigator/index.php trunk/src/dbpedia-navigator/master.php trunk/src/dbpedia-navigator/pear/ Modified: trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/Ajax-Test/SparqlConnection.php 2007-11-20 08:42:28 UTC (rev 284) @@ -8,16 +8,29 @@ private $id; private $ksID; - function SparqlConnection($DBPediaUrl,$DLLearnerUri) + function SparqlConnection($DBPediaUrl,$DLLearnerUri,$id=0,$ksID=0) { ini_set('default_socket_timeout',200); $this->DBPediaUrl=$DBPediaUrl; $this->DLLearnerUri=$DLLearnerUri; $this->client=new SoapClient("main.wsdl"); - $this->id=$this->client->generateID(); - $this->ksID = $this->client->addKnowledgeSource($this->id, "sparql", $this->DBPediaUrl); + $this->id=$id; + $this->ksID=$ksID; } + function getIDs() + { + $id=$this->client->generateID(); + $ksID=$this->client->addKnowledgeSource($id,"sparql",$this->DBPediaUrl); + return array(0 => $id, 1 => $ksID); + } + + function test() + { + $object=$this->client->test($this->id,$this->ksID); + return $object->item; + } + function getConceptFromExamples($ttl,$posExamples,$negExamples) { $this->client->applyConfigEntryInt($this->id, $this->ksID, "numberOfRecursions", 2); @@ -104,9 +117,9 @@ return array(); } - function getSubjects($ttl,$label='Leipzig',$limit=5) + function getSubjects($ttl,$label) { - $options=array("subjects",$label,$limit); + $options=array("subjects",$label,15); $this->client->startThread($this->id,$this->ksID,$options); $i = 1; $sleeptime = 1; @@ -155,70 +168,7 @@ return array(); } - /*public function testSoapTime() - { - $start = microtime(true); - $this->id=$this->client->generateID(); - $test=$this->client->debug("Test"); - $time=microtime(true)-$start; - return "Word: ".$test." got from SOAP in: ".$time; - }*/ - - public function startSearchAndShowArticle($keyword) - { - //TODO work on $keyword to get white space out - //TODO change article get function - $options=array("triples","http://dbpedia.org/resource/".$keyword); - $this->client->startThread($this->id,$this->ksID,$options); - - $options=array("subjects",$keyword,15); - $this->client->startThread($this->id,$this->ksID,$options); - } - - public function checkSearch($stop) - { - $this->client=new SoapClient("main.wsdl"); - if ($stop){ - $this->client->stopSparqlThread($this->id,$this->ksID,"subjects"); - return; - } - - // see if algorithm is running - if (!$this->client->isThreadRunning($this->id,$this->ksID,"subjects")) - { - $object=$this->client->getFromSparql($this->id,$this->ksID,"subjects"); - return $object->item; - } - return NULL; - } - - public function checkShowArticle($stop) - { - $this->client=new SoapClient("main.wsdl"); - if ($stop){ - $this->client->stopSparqlThread($this->id,$this->ksID,"triples"); - return; - } - - if (!$this->client->isThreadRunning($this->id,$this->ksID,"triples")) - { - $object=$this->client->getFromSparql($this->id,$this->ksID,"triples"); - $array=$object->item; - if (count($array)==1) return $array; - $ret=array(); - foreach ($array as $element) - { - $items=preg_split("[<]",$element,-1, PREG_SPLIT_NO_EMPTY); - $ret[$items[0]]=$items[1]; - } - return $ret; - } - return NULL; - } - public function loadWSDLfiles($wsdluri){ - ini_set("soap.wsdl_cache_enabled","0"); - $main=SparqlConnection::getwsdl($wsdluri); $other=SparqlConnection::getOtherWSDL($main); $newMain=SparqlConnection::changeWSDL($main); Modified: trunk/src/dbpedia-navigator/Ajax-Test/ajax.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/ajax.php 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/Ajax-Test/ajax.php 2007-11-20 08:42:28 UTC (rev 284) @@ -7,10 +7,7 @@ 'onResponseDelay' => 'showLoadingSubjects', 'beforeResponseProcessing' => 'hideLoadingSubjects' )); -$xajax->register(XAJAX_FUNCTION, 'getarticle', array( - 'onResponseDelay' => 'showLoadingArticle', - 'beforeResponseProcessing' => 'hideLoadingArticle' - )); +$xajax->registerFunction('getarticle'); $xajax->registerFunction('addPositive'); $xajax->registerFunction('addNegative'); $xajax->registerFunction('clearPositives'); @@ -24,9 +21,4 @@ 'beforeResponseProcessing' => 'hideLoadingConceptSubjects' )); $xajax->registerFunction('searchAndShowArticle'); -$xajax->register(XAJAX_FUNCTION, 'showThisSearchResult', array( - 'onResponseDelay' => 'showLoadingSubjects', - 'beforeResponseProcessing' => 'hideLoadingSubjects' - )); -$xajax->registerFunction('showThisArticle'); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php 2007-11-20 08:42:28 UTC (rev 284) @@ -7,25 +7,25 @@ require("ajax.php"); $xajax->processRequest(); -function getsubjects($label, $limit) +function getsubjects($label) { - include_once("Settings.php"); + require_once("Settings.php"); require_once("SparqlConnection.php"); $settings=new Settings(); - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); $content=""; - $subjects=$sc->getSubjects($settings->sparqlttl,$label,$limit); + $subjects=$sc->getSubjects($settings->sparqlttl,$label); if (count($subjects)==1) { if (strpos($subjects,"[Error]")===0) $content.=substr($subjects,7); - else $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subjects."');return false;\">".urldecode(substr (strrchr ($subjects, "/"), 1))."</a><br/>"; + else $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subjects."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; } else if (count($subjects)==0) $content.="No search result found in time."; else{ foreach ($subjects as $subject) { - $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subject."');return false;\">".urldecode(substr (strrchr ($subject, "/"), 1))."</a><br/>"; + $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subject."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; } } @@ -34,30 +34,65 @@ return $objResponse; } -function getarticle($subject) +function getarticle($subject,$fromCache) { - include_once("Settings.php"); - require_once("SparqlConnection.php"); - $settings=new Settings(); - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); - $triples=$sc->getTriples($settings->sparqlttl,$subject); - $content=""; - if (count($triples)==1) - { - $content.=substr($triples,7); - } - else if (count($triples)==0) $content.="Article not found."; - else { + if (isset($_SESSION['articles'])) + foreach ($_SESSION['articles'] as $key => $value) + { + if ($value['subject']==$subject){ + $fromCache=$key; + break; + } + } + if ($fromCache==-1) { + require_once("Settings.php"); + require_once("SparqlConnection.php"); + $settings=new Settings(); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); + $triples=$sc->getTriples($settings->sparqlttl,$subject); $content=""; - $content.="<img src=\"".$triples['http://xmlns.com/foaf/0.1/depiction']."\" alt=\"Picture of ".urldecode(substr (strrchr ($subject, "/"), 1))."\" width=\"50\"/ style=\"float:left\">"; - $content.="<div>".urldecode($triples['http://dbpedia.org/property/abstract'])."</div>"; + if (count($triples)==1) + { + $content.=substr($triples,7); + } + else if (count($triples)==0) $content.="Article not found."; + else { + $content=""; + $content.="<img src=\"".$triples['http://xmlns.com/foaf/0.1/depiction']."\" alt=\"Picture of ".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."\" width=\"50\"/ style=\"float:left\">"; + $content.="<div>".urldecode($triples['http://dbpedia.org/property/abstract'])."</div>"; + + $contentbuttons="<input type=\"button\" value=\"Positive\" class=\"button\" onclick=\"xajax_addPositive('".$subject."');return false;\" /> <input type=\"button\" value=\"Negative\" class=\"button\" onclick=\"xajax_addNegative('".$subject."');return false;\" />"; + } - $contentbuttons="<input type=\"button\" value=\"Positive\" class=\"button\" onclick=\"xajax_addPositive('".$subject."');return false;\" /> <input type=\"button\" value=\"Negative\" class=\"button\" onclick=\"xajax_addNegative('".$subject."');return false;\" />"; + //store article in session, to navigate between last 5 articles quickly + $contentArray=array('content' => $content,'contentbuttons' => $contentbuttons, 'subject' => $subject); + if (!isset($_SESSION['nextArticle'])){ + $_SESSION['nextArticle']=0; + $_SESSION['articles']=array(); + } + if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; + $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; + $_SESSION['currentArticle']=$_SESSION['nextArticle']; + $_SESSION['nextArticle']++; } + else { + $content=$_SESSION['articles'][$fromCache]['content']; + $contentbuttons=$_SESSION['articles'][$fromCache]['contentbuttons']; + $subject=$_SESSION['articles'][$fromCache]['subject']; + } + $lastArticles=""; + foreach ($_SESSION['articles'] as $key => $value) + { + $lastArticles.="<a href=\"\" onclick=\"xajax_getarticle('',".$key.");return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($value['subject'], "/"), 1)))."</a><br/>"; + } + + //build the response $objResponse = new xajaxResponse(); $objResponse->assign("articlecontent", "innerHTML", $content); $objResponse->assign("contentbuttons", "innerHTML", $contentbuttons); + $objResponse->assign("ArticleTitle","innerHTML",str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))); + $objResponse->assign("lastarticles","innerHTML",$lastArticles); return $objResponse; } @@ -73,7 +108,7 @@ $_SESSION['positive']=$array; } - $content=urldecode(substr (strrchr ($subject, "/"), 1))."<br/>"; + $content=str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."<br/>"; $objResponse = new xajaxResponse(); $objResponse->append("Positives", "innerHTML", $content); @@ -92,7 +127,7 @@ $_SESSION['negative']=$array; } - $content=urldecode(substr (strrchr ($subject, "/"), 1))."<br/>"; + $content=str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."<br/>"; $objResponse = new xajaxResponse(); $objResponse->append("Negatives", "innerHTML", $content); @@ -124,7 +159,7 @@ require_once("Settings.php"); require_once("SparqlConnection.php"); $settings=new Settings(); - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); $concept=$sc->getConceptFromExamples($settings->sparqlttl,$_SESSION['positive'],$_SESSION['negative']); $_SESSION['lastLearnedConcept']=$concept; @@ -142,7 +177,7 @@ require_once("Settings.php"); require_once("SparqlConnection.php"); $settings=new Settings(); - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); $content=""; if (isset($_SESSION['lastLearnedConcept'])) @@ -151,13 +186,13 @@ if (count($subjects)==1) { if (strpos($subjects,"[Error]")===0) $content.=substr($subjects,7); - else $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subjects."');return false;\">".urldecode(substr (strrchr ($subjects, "/"), 1))."</a><br/>"; + else $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subjects."');return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; } else if (count($subjects)==0) $content.="No examples for concept found in time."; else { foreach ($subjects as $subject) { - $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subject."');return false;\">".urldecode(substr (strrchr ($subject, "/"), 1))."</a><br/>"; + $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subject."');return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; } } } @@ -174,111 +209,14 @@ require_once("SparqlConnection.php"); $settings=new Settings(); - $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); $content=""; - $sc->startSearchAndShowArticle($keyword); $objResponse = new xajaxResponse(); - $objResponse->call('xajax_showThisArticle', urlencode(serialize($sc)),"http://dbpedia.org/resource/".$keyword); - $objResponse->call('xajax_showThisSearchResult', urlencode(serialize($sc))); + $objResponse->call('xajax_getarticle', "http://dbpedia.org/resource/".str_replace(" ","_",$keyword),-1); + $objResponse->call('xajax_getsubjects',$keyword); return $objResponse; } -function showThisSearchResult($sc) -{ - require_once("Settings.php"); - require_once("SparqlConnection.php"); - $settings=new Settings(); - $sc=unserialize(urldecode($sc)); - $objResponse = new xajaxResponse(); - $i = 1; - $sleeptime = 1; - $searchComplete=false; - do { - if (!$searchComplete) $searchResult=$sc->checkSearch(false); - if (!is_null($searchResult)){ - $searchComplete=true; - break; - } - - $seconds = $i * $sleeptime; - $i++; - - // sleep a while - sleep($sleeptime); - } while ($seconds<$settings->sparqlttl); - - if (!$searchComplete){ - $sc->checkSearch(true); - $objResponse->assign("searchcontent","innerHtml","No search result found in time."); - } - - $content=""; - if (count($searchResult)==1) - { - if (strpos($searchResult,"[Error]")===0) $content.=substr($searchResult,7); - else $content.="<a href=\"\" onclick=\"xajax_getarticle('".$searchResult."');return false;\">".urldecode(substr (strrchr ($searchResult, "/"), 1))."</a><br/>"; - } - else if (count($searchResult)==0) $content.="No search result found in time."; - else{ - foreach ($searchResult as $result) - { - $content.="<a href=\"\" onclick=\"xajax_getarticle('".$result."');return false;\">".urldecode(substr (strrchr ($result, "/"), 1))."</a><br/>"; - } - } - - - $objResponse->assign("searchcontent", "innerHTML", $content); - return $objResponse; -} - -function showThisArticle($sc,$subject) -{ - require_once("Settings.php"); - require_once("SparqlConnection.php"); - $settings=new Settings(); - $sc=unserialize(urldecode($sc)); - $i = 1; - $sleeptime = 1; - $showArticleComplete=false; - do { - if (!$showArticleComplete) $article=$sc->checkShowArticle(false); - if (!is_null($article)){ - $showArticleComplete=true; - break; - } - - $seconds = $i * $sleeptime; - $i++; - - // sleep a while - sleep($sleeptime); - } while ($seconds<$settings->sparqlttl); - - $content=""; - if (!$showArticleComplete){ - $sc->checkShowArticle(true); - } - - - if (count($article)==1) - { - $content.=substr($article,7); - } - else if (count($article)==0) $content.="Article not found."; - else { - $content=""; - $content.="<img src=\"".$article['http://xmlns.com/foaf/0.1/depiction']."\" alt=\"Picture of ".urldecode(substr (strrchr ($subject, "/"), 1))."\" width=\"50\"/ style=\"float:left\">"; - $content.="<div>".urldecode($article['http://dbpedia.org/property/abstract'])."</div>"; - - $contentbuttons="<input type=\"button\" value=\"Positive\" class=\"button\" onclick=\"xajax_addPositive('".$subject."');return false;\" /> <input type=\"button\" value=\"Negative\" class=\"button\" onclick=\"xajax_addNegative('".$subject."');return false;\" />"; - } - - $objResponse = new xajaxResponse(); - $objResponse->assign("articlecontent", "innerHTML", $content); - $objResponse->assign("contentbuttons", "innerHTML", $contentbuttons); - return $objResponse; -} - ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/Ajax-Test/index.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/index.php 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/Ajax-Test/index.php 2007-11-20 08:42:28 UTC (rev 284) @@ -1,7 +1,15 @@ <?php ini_set('error_reporting',E_ALL); ini_set('max_execution_time',200); +ini_set("soap.wsdl_cache_enabled","1"); session_start(); +require_once('Settings.php'); +require_once('SparqlConnection.php'); +$settings=new Settings(); +$sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); +$ids=$sc->getIDs(); +$_SESSION['id']=$ids[0]; +$_SESSION['ksID']=$ids[1]; echo "<a href='clearsession.php'>start from scratch</a>"; @@ -94,7 +102,7 @@ <div id="content"> <div class="box"> - <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left">Article</td><td class="right"><span id="contentbuttons"></span></td></tr></table></div> + <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left" id="ArticleTitle">Article</td><td class="right"><span id="contentbuttons"></span></td></tr></table></div> <div class="boxcontent" id="article"> <div id="articlecontent" style="display:block"></div> <div id="loadingArticle" style="display:none"><img src="ajax-loader.gif" alt="Loading..."/></div> @@ -117,6 +125,12 @@ </div> <!-- boxcontent --> </div> <!-- box --> +<div class="box"> + <div class="boxtitle">Last Articles</div> + <div class="boxcontent" id="lastarticles"> + </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><!-- rightSidebar --> <div id="clear"></div> Deleted: trunk/src/dbpedia-navigator/Settings.php =================================================================== --- trunk/src/dbpedia-navigator/Settings.php 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/Settings.php 2007-11-20 08:42:28 UTC (rev 284) @@ -1,7 +0,0 @@ -<?php - -class Settings{ - public $wsdluri="http://localhost:8181/services?wsdl"; - public $dbpediauri="http://dbpedia.openlinksw.com:8890/sparql"; -} -?> \ No newline at end of file Deleted: trunk/src/dbpedia-navigator/SparqlConnection.php =================================================================== --- trunk/src/dbpedia-navigator/SparqlConnection.php 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/SparqlConnection.php 2007-11-20 08:42:28 UTC (rev 284) @@ -1,195 +0,0 @@ -<?php - -require_once 'pear/HTTP_Request.php'; - -class SparqlConnection -{ - private $DBPediaUrl; - private $DLLearnerUri; - private $client; - - function SparqlConnection($DBPediaUrl,$DLLearnerUri) - { - ini_set("soap.wsdl_cache_enabled","0"); - ini_set('default_socket_timeout',200); - $this->DBPediaUrl=$DBPediaUrl; - $this->DLLearnerUri=$DLLearnerUri; - $this->loadWSDLfiles($DLLearnerUri); - $this->client=new SoapClient("main.wsdl"); - } - - function getConceptFromExamples($posExamples,$negExamples) - { - $id=$this->client->generateID(); - - $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); - $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 2); - $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array_merge($posExamples,$negExamples)); - $this->client->applyConfigEntryInt($id, $ksID, "filterMode", 0); - $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); - $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); - $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); - $this->client->applyConfigEntryString($id, $ksID, "format", "KB"); - $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", true); - - $this->client->setReasoner($id, "dig"); - $this->client->setLearningProblem($id, "posNegDefinition"); - $this->client->setPositiveExamples($id, $posExamples); - $this->client->setNegativeExamples($id, $negExamples); - $this->client->setLearningAlgorithm($id, "refinement"); - - $start = microtime(true); - - $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); - - $i = 1; - $sleeptime = 1; - - do { - // sleep a while - sleep($sleeptime); - - // see what we have learned so far - $concept=$this->client->getCurrentlyBestConcept($id); - $running=$this->client->isAlgorithmRunning($id); - - $seconds = $i * $sleeptime; - - echo 'result after '.$seconds.' seconds of sleep: '.$concept.'<br />'; - - $i++; - } while($running); - - echo 'algorithm finished'; - } - return $concept; - } - - function getTriples($individual) - { - $id=$this->client->generateID(); - - $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); - $this->client->applyConfigEntryInt($id, $ksID, "numberOfRecursions", 1); - $this->client->applyConfigEntryStringArray($id, $ksID, "instances", array($individual)); - $this->client->applyConfigEntryInt($id, $ksID, "filterMode", -1); - $this->client->applyConfigEntryStringArray($id, $ksID, "predList", array()); - $this->client->applyConfigEntryStringArray($id, $ksID, "objList", array()); - $this->client->applyConfigEntryStringArray($id, $ksID, "classList", array()); - $this->client->applyConfigEntryString($id, $ksID, "format", "Array"); - $this->client->applyConfigEntryBoolean($id, $ksID, "dumpToFile", false); - $this->client->applyConfigEntryBoolean($id,$ksID,"useLits",true); - - $object=$this->client->getTriples($id,$ksID); - $array=$object->item; - $ret=array(); - foreach ($array as $element) - { - $items=preg_split("[<]",$element,-1, PREG_SPLIT_NO_EMPTY); - $ret[]=$items; - } - - return $ret; - } - - function getSubjects($label,$limit) - { - $id=$this->client->generateID(); - - $ksID = $this->client->addKnowledgeSource($id, "sparql", $this->DBPediaUrl); - $object=$this->client->getSubjects($id,$ksID,$label,$limit); - return $object->item; - } - - private function loadWSDLfiles($wsdluri){ - $main=$this->getwsdl($wsdluri); - $other=$this->getOtherWSDL($main); - $newMain=$this->changeWSDL($main); - $this->writeToFile("main.wsdl",$newMain); - $x=0; - foreach ($other as $o){ - $this->writeToFile("def".($x++).".xsd",$this->getwsdl($o)); - } - - } - - private function changeWSDL($wsdl){ - $before="<xsd:import schemaLocation=\""; - $after="\" namespace=\""; - $newWSDL=""; - $desca="def"; - $descb=".xsd"; - $x=0; - while($posstart= strpos ( $wsdl, $before )){ - - $posstart+=strlen($before); - $newWSDL.=substr($wsdl,0,$posstart); - $wsdl=substr($wsdl,$posstart); - $newWSDL.=$desca.($x++).$descb; - $posend= strpos ( $wsdl, $after ); - $wsdl=substr($wsdl,$posend); - - } - return $newWSDL.$wsdl; - - } - - private function getOtherWSDL($wsdl){ - $before="<xsd:import schemaLocation=\""; - $after="\" namespace=\""; - $ret=array(); - while($posstart= strpos ( $wsdl, $before )){ - $posstart+=strlen($before); - $wsdl=substr($wsdl,$posstart); - $posend= strpos ( $wsdl, $after ); - $tmp=substr($wsdl,0,$posend); - $ret[]=$tmp; - $wsdl=substr($wsdl,$posend+strlen($after)); - } - return $ret; - } - - - - - private function getwsdl($wsdluri){ - // this is copied from the Pear example - // please don't ask me how it works - $req = &new HTTP_Request($wsdluri); - $message=""; - $req->setMethod(HTTP_REQUEST_METHOD_GET); - $req->sendRequest(); - $ret=$req->getResponseBody(); - return $ret; - } - - - - private function writeToFile($filename,$content){ - - $fp=fopen($filename,"w"); - fwrite($fp,$content); - fclose($fp); - - } -} -?> \ No newline at end of file Deleted: trunk/src/dbpedia-navigator/default.css =================================================================== --- trunk/src/dbpedia-navigator/default.css 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/default.css 2007-11-20 08:42:28 UTC (rev 284) @@ -1,453 +0,0 @@ -/** - * default.css - * main Ontowiki style sheet - * @author: Norman Heino - * @version: $Id: default.css 751 2007-02-14 19:20:17Z nheino $ - */ - -/* remove browser specific margins */ -* { - margin: 0; - padding: 0; -} - -html { - font: 80%/1.2 "Lucida Grande", Helvetica, Arial, sans-serif; -} - -p { - margin: 8px 0; -} - -h2 { - margin: 0.5em 0 0.1em 0; -/* background-color: #eee;*/ - font-size: 110%; -} - - -/* - * Main site structure - */ - -#wrapper { - position: relative; - max-width: 100%; - padding: 15px; -/* margin: 15px;*/ -} - -#content { - margin: 0 19em; - overflow: hidden; -/* border-left: 1px solid #bbb; - border-right: 1px solid #bbb; - padding: 0 5px;*/ -} - -/* - * Side bars are positioned absolutely due to several reasons: - * (1)Internet Explorer has problems displaying float elements, - * (2) the content's position in html is irrelevant, - * (3) positioning the content div is more straightforward. - */ -#leftSidebar { - position: absolute; - width: 18em; -} - -#rightSidebar { - position: absolute; - width: 18em; - top: 15px; - right: 15px; -} - -#clear { - clear: both; -} - - -/* - * sidebar content (boxes) - */ - -.box { - color: #666; - margin-bottom: 20px; - border: 1px solid #bbb; - font-size: 85%; -} - -/*.box td { - font-size: 100%; -}*/ - -.box .boxtitle { - color: #666; - background-color: #eee; - padding: 3px 0.4em; - font-weight: bold; - white-space: nowrap; -} - -.box .boxtitle .boxtitle_string { - width: 80%; - overflow: hidden; -/* display: none;*/ -} - -.box .boxcontent { - padding: 0.6em; - border-top: 1px solid #bbb; -} - -/* restrict content of certain boxes */ -.box#predicates .boxcontent, -.box#classes .boxcontent { - overflow: hidden; -} - -.box p { - margin: 0 2px 4px 0; -} - -.box ul, .box ol { - margin: 0px; -/* padding-left: 15px;*/ - list-style-position: inside; -} - -.box ul.no_bullet, .box ul.no_bullet { - list-style-type: none; -} - -.box ul li.horizontal, .box ol li.horizontal, -.box ul.horizontal, .box ol.horizontal { - display: inline; -} - -.box a.title_switch { - position: absolute; - right: 0.5em; - margin: auto 0; - color: #666; - border: 1px solid #bbb; - width: 1em; - height: 1em; - background-color: #fff; - text-align: center; -} - -.box a.title_switch:hover { - color: #02a; - text-decoration: none; - background-color: #eee; -} - -.box hr { - margin: 0.5em 0; - border: none; - border-top: 1px dotted #bbb; - height: 0; -} - -.box#classes .boxcontent a { - display: block; -} - -/*.box select { - width: 250px; /* TODO remove absolute size */ -}*/ - -.box input { - width: auto; -} - -.box td input { - width: 100%; -} - -.box img.rating { - position: relative; - top: 1px; -} - -.hidden { - display: none; -} - - -/* - * Links - */ - -a, a:link, a:visited { - color: #02a; - text-decoration: none; - cursor: pointer; -} - -a:hover { - text-decoration: underline; -} - - -/* - * Tabs - */ - -/* all the tabs */ -.tabs { - float: left; - width: 100%; - background: #fff url("../images/tabs_back.png") repeat-x bottom; -} - -.tabs ul { - list-style: none; -} - -.tabs li { - float: left; - margin-right: 1px; -} - -.tabs a { - display: block; - margin-top: 1px; - padding: 0.35em 1.35em; - background-image: url("../images/tab_back.png"); - background-repeat: repeat-x; - background-color: #cbcbcb; - border: 1px solid #bbb; -} - -.tabs a:hover { - background: #fff; - text-decoration: none; -} - -.tabs a.current { - background: #fff; - border-bottom: 1px solid #fff; -} - -/* horizontal line underneath the tabs */ -#tab-line { - height: 1em; - clear: both; -} - -#instances { - float: right; -} - -.selected { - background-color: #bde; /*#b4d5fe;*/ -} - -.button { - border: solid black 1px; - padding: 0px 1px; - background-color: #eee; -} - -/* - * Tables - */ - -tr.odd { - background-color: #ccc; -} - -tr.even { - background-color: #eee; -} - -table.instanceTable th { - text-align: left; -/* background-color: #eee;*/ -} - -table.instanceTable > tbody > tr > td { - padding-top: 0.5em; -} - -table.instanceTable td.property { - text-align: right; - font-style: italic; - padding-right: 5px; -} - -table.instanceTable ul { - margin: 0px; - padding-left: 20px; -} - -table.instanceTable { - width: 100%; -} - -.searchHighlight { - background-color: orange; -} - -table.tripletable { - width: 100%; - font-size: 90%; -} - -.tripletable td { - padding: 0.4em; -} - -table.blind tr td { - padding-top: 0.4em; -} - -/* - * Instances - */ - -.instance .instance { - margin-left: 13px; - background-color: #ddd; -} -.instance .instance td { - font-size: 90%; -} -.instance .instance .instance { - background-color: #eee; -} - -.instance .instance .instance .instance { - background-color: #fff; -} - -#instanceEdit { - border-spacing: 0px; - width: 100%; -} - -#instanceEdit input, #instanceEdit textarea { -/* width: 250px;*/ - background-color: #fff; - font-size: 95%; - font-family: "Lucida Grande", Helvetica, Arial, sans-serif; - padding: 0.1em 0; -} - -#instanceEdit > tbody > tr > td, #instanceEdit > tr > td { - background-color: #eee; - padding: 5px; - border-bottom: 2px solid #fdfdfd; -} - -/* - * Calendar - */ - -table.calendar { - margin-top: 1em; - width: 100%; - height: 730px; - table-layout: fixed; - font-size: 90%; -} - -.calendar .weekday0 { - background-color: #eee; - padding: 0.4em; -} -.calendar .weekday1 { - background-color: #f5f5f5; - padding: 0.4em; -} -.calendar .weekend0 { - background-color: #ddd; - padding: 0.4em; -} -.calendar .weekend1 { - background-color: #eaeaea; - padding: 0.4em; -} - -#map { - margin-top: 0.5em; - width: 100%; - height: 750px; - font-size: 90%; -} - -#map .instance td { - font-size: 80%; - padding: 0 3px; - border-bottom: 5px solid white; -} - -#superClassPath { - margin-bottom: 0.5em; -} - -img { - border: none; -} - -span.submit { - float: right; - padding-right: 100px; -} - -/* - * Autosuggest box - */ -div.autosuggest { - font-size: 85%; - position: absolute; - background-color: #fff; - border: 1px solid #bbb; -} - -div.autosuggest ul { - list-style-type: none; - list-style-position: inside; - padding-left: 0px; -} - -div.autosuggest ul li.selected { - background-color: #bde; -} - -div.autosuggest ul li { - display: block; - padding: 0.2em; -/* height: 22px;*/ - cursor: pointer; -} - -span.formal { - display: none; -} - -/* - * Layer - */ -#layer { - width: 100%; - height: 100%; - position: absolute; - background-image: url("../images/black_50.png"); - background-repeat: repeat; - z-index: 98; -} - -#layerContent { - margin-top: 100px; - margin: auto; - width: 500px; - height: 300px; - background-color: #ffb; - border: 2px solid #bbb; - z-index: 99; -} Deleted: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/index.php 2007-11-20 08:42:28 UTC (rev 284) @@ -1,190 +0,0 @@ -<?php - -@session_start(); - -include_once("Settings.php"); -include_once("SparqlConnection.php"); - - ini_set('error_reporting',E_ALL); - ini_set('max_execution_time',200); - -//clear session -echo "<a href='index.php?clearsession=clear'>start from scratch</a>"; -if(isset($_GET['clearsession'])){ - session_unset(); -} - -//initialize variables -$content=""; -$positiveAdd=""; -$negativeAdd=""; - -//initialize the sparql connection -$settings=new Settings(); -$sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); - - -//add positives or negatives to session -if (@$_GET['action']=='AddPositive'){ - $_GET=$_SESSION["lastGet"]; - $content=$_SESSION['lastContent']; - 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"]; - $content=$_SESSION['lastContent']; - if (!isset($_SESSION['negative'])){ - $array=array($_GET['subject']); - $_SESSION['negative']=$array; - } - else{ - $array=$_SESSION['negative']; - $array[]=$_GET['subject']; - $_SESSION['negative']=$array; - } -} - -//delete Positives or Negatives from Session -if (@$_GET['action']=='ClearPositive'){ - $_GET=$_SESSION["lastGet"]; - $content=$_SESSION['lastContent']; - unset($_SESSION['positive']); -} -if (@$_GET['action']=='ClearNegative'){ - $_GET=$_SESSION["lastGet"]; - $content=$_SESSION['lastContent']; - unset($_SESSION['negative']); -} - -//learn a concept -if (@$_GET['action']=="GetConcept") -{ - $_GET=$_SESSION["lastGet"]; - $content=$_SESSION['lastContent']; - $conc=$sc->getConceptFromExamples($_SESSION['positive'],$_SESSION['negative']); - $_SESSION['learnedConcept']=$conc; -} - -//Get Search result -if (@$_GET['action']=='Search') -{ - $label=$_GET['search']; - $limit=$_GET['limit']; - $_GET=$_SESSION["lastGet"]; - $content=$_SESSION['lastContent']; - $subjects=$sc->getSubjects($label,$limit); - $_SESSION['lastSubjectSearch']=$subjects; -} - -//SearchBox - $search="<form action=\"index.php\" method=\"GET\">\n". - "<table border=\"0\">\n". - "<tr><tb>Search:<br/></tb></tr>\n". - "<tr><tb><input type=\"textfield\" name=\"search\"><select name=\"limit\" size=\"1\">\n". - "<option>1</option>\n". - "<option selected=\"selected\">5</option>\n". - "<option>10</option>\n". - "<option>15</option>\n". - "</select><br/></tb></tr>\n". - "<tr><tb><input type=\"submit\" name=\"action\" value=\"Search\"><input type=\"submit\" name=\"action\" value=\"Fulltext\"></tb></tr>\n". - "</table>\n". - "</form>\n"; - - -if (isset($_SESSION['learnedConcept'])) $learnedConc="<br/>Last learned Concept: ".$_SESSION['learnedConcept']; -else $learnedConc=""; - -if (isset($_SESSION['lastSubjectSearch'])){ - $search.="<br/>Last Search:<br/><br/>\n"; - $subjects=$_SESSION['lastSubjectSearch']; - foreach ($subjects as $subject){ - $search.="<a href=\"index.php?action=showPage&subject=".$subject."\">".$subject."</a><br/>\n"; - } -} - -//Show Subject Page -if ((@$_GET['action']=="showPage")&&($content==="")) -{ - $triples=$sc->getTriples($_GET['subject']); - foreach ($triples as $triple){ - $content.="Subject: ".urldecode($triple[0])."<br/>Predicate: ".urldecode($triple[1])."<br/>Object: ".urldecode($triple[2])."<br/><br/>\n"; - } -} - -//if an articel is shown, you can add it to Positives or Negatives -if (@$_GET['action']=="showPage") -{ - $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.=$learnedConc; - - -$_SESSION['lastGet']=$_GET; -$_SESSION['lastContent']=$content; -//include master -include("master.php"); - -echo $masterContent; - - -//make a box -function makeBox($title,$content,$toggleBoxContent=true) -{ - if($toggleBoxContent) - { - $click="<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a>"; - } - else{$click="";} - - $ret=" - <div class=\"box\" id=\"ontology\"> - <div class=\"boxtitle\">".$title.$click."</div> - <div class=\"boxcontent\"> - ".$content." - </div> <!-- boxcontent --> - </div> <!-- box -->"; - return $ret; -} -?> \ No newline at end of file Deleted: trunk/src/dbpedia-navigator/master.php =================================================================== --- trunk/src/dbpedia-navigator/master.php 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/master.php 2007-11-20 08:42:28 UTC (rev 284) @@ -1,71 +0,0 @@ -<?php - -$masterContent=" - - -<html> - <head> - <title>DL Learner</title> - <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\"/> - <link rel=\"stylesheet\" href=\"default.css\"/> - </head> - <body> -<script type=\"text/javascript\" src=\"jscript/wz_tooltip.js\"></script> -<script type=\"text/javascript\" src=\"jscript/scripts.js\"></script> -<h3>DBPedia-Navigator-Test</h3> -<div id=\"layer\" style=\"display:none\"><div id=\"layerContent\" style=\"display:none\"></div></div> -<div id=\"wrapper\"> - -<div id=\"leftSidebar\"> - -<div class=\"box\" id=\"search\"> - <div class=\"boxtitle\">Search<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> - <div class=\"boxcontent\"> - ".$search." - </div> <!-- boxcontent --> - -</div> <!-- box --> - -<div class=\"box\" id=\"examples\"> - <div class=\"boxtitle\">Examples<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> - <div class=\"boxcontent\"> - ".$examples." - </div> <!-- boxcontent --> - -</div> <!-- box --> - -<div class=\"box\" id=\"examples\"> - <div class=\"boxtitle\">Concept<a class=\"title_switch\" onclick=\"toggleBoxContent(this);\">\x96</a></div> - <div class=\"boxcontent\"> - ".$concept." - </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 --> - -<div id=\"content\"> -<div class=\"box\" id=\"search\"> - <div class=\"boxtitle\">Content</div> - <div class=\"boxcontent\"> - ".$content." - </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><!-- content --> - -<div id=\"rightSidebar\"> - -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> -</div><!-- rightSidebar --> - - <div id=\"clear\"></div> -</div><!-- wrapper --> - - </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. |
From: <sk...@us...> - 2007-11-20 08:51:36
|
Revision: 285 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=285&view=rev Author: sknappe Date: 2007-11-20 00:51:34 -0800 (Tue, 20 Nov 2007) Log Message: ----------- moved ajax version to root folder Added Paths: ----------- trunk/src/dbpedia-navigator/Settings.php trunk/src/dbpedia-navigator/SparqlConnection.php trunk/src/dbpedia-navigator/ajax-loader.gif trunk/src/dbpedia-navigator/ajax.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/clearsession.php trunk/src/dbpedia-navigator/index.php trunk/src/dbpedia-navigator/pear/ trunk/src/dbpedia-navigator/pear/HTTP_Request.php trunk/src/dbpedia-navigator/pear/PEAR.php trunk/src/dbpedia-navigator/pear/Socket.php trunk/src/dbpedia-navigator/pear/URL.php trunk/src/dbpedia-navigator/xajax/ trunk/src/dbpedia-navigator/xajax/LICENSE.txt trunk/src/dbpedia-navigator/xajax/README.txt trunk/src/dbpedia-navigator/xajax/copyright.inc.php trunk/src/dbpedia-navigator/xajax/documentation/ trunk/src/dbpedia-navigator/xajax/examples/ trunk/src/dbpedia-navigator/xajax/release_notes.txt trunk/src/dbpedia-navigator/xajax/tests/ trunk/src/dbpedia-navigator/xajax/xajax_controls/ trunk/src/dbpedia-navigator/xajax/xajax_core/ trunk/src/dbpedia-navigator/xajax/xajax_js/ trunk/src/dbpedia-navigator/xajax/xajax_plugins/ Removed Paths: ------------- trunk/src/dbpedia-navigator/Ajax-Test/ trunk/src/dbpedia-navigator/pear/HTTP_Request.php trunk/src/dbpedia-navigator/pear/PEAR.php trunk/src/dbpedia-navigator/pear/Socket.php trunk/src/dbpedia-navigator/pear/URL.php trunk/src/dbpedia-navigator/xajax/LICENSE.txt trunk/src/dbpedia-navigator/xajax/README.txt trunk/src/dbpedia-navigator/xajax/copyright.inc.php trunk/src/dbpedia-navigator/xajax/documentation/ trunk/src/dbpedia-navigator/xajax/examples/ trunk/src/dbpedia-navigator/xajax/release_notes.txt trunk/src/dbpedia-navigator/xajax/tests/ trunk/src/dbpedia-navigator/xajax/xajax_controls/ trunk/src/dbpedia-navigator/xajax/xajax_core/ trunk/src/dbpedia-navigator/xajax/xajax_js/ trunk/src/dbpedia-navigator/xajax/xajax_plugins/ Added: trunk/src/dbpedia-navigator/Settings.php =================================================================== --- trunk/src/dbpedia-navigator/Settings.php (rev 0) +++ trunk/src/dbpedia-navigator/Settings.php 2007-11-20 08:51:34 UTC (rev 285) @@ -0,0 +1,8 @@ +<?php + +class Settings{ + public $wsdluri="http://localhost:8181/services?wsdl"; + public $dbpediauri="http://localhost:8890/sparql"; + public $sparqlttl=60; +} +?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/SparqlConnection.php =================================================================== --- trunk/src/dbpedia-navigator/SparqlConnection.php (rev 0) +++ trunk/src/dbpedia-navigator/SparqlConnection.php 2007-11-20 08:51:34 UTC (rev 285) @@ -0,0 +1,243 @@ +<?php + +class SparqlConnection +{ + private $DBPediaUrl; + private $DLLearnerUri; + private $client; + private $id; + private $ksID; + + function SparqlConnection($DBPediaUrl,$DLLearnerUri,$id=0,$ksID=0) + { + ini_set('default_socket_timeout',200); + $this->DBPediaUrl=$DBPediaUrl; + $this->DLLearnerUri=$DLLearnerUri; + $this->client=new SoapClient("main.wsdl"); + $this->id=$id; + $this->ksID=$ksID; + } + + function getIDs() + { + $id=$this->client->generateID(); + $ksID=$this->client->addKnowledgeSource($id,"sparql",$this->DBPediaUrl); + return array(0 => $id, 1 => $ksID); + } + + function test() + { + $object=$this->client->test($this->id,$this->ksID); + return $object->item; + } + + function getConceptFromExamples($ttl,$posExamples,$negExamples) + { + $this->client->applyConfigEntryInt($this->id, $this->ksID, "numberOfRecursions", 2); + $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "filterMode", 0); + $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "predList", array()); + $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "objList", array()); + $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "classList", array()); + $this->client->applyConfigEntryString($this->id, $this->ksID, "format", "KB"); + $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "dumpToFile", true); + + $this->client->setReasoner($this->id, "dig"); + $this->client->setLearningProblem($this->id, "posNegDefinition"); + $this->client->setPositiveExamples($this->id, $posExamples); + $this->client->setNegativeExamples($this->id, $negExamples); + $this->client->setLearningAlgorithm($this->id, "refinement"); + + $start = microtime(true); + + $this->client->init($this->id); + + $threaded=true; + + if($threaded == false) { + + $concept = $this->client->learn($this->id); + + } else { + + $this->client->learnThreaded($this->id); + + $i = 1; + $sleeptime = 1; + + do { + // sleep a while + sleep($sleeptime); + + // see what we have learned so far + $concept=$this->client->getCurrentlyBestConcept($this->id); + $running=$this->client->isAlgorithmRunning($this->id); + + $seconds = $i * $sleeptime; + + $i++; + } while($seconds<$ttl&&$running); + + $this->client->stop($this->id); + } + return $concept; + } + + function getTriples($ttl,$individual) + { + $options=array("triples",$individual); + $this->client->startThread($this->id,$this->ksID,$options); + $i = 1; + $sleeptime = 1; + + do { + // sleep a while + sleep($sleeptime); + + // see if algorithm is running + if (!$this->client->isThreadRunning($this->id,$this->ksID,"triples")) + { + $object=$this->client->getFromSparql($this->id,$this->ksID,"triples"); + $array=$object->item; + if (count($array)==1) return $array; + $ret=array(); + foreach ($array as $element) + { + $items=preg_split("[<]",$element,-1, PREG_SPLIT_NO_EMPTY); + $ret[$items[0]]=$items[1]; + } + return $ret; + } + + $seconds = $i * $sleeptime; + $i++; + } while($seconds<$ttl); + + $this->client->stopSparqlThread($this->id,$this->ksID,"triples"); + return array(); + } + + function getSubjects($ttl,$label) + { + $options=array("subjects",$label,15); + $this->client->startThread($this->id,$this->ksID,$options); + $i = 1; + $sleeptime = 1; + + do { + // sleep a while + sleep($sleeptime); + + // see if algorithm is running + if (!$this->client->isThreadRunning($this->id,$this->ksID,"subjects")) + { + $object=$this->client->getFromSparql($this->id,$this->ksID,"subjects"); + return $object->item; + } + + $seconds = $i * $sleeptime; + $i++; + } while($seconds<$ttl); + + $this->client->stopSparqlThread($this->id,$this->ksID,"subjects"); + return array(); + } + + function getSubjectsFromConcept($ttl,$concept) + { + $options=array("conceptSubjects",$concept); + $this->client->startThread($this->id,$this->ksID,$options); + $i = 1; + $sleeptime = 1; + do { + // sleep a while + sleep($sleeptime); + + // see if algorithm is running + if (!$this->client->isThreadRunning($this->id,$this->ksID,"conceptSubjects")) + { + $object=$this->client->getFromSparql($this->id,$this->ksID,"conceptSubjects"); + return $object->item; + } + + $seconds = $i * $sleeptime; + $i++; + } while($seconds<$ttl); + + $this->client->stopSparqlThread($this->id,$this->ksID,"conceptSubjects"); + return array(); + } + + public function loadWSDLfiles($wsdluri){ + $main=SparqlConnection::getwsdl($wsdluri); + $other=SparqlConnection::getOtherWSDL($main); + $newMain=SparqlConnection::changeWSDL($main); + SparqlConnection::writeToFile("main.wsdl",$newMain); + $x=0; + foreach ($other as $o){ + SparqlConnection::writeToFile("def".($x++).".xsd",SparqlConnection::getwsdl($o)); + } + + } + + private function changeWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $newWSDL=""; + $desca="def"; + $descb=".xsd"; + $x=0; + while($posstart= strpos ( $wsdl, $before )){ + + $posstart+=strlen($before); + $newWSDL.=substr($wsdl,0,$posstart); + $wsdl=substr($wsdl,$posstart); + $newWSDL.=$desca.($x++).$descb; + $posend= strpos ( $wsdl, $after ); + $wsdl=substr($wsdl,$posend); + + } + return $newWSDL.$wsdl; + + } + + private function getOtherWSDL($wsdl){ + $before="<xsd:import schemaLocation=\""; + $after="\" namespace=\""; + $ret=array(); + while($posstart= strpos ( $wsdl, $before )){ + $posstart+=strlen($before); + $wsdl=substr($wsdl,$posstart); + $posend= strpos ( $wsdl, $after ); + $tmp=substr($wsdl,0,$posend); + $ret[]=$tmp; + $wsdl=substr($wsdl,$posend+strlen($after)); + } + return $ret; + } + + + + + private function getwsdl($wsdluri){ + // this is copied from the Pear example + // please don't ask me how it works + $req = &new HTTP_Request($wsdluri); + $message=""; + $req->setMethod(HTTP_REQUEST_METHOD_GET); + $req->sendRequest(); + $ret=$req->getResponseBody(); + return $ret; + } + + + + private function writeToFile($filename,$content){ + + $fp=fopen($filename,"w"); + fwrite($fp,$content); + fclose($fp); + + } +} +?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/ajax-loader.gif (from rev 283, trunk/src/dbpedia-navigator/Ajax-Test/ajax-loader.gif) =================================================================== (Binary files differ) Copied: trunk/src/dbpedia-navigator/ajax.php (from rev 284, trunk/src/dbpedia-navigator/Ajax-Test/ajax.php) =================================================================== --- trunk/src/dbpedia-navigator/ajax.php (rev 0) +++ trunk/src/dbpedia-navigator/ajax.php 2007-11-20 08:51:34 UTC (rev 285) @@ -0,0 +1,24 @@ +<?php +require_once ("xajax/xajax_core/xajax.inc.php"); +$sid = session_id(); + +$xajax = new xajax("ajaxfunctions.php?sid=$sid"); +$xajax->register(XAJAX_FUNCTION, 'getsubjects', array( + 'onResponseDelay' => 'showLoadingSubjects', + 'beforeResponseProcessing' => 'hideLoadingSubjects' + )); +$xajax->registerFunction('getarticle'); +$xajax->registerFunction('addPositive'); +$xajax->registerFunction('addNegative'); +$xajax->registerFunction('clearPositives'); +$xajax->registerFunction('clearNegatives'); +$xajax->register(XAJAX_FUNCTION, 'learnConcept', array( + 'onResponseDelay' => 'showLoadingConcept', + 'beforeResponseProcessing' => 'hideLoadingConcept' + )); +$xajax->register(XAJAX_FUNCTION, 'getSubjectsFromConcept', array( + 'onResponseDelay' => 'showLoadingConceptSubjects', + 'beforeResponseProcessing' => 'hideLoadingConceptSubjects' + )); +$xajax->registerFunction('searchAndShowArticle'); +?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/ajaxfunctions.php (from rev 284, trunk/src/dbpedia-navigator/Ajax-Test/ajaxfunctions.php) =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php (rev 0) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2007-11-20 08:51:34 UTC (rev 285) @@ -0,0 +1,222 @@ +<?php +ini_set('max_execution_time',200); +$sid = $_GET['sid']; +session_id($sid); +session_start(); + +require("ajax.php"); +$xajax->processRequest(); + +function getsubjects($label) +{ + require_once("Settings.php"); + require_once("SparqlConnection.php"); + $settings=new Settings(); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); + + $content=""; + $subjects=$sc->getSubjects($settings->sparqlttl,$label); + if (count($subjects)==1) + { + if (strpos($subjects,"[Error]")===0) $content.=substr($subjects,7); + else $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subjects."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; + } + else if (count($subjects)==0) $content.="No search result found in time."; + else{ + foreach ($subjects as $subject) + { + $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subject."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; + } + } + + $objResponse = new xajaxResponse(); + $objResponse->assign("searchcontent", "innerHTML", $content); + return $objResponse; +} + +function getarticle($subject,$fromCache) +{ + if (isset($_SESSION['articles'])) + foreach ($_SESSION['articles'] as $key => $value) + { + if ($value['subject']==$subject){ + $fromCache=$key; + break; + } + } + if ($fromCache==-1) { + require_once("Settings.php"); + require_once("SparqlConnection.php"); + $settings=new Settings(); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); + $triples=$sc->getTriples($settings->sparqlttl,$subject); + $content=""; + if (count($triples)==1) + { + $content.=substr($triples,7); + } + else if (count($triples)==0) $content.="Article not found."; + else { + $content=""; + $content.="<img src=\"".$triples['http://xmlns.com/foaf/0.1/depiction']."\" alt=\"Picture of ".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."\" width=\"50\"/ style=\"float:left\">"; + $content.="<div>".urldecode($triples['http://dbpedia.org/property/abstract'])."</div>"; + + $contentbuttons="<input type=\"button\" value=\"Positive\" class=\"button\" onclick=\"xajax_addPositive('".$subject."');return false;\" /> <input type=\"button\" value=\"Negative\" class=\"button\" onclick=\"xajax_addNegative('".$subject."');return false;\" />"; + } + + //store article in session, to navigate between last 5 articles quickly + $contentArray=array('content' => $content,'contentbuttons' => $contentbuttons, 'subject' => $subject); + if (!isset($_SESSION['nextArticle'])){ + $_SESSION['nextArticle']=0; + $_SESSION['articles']=array(); + } + if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; + $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; + $_SESSION['currentArticle']=$_SESSION['nextArticle']; + $_SESSION['nextArticle']++; + } + else { + $content=$_SESSION['articles'][$fromCache]['content']; + $contentbuttons=$_SESSION['articles'][$fromCache]['contentbuttons']; + $subject=$_SESSION['articles'][$fromCache]['subject']; + } + + $lastArticles=""; + foreach ($_SESSION['articles'] as $key => $value) + { + $lastArticles.="<a href=\"\" onclick=\"xajax_getarticle('',".$key.");return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($value['subject'], "/"), 1)))."</a><br/>"; + } + + //build the response + $objResponse = new xajaxResponse(); + $objResponse->assign("articlecontent", "innerHTML", $content); + $objResponse->assign("contentbuttons", "innerHTML", $contentbuttons); + $objResponse->assign("ArticleTitle","innerHTML",str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))); + $objResponse->assign("lastarticles","innerHTML",$lastArticles); + return $objResponse; +} + +function addPositive($subject) +{ + if (!isset($_SESSION['positive'])){ + $array=array($subject); + $_SESSION['positive']=$array; + } + else{ + $array=$_SESSION['positive']; + $array[]=$subject; + $_SESSION['positive']=$array; + } + + $content=str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."<br/>"; + + $objResponse = new xajaxResponse(); + $objResponse->append("Positives", "innerHTML", $content); + return $objResponse; +} + +function addNegative($subject) +{ + if (!isset($_SESSION['negative'])){ + $array=array($subject); + $_SESSION['negative']=$array; + } + else{ + $array=$_SESSION['negative']; + $array[]=$subject; + $_SESSION['negative']=$array; + } + + $content=str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."<br/>"; + + $objResponse = new xajaxResponse(); + $objResponse->append("Negatives", "innerHTML", $content); + return $objResponse; +} + +function clearPositives() +{ + unset($_SESSION['positive']); + + $objResponse = new xajaxResponse(); + $objResponse->assign("Positives", "innerHTML", ""); + return $objResponse; +} + +function clearNegatives() +{ + unset($_SESSION['negative']); + + $objResponse = new xajaxResponse(); + $objResponse->assign("Negatives", "innerHTML", ""); + return $objResponse; +} + +function learnConcept() +{ + 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,$_SESSION['id'],$_SESSION['ksID']); + + $concept=$sc->getConceptFromExamples($settings->sparqlttl,$_SESSION['positive'],$_SESSION['negative']); + $_SESSION['lastLearnedConcept']=$concept; + if (strlen(substr (strrchr ($concept, "/"), 1))>0) $concept=urldecode(substr (strrchr ($concept, "/"), 1)); + } + else $concept="You must choose at least one<br/> positive and one negative example."; + + $objResponse = new xajaxResponse(); + $objResponse->assign("conceptcontent", "innerHTML", $concept); + return $objResponse; +} + +function getSubjectsFromConcept() +{ + require_once("Settings.php"); + require_once("SparqlConnection.php"); + $settings=new Settings(); + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); + + $content=""; + if (isset($_SESSION['lastLearnedConcept'])) + { + $subjects=$sc->getSubjectsFromConcept($settings->sparqlttl,$_SESSION['lastLearnedConcept']); + if (count($subjects)==1) + { + if (strpos($subjects,"[Error]")===0) $content.=substr($subjects,7); + else $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subjects."');return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; + } + else if (count($subjects)==0) $content.="No examples for concept found in time."; + else { + foreach ($subjects as $subject) + { + $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subject."');return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; + } + } + } + else $content.="No concept to get Subjects from."; + + $objResponse = new xajaxResponse(); + $objResponse->assign("conceptsubjectcontent", "innerHTML", $content); + return $objResponse; +} + +function searchAndShowArticle($keyword) +{ + require_once("Settings.php"); + require_once("SparqlConnection.php"); + $settings=new Settings(); + + $sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); + + $content=""; + + $objResponse = new xajaxResponse(); + $objResponse->call('xajax_getarticle', "http://dbpedia.org/resource/".str_replace(" ","_",$keyword),-1); + $objResponse->call('xajax_getsubjects',$keyword); + return $objResponse; +} + +?> \ No newline at end of file Copied: trunk/src/dbpedia-navigator/clearsession.php (from rev 283, trunk/src/dbpedia-navigator/Ajax-Test/clearsession.php) =================================================================== --- trunk/src/dbpedia-navigator/clearsession.php (rev 0) +++ trunk/src/dbpedia-navigator/clearsession.php 2007-11-20 08:51:34 UTC (rev 285) @@ -0,0 +1,12 @@ +<?php +session_start(); + +session_unset(); +ob_start(); +require_once 'pear/HTTP_Request.php'; +require_once 'SparqlConnection.php'; +require_once 'Settings.php'; +$settings=new Settings(); +SparqlConnection::loadWSDLfiles($settings->wsdluri); +header("Location: http://" . $_SERVER["HTTP_HOST"] . "/Ajax-Test/index.php"); +?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php (rev 0) +++ trunk/src/dbpedia-navigator/index.php 2007-11-20 08:51:34 UTC (rev 285) @@ -0,0 +1,140 @@ +<?php +ini_set('error_reporting',E_ALL); +ini_set('max_execution_time',200); +ini_set("soap.wsdl_cache_enabled","1"); +session_start(); +require_once('Settings.php'); +require_once('SparqlConnection.php'); +$settings=new Settings(); +$sc=new SparqlConnection($settings->dbpediauri,$settings->wsdluri); +$ids=$sc->getIDs(); +$_SESSION['id']=$ids[0]; +$_SESSION['ksID']=$ids[1]; + +echo "<a href='clearsession.php'>start from scratch</a>"; + +require("ajax.php"); + +echo '<?xml version="1.0" encoding="UTF-8"?>'; +?> +<html> + <head> + <title>DL Learner</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> + <link rel="stylesheet" href="default.css"/> + <?php $xajax->printJavascript('xajax/'); ?> + <script type="text/javascript"> + showLoadingSubjects = function() { + xajax.$('loadingSubject').style.display='block'; + xajax.$('searchcontent').style.display = 'none'; + }; + hideLoadingSubjects = function() { + xajax.$('loadingSubject').style.display = 'none'; + xajax.$('searchcontent').style.display='block'; + }; + showLoadingArticle = function() { + xajax.$('loadingArticle').style.display='block'; + xajax.$('articlecontent').style.display = 'none'; + }; + 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'; + }; + showLoadingConceptSubjects = function() { + xajax.$('loadingConceptSubjects').style.display='block'; + xajax.$('conceptsubjectcontent').style.display = 'none'; + }; + hideLoadingConceptSubjects = function() { + xajax.$('loadingConceptSubjects').style.display = 'none'; + xajax.$('conceptsubjectcontent').style.display = 'block'; + } + </script> + </head> + <body> +<h3>DBPedia-Navigator-Test</h3> +<div id="layer" style="display:none"><div id="layerContent" style="display:none"></div></div> +<div id="wrapper"> +<div id="leftSidebar"> + +<div class="box"> + <div class="boxtitle">Search</div> + <div class="boxcontent" id="search"> + Search:<br/> + <input type="textfield" name="label" id="label"><br/> + <input type="button" value="Article" class="button" onclick="xajax_searchAndShowArticle(document.getElementById('label').value);return false;" /> <input type="button" value="Fulltext" class="button" onclick=""/> + </div> <!-- boxcontent --> +</div> <!-- box --> + +<div class="box"> + <div class="boxtitle">Searchresults</div> + <div class="boxcontent"> + <div id="searchcontent" style="display:block"></div> + <div id="loadingSubject" style="display:none"><img src="ajax-loader.gif" alt="Loading..."/></div> + </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 --> + +<div class="box" id="conceptSubjects"> + <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left">Subjects From Concept</td><td class="right"><input type="button" value="Show" class="button" onclick="xajax_getSubjectsFromConcept();return false;" /></td></tr></table></div> + <div class="boxcontent"> + <div id="conceptsubjectcontent" style="display:none"></div> + <div id="loadingConceptSubjects" 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 --> + +<div id="content"> +<div class="box"> + <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left" id="ArticleTitle">Article</td><td class="right"><span id="contentbuttons"></span></td></tr></table></div> + <div class="boxcontent" id="article"> + <div id="articlecontent" style="display:block"></div> + <div id="loadingArticle" 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><!-- content --> +<div id="rightSidebar"> + +<div class="box"> + <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left">Positives</td><td class="right"><input type="button" value="Clear" class="button" onclick="xajax_clearPositives();return false;" /></td></tr></table></div> + <div class="boxcontent" id="Positives"> + </div> <!-- boxcontent --> +</div> <!-- box --> + +<div class="box"> + <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left">Negatives</td><td class="right"><input type="button" value="Clear" class="button" onclick="xajax_clearNegatives();return false;" /></td></tr></table></div> + <div class="boxcontent" id="Negatives"> + </div> <!-- boxcontent --> +</div> <!-- box --> + +<div class="box"> + <div class="boxtitle">Last Articles</div> + <div class="boxcontent" id="lastarticles"> + </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><!-- rightSidebar --> +<div id="clear"></div> +</div> + </body> +</html> + \ No newline at end of file Copied: trunk/src/dbpedia-navigator/pear (from rev 283, trunk/src/dbpedia-navigator/Ajax-Test/pear) Deleted: trunk/src/dbpedia-navigator/pear/HTTP_Request.php =================================================================== --- trunk/src/dbpedia-navigator/Ajax-Test/pear/HTTP_Request.php 2007-11-12 15:19:23 UTC (rev 283) +++ trunk/src/dbpedia-navigator/pear/HTTP_Request.php 2007-11-20 08:51:34 UTC (rev 285) @@ -1,2760 +0,0 @@ -<?php - -// +-----------------------------------------------------------------------+ -// | Copyright (c) 2002-2003, Richard Heyes | -// | All rights reserved. | -// | | -// | Redistribution and use in source and binary forms, with or without | -// | modification, are permitted provided that the following conditions | -// | are met: | -// | | -// | o Redistributions of source code must retain the above copyright | -// | notice, this list of conditions and the following disclaimer. | -// | o Redistributions in binary form must reproduce the above copyright | -// | notice, this list of conditions and the following disclaimer in the | -// | documentation and/or other materials provided with the distribution.| -// | o The names of the authors may not be used to endorse or promote | -// | products derived from this software without specific prior written | -// | permission. | -// | | -// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | -// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | -// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | -// | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | - -// | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | - -// | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | - -// | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | - -// | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | - -// | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | - -// | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | - -// | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | - -// | | - -// +-----------------------------------------------------------------------+ - -// | Author: Richard Heyes <ri...@ph...> | - -// +-----------------------------------------------------------------------+ - -/* -// $Id: Request.php,v 1.1 2006/12/12 16:42:26 punkrock Exp $ -// -// HTTP_Request Class -// -// Simple example, (Fetches yahoo.com and displays it): -// -// $a = &new HTTP_Request('http://localhost:8081'); -// $a->sendRequest(); -// echo $a->getResponseBody(); -*/ - - - -require_once 'PEAR.php'; - -require_once 'Socket.php'; - -require_once 'URL.php'; - - - -define('HTTP_REQUEST_METHOD_GET', 'GET', true); - -define('HTTP_REQUEST_METHOD_HEAD', 'HEAD', true); - -define('HTTP_REQUEST_METHOD_POST', 'POST', true); - -define('HTTP_REQUEST_METHOD_PUT', 'PUT', true); - -define('HTTP_REQUEST_METHOD_DELETE', 'DELETE', true); - -define('HTTP_REQUEST_METHOD_OPTIONS', 'OPTIONS', true); - -define('HTTP_REQUEST_METHOD_TRACE', 'TRACE', true); - - - -define('HTTP_REQUEST_HTTP_VER_1_0', '1.0', true); - -define('HTTP_REQUEST_HTTP_VER_1_1', '1.1', true); - - - -class HTTP_Request { - - - - /** - - * Instance of Net_URL - - * @var object Net_URL - - */ - - var $_url; - - - - /** - - * Type of request - - * @var string - - */ - - var $_method; - - - - /** - - * HTTP Version - - * @var string - - */ - - var $_http; - - - - /** - - * Request headers - - * @var array - - */ - - var $_requestHeaders; - - - - /** - - * Basic Auth Username - - * @var string - - */ - - var $_user; - - - - /** - - * Basic Auth Password - - * @var string - - */ - - var $_pass; - - - - /** - - * Socket object - - * @var object Net_Socket - - */ - - var $_sock; - - - - /** - - * Proxy server - - * @var string - - */ - - var $_proxy_host; - - - - /** - - * Proxy port - - * @var integer - - */ - - var $_proxy_port; - - - - /** - - * Proxy username - - * @var string - - */ - - var $_proxy_user; - - - - /** - - * Proxy password - - * @var string - - */ - - var $_proxy_pass; - - - - /** - - * Post data - - * @var array - - */ - - var $_postData; - - - - /** - - * Request body - - * @var string - - */ - - var $_body; - - - - /** - - * A list of methods that MUST NOT have a request body, per RFC 2616 - - * @var array - - */ - - var $_bodyDisallowed = array('TRACE'); - - - - /** - - * Files to post - - * @var array - - */ - - var $_postFiles = array(); - - - - /** - - * Connection timeout. - - * @var float - - */ - - var $_timeout; - - - - /** - - * HTTP_Response object - - * @var object HTTP_Response - - */ - - var $_response; - - - - /** - - * Whether to allow redirects - - * @var boolean - - */ - - var $_allowRedirects; - - - - /** - - * Maximum redirects allowed - - * @var integer - - */ - - var $_maxRedirects; - - - - /** - - * Current number of redirects - - * @var integer - - */ - - var $_redirects; - - - - /** - - * Whether to append brackets [] to array variables - - * @var bool - - */ - - var $_useBrackets = true; - - - - /** - - * Attached listeners - - * @var array - - */ - - var $_listeners = array(); - - - - /** - - * Whether to save response body in response object property - - * @var bool - - */ - - var $_saveBody = true; - - - - /** - - * Timeout for reading from socket (array(seconds, microseconds)) - - * @var array - - */ - - var $_readTimeout = null; - - - - /** - - * Options to pass to Net_Socket::connect. See stream_context_create - - * @var array - - */ - - var $_socketOptions = null; - - - - /** - - * Constructor - - * - - * Sets up the object - - * @param string The url to fetch/access - - * @param array Associative array of parameters which can have the following keys: - - * <ul> - - * <li>method - Method to use, GET, POST etc (string)</li> - - * <li>http - HTTP Version to use, 1.0 or 1.1 (string)</li> - - * <li>user - Basic Auth username (string)</li> - - * <li>pass - Basic Auth password (string)</li> - - * <li>proxy_host - Proxy server host (string)</li> - - * <li>proxy_port - Proxy server port (integer)</li> - - * <li>proxy_user - Proxy auth username (string)</li> - - * <li>proxy_pass - Proxy auth password (string)</li> - - * <li>timeout - Connection timeout in seconds (float)</li> - - * <li>allowRedirects - Whether to follow redirects or not (bool)</li> - - * <li>maxRedirects - Max number of redirects to follow (integer)</li> - - * <li>useBrackets - Whether to append [] to array variable names (bool)</li> - - * <li>saveBody - Whether to save response body in response object property (bool)</li> - - * <li>readTimeout - Timeout for reading / writing data over the socket (array (seconds, microseconds))</li> - - * <li>socketOptions - Options to pass to Net_Socket object (array)</li> - - * </ul> - - * @access public - - */ - - function HTTP_Request($url = '', $params = array()) - - { - - $this->_method = HTTP_REQUEST_METHOD_GET; - - $this->_http = HTTP_REQUEST_HTTP_VER_1_1; - - $this->_requestHeaders = array(); - - $this->_postData = array(); - - $this->_body = null; - - - - $this->_user = null; - - $this->_pass = null; - - - - $this->_proxy_host = null; - - $this->_proxy_port = null; - - $this->_proxy_user = null; - - $this->_proxy_pass = null; - - - - $this->_allowRedirects = false; - - $this->_maxRedirects = 3; - - $this->_redirects = 0; - - - - $this->_timeout = null; - - $this->_response = null; - - - - foreach ($params as $key => $value) { - - $this->{'_' . $key} = $value; - - } - - - - if (!empty($url)) { - - $this->setURL($url); - - } - - - - // Default useragent - - $this->addHeader('User-Agent', 'PEAR HTTP_Request class ( http://pear.php.net/ )'); - - - - // We don't do keep-alives by default - - $this->addHeader('Connection', 'close'); - - - - // Basic authentication - - if (!empty($this->_user)) { - - $this->addHeader('Authorization', 'Basic ' . base64_encode($this->_user . ':' . $this->_pass)); - - } - - - - // Proxy authentication (see bug #5913) - - if (!empty($this->_proxy_user)) { - - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($this->_proxy_user . ':' . $this->_proxy_pass)); - - } - - - - // Use gzip encoding if possible - - // Avoid gzip encoding if using multibyte functions (see #1781) - - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && extension_loaded('zlib') && - - 0 == (2 & ini_get('mbstring.func_overload'))) { - - - - $this->addHeader('Accept-Encoding', 'gzip'); - - } - - } - - - - /** - - * Generates a Host header for HTTP/1.1 requests - - * - - * @access private - - * @return string - - */ - - function _generateHostHeader() - - { - - if ($this->_url->port != 80 AND strcasecmp($this->_url->protocol, 'http') == 0) { - - $host = $this->_url->host . ':' . $this->_url->port; - - - - } elseif ($this->_url->port != 443 AND strcasecmp($this->_url->protocol, 'https') == 0) { - - $host = $this->_url->host . ':' . $this->_url->port; - - - - } elseif ($this->_url->port == 443 AND strcasecmp($this->_url->protocol, 'https') == 0 AND strpos($this->_url->url, ':443') !== false) { - - $host = $this->_url->host . ':' . $this->_url->port; - - - - } else { - - $host = $this->_url->host; - - } - - - - return $host; - - } - - - - /** - - * Resets the object to its initial state (DEPRECATED). - - * Takes the same parameters as the constructor. - - * - - * @param string $url The url to be requested - - * @param array $params Associative array of parameters - - * (see constructor for details) - - * @access public - - * @deprecated deprecated since 1.2, call the constructor if this is necessary - - */ - - function reset($url, $params = array()) - - { - - $this->HTTP_Request($url, $params); - - } - - - - /** - - * Sets the URL to be requested - - * - - * @param string The url to be requested - - * @access public - - */ - - function setURL($url) - - { - - $this->_url = &new Net_URL($url, $this->_useBrackets); - - - - if (!empty($this->_url->user) || !empty($this->_url->pass)) { - - $this->setBasicAuth($this->_url->user, $this->_url->pass); - - } - - - - if (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http) { - - $this->addHeader('Host', $this->_generateHostHeader()); - - } - - - - // set '/' instead of empty path rather than check later (see bug #8662) - - if (empty($this->_url->path)) { - - $this->_url->path = '/'; - - } - - } - - - - /** - - * Returns the current request URL - - * - - * @return string Current request URL - - * @access public - - */ - - function getUrl($url) - - { - - return empty($this->_url)? '': $this->_url->getUrl(); - - } - - - - /** - - * Sets a proxy to be used - - * - - * @param string Proxy host - - * @param int Proxy port - - * @param string Proxy username - - * @param string Proxy password - - * @access public - - */ - - function setProxy($host, $port = 8080, $user = null, $pass = null) - - { - - $this->_proxy_host = $host; - - $this->_proxy_port = $port; - - $this->_proxy_user = $user; - - $this->_proxy_pass = $pass; - - - - if (!empty($user)) { - - $this->addHeader('Proxy-Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - - } - - } - - - - /** - - * Sets basic authentication parameters - - * - - * @param string Username - - * @param string Password - - */ - - function setBasicAuth($user, $pass) - - { - - $this->_user = $user; - - $this->_pass = $pass; - - - - $this->addHeader('Authorization', 'Basic ' . base64_encode($user . ':' . $pass)); - - } - - - - /** - - * Sets the method to be used, GET, POST etc. - - * - - * @param string Method to use. Use the defined constants for this - - * @access public - - */ - - function setMethod($method) - - { - - $this->_method = $method; - - } - - - - /** - - * Sets the HTTP version to use, 1.0 or 1.1 - - * - - * @param string Version to use. Use the defined constants for this - - * @access public - - */ - - function setHttpVer($http) - - { - - $this->_http = $http; - - } - - - - /** - - * Adds a request header - - * - - * @param string Header name - - * @param string Header value - - * @access public - - */ - - function addHeader($name, $value) - - { - - $this->_requestHeaders[strtolower($name)] = $value; - - } - - - - /** - - * Removes a request header - - * - - * @param string Header name to remove - - * @access public - - */ - - function removeHeader($name) - - { - - if (isset($this->_requestHeaders[strtolower($name)])) { - - unset($this->_requestHeaders[strtolower($name)]); - - } - - } - - - - /** - - * Adds a querystring parameter - - * - - * @param string Querystring parameter name - - * @param string Querystring parameter value - - * @param bool Whether the value is already urlencoded or not, default = not - - * @access public - - */ - - function addQueryString($name, $value, $preencoded = false) - - { - - $this->_url->addQueryString($name, $value, $preencoded); - - } - - - - /** - - * Sets the querystring to literally what you supply - - * - - * @param string The querystring data. Should be of the format foo=bar&x=y etc - - * @param bool Whether data is already urlencoded or not, default = already encoded - - * @access public - - */ - - function addRawQueryString($querystring, $preencoded = true) - - { - - $this->_url->addRawQueryString($querystring, $preencoded); - - } - - - - /** - - * Adds postdata items - - * - - * @param string Post data name - - * @param string Post data value - - * @param bool Whether data is already urlencoded or not, default = not - - * @access public - - */ - - function addPostData($name, $value, $preencoded = false) - - { - - if ($preencoded) { - - $this->_postData[$name] = $value; - - } else { - - $this->_postData[$name] = $this->_arrayMapRecursive('urlencode', $value); - - } - - } - - - - /** - - * Recursively applies the callback function to the value - - * - - * @param mixed Callback function - - * @param mixed Value to process - - * @access private - - * @return mixed Processed value - - */ - - function _arrayMapRecursive($callback, $value) - - { - - if (!is_array($value)) { - - return call_user_func($callback, $value); - - } else { - - $map = array(); - - foreach ($value as $k => $v) { - - $map[$k] = $this->_arrayMapRecursive($callback, $v); - - } - - return $map; - - } - - } - - - - /** - - * Adds a file to upload - - * - - * This also changes content-type to 'multipart/form-data' for proper upload - - * - - * @access public - - * @param string name of file-upload field - - * @param mixed file name(s) - - * @param mixed content-type(s) of file(s) being uploaded - - * @return bool true on success - - * @throws PEAR_Error - - */ - - function addFile($inputName, $fileName, $contentType = 'application/octet-stream') - - { - - if (!is_array($fileName) && !is_readable($fileName)) { - - return PEAR::raiseError("File '{$fileName}' is not readable"); - - } elseif (is_array($fileName)) { - - foreach ($fileName as $name) { - - if (!is_readable($name)) { - - return PEAR::raiseError("File '{$name}' is not readable"); - - } - - } - - } - - $this->addHeader('Content-Type', 'multipart/form-data'); - - $this->_postFiles[$inputName] = array( - - 'name' => $fileName, - - 'type' => $contentType - - ); - - return true; - - } - - - - /** - - * Adds raw postdata (DEPRECATED) - - * - - * @param string The data - - * @param bool Whether data is preencoded or not, default = already encoded - - * @access public - - * @deprecated deprecated since 1.3.0, method setBody() should be used instead - - */ - - function addRawPostData($postdata, $preencoded = true) - - { - - $this->_body = $preencoded ? $postdata : urlencode($postdata); - - } - - - - /** - - * Sets the request body (for POST, PUT and similar requests) - - * - - * @param string Request body - - * @access public - - */ - - function setBody($body) - - { - - $this->_body = $body; - - } - - - - /** - - * Clears any postdata that has been added (DEPRECATED). - - * - - * Useful for multiple request scenarios. - - * - - * @access public - - * @deprecated deprecated since 1.2 - - */ - - function clearPostData() - - { - - $this->_postData = null; - - } - - - - /** - - * Appends a cookie to "Cookie:" header - - * - - * @param string $name cookie name - - * @param string $value cookie value - - * @access public - - */ - - function addCookie($name, $value) - - { - - $cookies = isset($this->_requestHeaders['cookie']) ? $this->_requestHeaders['cookie']. '; ' : ''; - - $this->addHeader('Cookie', $cookies . $name . '=' . $value); - - } - - - - /** - - * Clears any cookies that have been added (DEPRECATED). - - * - - * Useful for multiple request scenarios - - * - - * @access public - - * @deprecated deprecated since 1.2 - - */ - - function clearCookies() - - { - - $this->removeHeader('Cookie'); - - } - - - - /** - - * Sends the request - - * - - * @access public - - * @param bool Whether to store response body in Response object property, - - * set this to false if downloading a LARGE file and using a Listener - - * @return mixed PEAR error on error, true otherwise - - */ - - function sendRequest($saveBody = true){ - - if (!is_a($this->_url, 'Net_URL')) { - - return PEAR::raiseError('No URL given.'); - - } - - - - $host = isset($this->_proxy_host) ? $this->_proxy_host : $this->_url->host; - - $port = isset($this->_proxy_port) ? $this->_proxy_port : $this->_url->port; - - - - // 4.3.0 supports SSL connections using OpenSSL. The function test determines - - // we running on at least 4.3.0 - - if (strcasecmp($this->_url->protocol, 'https') == 0 AND function_exists('file_get_contents') AND extension_loaded('openssl')) { - - if (isset($this->_proxy_host)) { - - return PEAR::raiseError('HTTPS proxies are not supported.'); - - } - - $host = 'ssl://' . $host; - - } - - - - // magic quotes may fuck up file uploads and chunked response processing - - $magicQuotes = ini_get('magic_quotes_runtime'); - - ini_set('magic_quotes_runtime', false); - - - - // RFC 2068, section 19.7.1: A client MUST NOT send the Keep-Alive - - // connection token to a proxy server... - - if (isset($this->_proxy_host) && !empty($this->_requestHeaders['connection']) && - - 'Keep-Alive' == $this->_requestHeaders['connection']) - - { - - $this->removeHeader('connection'); - - } - - - - $keepAlive = (HTTP_REQUEST_HTTP_VER_1_1 == $this->_http && empty($this->_requestHeaders['connection'])) || - - (!empty($this->_requestHeaders['connection']) && 'Keep-Alive' == $this->_requestHeaders['connection']); - - $sockets = &PEAR::getStaticProperty('HTTP_Request', 'sockets'); - - $sockKey = $host . ':' . $port; - - unset($this->_sock); - - - - // There is a connected socket in the "static" property? - - if ($keepAlive && !empty($sockets[$sockKey]) && - - !empty($sockets[$sockKey]->fp)) - - { - - $this->_sock =& $sockets[$sockKey]; - - $err = null; - - } else { - - $this->_notify('connect'); - - $this->_sock =& new Net_Socket(); - - $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions); - - } - - PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest()); - - - - if (!PEAR::isError($err)) { - - if (!empty($this->_readTimeout)) { - - $this->_sock->setTimeout($this->_readTimeout[0], $this->_readTimeout[1]); - - } - - - - $this->_notify('sentRequest'); - - - - // Read the response - - $this->_response = &new HTTP_Response($this->_sock, $this->_listeners); - - $err = $this->_response->process( - - $this->_saveBody && $saveBody, - - HTTP_REQUEST_METHOD_HEAD != $this->_method - - ); - - - - if ($keepAlive) { - - $keepAlive = (isset($this->_response->_headers['content-length']) - - || (isset($this->_response->_headers['transfer-encoding']) - - && strtolower($this->_response->_headers['transfer-encoding']) == 'chunked')); - - if ($keepAlive) { - - if (isset($this->_response->_headers['connection'])) { - - $keepAlive = strtolower($this->_response->_headers['connection']) == 'keep-alive'; - - } else { - - $keepAlive = 'HTTP/'.HTTP_REQUEST_HTTP_VER_1_1 == $this->_response->_protocol; - - } - - } - - } - - } - - - - ini_set('magic_quotes_runtime', $magicQuotes); - - - - if (PEAR::isError($err)) { - - return $err; - - } - - - - if (!$keepAlive) { - - $this->disconnect(); - - // Store the connected socket in "static" property - - } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) { - - $sockets[$sockKey] =& $this->_sock; - - } - - - - // Check for redirection - - if ( $this->_allowRedirects - - AND $this->_redirects <= $this->_maxRedirects - - AND $this->getResponseCode() > 300 - - AND $this->getResponseCode() < 399 - - AND !empty($this->_response->_headers['location'])) { - - - - - - $redirect = $this->_response->_headers['location']; - - - - // Absolute URL - - if (preg_match('/^https?:\/\//i', $redirect)) { - - $this->_url = &new Net_URL($redirect); - - $this->addHeader('Host', $this->_generateHostHeader()); - - // Absolute path - - } elseif ($redirect{0} == '/') { - - $this->_url->path = $redirect; - - - - // Relative path - - } elseif (substr($redirect, 0, 3) == '../' OR substr($redirect, 0, 2) == './') { - - if (substr($this->_url->path, -1) == '/') { - - $redirect = $this->_url->path . $redirect; - - } else { - - $redirect = dirname($this->_url->path) . '/' . $redirect; - - } - - $redirect = Net_URL::resolvePath($redirect); - - $this->_url->path = $redirect; - - - - // Filename, no path - - } else { - - if (substr($this->_url->path, -1) == '/') { - - $redirect = $this->_url->path . $redirect; - - } else { - - $redirect = dirname($this->_url->path) . '/' . $redirect; - - } - - $this->_url->path = $redirect; - - } - - - - $this->_redirects++; - - return $this->sendRequest($saveBody); - - - - // Too many redirects - - } elseif ($this->_allowRedirects AND $this->_redirects > $this->_maxRedirects) { - - return PEAR::raiseError('Too many redirects'); - - } - - - - return true; - - } - - - - /** - - * Disconnect the socket, if connected. Only useful if using Keep-Alive. - - * - - * @access public - - */ - - function disconnect() - - { - - if (!empty($this->_sock) && !empty($this->_sock->fp)) { - - $this->_notify('disconnect'); - - $this->_sock->disconnect(); - - } - - } - - - - /** - - * Returns the response code - - * - - * @access public - - * @return mixed Response code, false if not set - - */ - - function getResponseCode() - - { - - return isset($this->_response->_code) ? $this->_response->_code : false; - - } - - - - /** - - * Returns either the named header or all if no name given - - * - - * @access public - - * @param string The header name to return, do not set to get all headers - - * @return mixed either the value of $headername (false if header is not present) - - * or an array of all headers - - */ - - function getResponseHeader($headername = null) - - { - - if (!isset($headername)) { - - return isset($this->_response->_headers)? $this->_response->_headers: array(); - - } else { - - $headername = strtolower($headername); - - return isset($this->_response->_headers[$headername]) ? $this->_response->_headers[$headername] : false; - - } - - } - - - - /** - - * Returns the body of the response - - * - - * @access public - - * @return mixed response body, false if not set - - */ - - function getResponseBody() - - { - - return isset($this->_response->_body) ? $this->_response->_body : false; - - } - - - - /** - - * Returns cookies set in response - - * - - * @access public - - * @return mixed array of response cookies, false if none are present - - */ - - function getResponseCookies() - - { - - return isset($this->_response->_cookies) ? $this->_response->_cookies : false; - - } - - - - /** - - * Builds the request string - - * - - * @access private - - * @return string The request string - - */ - - function _buildRequest() - - { - - $separator = ini_get('arg_separator.output'); - - ini_set('arg_separator.output', '&'); - - $querystring = ($querystring = $this->_url->getQueryString()) ? '?' . $querystring : ''; - - ini_set('arg_separator.output', $separator); - - - - $host = isset($this->_proxy_host) ? $this->_url->protocol . '://' . $this->_url->host : ''; - - $port = (isset($this->_proxy_host) AND $this->_url->port != 80) ? ':' . $this->_url->port : ''; - - $path = $this->_url->path . $querystring; - - $url = $host . $port . $path; - - - - $request = $this->_method . ' ' . $url . ' HTTP/' . $this->_http . "\r\n"; - - - - if (in_array($this->_method, $this->_bodyDisallowed) || - - (empty($this->_body) && (HTTP_REQUEST_METHOD_POST != $this->_method || - - (empty($this->_postData) && empty($this->_postFiles))))) - - { - - $this->removeHeader('Content-Type'); - - } else { - - if (empty($this->_requestHeaders['content-type'])) { - - // Add default content-type - - $this->addHeader('Content-Type', 'application/x-www-form-urlencoded'); - - } elseif ('multipart/form-data' == $this->_requestHeaders['content-type']) { - - $boundary = 'HTTP_Request_' . md5(uniqid('request') . microtime()); - - $this->addHeader('Content-Type', 'multipart/form-data; boundary=' . $boundary); - - } - - } - - - - // Request Headers - - if (!empty($this->_requestHeaders)) { - - foreach ($this->_requestHeaders as $name => $value) { - - $canonicalName = implode('-', array_map('ucfirst', explode('-', $name))); - - $request .= $canonicalName . ': ' . $value . "\r\n"; - - } - - } - - - - // No post data or wrong method, so simply add a final CRLF - - if (in_array($this->_method, $this->_bodyDisallowed) || - - (HTTP_REQUEST_METHOD_POST != $this->_method && empty($this->_body))) { - - - - $request .= "\r\n"; - - - - // Post data if it's an array - - } elseif (HTTP_REQUEST_METHOD_POST == $this->_method && - - (!empty($this->_postData) || !empty($this->_postFiles))) { - - - - // "normal" POST request - - if (!isset($boundary)) { - - $postdata = implode('&', array_map( - - create_function('$a', 'return $a[0] . \'=\' . $a[1];'), - - $this->_flattenArray('', $this->_postData) - - )); - - - - // multipart request, probably with file uploads - - } else { - - $postdata = ''; - - if (!empty($this->_postData)) { - - $flatData = $this->_flattenArray('', $this->_postData); - - foreach ($flatData as $item) { - - $postdata .= '--' . $boundary . "\r\n"; - - $postdata .= 'Content-Disposition: form-data; name="' . $item[0] . '"'; - - $postdata .= "\r\n\r\n" . urldecode($item[1]) . "\r\n"; - - } - - } - - foreach ($this->_postFiles as $name => $value) { - - if (is_array($value['name'])) { - - $varname = $name . ($this->_useBrackets? '[]': ''); - - } else { - - $varname = $name; - - $value['name'] = array($value['name']); - - } - - foreach ($value['name'] as $key => $filename) { - - $fp = fopen($filename, 'r'); - - $data = fread($fp, filesize($filename)); - - fclose($fp); - - $basename = basename($filename); - - $type = is_array($value['type'])? @$value['type'][$key]: $value['type']; - - - - $postdata .= '--' . $boundary . "\r\n"; - - $postdata .= 'Content-Disposition: form-data; name="' . $varname . '"; filename="' . $basename . '"'; - - $postdata .= "\r\nContent-Type: " . $type; - - $postdata .= "\r\n\r\n" . $data . "\r\n"; - - } - - } - - $postdata .= '--' . $boundary . "--\r\n"; - - } - - $request .= 'Content-Length: ' . strlen($postdata) . "\r\n\r\n"; - - $request .= $postdata; - - - - // Explicitly set request body - - } elseif (!empty($this->_body)) { - - - - $request .= 'Content-Length: ' . strlen($this->_body) . "\r\n\r\n"; - - $request .= $this->_body; - - } - - - - return $request; - - } - - - - /** - - * Helper function to change the (probably multidimensional) associative array - - * into the simple one. - - * - - * @param string name for item - - * @param mixed item's values - - * @return array array with the following items: array('item name', 'item value'); - - */ - - function _flattenArray($name, $values) - - { - - if (!is_array($values)) { - - return array(array($name, $values)); - - } else { - - $ret = array(); - - foreach ($values as $k => $v) { - - if (empty($name)) { - - $newName = $k; - - } elseif ($this->_useBrackets) { - - $newName = $name . '[' . $k . ']'; - - } else { - - $newName = $name; - - } - - $ret = array_merge($ret, $this->_flattenArray($newName, $v)); - - } - - return $ret; - - } - - } - - - - - - /** - - * Adds a Listener to the list of listeners that are notified of - - * the object's events - - * - - * @param object HTTP_Request_Listener instance to attach - - * @return boolean whether the listener was successfully attached - - * @access public - - */ - - function attach(&$listener) - - { - - ... [truncated message content] |
From: <jen...@us...> - 2008-01-09 09:26:22
|
Revision: 352 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=352&view=rev Author: jenslehmann Date: 2008-01-09 01:26:20 -0800 (Wed, 09 Jan 2008) Log Message: ----------- - fixed DBpedia Navigator HTML header - fixed clear session script - added images Modified Paths: -------------- trunk/src/dbpedia-navigator/clearsession.php trunk/src/dbpedia-navigator/default.css trunk/src/dbpedia-navigator/index.php Added Paths: ----------- trunk/src/dbpedia-navigator/images/ trunk/src/dbpedia-navigator/images/tab_back.png trunk/src/dbpedia-navigator/images/valid-css.png trunk/src/dbpedia-navigator/images/valid-xhtml10.png Modified: trunk/src/dbpedia-navigator/clearsession.php =================================================================== --- trunk/src/dbpedia-navigator/clearsession.php 2008-01-09 08:51:30 UTC (rev 351) +++ trunk/src/dbpedia-navigator/clearsession.php 2008-01-09 09:26:20 UTC (rev 352) @@ -7,6 +7,7 @@ require_once 'SparqlConnection.php'; require_once 'Settings.php'; $settings=new Settings(); -SparqlConnection::loadWSDLfiles($settings->wsdluri); -header("Location: http://" . $_SERVER["HTTP_HOST"] . "/Ajax-Test/index.php"); +SparqlConnection::loadWSDLfiles($settings->wsdluri); +$index_uri = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).'/index.php'; +header('Location: ' . $index_uri); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/default.css =================================================================== --- trunk/src/dbpedia-navigator/default.css 2008-01-09 08:51:30 UTC (rev 351) +++ trunk/src/dbpedia-navigator/default.css 2008-01-09 09:26:20 UTC (rev 352) @@ -1,8 +1,8 @@ /** - * default.css - * main Ontowiki style sheet + * Main DBpedia Navigator Style Sheet. + * * @author: Norman Heino - * @version: $Id: default.css 751 2007-02-14 19:20:17Z nheino $ + * @author: Jens Lehmann */ /* remove browser specific margins */ Added: trunk/src/dbpedia-navigator/images/tab_back.png =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/tab_back.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/valid-css.png =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/valid-css.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/valid-xhtml10.png =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/valid-xhtml10.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-09 08:51:30 UTC (rev 351) +++ trunk/src/dbpedia-navigator/index.php 2008-01-09 09:26:20 UTC (rev 352) @@ -11,13 +11,14 @@ $_SESSION['id']=$ids[0]; $_SESSION['ksID']=$ids[1]; -echo "<a href='clearsession.php'>start from scratch</a>"; - require("ajax.php"); echo '<?xml version="1.0" encoding="UTF-8"?>'; -?> -<html> +?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>DL Learner</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> @@ -58,7 +59,8 @@ } </script> </head> - <body> + <body> +<p><a href='clearsession.php'>start from scratch</a></p> <h3>DBPedia-Navigator-Test</h3> <div id="layer" style="display:none"><div id="layerContent" style="display:none"></div></div> <div id="wrapper"> @@ -134,7 +136,18 @@ <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> </div><!-- rightSidebar --> <div id="clear"></div> -</div> +</div> +<?php + +$uri = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; + +echo '<a href="http://validator.w3.org/check?uri='.$uri.'"'; +echo '><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>'."\n"; + +?> + </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. |
From: <jen...@us...> - 2008-01-09 09:37:12
|
Revision: 353 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=353&view=rev Author: jenslehmann Date: 2008-01-09 01:37:00 -0800 (Wed, 09 Jan 2008) Log Message: ----------- fixed all CSS and HTML validation errors on index page Modified Paths: -------------- trunk/src/dbpedia-navigator/default.css trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/default.css =================================================================== --- trunk/src/dbpedia-navigator/default.css 2008-01-09 09:26:20 UTC (rev 352) +++ trunk/src/dbpedia-navigator/default.css 2008-01-09 09:37:00 UTC (rev 353) @@ -156,10 +156,6 @@ display: block; } -/*.box select { - width: 250px; /* TODO remove absolute size */ -}*/ - .box input { width: auto; } Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-09 09:26:20 UTC (rev 352) +++ trunk/src/dbpedia-navigator/index.php 2008-01-09 09:37:00 UTC (rev 353) @@ -70,8 +70,9 @@ <div class="boxtitle">Search</div> <div class="boxcontent" id="search"> Search:<br/> - <input type="textfield" name="label" id="label"><br/> - <input type="button" value="Article" class="button" onclick="xajax_searchAndShowArticle(document.getElementById('label').value);return false;" /> <input type="button" value="Fulltext" class="button" onclick=""/> + <input type="text" name="label" id="label" /><br/> + <input type="button" value="Article" class="button" onclick="xajax_searchAndShowArticle(document.getElementById('label').value);return false;" /> + <input type="button" value="Fulltext" class="button" onclick=""/> </div> <!-- boxcontent --> </div> <!-- box --> @@ -99,7 +100,7 @@ </div> <!-- boxcontent --> </div> <!-- box --> -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> </div><!-- END leftSidebar --> <div id="content"> @@ -111,7 +112,7 @@ </div> <!-- boxcontent --> </div> <!-- box --> -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> </div><!-- content --> <div id="rightSidebar"> @@ -133,7 +134,7 @@ </div> <!-- boxcontent --> </div> <!-- box --> -<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> +<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> </div><!-- rightSidebar --> <div id="clear"></div> </div> @@ -141,10 +142,10 @@ $uri = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; -echo '<a href="http://validator.w3.org/check?uri='.$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 '<a href="http://jigsaw.w3.org/css-validator/validator?uri='.$uri.'"'; -echo '><img src="images/valid-css.png" alt="valid CSS" /></a>'."\n"; +echo '><img src="images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-01-09 13:42:43
|
Revision: 355 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=355&view=rev Author: jenslehmann Date: 2008-01-09 05:42:40 -0800 (Wed, 09 Jan 2008) Log Message: ----------- layout change from absolute to relative layout, added footer, added technology buttons Modified Paths: -------------- trunk/src/dbpedia-navigator/default.css trunk/src/dbpedia-navigator/index.php Added Paths: ----------- trunk/src/dbpedia-navigator/images/sw-owl-green.png trunk/src/dbpedia-navigator/images/sw-sparql-green.png Modified: trunk/src/dbpedia-navigator/default.css =================================================================== --- trunk/src/dbpedia-navigator/default.css 2008-01-09 11:25:03 UTC (rev 354) +++ trunk/src/dbpedia-navigator/default.css 2008-01-09 13:42:40 UTC (rev 355) @@ -10,11 +10,11 @@ margin: 0; padding: 0; } - + html { font: 80%/1.2 "Lucida Grande", Helvetica, Arial, sans-serif; } - + p { margin: 8px 0; } @@ -32,15 +32,21 @@ */ #wrapper { - position: relative; - max-width: 100%; - padding: 15px; + /*position: relative;*/ + max-width: 100%; + padding: 1%; +/* padding: 15px; */ /* margin: 15px;*/ } #content { - margin: 0 19em; - overflow: hidden; + /*margin: 0 19em; + overflow: hidden;*/ + /*width: 10%;*/ + width: 60%; + float: left; + margin-left: 3px; + margin-right: 3px; /* border-left: 1px solid #bbb; border-right: 1px solid #bbb; padding: 0 5px;*/ @@ -53,15 +59,20 @@ * (3) positioning the content div is more straightforward. */ #leftSidebar { - position: absolute; - width: 18em; + /* position: absolute; */ + width: 18%; + min-width: 150px; + float: left; } #rightSidebar { - position: absolute; - width: 18em; - top: 15px; - right: 15px; + /* position: absolute; */ + /*float: right;*/ + width: 18%; + min-width: 150px; + float: left; + /*top: 15px; + right: 15px;*/ } #clear { @@ -335,4 +346,17 @@ #label { margin-bottom: 0.1em; +} + +#article { + min-height: 500px; +} + +#credits { + border: none; +} + +#footer { + clear: both; + text-align: center; } \ No newline at end of file Added: trunk/src/dbpedia-navigator/images/sw-owl-green.png =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/sw-owl-green.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/sw-sparql-green.png =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/sw-sparql-green.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-09 11:25:03 UTC (rev 354) +++ trunk/src/dbpedia-navigator/index.php 2008-01-09 13:42:40 UTC (rev 355) @@ -62,12 +62,12 @@ </script> </head> <body> - -<p><a href='clearsession.php'>start from scratch</a></p> + <h1>DBPedia Navigator</h1> <div id="layer" style="display:none"> <div id="layerContent" style="display:none"></div> -</div> +</div> + <div id="wrapper"> <div id="leftSidebar"> @@ -105,16 +105,19 @@ </div> <!-- boxcontent --> </div> <!-- box --> - <div id="validation"> - <?php - $uri = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; + <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> at + the <a href="http:/aksw.org">AKSW</a> research group (University of Leipzig).</p> - 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 '<a href="http://jigsaw.w3.org/css-validator/validator?uri='.$uri.'"'; - echo '><img src="images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; - ?> - </div> + <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> + </div> + + </div><!-- END leftSidebar --> @@ -150,11 +153,24 @@ </div><!-- rightSidebar --> - <!-- <div id="clear"></div> --> - - + <!-- <div id="clear"></div> --> -</div><!-- wrapper --> +</div><!-- wrapper --> +<div id="footer"> + <p>Licensed under the GNU General Public License (GPL) 3 as part of the DL-Learner open source + project.<br />Copyright © Jens Lehmann 2007-2008 </p> + <div id="validation"> + <?php + $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 '<a href="http://jigsaw.w3.org/css-validator/validator?uri='.$uri.'"'; + echo '><img src="images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; + ?> + </div> + <p><a href='clearsession.php'>restart session and redownload WSDL file (for debugging)</a></p> +</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. |
From: <jen...@us...> - 2008-01-09 16:32:38
|
Revision: 356 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=356&view=rev Author: jenslehmann Date: 2008-01-09 08:32:14 -0800 (Wed, 09 Jan 2008) Log Message: ----------- - various userinterface improvements - started article display Modified Paths: -------------- trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/default.css trunk/src/dbpedia-navigator/index.php Added Paths: ----------- trunk/src/dbpedia-navigator/images/green-plus.png trunk/src/dbpedia-navigator/images/red-minus.png trunk/src/dbpedia-navigator/images/remove.png trunk/src/dbpedia-navigator/images/wikipedia_favicon.ico trunk/src/dbpedia-navigator/images/wikipedia_favicon.png Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-09 13:42:40 UTC (rev 355) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-09 16:32:14 UTC (rev 356) @@ -55,13 +55,40 @@ { $content.=substr($triples,7); } - else if (count($triples)==0) $content.="Article not found."; - else { - $content=""; - $content.="<img src=\"".$triples['http://xmlns.com/foaf/0.1/depiction']."\" alt=\"Picture of ".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."\" width=\"50\"/ style=\"float:left\">"; - $content.="<div>".urldecode($triples['http://dbpedia.org/property/abstract'])."</div>"; + else if (count($triples)==0) + $content.="Did not find an article with that name."; + else { + + // goal: display the data in a nice (DBpedia specific way), maybe similar to + // dbpedia.org/search + + $content=""; + // replace by label(?) + $subject_nice = str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1))); + + // display a picture if there is one + if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) + $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'].'" alt="Picture of '.$subject_nice.'" style="float:right; max-width:200px;" \>'; + + // add short description in english + $content.="<h3>Short Description</h3><p>".urldecode($triples['http://dbpedia.org/property/abstract'])."</p>"; + + // 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" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'].'">view Wikipedia article</a>, '; + $content .= '<a href="'.$subject.'">view DBpedia resource description</a></p>'; + + // display a list of classes + + // filter out uninteresting properties + // unset + + // display the remaining properties as list which can be used for further navigation + + $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); - $contentbuttons="<input type=\"button\" value=\"Positive\" class=\"button\" onclick=\"xajax_addPositive('".$subject."');return false;\" /> <input type=\"button\" value=\"Negative\" class=\"button\" onclick=\"xajax_addNegative('".$subject."');return false;\" />"; + // $contentbuttons="<input type=\"button\" value=\"Positive\" class=\"button\" onclick=\"xajax_addPositive('".$subject."');return false;\" /> <input type=\"button\" value=\"Negative\" class=\"button\" onclick=\"xajax_addNegative('".$subject."');return false;\" />"; + $contentbuttons='<img src="images/green-plus.png" alt="positive example" onclick="xajax_addPositive(\''.$subject.'\')" /> <img src="images/red-minus.png" alt="negative example" onclick="xajax_addNegative(\''.$subject.'\') />'; } //store article in session, to navigate between last 5 articles quickly @@ -218,5 +245,15 @@ $objResponse->call('xajax_getsubjects',$keyword); return $objResponse; } + +// helper function +function get_triple_table($triples) { + $table = '<table border="1"><tr><td>predicate</td><td>object</td></tr>'; + foreach($triples as $predicate=>$object) { + $table .= '<tr><td>'.$predicate.'</td><td>'.$object.'</td></tr>'; + } + $table .= '</table>'; + return $table; +} ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/default.css =================================================================== --- trunk/src/dbpedia-navigator/default.css 2008-01-09 13:42:40 UTC (rev 355) +++ trunk/src/dbpedia-navigator/default.css 2008-01-09 16:32:14 UTC (rev 356) @@ -356,6 +356,20 @@ border: none; } +#positivesboxtitle { + /*color: black;*/ + background-color: lightgreen; +} + +#negativesboxtitle { + /*color: black;*/ + background-color: #ee6666; +} + +#ArticleTitle { + font-size: 110%; +} + #footer { clear: both; text-align: center; Added: trunk/src/dbpedia-navigator/images/green-plus.png =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/green-plus.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/red-minus.png =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/red-minus.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/remove.png =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/remove.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/wikipedia_favicon.ico =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/wikipedia_favicon.ico ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/wikipedia_favicon.png =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/wikipedia_favicon.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-09 13:42:40 UTC (rev 355) +++ trunk/src/dbpedia-navigator/index.php 2008-01-09 16:32:14 UTC (rev 356) @@ -63,7 +63,7 @@ </head> <body> -<h1>DBPedia Navigator</h1> +<h1>DBpedia Navigator</h1> <div id="layer" style="display:none"> <div id="layerContent" style="display:none"></div> </div> @@ -74,10 +74,12 @@ <div class="box"> <div class="boxtitle">Search DBpedia</div> <div class="boxcontent" id="search"> - <!-- Search:<br/> --> + <!-- Search:<br/> --> + <form onSubmit="xajax_searchAndShowArticle(document.getElementById('label').value);return false;"> <input type="text" name="label" id="label" /><br/> - <input type="button" value="Search" class="button" onclick="xajax_searchAndShowArticle(document.getElementById('label').value);return false;" /> - <!-- <input type="button" value="Fulltext" class="button" onclick=""/> --> + <input type="button" value="Search" class="button" onclick="xajax_searchAndShowArticle(document.getElementById('label').value);return false;" /> + <!-- <input type="button" value="Fulltext" class="button" onclick=""/> --> + </form> </div> <!-- boxcontent --> </div> <!-- box --> @@ -123,9 +125,14 @@ <div id="content"> <div class="box"> - <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left" id="ArticleTitle">Article</td><td class="right"><span id="contentbuttons"></span></td></tr></table></div> + <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left" id="ArticleTitle">Welcome</td><td class="right"><span id="contentbuttons"></span></td></tr></table></div> <div class="boxcontent" id="article"> - <div id="articlecontent" style="display:block"></div> + <div id="articlecontent" style="display:block"> + <br /><br /> + Welcome to the DBpedia Navigator interface! DBpedia Navigator allows you to search DBpedia + and uses the background knowledge in DBpedia to suggest possible interesting navigation + links. + </div> <div id="loadingArticle" style="display:none"><img src="ajax-loader.gif" alt="Loading..."/></div> </div> <!-- boxcontent --> </div> <!-- box --> @@ -134,19 +141,19 @@ <div id="rightSidebar"> <div class="box"> - <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left">Positives</td><td class="right"><input type="button" value="Clear" class="button" onclick="xajax_clearPositives();return false;" /></td></tr></table></div> + <div class="boxtitlewithbutton" id="positivesboxtitle">search relevant <input type="button" value="Clear" class="button" onclick="xajax_clearPositives();return false;" /></div> <div class="boxcontent" id="Positives"> </div> <!-- boxcontent --> </div> <!-- box --> <div class="box"> - <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left">Negatives</td><td class="right"><input type="button" value="Clear" class="button" onclick="xajax_clearNegatives();return false;" /></td></tr></table></div> + <div class="boxtitlewithbutton" id="negativesboxtitle">not relevant <input type="button" value="Clear" class="button" onclick="xajax_clearNegatives();return false;" /></div> <div class="boxcontent" id="Negatives"> </div> <!-- boxcontent --> </div> <!-- box --> <div class="box"> - <div class="boxtitle">Last Articles</div> + <div class="boxtitle">Articles Last Viewed</div> <div class="boxcontent" id="lastarticles"> </div> <!-- boxcontent --> </div> <!-- box --> @@ -169,8 +176,19 @@ echo '><img src="images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; ?> </div> - <p><a href='clearsession.php'>restart session and redownload WSDL file (for debugging)</a></p> -</div> + <p><a href='clearsession.php'>restart session and redownload WSDL file (for debugging)</a></p> + <p> +ToDo: +<ul> + <li>get learning process working (with new SPARQL component)</li> + <li>get local DBpedia SPARQL endpoint working</li> + <li>many queries work correctly on the server, but yield to response in the interface (seems to be rather random)</li> + <li>fix sometimes occurring PHP errors and warnings</li> +</ul> +</p> +</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. |
From: <jen...@us...> - 2008-01-11 11:45:23
|
Revision: 366 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=366&view=rev Author: jenslehmann Date: 2008-01-11 03:45:18 -0800 (Fri, 11 Jan 2008) Log Message: ----------- improved article display (intermediate commit due to dead DBpedia SPARQL endpoint) Modified Paths: -------------- trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-11 09:23:49 UTC (rev 365) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-11 11:45:18 UTC (rev 366) @@ -50,14 +50,15 @@ $settings=new Settings(); $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); $triples=$sc->getTriples($settings->sparqlttl,$subject); - $content=""; + $content="";$contentbuttons=""; if (count($triples)==1) - { + { + // ToDo: find out why this was treated in a special way by Sebastian $content.=substr($triples,7); } - else if (count($triples)==0) + else if (count($triples)==0) { $content.="Did not find an article with that name."; - else { + } else { // goal: display the data in a nice (DBpedia specific way), maybe similar to // dbpedia.org/search @@ -77,12 +78,16 @@ if(isset($triples['http://xmlns.com/foaf/0.1/page'])) $content .= '<p><img src="images/wikipedia_favicon.png" alt"Wikipedia" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0].'">view Wikipedia article</a>, '; $content .= '<a href="'.$subject.'">view DBpedia resource description</a></p>'; - + // display a list of classes + if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) + $content .= '<p>Classes: '.array_to_comma($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; // filter out uninteresting properties - // unset - + 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']); + // display the remaining properties as list which can be used for further navigation $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); @@ -249,7 +254,10 @@ return $objResponse; } -// helper function +/////////////////////// +// Helper Functions. // +/////////////////////// + function get_triple_table($triples) { $table = '<table border="1"><tr><td>predicate</td><td>object</td></tr>'; @@ -264,5 +272,13 @@ $table .= '</table>'; return $table; } + +function array_to_comma_separated_list($ar) { + $string = $ar[0]; + for($i=1; $i<count($ar); $i++) { + $string .= $ar[$i] . ', '; + } + return $string; +} ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-11 09:23:49 UTC (rev 365) +++ trunk/src/dbpedia-navigator/index.php 2008-01-11 11:45:18 UTC (rev 366) @@ -118,8 +118,8 @@ <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> at - the <a href="http:/aksw.org">AKSW</a> research group (University of Leipzig).</p> + ... 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://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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-01-13 10:22:21
|
Revision: 368 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=368&view=rev Author: jenslehmann Date: 2008-01-13 02:22:16 -0800 (Sun, 13 Jan 2008) Log Message: ----------- extended ToDo list and minor improvements Modified Paths: -------------- trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/default.css trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-11 17:01:00 UTC (rev 367) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-13 10:22:16 UTC (rev 368) @@ -83,10 +83,19 @@ if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; - // filter out uninteresting properties + if(isset($triples['http://dbpedia.org/property/reference'])) { + $content .= '<p>references: <ul>'; + foreach($triples['http://dbpedia.org/property/reference'] as $reference) + $content .= '<li><a href="'.$reference.'">'.$reference.'</a></li>'; + $content .= '</ul></p>'; + } + + // filter out uninteresting properties and properties which + // have already been displayed 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://dbpedia.org/property/abstract']); + unset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']); // display the remaining properties as list which can be used for further navigation Modified: trunk/src/dbpedia-navigator/default.css =================================================================== --- trunk/src/dbpedia-navigator/default.css 2008-01-11 17:01:00 UTC (rev 367) +++ trunk/src/dbpedia-navigator/default.css 2008-01-13 10:22:16 UTC (rev 368) @@ -374,4 +374,9 @@ #footer { clear: both; text-align: center; +} + +#todo { + padding: 15px; + margin: 10px; } \ No newline at end of file Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-11 17:01:00 UTC (rev 367) +++ trunk/src/dbpedia-navigator/index.php 2008-01-13 10:22:16 UTC (rev 368) @@ -182,19 +182,64 @@ echo '><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> - <p> -ToDo: -<ul> - <li>get learning process working (with new SPARQL component)</li> - <li>get local DBpedia SPARQL endpoint working</li> - <li>many queries work correctly on the server, but yield to response in the interface (seems to be rather random)</li> - <li>fix sometimes occurring PHP errors and warnings</li> - <li>would be interesting to somehow view the Wikipedia article (without the left navigation part, + <p><a href='rebuild.php'>rebuild [restart session and redownload WSDL file (for debugging)]</a></p> +</div> + +<div id="todo"> +<b>ToDo:</b> +<ul style="float:left"> + <li>Get learning process working (with new SPARQL component).</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>Currently there are three SPARQL query methods: for labels, subjects, and article. These should + probably be replaced by a single web service method which allows to execute a SPARQL query. This will + greatly simplify the DL-Learner code while making the PHP code only slightly more complex. Such a method + also makes much more sense as a web service method, because other applications will need different SPARQL + queries. Similar to the learn method, there should be a threaded and a non-threaded version of the SPARQL + query method. This allows not to have the overhead of creating a separate thread for simple SPARQL queries + (especially since we assume that the DBpedia SPARQL endpoint is local).</li> + <li>Automatically learn concepts whenever an example has been added (and there is at least one + positive example present).</li> + <li>Show n (for example 5) instead of 1 best concept.</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>Move the "Learned Concepts" box above the main box in the center.</li> + <li>Remove the "Subjects from Concept" box and instead change the learned concepts to links (clicking + on a link shows instances of the concept).</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>Display "server call" in progress (or "n server calls in progress") in the top right corner + of the screen whenever AJAX queries are executed.</li> + <li>Allow to disable caching functionality (in Settings.php).</li> + <li>Fix the rebuild.php script such that PHP replaces the cached WSDL file by the new one.</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>Improve search functionality [we will probably get feedback from Georgi in February].</li> + <li>[maybe] Display a tag cloud similar to <a href="http://dbpedia.org/search/">DBpedia search</a>.</li> + <li>Get a nice DBpedia Navigator logo (preferrably in SVG format) [currently in contact with Matt, but not + sure he has time to help].</li> + <li>[maybe] Instead of only allowing a search as entry point to the application, also display + a navigatable class tree.</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> + <li>[maybe] Would be interesting to somehow view the Wikipedia article (without the left navigation part, tabs etc.) as an overlay, because the Wikipedia article will almost always be a human-friendlier - description of an object compared to the extracted one</li> + description of an object compared to the extracted one.</li> </ul> -</p> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-15 09:29:21
|
Revision: 371 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=371&view=rev Author: sknappe Date: 2008-01-15 01:29:18 -0800 (Tue, 15 Jan 2008) Log Message: ----------- Articles are now automatically added to relevant interests but can be swapped to unrelevant or removed changed the way xajax is used to get better performance Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Added Paths: ----------- trunk/src/dbpedia-navigator/images/minus.jpg trunk/src/dbpedia-navigator/images/plus.jpg Modified: trunk/src/dbpedia-navigator/ajax.php =================================================================== --- trunk/src/dbpedia-navigator/ajax.php 2008-01-14 11:54:55 UTC (rev 370) +++ trunk/src/dbpedia-navigator/ajax.php 2008-01-15 09:29:18 UTC (rev 371) @@ -3,15 +3,18 @@ $sid = session_id(); $xajax = new xajax("ajaxfunctions.php?sid=$sid"); -$xajax->register(XAJAX_FUNCTION, 'getsubjects', array( +$xajax->configureMany(array('debug'=>true)); +$xajax->register(XAJAX_FUNCTION, 'showSubjects', array( 'onResponseDelay' => 'showLoadingSubjects', 'beforeResponseProcessing' => 'hideLoadingSubjects' )); $xajax->registerFunction('getarticle'); -$xajax->registerFunction('addPositive'); -$xajax->registerFunction('addNegative'); +$xajax->registerFunction('toPositive'); +$xajax->registerFunction('toNegative'); $xajax->registerFunction('clearPositives'); $xajax->registerFunction('clearNegatives'); +$xajax->registerFunction('showInterests'); +$xajax->registerFunction('getAndShowArticle'); $xajax->register(XAJAX_FUNCTION, 'learnConcept', array( 'onResponseDelay' => 'showLoadingConcept', 'beforeResponseProcessing' => 'hideLoadingConcept' @@ -20,5 +23,9 @@ 'onResponseDelay' => 'showLoadingConceptSubjects', 'beforeResponseProcessing' => 'hideLoadingConceptSubjects' )); -$xajax->registerFunction('searchAndShowArticle'); +$xajax->registerFunction('getAndShowSubjects'); +$xajax->registerFunction('getsubjects'); +$xajax->registerFunction('showArticle'); +$xajax->registerFunction('removePosInterest'); +$xajax->registerFunction('removeNegInterest'); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-14 11:54:55 UTC (rev 370) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-15 09:29:18 UTC (rev 371) @@ -16,24 +16,37 @@ $content=""; $subjects=$sc->getSubjects($settings->sparqlttl,$label); + if (count($subjects)==1) { if (strpos($subjects,"[Error]")===0) $content.=substr($subjects,7); - else $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subjects."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; + else $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".str_replace("_"," ",substr (strrchr ($subjects, "/"), 1))."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; } else if (count($subjects)==0) $content.="No search result found in time."; else{ foreach ($subjects as $subject) { - $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subject."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; + $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".str_replace("_"," ",substr (strrchr ($subject, "/"), 1))."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; } } + $_SESSION['subjects']=$content; + $objResponse = new xajaxResponse(); - $objResponse->assign("searchcontent", "innerHTML", $content); return $objResponse; } +function showSubjects() +{ + while (!isset($_SESSION['subjects'])){ + sleep(0.5); + } + $objResponse = new xajaxResponse(); + $objResponse->assign("searchcontent", "innerHTML", $_SESSION['subjects']); + unset($_SESSION['subjects']); + return $objResponse; +} + function getarticle($subject,$fromCache) { if (isset($_SESSION['articles'])) @@ -50,7 +63,7 @@ $settings=new Settings(); $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); $triples=$sc->getTriples($settings->sparqlttl,$subject); - $content="";$contentbuttons=""; + $content=""; if (count($triples)==1) { // ToDo: find out why this was treated in a special way by Sebastian @@ -99,14 +112,11 @@ // display the remaining properties as list which can be used for further navigation - $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); - - // $contentbuttons="<input type=\"button\" value=\"Positive\" class=\"button\" onclick=\"xajax_addPositive('".$subject."');return false;\" /> <input type=\"button\" value=\"Negative\" class=\"button\" onclick=\"xajax_addNegative('".$subject."');return false;\" />"; - $contentbuttons='<img src="images/green-plus.png" alt="positive example" onclick="xajax_addPositive(\''.$subject.'\')" /> <img src="images/red-minus.png" alt="negative example" onclick="xajax_addNegative(\''.$subject.'\') />'; + $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); } //store article in session, to navigate between last 5 articles quickly - $contentArray=array('content' => $content,'contentbuttons' => $contentbuttons, 'subject' => $subject); + $contentArray=array('content' => $content,'subject' => $subject); if (!isset($_SESSION['nextArticle'])){ $_SESSION['nextArticle']=0; $_SESSION['articles']=array(); @@ -118,60 +128,101 @@ } else { $content=$_SESSION['articles'][$fromCache]['content']; - $contentbuttons=$_SESSION['articles'][$fromCache]['contentbuttons']; $subject=$_SESSION['articles'][$fromCache]['subject']; } $lastArticles=""; foreach ($_SESSION['articles'] as $key => $value) { - $lastArticles.="<a href=\"\" onclick=\"xajax_getarticle('',".$key.");return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($value['subject'], "/"), 1)))."</a><br/>"; + $lastArticles.="<a href=\"\" onclick=\"xajax_getAndShowArticle('',".$key.");return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($value['subject'], "/"), 1)))."</a><br/>"; } + //Add Positives to Session + if (!isset($_SESSION['positive'])){ + $array=array($subject => $subject); + $_SESSION['positive']=$array; + } + else{ + $array=$_SESSION['positive']; + $array[$subject]=$subject; + $_SESSION['positive']=$array; + } + + //build Subject and Searchresults + $searchResult="<a href=\"\" onclick=\"xajax_getAndShowArticle('".$subject."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; + $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".str_replace("_"," ",substr (strrchr ($subject, "/"), 1))."');return false;\">Show more Results</a>"; + + //put whole site content into session + $_SESSION['artContent']=$content; + $_SESSION['artTitle']=str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1))); + $_SESSION['artLast']=$lastArticles; + $_SESSION['artSubjects']=$searchResult; + //build the response $objResponse = new xajaxResponse(); - $objResponse->assign("articlecontent", "innerHTML", $content); - $objResponse->assign("contentbuttons", "innerHTML", $contentbuttons); - $objResponse->assign("ArticleTitle","innerHTML",str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))); - $objResponse->assign("lastarticles","innerHTML",$lastArticles); return $objResponse; } -function addPositive($subject) +function showArticle() { + while (!isset($_SESSION['artLast'])){ + sleep(0.5); + } + $objResponse = new xajaxResponse(); + $objResponse->assign("articlecontent", "innerHTML", $_SESSION['artContent']); + $objResponse->assign("ArticleTitle","innerHTML",$_SESSION['artTitle']); + $objResponse->assign("lastarticles","innerHTML",$_SESSION['artLast']); + $objResponse->assign("searchcontent", "innerHTML", $_SESSION['artSubjects']); + unset($_SESSION['artContent']); + unset($_SESSION['artTitle']); + unset($_SESSION['artLast']); + unset($_SESSION['artSubjects']); + + $objResponse->call('xajax_showInterests'); + return $objResponse; +} + +function getAndShowArticle($subject,$fromCache) +{ + $objResponse = new xajaxResponse(); + $objResponse->call('xajax_getarticle',"http://dbpedia.org/resource/".str_replace(" ","_",$subject),$fromCache); + $objResponse->call('xajax_showArticle'); + return $objResponse; +} + +function toPositive($subject) +{ + unset($_SESSION['negative'][$subject]); if (!isset($_SESSION['positive'])){ - $array=array($subject); + $array=array($subject => $subject); $_SESSION['positive']=$array; } else{ $array=$_SESSION['positive']; - $array[]=$subject; + $array[$subject]=$subject; $_SESSION['positive']=$array; } - $content=str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."<br/>"; - $objResponse = new xajaxResponse(); - $objResponse->append("Positives", "innerHTML", $content); + $objResponse->call('xajax_showInterests'); return $objResponse; } -function addNegative($subject) +function toNegative($subject) { + unset($_SESSION['positive'][$subject]); if (!isset($_SESSION['negative'])){ - $array=array($subject); + $array=array($subject => $subject); $_SESSION['negative']=$array; } else{ $array=$_SESSION['negative']; - $array[]=$subject; + $array[$subject]=$subject; $_SESSION['negative']=$array; } - $content=str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."<br/>"; - $objResponse = new xajaxResponse(); - $objResponse->append("Negatives", "innerHTML", $content); + $objResponse->call('xajax_showInterests'); return $objResponse; } @@ -193,6 +244,42 @@ return $objResponse; } +function showInterests() +{ + //add Positives and Negatives to Interests + $posInterests=""; + if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ + $posInterests=$posInterests.str_replace("_"," ",urldecode(substr (strrchr ($pos, "/"), 1)))." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; + } + $negInterests=""; + if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ + $negInterests=$negInterests.str_replace("_"," ",urldecode(substr (strrchr ($neg, "/"), 1)))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$pos."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; + } + + $objResponse=new xajaxResponse(); + $objResponse->assign('Positives','innerHTML',$posInterests); + $objResponse->assign('Negatives','innerHTML',$negInterests); + return $objResponse; +} + +function removePosInterest($subject) +{ + unset($_SESSION['positive'][$subject]); + + $objResponse = new xajaxResponse(); + $objResponse->call('xajax_showInterests'); + return $objResponse; +} + +function removeNegInterest($subject) +{ + unset($_SESSION['negative'][$subject]); + + $objResponse = new xajaxResponse(); + $objResponse->call('xajax_showInterests'); + return $objResponse; +} + function learnConcept() { if (isset($_SESSION['positive'])) @@ -247,19 +334,11 @@ return $objResponse; } -function searchAndShowArticle($keyword) +function getAndShowSubjects($keyword) { - require_once("Settings.php"); - require_once("DLLearnerConnection.php"); - $settings=new Settings(); - - $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); - - $content=""; - $objResponse = new xajaxResponse(); - $objResponse->call('xajax_getarticle', "http://dbpedia.org/resource/".str_replace(" ","_",$keyword),-1); $objResponse->call('xajax_getsubjects',$keyword); + $objResponse->call('xajax_showSubjects'); return $objResponse; } Added: trunk/src/dbpedia-navigator/images/minus.jpg =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/minus.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/plus.jpg =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/plus.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-14 11:54:55 UTC (rev 370) +++ trunk/src/dbpedia-navigator/index.php 2008-01-15 09:29:18 UTC (rev 371) @@ -81,9 +81,9 @@ <div class="boxtitle">Search DBpedia</div> <div class="boxcontent" id="search"> <!-- Search:<br/> --> - <form onSubmit="xajax_searchAndShowArticle(document.getElementById('label').value);return false;"> + <form onSubmit="xajax_getAndShowArticle(document.getElementById('label').value,-1);return false;"> <input type="text" name="label" id="label" /><br/> - <input type="button" value="Search" class="button" onclick="xajax_searchAndShowArticle(document.getElementById('label').value);return false;" /> + <input type="button" value="Search" class="button" onclick="xajax_getAndShowArticle(document.getElementById('label').value,-1);return false;" /> <!-- <input type="button" value="Fulltext" class="button" onclick=""/> --> </form> </div> <!-- boxcontent --> @@ -131,7 +131,7 @@ <div id="content"> <div class="box"> - <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left" id="ArticleTitle">Welcome</td><td class="right"><span id="contentbuttons"></span></td></tr></table></div> + <div class="boxtitle" id="ArticleTitle">Welcome</div> <div class="boxcontent" id="article"> <div id="articlecontent" style="display:block"> <br /><br /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-15 13:31:16
|
Revision: 373 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=373&view=rev Author: sknappe Date: 2008-01-15 05:31:14 -0800 (Tue, 15 Jan 2008) Log Message: ----------- when nothing is found, now automatically a search is started Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-15 10:21:31 UTC (rev 372) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-15 13:31:14 UTC (rev 373) @@ -113,8 +113,8 @@ if (!$this->client->isThreadRunning($this->id,$this->ksID,"triples")) { $object=$this->client->getFromSparql($this->id,$this->ksID,"triples"); - if (count($object)==0) return array(); - $array=$object->item; + @$array=$object->item; + if ($array==NULL) return array(); if (count($array)==1) return $array; $ret=array(); foreach ($array as $element) @@ -260,4 +260,12 @@ } } -?> \ No newline at end of file + +/*require_once("Settings.php"); +require_once("DLLearnerConnection.php"); +$settings=new Settings(); +$sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri); +$ids=$sc->getIDs(); +$sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$ids[0],$ids[1]); +$triples=$sc->getTriples($settings->sparqlttl,"dog");*/ +?> Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-15 10:21:31 UTC (rev 372) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-15 13:31:14 UTC (rev 373) @@ -20,13 +20,13 @@ if (count($subjects)==1) { if (strpos($subjects,"[Error]")===0) $content.=substr($subjects,7); - else $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".str_replace("_"," ",substr (strrchr ($subjects, "/"), 1))."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; + else $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".str_replace("_"," ",substr (strrchr ($subjects, "/"), 1))."',-2);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; } else if (count($subjects)==0) $content.="No search result found in time."; else{ foreach ($subjects as $subject) { - $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".str_replace("_"," ",substr (strrchr ($subject, "/"), 1))."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; + $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".str_replace("_"," ",substr (strrchr ($subject, "/"), 1))."',-2);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; } } @@ -57,20 +57,22 @@ break; } } - if ($fromCache==-1) { + if ($fromCache<0) { require_once("Settings.php"); require_once("DLLearnerConnection.php"); $settings=new Settings(); $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); $triples=$sc->getTriples($settings->sparqlttl,$subject); $content=""; + $searchResult=""; + $objResponse = new xajaxResponse(); if (count($triples)==1) { // ToDo: find out why this was treated in a special way by Sebastian $content.=substr($triples,7); } else if (count($triples)==0) { - $content.="Did not find an article with that name."; + $content.="Did not find an article with that name. Similar Articles are shown under 'Search Results'."; } else { // goal: display the data in a nice (DBpedia specific way), maybe similar to @@ -112,19 +114,34 @@ // display the remaining properties as list which can be used for further navigation - $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); + $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); + + //store article in session, to navigate between last 5 articles quickly + $contentArray=array('content' => $content,'subject' => $subject); + if (!isset($_SESSION['nextArticle'])){ + $_SESSION['nextArticle']=0; + $_SESSION['articles']=array(); + } + if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; + $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; + $_SESSION['currentArticle']=$_SESSION['nextArticle']; + $_SESSION['nextArticle']++; + + //Add Positives to Session + if (!isset($_SESSION['positive'])){ + $array=array($subject => $subject); + $_SESSION['positive']=$array; + } + else{ + $array=$_SESSION['positive']; + $array[$subject]=$subject; + $_SESSION['positive']=$array; + } + + //build Subject and Searchresults + if ($fromCache==-1) + $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".str_replace("_"," ",substr (strrchr ($subject, "/"), 1))."');return false;\">Show more Results</a>"; } - - //store article in session, to navigate between last 5 articles quickly - $contentArray=array('content' => $content,'subject' => $subject); - if (!isset($_SESSION['nextArticle'])){ - $_SESSION['nextArticle']=0; - $_SESSION['articles']=array(); - } - if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; - $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; - $_SESSION['currentArticle']=$_SESSION['nextArticle']; - $_SESSION['nextArticle']++; } else { $content=$_SESSION['articles'][$fromCache]['content']; @@ -132,47 +149,33 @@ } $lastArticles=""; - foreach ($_SESSION['articles'] as $key => $value) - { - $lastArticles.="<a href=\"\" onclick=\"xajax_getAndShowArticle('',".$key.");return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($value['subject'], "/"), 1)))."</a><br/>"; - } + if (isset($_SESSION['articles'])) + foreach ($_SESSION['articles'] as $key => $value) + { + $lastArticles.="<a href=\"\" onclick=\"xajax_getAndShowArticle('',".$key.");return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($value['subject'], "/"), 1)))."</a><br/>"; + } - //Add Positives to Session - if (!isset($_SESSION['positive'])){ - $array=array($subject => $subject); - $_SESSION['positive']=$array; - } - else{ - $array=$_SESSION['positive']; - $array[$subject]=$subject; - $_SESSION['positive']=$array; - } - - //build Subject and Searchresults - $searchResult="<a href=\"\" onclick=\"xajax_getAndShowArticle('".$subject."',-1);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; - $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".str_replace("_"," ",substr (strrchr ($subject, "/"), 1))."');return false;\">Show more Results</a>"; - //put whole site content into session $_SESSION['artContent']=$content; $_SESSION['artTitle']=str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1))); $_SESSION['artLast']=$lastArticles; $_SESSION['artSubjects']=$searchResult; - //build the response - $objResponse = new xajaxResponse(); return $objResponse; } function showArticle() { - while (!isset($_SESSION['artLast'])){ + while (!isset($_SESSION['artSubjects'])){ sleep(0.5); } $objResponse = new xajaxResponse(); $objResponse->assign("articlecontent", "innerHTML", $_SESSION['artContent']); $objResponse->assign("ArticleTitle","innerHTML",$_SESSION['artTitle']); $objResponse->assign("lastarticles","innerHTML",$_SESSION['artLast']); - $objResponse->assign("searchcontent", "innerHTML", $_SESSION['artSubjects']); + if ($_SESSION['artSubjects']!="") $objResponse->assign("searchcontent", "innerHTML", $_SESSION['artSubjects']); + if (strpos($_SESSION['artContent'],"Did not find an article with that name")===0) + $objResponse->call('xajax_getAndShowSubjects',$_SESSION['artTitle']); unset($_SESSION['artContent']); unset($_SESSION['artTitle']); unset($_SESSION['artLast']); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-15 15:24:22
|
Revision: 374 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=374&view=rev Author: sknappe Date: 2008-01-15 07:24:16 -0800 (Tue, 15 Jan 2008) Log Message: ----------- fixed bug, that learning wasn't possible Modified Paths: -------------- trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-15 13:31:14 UTC (rev 373) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-15 15:24:16 UTC (rev 374) @@ -287,15 +287,22 @@ { if (isset($_SESSION['positive'])) { + $posArray=array(); + foreach ($_SESSION['positive'] as $pos) + $posArray[]=$pos; + $negArray=array(); + if (isset($_SESSION['negative'])) + foreach ($_SESSION['negative'] as $neg) + $negArray[]=$neg; + require_once("Settings.php"); require_once("DLLearnerConnection.php"); $settings=new Settings(); $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); - if(isset($_SESSION['negative'])) - $concept=$sc->getConceptFromExamples($settings->sparqlttl,$_SESSION['positive'],$_SESSION['negative']); - else - $concept=$sc->getConceptFromExamples($settings->sparqlttl,$_SESSION['positive'], array()); + + $concept=$sc->getConceptFromExamples($settings->sparqlttl,$posArray,$negArray); + $_SESSION['lastLearnedConcept']=$concept; if (strlen(substr (strrchr ($concept, "/"), 1))>0) $concept=urldecode(substr (strrchr ($concept, "/"), 1)); } Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-15 13:31:14 UTC (rev 373) +++ trunk/src/dbpedia-navigator/index.php 2008-01-15 15:24:16 UTC (rev 374) @@ -238,7 +238,10 @@ <li>[if possible] Find an easy way to validate HTML/JS in AJAX applications.</li> <li>[maybe] Would be interesting to somehow view the Wikipedia article (without the left navigation part, tabs etc.) as an overlay, because the Wikipedia article will almost always be a human-friendlier - description of an object compared to the extracted one.</li> + description of an object compared to the extracted one.</li> + <li>Handle redirect for example if you look for 'Deutschland'</li> + <li>Ich habe mir gestern deswegen mal angeschaut welche fertigen SPARQL-APIs es gibt. Eine der verbreitesten und deshalb auch aktiven Projekt ist Jena. F\xFCr uns relevant ist das ARQ-Teilprojekt: http://jena.sourceforge.net/ARQ/. + </li> </ul> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-16 12:42:49
|
Revision: 380 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=380&view=rev Author: sknappe Date: 2008-01-16 04:42:45 -0800 (Wed, 16 Jan 2008) Log Message: ----------- some bugfixes and added class for finding natural terms for concepts Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Added Paths: ----------- trunk/src/dbpedia-navigator/NaturalConcepts.php trunk/src/dbpedia-navigator/learningExamples.txt Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-16 02:39:20 UTC (rev 379) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-16 12:42:45 UTC (rev 380) @@ -45,7 +45,7 @@ function getConceptFromExamples($ttl,$posExamples,$negExamples) { - $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth", 2); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "predList", array()); // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "objList", array()); Added: trunk/src/dbpedia-navigator/NaturalConcepts.php =================================================================== --- trunk/src/dbpedia-navigator/NaturalConcepts.php (rev 0) +++ trunk/src/dbpedia-navigator/NaturalConcepts.php 2008-01-16 12:42:45 UTC (rev 380) @@ -0,0 +1,31 @@ +<?php + +class NaturalConcepts +{ + private $concept; + + function NaturalConcepts($conc){ + $this->concept=$conc; + } + + function getNaturalConcept(){ + $identifiedConcepts=$this->identifyConcepts(); + return $identifiedConcepts; + } + + function identifyConcepts() + { + $ret=array(); + while (true){ + $nextpos=strpos("http",$this->concept); + $nextend=strpos() + } + return $ret; + } +} + +$conc="EXISTS http://dbpedia.org/property/website AND http://dbpedia.org/resource/Berlin"; +$nc=new NaturalConcepts($conc); +$ic=$nc->getNaturalConcept(); +print_r($ic); +?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-16 02:39:20 UTC (rev 379) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-16 12:42:45 UTC (rev 380) @@ -256,7 +256,7 @@ } $negInterests=""; if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ - $negInterests=$negInterests.str_replace("_"," ",urldecode(substr (strrchr ($neg, "/"), 1)))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$pos."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; + $negInterests=$negInterests.str_replace("_"," ",urldecode(substr (strrchr ($neg, "/"), 1)))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; } $objResponse=new xajaxResponse(); Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-16 02:39:20 UTC (rev 379) +++ trunk/src/dbpedia-navigator/index.php 2008-01-16 12:42:45 UTC (rev 380) @@ -188,7 +188,8 @@ <div id="todo"> <b>ToDo:</b> <ul style="float:left"> - <li>Get learning process working (with new SPARQL component).</li> + <li>Get learning component fast.</li> + <li>Learning as a Thread.</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> Added: trunk/src/dbpedia-navigator/learningExamples.txt =================================================================== --- trunk/src/dbpedia-navigator/learningExamples.txt (rev 0) +++ trunk/src/dbpedia-navigator/learningExamples.txt 2008-01-16 12:42:45 UTC (rev 380) @@ -0,0 +1,37 @@ ++Pythagoras +-Plato +-------- +http://dbpedia.org/class/yago/ReligiousPerson109628382 + ++Angela Merkel +-Joschka Fischer +---------------- +http://dbpedia.org/class/yago/Adult109605289 (length 1, depth 1) +http://dbpedia.org/class/yago/Communicator109610660 (length 1, depth 1) +http://dbpedia.org/class/yago/Female109619168 (length 1, depth 1) +http://dbpedia.org/class/yago/Scientist110560637 (length 1, depth 1) + ++Germany +-Russia +-Mongolia +--------------- +http://dbpedia.org/class/yago/PhysicalEntity100001930 + ++Tiger +-Elefant +--------------- +http://dbpedia.org/class/yago/CausalAgent100007347 + ++Mother ++Father +-Child +----------------- +http://dbpedia.org/class/yago/Adult109605289 + ++Leipzig ++Dresden +-Berlin +-Hamburg +---------------- +EXISTS http://dbpedia.org/property/wappen.TOP +EXISTS http://dbpedia.org/property/wordnet_type.TOP \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-24 10:13:18
|
Revision: 425 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=425&view=rev Author: sknappe Date: 2008-01-24 02:13:14 -0800 (Thu, 24 Jan 2008) Log Message: ----------- now partly works with the new sparql component of the dl-learner Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/NaturalConcepts.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-24 09:31:09 UTC (rev 424) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-24 10:13:14 UTC (rev 425) @@ -9,8 +9,8 @@ class DLLearnerConnection { private $DBPediaUrl; - private $DLLearnerUri; - + private $ttl; + private $lang; // private $client; @@ -20,11 +20,14 @@ // ID of the DBpedia knowledge source private $ksID; - function DLLearnerConnection($DBPediaUrl,$DLLearnerUri,$id=0,$ksID=0) + function DLLearnerConnection($id=0,$ksID=0) { ini_set('default_socket_timeout',200); - $this->DBPediaUrl=$DBPediaUrl; - $this->DLLearnerUri=$DLLearnerUri; + require_once("Settings.php"); + $settings=new Settings(); + $this->ttl=$settings->sparqlttl; + $this->lang=$settings->language; + $this->DBPediaUrl=$settings->dbpediauri; $this->client=new SoapClient("main.wsdl"); $this->id=$id; $this->ksID=$ksID; @@ -35,12 +38,6 @@ $id=$this->client->generateID(); $ksID=$this->client->addKnowledgeSource($id,"sparql",$this->DBPediaUrl); return array(0 => $id, 1 => $ksID); - } - - function test() - { - $object=$this->client->test($this->id,$this->ksID); - return $object->item; } function getConceptFromExamples($ttl,$posExamples,$negExamples) @@ -97,95 +94,70 @@ } return $concept; } + + function getTriples($label) + { + $query="SELECT ?pred ?obj ". + "WHERE {<http://dbpedia.org/resource/".str_replace(' ','_',$label)."> ?pred ?obj}"; + $result=$this->getSparqlResult($query); + $ret=array(); + foreach ($result->item as $results){ + $value=$results->item[1]; + if (strpos($value,"@".$this->lang)==(strlen($value)-strlen("@".$this->lang))) $ret[$results->item[0]][]=substr($value,0,strlen($value)-strlen("@".$this->lang)); + if (strpos($value,"@")!=(strlen($value)-strlen($this->lang)-1)) $ret[$results->item[0]][]=$value; + } + return $ret; + } - function getTriples($ttl,$individual) + function getSparqlResult($query) { - $options=array("triples",$individual); - $this->client->startThread($this->id,$this->ksID,$options); + $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "defaultGraphURIs", array("http://dbpedia.org")); + $queryID=$this->client->sparqlQueryThreaded($this->id,$this->ksID,$query); + $running=true; $i = 1; $sleeptime = 1; - + do { // sleep a while sleep($sleeptime); - // see if algorithm is running - if (!$this->client->isThreadRunning($this->id,$this->ksID,"triples")) - { - $object=$this->client->getFromSparql($this->id,$this->ksID,"triples"); - @$array=$object->item; - if ($array==NULL) return array(); - if (count($array)==1) return $array; - $ret=array(); - foreach ($array as $element) - { - $items=preg_split("[<]",$element,-1, PREG_SPLIT_NO_EMPTY); - - // each property can occur multiple times (!) - // bug: $ret[$items[0]]=$items[1]; - - $ret[$items[0]][] = $items[1]; - } - return $ret; + + $running=$this->client->isSparqlQueryRunning($this->id,$this->ksID,$queryID); + if (!$running){ + $result=$this->client->sparqlQuery($this->id,$this->ksID,$queryID); + return $result; } $seconds = $i * $sleeptime; $i++; - } while($seconds<$ttl); - - $this->client->stopSparqlThread($this->id,$this->ksID,"triples"); - return array(); + } while($seconds<$this->ttl); + $this->client->stopSparqlQuery($id,$ksID,$queryID); } - function getSubjects($ttl,$label) + function getSubjects($label) { - $options=array("subjects",$label,15); - $this->client->startThread($this->id,$this->ksID,$options); - $i = 1; - $sleeptime = 1; - - do { - // sleep a while - sleep($sleeptime); - - // see if algorithm is running - if (!$this->client->isThreadRunning($this->id,$this->ksID,"subjects")) - { - $object=$this->client->getFromSparql($this->id,$this->ksID,"subjects"); - return $object->item; - } - - $seconds = $i * $sleeptime; - $i++; - } while($seconds<$ttl); - - $this->client->stopSparqlThread($this->id,$this->ksID,"subjects"); - return array(); + $query="SELECT DISTINCT ?subject\n". + "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}\n". + "LIMIT 10"; + $result=$this->getSparqlResult($query); + $ret=array(); + foreach ($result->item as $results){ + $ret[]=$results->item; + } + return $ret; } - function getSubjectsFromConcept($ttl,$concept) + function getSubjectsFromConcept($concept) { - $options=array("conceptSubjects",$concept); - $this->client->startThread($this->id,$this->ksID,$options); - $i = 1; - $sleeptime = 1; - do { - // sleep a while - sleep($sleeptime); - - // see if algorithm is running - if (!$this->client->isThreadRunning($this->id,$this->ksID,"conceptSubjects")) - { - $object=$this->client->getFromSparql($this->id,$this->ksID,"conceptSubjects"); - return $object->item; - } - - $seconds = $i * $sleeptime; - $i++; - } while($seconds<$ttl); - - $this->client->stopSparqlThread($this->id,$this->ksID,"conceptSubjects"); - return array(); + $query="SELECT DISTINCT ?subject\n". + "WHERE { ?subject a <".$concept.">}\n". + "LIMIT 10"; + $result=$this->getSparqlResult($query); + $ret=array(); + foreach ($result->item as $results){ + $ret[]=$results->item[0]; + } + return $ret; } public function loadWSDLfiles($wsdluri){ Modified: trunk/src/dbpedia-navigator/NaturalConcepts.php =================================================================== --- trunk/src/dbpedia-navigator/NaturalConcepts.php 2008-01-24 09:31:09 UTC (rev 424) +++ trunk/src/dbpedia-navigator/NaturalConcepts.php 2008-01-24 10:13:14 UTC (rev 425) @@ -10,6 +10,7 @@ function getNaturalConcept(){ $identifiedConcepts=$this->identifyConcepts(); + $labels=$this->getLabels($identifiedConcepts); return $identifiedConcepts; } @@ -32,9 +33,23 @@ $offset=$treffer[0][1]; } - print_r($ret); return $ret; } + + function getLabels($conc) + { + $query="SELECT DISTINCT "; + for ($i=0;$i<count($conc)-1;$i++) + $query.="?obj".$i.", "; + $query.="?obj".$i."\n"; + $query.="WHERE {\n"; + foreach ($conc as $key=>$con){ + $query.="<".$con."> <http://www.w3.org/2000/01/rdf-schema#label> ?obj".$key.".\n"; + } + $query.="}"; + print $query; + return $query; + } } $conc="EXISTS http://dbpedia.org/property/website.TOP AND http://dbpedia.org/resource/Berlin"; Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-24 09:31:09 UTC (rev 424) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-24 10:13:14 UTC (rev 425) @@ -9,13 +9,11 @@ function getsubjects($label) { - require_once("Settings.php"); require_once("DLLearnerConnection.php"); - $settings=new Settings(); - $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); + $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); $content=""; - $subjects=$sc->getSubjects($settings->sparqlttl,$label); + $subjects=$sc->getSubjects($label); if (count($subjects)==1) { @@ -26,7 +24,7 @@ else{ foreach ($subjects as $subject) { - $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".str_replace("_"," ",substr (strrchr ($subject, "/"), 1))."',-2);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; + $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; } } @@ -58,64 +56,63 @@ } } if ($fromCache<0) { - require_once("Settings.php"); require_once("DLLearnerConnection.php"); - $settings=new Settings(); - $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); - $triples=$sc->getTriples($settings->sparqlttl,$subject); + $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); + $triples=$sc->getTriples($subject); $content=""; $searchResult=""; $objResponse = new xajaxResponse(); if (count($triples)==1) - { + { // ToDo: find out why this was treated in a special way by Sebastian $content.=substr($triples,7); } - else if (count($triples)==0) { + else if (count($triples)==0) { $content.="Did not find an article with that name. Similar Articles are shown under 'Search Results'."; - } else { - - // goal: display the data in a nice (DBpedia specific way), maybe similar to - // dbpedia.org/search + } else { - $content=""; - // replace by label(?) - $subject_nice = str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1))); - - // display a picture if there is one + // goal: display the data in a nice (DBpedia specific way), maybe similar to + // dbpedia.org/search + + $content=""; + + // replace by label(?) + //$subject_nice = str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1))); + + // display a picture if there is one if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) - $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0].'" alt="Picture of '.$subject_nice.'" style="float:right; max-width:200px;" \>'; - + $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0].'" alt="Picture of '.$subject_nice.'" style="float:right; max-width:200px;" \>'; + // add short description in english $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0])."</p>"; - - // 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" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0].'">view Wikipedia article</a>, '; - $content .= '<a href="'.$subject.'">view DBpedia resource description</a></p>'; - - // display a list of classes - if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) - $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; - - if(isset($triples['http://dbpedia.org/property/reference'])) { - $content .= '<p>references: <ul>'; - foreach($triples['http://dbpedia.org/property/reference'] as $reference) - $content .= '<li><a href="'.$reference.'">'.$reference.'</a></li>'; - $content .= '</ul></p>'; - } - - // filter out uninteresting properties and properties which - // have already been displayed - 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']); - - // display the remaining properties as list which can be used for further navigation - - $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); + + // 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" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0].'">view Wikipedia article</a>, '; + $content .= '<a href="'.$subject.'">view DBpedia resource description</a></p>'; + // display a list of classes + if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) + $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; + + if(isset($triples['http://dbpedia.org/property/reference'])) { + $content .= '<p>references: <ul>'; + foreach($triples['http://dbpedia.org/property/reference'] as $reference) + $content .= '<li><a href="'.$reference.'">'.$reference.'</a></li>'; + $content .= '</ul></p>'; + } + + // filter out uninteresting properties and properties which + // have already been displayed + 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']); + + // display the remaining properties as list which can be used for further navigation + + $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); + //store article in session, to navigate between last 5 articles quickly $contentArray=array('content' => $content,'subject' => $subject); if (!isset($_SESSION['nextArticle'])){ @@ -140,7 +137,7 @@ //build Subject and Searchresults if ($fromCache==-1) - $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".str_replace("_"," ",substr (strrchr ($subject, "/"), 1))."');return false;\">Show more Results</a>"; + $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".$subject."');return false;\">Show more Results</a>"; } } else { @@ -152,12 +149,12 @@ if (isset($_SESSION['articles'])) foreach ($_SESSION['articles'] as $key => $value) { - $lastArticles.="<a href=\"\" onclick=\"xajax_getAndShowArticle('',".$key.");return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($value['subject'], "/"), 1)))."</a><br/>"; + $lastArticles.="<a href=\"\" onclick=\"xajax_getAndShowArticle('',".$key.");return false;\">".$value['subject']."</a><br/>"; } //put whole site content into session $_SESSION['artContent']=$content; - $_SESSION['artTitle']=str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1))); + $_SESSION['artTitle']=$triples['http://www.w3.org/2000/01/rdf-schema#label']; $_SESSION['artLast']=$lastArticles; $_SESSION['artSubjects']=$searchResult; @@ -188,7 +185,7 @@ function getAndShowArticle($subject,$fromCache) { $objResponse = new xajaxResponse(); - $objResponse->call('xajax_getarticle',"http://dbpedia.org/resource/".str_replace(" ","_",$subject),$fromCache); + $objResponse->call('xajax_getarticle',$subject,$fromCache); $objResponse->call('xajax_showArticle'); return $objResponse; } @@ -252,11 +249,11 @@ //add Positives and Negatives to Interests $posInterests=""; if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ - $posInterests=$posInterests.str_replace("_"," ",urldecode(substr (strrchr ($pos, "/"), 1)))." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; + $posInterests=$posInterests.$pos." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; } $negInterests=""; if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ - $negInterests=$negInterests.str_replace("_"," ",urldecode(substr (strrchr ($neg, "/"), 1)))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; + $negInterests=$negInterests.$neg." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; } $objResponse=new xajaxResponse(); Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-24 09:31:09 UTC (rev 424) +++ trunk/src/dbpedia-navigator/index.php 2008-01-24 10:13:14 UTC (rev 425) @@ -5,10 +5,8 @@ ini_set("soap.wsdl_cache_enabled","1"); session_start(); -require_once('Settings.php'); require_once('DLLearnerConnection.php'); -$settings=new Settings(); -$sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri); +$sc=new DLLearnerConnection(); $ids=$sc->getIDs(); $_SESSION['id']=$ids[0]; $_SESSION['ksID']=$ids[1]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 14:27:24
|
Revision: 433 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=433&view=rev Author: sknappe Date: 2008-01-28 06:27:16 -0800 (Mon, 28 Jan 2008) Log Message: ----------- fixed some bugs Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-28 14:26:54 UTC (rev 432) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-28 14:27:16 UTC (rev 433) @@ -40,7 +40,7 @@ return array(0 => $id, 1 => $ksID); } - function getConceptFromExamples($ttl,$posExamples,$negExamples) + function getConceptFromExamples($posExamples,$negExamples) { $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); @@ -88,7 +88,7 @@ $seconds = $i * $sleeptime; $i++; - } while($seconds<$ttl&&$running); + } while($seconds<$this->ttl&&$running); $this->client->stop($this->id); } Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 14:26:54 UTC (rev 432) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 14:27:16 UTC (rev 433) @@ -292,21 +292,20 @@ foreach ($_SESSION['negative'] as $neg) $negArray[]=$neg; - require_once("Settings.php"); require_once("DLLearnerConnection.php"); - $settings=new Settings(); - $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); + $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); - $concept=$sc->getConceptFromExamples($settings->sparqlttl,$posArray,$negArray); + $concept=$sc->getConceptFromExamples($posArray,$negArray); $_SESSION['lastLearnedConcept']=$concept; - if (strlen(substr (strrchr ($concept, "/"), 1))>0) $concept=urldecode(substr (strrchr ($concept, "/"), 1)); + if (strlen(substr (strrchr ($concept, "/"), 1))>0) $concept="<a href=\"\" onclick=\"xajax_getSubjectsFromConcept();return false;\" />".urldecode(substr (strrchr ($concept, "/"), 1))."</a>"; + else $concept="<a href=\"\" onclick=\"xajax_getSubjectsFromConcept();return false;\" />".$concept."</a>"; } else $concept="You must choose at least one<br/> positive example."; $objResponse = new xajaxResponse(); - $objResponse->assign("conceptcontent", "innerHTML", $concept); + $objResponse->assign("conceptlink", "innerHTML", $concept); return $objResponse; } Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-28 14:26:54 UTC (rev 432) +++ trunk/src/dbpedia-navigator/index.php 2008-01-28 14:27:16 UTC (rev 433) @@ -68,7 +68,7 @@ <body> <!-- <h1>DBpedia Navigator</h1> --> -<img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> +<img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> <span id="conceptlink"></span> <div id="layer" style="display:none"> <div id="layerContent" style="display:none"></div> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 15:35:42
|
Revision: 437 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=437&view=rev Author: sknappe Date: 2008-01-28 07:35:28 -0800 (Mon, 28 Jan 2008) Log Message: ----------- the correct URI's are now send to Web-Service Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-28 15:30:34 UTC (rev 436) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-28 15:35:28 UTC (rev 437) @@ -42,7 +42,7 @@ function getConceptFromExamples($posExamples,$negExamples) { - $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",2); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "predList", array()); // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "objList", array()); Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 15:30:34 UTC (rev 436) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 15:35:28 UTC (rev 437) @@ -126,12 +126,12 @@ //Add Positives to Session if (!isset($_SESSION['positive'])){ - $array=array($subject => $subject); + $array=array($subject => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); $_SESSION['positive']=$array; } else{ $array=$_SESSION['positive']; - $array[$subject]=$subject; + $array[$subject]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); $_SESSION['positive']=$array; } @@ -249,11 +249,11 @@ //add Positives and Negatives to Interests $posInterests=""; if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ - $posInterests=$posInterests.$pos." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; + $posInterests=$posInterests.substr (strrchr ($pos, "/"), 1)." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; } $negInterests=""; if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ - $negInterests=$negInterests.$neg." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; + $negInterests=$negInterests.substr (strrchr ($neg, "/"), 1)." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; } $objResponse=new xajaxResponse(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-30 10:26:42
|
Revision: 463 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=463&view=rev Author: sknappe Date: 2008-01-30 02:26:38 -0800 (Wed, 30 Jan 2008) Log Message: ----------- changed for new Web-Service interface Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/rebuild.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-30 07:20:32 UTC (rev 462) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-30 10:26:38 UTC (rev 463) @@ -44,11 +44,8 @@ { $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); - // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "predList", array()); - // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "objList", array()); - // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "classList", array()); - // $this->client->applyConfigEntryString($this->id, $this->ksID, "format", "KB"); - // $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "dumpToFile", true); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedFilter", 5); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedEndpoint", 1); $this->client->setReasoner($this->id, "dig"); if(empty($negExamples)) @@ -111,28 +108,31 @@ function getSparqlResult($query) { - $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "defaultGraphURIs", array("http://dbpedia.org")); - $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "cached", true); - $queryID=$this->client->sparqlQueryThreaded($this->id,$this->ksID,$query); - $running=true; - $i = 1; - $sleeptime = 1; - - do { - // sleep a while - sleep($sleeptime); - + try { + $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "defaultGraphURIs", array("http://dbpedia.org")); + $queryID=$this->client->sparqlQueryThreaded($this->id,$this->ksID,$query); + $running=true; + $i = 1; + $sleeptime = 1; - $running=$this->client->isSparqlQueryRunning($this->id,$queryID); - if (!$running){ - $result=$this->client->getAsStringArray($this->id,$queryID); - return $result; - } - - $seconds = $i * $sleeptime; - $i++; - } while($seconds<$this->ttl); - $this->client->stopSparqlQuery($id,$queryID); + do { + // sleep a while + sleep($sleeptime); + + + $running=$this->client->isSparqlQueryRunning($this->id,$queryID); + if (!$running){ + $result=$this->client->getAsStringArray($this->id,$queryID); + return $result; + } + + $seconds = $i * $sleeptime; + $i++; + } while($seconds<$this->ttl); + $this->client->stopSparqlQuery($id,$queryID); + } catch (Exception $e){ + echo $e->getMessage(); + } } function getSubjects($label) @@ -233,12 +233,10 @@ } } - -/*require_once("Settings.php"); +/* require_once("DLLearnerConnection.php"); -$settings=new Settings(); -$sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri); +$sc=new DLLearnerConnection(); $ids=$sc->getIDs(); -$sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$ids[0],$ids[1]); -$triples=$sc->getTriples($settings->sparqlttl,"dog");*/ +$sc=new DLLearnerConnection($ids[0],$ids[1]); +$triples=$sc->getTriples("Leipzig");*/ ?> Modified: trunk/src/dbpedia-navigator/rebuild.php =================================================================== --- trunk/src/dbpedia-navigator/rebuild.php 2008-01-30 07:20:32 UTC (rev 462) +++ trunk/src/dbpedia-navigator/rebuild.php 2008-01-30 10:26:38 UTC (rev 463) @@ -14,11 +14,6 @@ // we need to make sure that PHP really uses the new WSDL file // and does not cache, so we disable the cache and load it ini_set("soap.wsdl_cache_enabled","0"); -$sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri); -//$sc->getIDs(); -// TODO: does not work; -// maybe try to set ttl of cache to 1 second, -// wait for 1 second and then redirect to start page // redirect to index page $index_uri = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).'/index.php'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-30 11:47:31
|
Revision: 466 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=466&view=rev Author: sknappe Date: 2008-01-30 03:47:27 -0800 (Wed, 30 Jan 2008) Log Message: ----------- first exception handling (not final) Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-30 11:21:13 UTC (rev 465) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-30 11:47:27 UTC (rev 466) @@ -108,31 +108,27 @@ function getSparqlResult($query) { - try { - $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "defaultGraphURIs", array("http://dbpedia.org")); - $queryID=$this->client->sparqlQueryThreaded($this->id,$this->ksID,$query); - $running=true; - $i = 1; - $sleeptime = 1; + $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "defaultGraphURIs", array("http://dbpedia.org")); + $queryID=$this->client->sparqlQueryThreaded($this->id,$this->ksID,$query); + $running=true; + $i = 1; + $sleeptime = 1; - do { - // sleep a while - sleep($sleeptime); + do { + // sleep a while + sleep($sleeptime); - $running=$this->client->isSparqlQueryRunning($this->id,$queryID); - if (!$running){ - $result=$this->client->getAsStringArray($this->id,$queryID); - return $result; - } + $running=$this->client->isSparqlQueryRunning($this->id,$queryID); + if (!$running){ + $result=$this->client->getAsStringArray($this->id,$queryID); + return $result; + } - $seconds = $i * $sleeptime; - $i++; - } while($seconds<$this->ttl); - $this->client->stopSparqlQuery($id,$queryID); - } catch (Exception $e){ - echo $e->getMessage(); - } + $seconds = $i * $sleeptime; + $i++; + } while($seconds<$this->ttl); + $this->client->stopSparqlQuery($id,$queryID); } function getSubjects($label) Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-30 11:21:13 UTC (rev 465) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-30 11:47:27 UTC (rev 466) @@ -58,86 +58,97 @@ if ($fromCache<0) { require_once("DLLearnerConnection.php"); $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); - $triples=$sc->getTriples($subject); $content=""; $searchResult=""; - $objResponse = new xajaxResponse(); - if (count($triples)==1) - { - // ToDo: find out why this was treated in a special way by Sebastian - $content.=substr($triples,7); - } - else if (count($triples)==0) { - $content.="Did not find an article with that name. Similar Articles are shown under 'Search Results'."; - } else { - - // goal: display the data in a nice (DBpedia specific way), maybe similar to - // dbpedia.org/search - - $content=""; - - // replace by label(?) - //$subject_nice = str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1))); + $lastArticles=""; + $artTitle=""; + try{ + $triples=$sc->getTriples($subject); + $objResponse = new xajaxResponse(); + if (count($triples)==1) + { + // ToDo: find out why this was treated in a special way by Sebastian + $content.=substr($triples,7); + } + else if (count($triples)==0) { + $content.="Did not find an article with that name. Similar Articles are shown under 'Search Results'."; + } else { - // display a picture if there is one - if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) - $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0].'" alt="Picture of '.$subject_nice.'" style="float:right; max-width:200px;" \>'; + // goal: display the data in a nice (DBpedia specific way), maybe similar to + // dbpedia.org/search + + $content=""; + + // replace by label(?) + //$subject_nice = str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1))); - // add short description in english - $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0])."</p>"; - - // 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" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0].'">view Wikipedia article</a>, '; - $content .= '<a href="'.$subject.'">view DBpedia resource description</a></p>'; + // display a picture if there is one + if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) + $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0].'" alt="Picture of '.$subject_nice.'" style="float:right; max-width:200px;" \>'; + + // add short description in english + $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0])."</p>"; + + // 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" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0].'">view Wikipedia article</a>, '; + $content .= '<a href="'.$subject.'">view DBpedia resource description</a></p>'; + + // display a list of classes + if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) + $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; + + if(isset($triples['http://dbpedia.org/property/reference'])) { + $content .= '<p>references: <ul>'; + foreach($triples['http://dbpedia.org/property/reference'] as $reference) + $content .= '<li><a href="'.$reference.'">'.$reference.'</a></li>'; + $content .= '</ul></p>'; + } - // display a list of classes - if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) - $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; - - if(isset($triples['http://dbpedia.org/property/reference'])) { - $content .= '<p>references: <ul>'; - foreach($triples['http://dbpedia.org/property/reference'] as $reference) - $content .= '<li><a href="'.$reference.'">'.$reference.'</a></li>'; - $content .= '</ul></p>'; - } + $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label']; - // filter out uninteresting properties and properties which - // have already been displayed - 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']); - - // display the remaining properties as list which can be used for further navigation - - $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); - - //store article in session, to navigate between last 5 articles quickly - $contentArray=array('content' => $content,'subject' => $subject); - if (!isset($_SESSION['nextArticle'])){ - $_SESSION['nextArticle']=0; - $_SESSION['articles']=array(); + + // filter out uninteresting properties and properties which + // have already been displayed + 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']); + + // display the remaining properties as list which can be used for further navigation + + $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); + + //store article in session, to navigate between last 5 articles quickly + $contentArray=array('content' => $content,'subject' => $subject); + if (!isset($_SESSION['nextArticle'])){ + $_SESSION['nextArticle']=0; + $_SESSION['articles']=array(); + } + if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; + $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; + $_SESSION['currentArticle']=$_SESSION['nextArticle']; + $_SESSION['nextArticle']++; + + //Add Positives to Session + if (!isset($_SESSION['positive'])){ + $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); + $_SESSION['positive']=$array; + } + else{ + $array=$_SESSION['positive']; + $array["http://dbpedia.org/resource/".str_replace(" ","_",$subject)]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); + $_SESSION['positive']=$array; + } + + //build Subject and Searchresults + if ($fromCache==-1) + $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".$subject."');return false;\">Show more Results</a>"; } - if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; - $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; - $_SESSION['currentArticle']=$_SESSION['nextArticle']; - $_SESSION['nextArticle']++; - - //Add Positives to Session - if (!isset($_SESSION['positive'])){ - $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); - $_SESSION['positive']=$array; - } - else{ - $array=$_SESSION['positive']; - $array["http://dbpedia.org/resource/".str_replace(" ","_",$subject)]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); - $_SESSION['positive']=$array; - } - - //build Subject and Searchresults - if ($fromCache==-1) - $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".$subject."');return false;\">Show more Results</a>"; + } catch (Exception $e) + { + $content=$e->getMessage(); + $artTitle="Fehler"; } } else { @@ -145,7 +156,6 @@ $subject=$_SESSION['articles'][$fromCache]['subject']; } - $lastArticles=""; if (isset($_SESSION['articles'])) foreach ($_SESSION['articles'] as $key => $value) { @@ -154,7 +164,7 @@ //put whole site content into session $_SESSION['artContent']=$content; - $_SESSION['artTitle']=$triples['http://www.w3.org/2000/01/rdf-schema#label']; + $_SESSION['artTitle']=$artTitle; $_SESSION['artLast']=$lastArticles; $_SESSION['artSubjects']=$searchResult; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-30 15:27:25
|
Revision: 467 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=467&view=rev Author: sknappe Date: 2008-01-30 07:27:18 -0800 (Wed, 30 Jan 2008) Log Message: ----------- more error handling Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/rebuild.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-30 11:47:27 UTC (rev 466) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-30 15:27:18 UTC (rev 467) @@ -28,7 +28,7 @@ $this->ttl=$settings->sparqlttl; $this->lang=$settings->language; $this->DBPediaUrl=$settings->dbpediauri; - $this->client=new SoapClient("main.wsdl"); + $this->client=new SoapClient("main.wsdl",array('features' => SOAP_SINGLE_ELEMENT_ARRAYS)); $this->id=$id; $this->ksID=$ksID; } @@ -97,12 +97,14 @@ $query="SELECT ?pred ?obj ". "WHERE {<http://dbpedia.org/resource/".str_replace(' ','_',$label)."> ?pred ?obj}"; $result=$this->getSparqlResult($query); + if (!$result->item) throw new Exception("Your query brought no result."); $ret=array(); foreach ($result->item as $results){ - $value=$results->item[1]; - if (strpos($value,"@".$this->lang)==(strlen($value)-strlen("@".$this->lang))) $ret[$results->item[0]][]=substr($value,0,strlen($value)-strlen("@".$this->lang)); - if (strpos($value,"@")!=(strlen($value)-strlen($this->lang)-1)) $ret[$results->item[0]][]=$value; + $value=$results->item[1]; + if (strpos($value,"@".$this->lang)==(strlen($value)-strlen("@".$this->lang))) $ret[$results->item[0]][]=substr($value,0,strlen($value)-strlen("@".$this->lang)); + if (strpos($value,"@")!=(strlen($value)-strlen($this->lang)-1)) $ret[$results->item[0]][]=$value; } + return $ret; } @@ -137,6 +139,7 @@ "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\"".$label."\"'@en}\n". "LIMIT 10"; $result=$this->getSparqlResult($query); + if (!$result->item) throw new Exception("Your query brought no result."); $ret=array(); foreach ($result->item as $results){ $ret[]=$results->item; @@ -234,5 +237,5 @@ $sc=new DLLearnerConnection(); $ids=$sc->getIDs(); $sc=new DLLearnerConnection($ids[0],$ids[1]); -$triples=$sc->getTriples("Leipzig");*/ +$triples=$sc->getTriples("tgzt");*/ ?> Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-30 11:47:27 UTC (rev 466) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-30 15:27:18 UTC (rev 467) @@ -10,22 +10,21 @@ function getsubjects($label) { require_once("DLLearnerConnection.php"); - $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); + //initialise content $content=""; - $subjects=$sc->getSubjects($label); - - if (count($subjects)==1) - { - if (strpos($subjects,"[Error]")===0) $content.=substr($subjects,7); - else $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".str_replace("_"," ",substr (strrchr ($subjects, "/"), 1))."',-2);return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; - } - else if (count($subjects)==0) $content.="No search result found in time."; - else{ + try{ + $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); + + + $subjects=$sc->getSubjects($label); + foreach ($subjects as $subject) { $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; } + } catch (Exception $e){ + $content=$e->getMessage(); } $_SESSION['subjects']=$content; @@ -47,7 +46,8 @@ function getarticle($subject,$fromCache) { - if (isset($_SESSION['articles'])) + //if article is in session, get it out of the session + if (isset($_SESSION['articles'])){ foreach ($_SESSION['articles'] as $key => $value) { if ($value['subject']==$subject){ @@ -55,96 +55,95 @@ break; } } + } + + //initialize the content variables + $content=""; + $searchResult=""; + $lastArticles=""; + $artTitle=""; + + //get the article + //if $fromCache is -2, no new SearchResults should be processed + //if $fromCache is -1, everything is normal + //if $fromCache is >=0, the article is taken out of the cache if ($fromCache<0) { - require_once("DLLearnerConnection.php"); - $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); - $content=""; - $searchResult=""; - $lastArticles=""; - $artTitle=""; + //if there are errors see catch block try{ + require_once("DLLearnerConnection.php"); + $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); $triples=$sc->getTriples($subject); - $objResponse = new xajaxResponse(); - if (count($triples)==1) - { - // ToDo: find out why this was treated in a special way by Sebastian - $content.=substr($triples,7); - } - else if (count($triples)==0) { - $content.="Did not find an article with that name. Similar Articles are shown under 'Search Results'."; - } else { - // goal: display the data in a nice (DBpedia specific way), maybe similar to - // dbpedia.org/search + //BUILD ARTICLE + // goal: display the data in a nice (DBpedia specific way), maybe similar to + // dbpedia.org/search - $content=""; - - // replace by label(?) - //$subject_nice = str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1))); - - // display a picture if there is one - if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) - $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0].'" alt="Picture of '.$subject_nice.'" style="float:right; max-width:200px;" \>'; + // display a picture if there is one + if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) + $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0].'" alt="Picture of '.$subject_nice.'" style="float:right; max-width:200px;" \>'; - // add short description in english - $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0])."</p>"; + // add short description in english + $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0])."</p>"; - // 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" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0].'">view Wikipedia article</a>, '; - $content .= '<a href="'.$subject.'">view DBpedia resource description</a></p>'; + // 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" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0].'">view Wikipedia article</a>, '; + $content .= '<a href="'.$subject.'">view DBpedia resource description</a></p>'; - // display a list of classes - if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) - $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; + // display a list of classes + if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) + $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; - if(isset($triples['http://dbpedia.org/property/reference'])) { - $content .= '<p>references: <ul>'; - foreach($triples['http://dbpedia.org/property/reference'] as $reference) - $content .= '<li><a href="'.$reference.'">'.$reference.'</a></li>'; - $content .= '</ul></p>'; - } - - $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label']; + if(isset($triples['http://dbpedia.org/property/reference'])) { + $content .= '<p>references: <ul>'; + foreach($triples['http://dbpedia.org/property/reference'] as $reference) + $content .= '<li><a href="'.$reference.'">'.$reference.'</a></li>'; + $content .= '</ul></p>'; + } + + + // filter out uninteresting properties and properties which + // have already been displayed + 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']); + + // display the remaining properties as list which can be used for further navigation + $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); + + + + //BUILD ARTICLE TITLE + $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label']; + + //store article in session, to navigate between last 5 articles quickly + $contentArray=array('content' => $content,'subject' => $subject); + if (!isset($_SESSION['nextArticle'])){ + $_SESSION['nextArticle']=0; + $_SESSION['articles']=array(); + } + if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; + $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; + $_SESSION['currentArticle']=$_SESSION['nextArticle']; + $_SESSION['nextArticle']++; - // filter out uninteresting properties and properties which - // have already been displayed - 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']); - - // display the remaining properties as list which can be used for further navigation + //Add Positives to Session + if (!isset($_SESSION['positive'])){ + $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); + $_SESSION['positive']=$array; + } + else{ + $array=$_SESSION['positive']; + $array["http://dbpedia.org/resource/".str_replace(" ","_",$subject)]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); + $_SESSION['positive']=$array; + } - $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); - - //store article in session, to navigate between last 5 articles quickly - $contentArray=array('content' => $content,'subject' => $subject); - if (!isset($_SESSION['nextArticle'])){ - $_SESSION['nextArticle']=0; - $_SESSION['articles']=array(); - } - if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; - $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; - $_SESSION['currentArticle']=$_SESSION['nextArticle']; - $_SESSION['nextArticle']++; - - //Add Positives to Session - if (!isset($_SESSION['positive'])){ - $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); - $_SESSION['positive']=$array; - } - else{ - $array=$_SESSION['positive']; - $array["http://dbpedia.org/resource/".str_replace(" ","_",$subject)]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); - $_SESSION['positive']=$array; - } - - //build Subject and Searchresults - if ($fromCache==-1) - $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".$subject."');return false;\">Show more Results</a>"; - } + + //BUILD SEARCHRESULT + if ($fromCache==-1) + $searchResult.="<a href=\"\" onclick=\"xajax_getAndShowSubjects('".$subject."');return false;\">Show more Results</a>"; } catch (Exception $e) { $content=$e->getMessage(); @@ -152,15 +151,18 @@ } } else { + //Article is in session $content=$_SESSION['articles'][$fromCache]['content']; $subject=$_SESSION['articles'][$fromCache]['subject']; } - if (isset($_SESSION['articles'])) + //Build lastArticles + if (isset($_SESSION['articles'])){ foreach ($_SESSION['articles'] as $key => $value) { $lastArticles.="<a href=\"\" onclick=\"xajax_getAndShowArticle('',".$key.");return false;\">".$value['subject']."</a><br/>"; } + } //put whole site content into session $_SESSION['artContent']=$content; @@ -168,6 +170,7 @@ $_SESSION['artLast']=$lastArticles; $_SESSION['artSubjects']=$searchResult; + $objResponse = new xajaxResponse(); return $objResponse; } Modified: trunk/src/dbpedia-navigator/rebuild.php =================================================================== --- trunk/src/dbpedia-navigator/rebuild.php 2008-01-30 11:47:27 UTC (rev 466) +++ trunk/src/dbpedia-navigator/rebuild.php 2008-01-30 15:27:18 UTC (rev 467) @@ -6,7 +6,7 @@ require_once 'pear/HTTP_Request.php'; require_once 'DLLearnerConnection.php'; require_once 'Settings.php'; -$settings=new Settings(); +$settings=new Settings(); // download new WSDL file DLLearnerConnection::loadWSDLfiles($settings->wsdluri); @@ -14,7 +14,6 @@ // we need to make sure that PHP really uses the new WSDL file // and does not cache, so we disable the cache and load it ini_set("soap.wsdl_cache_enabled","0"); - // redirect to index page $index_uri = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).'/index.php'; header('Location: ' . $index_uri); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-31 07:12:32
|
Revision: 475 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=475&view=rev Author: sknappe Date: 2008-01-30 23:12:28 -0800 (Wed, 30 Jan 2008) Log Message: ----------- some fixes, so that all functions work Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajax.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php trunk/src/dbpedia-navigator/learningExamples.txt Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-30 21:36:09 UTC (rev 474) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-31 07:12:28 UTC (rev 475) @@ -45,8 +45,8 @@ $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedFilter", 5); - $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedEndpoint", 1); - + $this->client->applyConfigEntryInt($this->id, $this->ksID, "predefinedEndpoint", 1); + $this->client->setReasoner($this->id, "dig"); if(empty($negExamples)) $this->client->setLearningProblem($this->id, "posOnlyDefinition"); @@ -142,7 +142,7 @@ if (!$result->item) throw new Exception("Your query brought no result."); $ret=array(); foreach ($result->item as $results){ - $ret[]=$results->item; + $ret[]=$results->item[0]; } return $ret; } @@ -153,6 +153,7 @@ "WHERE { ?subject a <".$concept.">}\n". "LIMIT 10"; $result=$this->getSparqlResult($query); + if (!$result->item) throw new Exception("Your query brought no result."); $ret=array(); foreach ($result->item as $results){ $ret[]=$results->item[0]; Modified: trunk/src/dbpedia-navigator/ajax.php =================================================================== --- trunk/src/dbpedia-navigator/ajax.php 2008-01-30 21:36:09 UTC (rev 474) +++ trunk/src/dbpedia-navigator/ajax.php 2008-01-31 07:12:28 UTC (rev 475) @@ -19,13 +19,14 @@ 'onResponseDelay' => 'showLoadingConcept', 'beforeResponseProcessing' => 'hideLoadingConcept' )); -$xajax->register(XAJAX_FUNCTION, 'getSubjectsFromConcept', array( - 'onResponseDelay' => 'showLoadingConceptSubjects', - 'beforeResponseProcessing' => 'hideLoadingConceptSubjects' - )); +$xajax->registerFunction('getSubjectsFromConcept'); $xajax->registerFunction('getAndShowSubjects'); $xajax->registerFunction('getsubjects'); $xajax->registerFunction('showArticle'); $xajax->registerFunction('removePosInterest'); $xajax->registerFunction('removeNegInterest'); +$xajax->registerFunction('showConcept'); +$xajax->registerFunction('learnAndShowConcept'); +$xajax->registerFunction('showSubjectsFromConcept'); +$xajax->registerFunction('getAndShowSubjectsFromConcept'); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-30 21:36:09 UTC (rev 474) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-31 07:12:28 UTC (rev 475) @@ -116,10 +116,10 @@ //BUILD ARTICLE TITLE - $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label']; + $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]; //store article in session, to navigate between last 5 articles quickly - $contentArray=array('content' => $content,'subject' => $subject); + $contentArray=array('content' => $content,'subject' => $artTitle); if (!isset($_SESSION['nextArticle'])){ $_SESSION['nextArticle']=0; $_SESSION['articles']=array(); @@ -153,7 +153,7 @@ else { //Article is in session $content=$_SESSION['articles'][$fromCache]['content']; - $subject=$_SESSION['articles'][$fromCache]['subject']; + $artTitle=$_SESSION['articles'][$fromCache]['subject']; } //Build lastArticles @@ -312,44 +312,33 @@ $concept=$sc->getConceptFromExamples($posArray,$negArray); $_SESSION['lastLearnedConcept']=$concept; - if (strlen(substr (strrchr ($concept, "/"), 1))>0) $concept="<a href=\"\" onclick=\"xajax_getSubjectsFromConcept();return false;\" />".urldecode(substr (strrchr ($concept, "/"), 1))."</a>"; - else $concept="<a href=\"\" onclick=\"xajax_getSubjectsFromConcept();return false;\" />".$concept."</a>"; + $concept="<a href=\"\" onclick=\"xajax_getAndShowSubjectsFromConcept();return false;\" />".$concept."</a>"; } - else $concept="You must choose at least one<br/> positive example."; + else $concept="You must choose at least one positive example."; + $_SESSION['conceptcontent']=$concept; + $objResponse = new xajaxResponse(); - $objResponse->assign("conceptlink", "innerHTML", $concept); return $objResponse; } function getSubjectsFromConcept() { - require_once("Settings.php"); - require_once("DLLearnerConnection.php"); - $settings=new Settings(); - $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); - $content=""; - if (isset($_SESSION['lastLearnedConcept'])) - { - $subjects=$sc->getSubjectsFromConcept($settings->sparqlttl,$_SESSION['lastLearnedConcept']); - if (count($subjects)==1) + try{ + require_once("DLLearnerConnection.php"); + $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); + $subjects=$sc->getSubjectsFromConcept($_SESSION['lastLearnedConcept']); + foreach ($subjects as $subject) { - if (strpos($subjects,"[Error]")===0) $content.=substr($subjects,7); - else $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subjects."');return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subjects, "/"), 1)))."</a><br/>"; + $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; } - else if (count($subjects)==0) $content.="No examples for concept found in time."; - else { - foreach ($subjects as $subject) - { - $content.="<a href=\"\" onclick=\"xajax_getarticle('".$subject."');return false;\">".str_replace("_"," ",urldecode(substr (strrchr ($subject, "/"), 1)))."</a><br/>"; - } - } + } catch (Exception $e){ + $content=$e->getMessage(); } - else $content.="No concept to get Subjects from."; - + + $_SESSION['conceptsubjectcontent']=$content; $objResponse = new xajaxResponse(); - $objResponse->assign("conceptsubjectcontent", "innerHTML", $content); return $objResponse; } @@ -360,6 +349,46 @@ $objResponse->call('xajax_showSubjects'); return $objResponse; } + +function learnAndShowConcept() +{ + $objResponse = new xajaxResponse(); + $objResponse->call('xajax_learnConcept'); + $objResponse->call('xajax_showConcept'); + return $objResponse; +} + +function showConcept() +{ + while (!isset($_SESSION['conceptcontent'])){ + sleep(0.5); + } + + $objResponse = new xajaxResponse(); + $objResponse->assign("conceptlink", "innerHTML", $_SESSION['conceptcontent']); + unset($_SESSION['conceptcontent']); + return $objResponse; +} + +function getAndShowSubjectsFromConcept() +{ + $objResponse = new xajaxResponse(); + $objResponse->call('xajax_getSubjectsFromConcept'); + $objResponse->call('xajax_showSubjectsFromConcept'); + return $objResponse; +} + +function showSubjectsFromConcept() +{ + while (!isset($_SESSION['conceptsubjectcontent'])){ + sleep(0.5); + } + + $objResponse = new xajaxResponse(); + $objResponse->assign("searchcontent", "innerHTML", $_SESSION['conceptsubjectcontent']); + unset($_SESSION['conceptsubjectcontent']); + return $objResponse; +} /////////////////////// // Helper Functions. // Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-30 21:36:09 UTC (rev 474) +++ trunk/src/dbpedia-navigator/index.php 2008-01-31 07:12:28 UTC (rev 475) @@ -39,14 +39,6 @@ xajax.$('loadingSubject').style.display = 'none'; xajax.$('searchcontent').style.display='block'; }; - showLoadingArticle = function() { - xajax.$('loadingArticle').style.display='block'; - xajax.$('articlecontent').style.display = 'none'; - }; - hideLoadingArticle = function() { - xajax.$('loadingArticle').style.display = 'none'; - xajax.$('articlecontent').style.display = 'block'; - }; showLoadingConcept = function() { xajax.$('loadingConcept').style.display='block'; xajax.$('conceptcontent').style.display = 'none'; @@ -55,20 +47,12 @@ xajax.$('loadingConcept').style.display = 'none'; xajax.$('conceptcontent').style.display = 'block'; }; - showLoadingConceptSubjects = function() { - xajax.$('loadingConceptSubjects').style.display='block'; - xajax.$('conceptsubjectcontent').style.display = 'none'; - }; - hideLoadingConceptSubjects = function() { - xajax.$('loadingConceptSubjects').style.display = 'none'; - xajax.$('conceptsubjectcontent').style.display = 'block'; - } </script> </head> <body> <!-- <h1>DBpedia Navigator</h1> --> -<img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> <span id="conceptlink"></span> +<img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> <input type="button" value="Learn" class="button" onclick="xajax_learnAndShowConcept();return false;" /> <span id="conceptlink"></span> <div id="layer" style="display:none"> <div id="layerContent" style="display:none"></div> </div> @@ -96,22 +80,6 @@ </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 --> - - <div class="box" id="conceptSubjects"> - <div class="boxtitlewithbutton"><table border="0" class="titletable"><tr><td class="left">Subjects From Concept</td><td class="right"><input type="button" value="Show" class="button" onclick="xajax_getSubjectsFromConcept();return false;" /></td></tr></table></div> - <div class="boxcontent"> - <div id="conceptsubjectcontent" style="display:none"></div> - <div id="loadingConceptSubjects" style="display:none"><img src="ajax-loader.gif" alt="Loading..."/></div> - </div> <!-- boxcontent --> - </div> <!-- box --> - <div class="box" id="credits"> <p>DBpedia Navigator is powered by ... <br /> <a href="http://dl-learner.org">DL-Learner</a><br /> Modified: trunk/src/dbpedia-navigator/learningExamples.txt =================================================================== --- trunk/src/dbpedia-navigator/learningExamples.txt 2008-01-30 21:36:09 UTC (rev 474) +++ trunk/src/dbpedia-navigator/learningExamples.txt 2008-01-31 07:12:28 UTC (rev 475) @@ -34,4 +34,12 @@ -Hamburg ---------------- EXISTS http://dbpedia.org/property/wappen.TOP -EXISTS http://dbpedia.org/property/wordnet_type.TOP \ No newline at end of file +EXISTS http://dbpedia.org/property/wordnet_type.TOP + ++Germany ++Poland ++France +-India +-Australia +----------------- +EXISTS http://dbpedia.org/property/leaderName.(http://dbpedia.org/class/yago/Politician110451263 AND http://dbpedia.org/class/yago/President110468559) \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-31 08:32:50
|
Revision: 476 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=476&view=rev Author: sknappe Date: 2008-01-31 00:32:43 -0800 (Thu, 31 Jan 2008) Log Message: ----------- Added loading Message Modified Paths: -------------- trunk/src/dbpedia-navigator/ajax.php trunk/src/dbpedia-navigator/default.css trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/ajax.php =================================================================== --- trunk/src/dbpedia-navigator/ajax.php 2008-01-31 07:12:28 UTC (rev 475) +++ trunk/src/dbpedia-navigator/ajax.php 2008-01-31 08:32:43 UTC (rev 476) @@ -5,8 +5,8 @@ $xajax = new xajax("ajaxfunctions.php?sid=$sid"); $xajax->configureMany(array('debug'=>true)); $xajax->register(XAJAX_FUNCTION, 'showSubjects', array( - 'onResponseDelay' => 'showLoadingSubjects', - 'beforeResponseProcessing' => 'hideLoadingSubjects' + 'onResponseDelay' => 'showLoading', + 'beforeResponseProcessing' => 'hideLoading' )); $xajax->registerFunction('getarticle'); $xajax->registerFunction('toPositive'); @@ -15,18 +15,24 @@ $xajax->registerFunction('clearNegatives'); $xajax->registerFunction('showInterests'); $xajax->registerFunction('getAndShowArticle'); -$xajax->register(XAJAX_FUNCTION, 'learnConcept', array( - 'onResponseDelay' => 'showLoadingConcept', - 'beforeResponseProcessing' => 'hideLoadingConcept' - )); +$xajax->registerFunction('learnConcept'); $xajax->registerFunction('getSubjectsFromConcept'); $xajax->registerFunction('getAndShowSubjects'); $xajax->registerFunction('getsubjects'); -$xajax->registerFunction('showArticle'); +$xajax->register(XAJAX_FUNCTION,'showArticle', array( + 'onResponseDelay' => 'showLoading', + 'beforeResponseProcessing' => 'hideLoading' + )); $xajax->registerFunction('removePosInterest'); $xajax->registerFunction('removeNegInterest'); -$xajax->registerFunction('showConcept'); +$xajax->register(XAJAX_FUNCTION,'showConcept', array( + 'onResponseDelay' => 'showLoading', + 'beforeResponseProcessing' => 'hideLoading' + )); $xajax->registerFunction('learnAndShowConcept'); -$xajax->registerFunction('showSubjectsFromConcept'); +$xajax->register(XAJAX_FUNCTION,'showSubjectsFromConcept', array( + 'onResponseDelay' => 'showLoading', + 'beforeResponseProcessing' => 'hideLoading' + )); $xajax->registerFunction('getAndShowSubjectsFromConcept'); ?> \ No newline at end of file Modified: trunk/src/dbpedia-navigator/default.css =================================================================== --- trunk/src/dbpedia-navigator/default.css 2008-01-31 07:12:28 UTC (rev 475) +++ trunk/src/dbpedia-navigator/default.css 2008-01-31 08:32:43 UTC (rev 476) @@ -31,6 +31,11 @@ * Main site structure */ +#Loading { + color: #666; + font-size: 85%; +} + #wrapper { /*position: relative;*/ max-width: 100%; Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-31 07:12:28 UTC (rev 475) +++ trunk/src/dbpedia-navigator/index.php 2008-01-31 08:32:43 UTC (rev 476) @@ -31,28 +31,18 @@ <link rel="stylesheet" href="default.css"/> <?php $xajax->printJavascript('xajax/'); ?> <script type="text/javascript"> - showLoadingSubjects = function() { - xajax.$('loadingSubject').style.display='block'; - xajax.$('searchcontent').style.display = 'none'; + showLoading = function() { + xajax.$('Loading').style.display='inline'; }; - hideLoadingSubjects = function() { - xajax.$('loadingSubject').style.display = 'none'; - xajax.$('searchcontent').style.display='block'; + hideLoading = function() { + xajax.$('Loading').style.display = 'none'; }; - 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> <body> <!-- <h1>DBpedia Navigator</h1> --> -<img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> <input type="button" value="Learn" class="button" onclick="xajax_learnAndShowConcept();return false;" /> <span id="conceptlink"></span> +<div><img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> <input type="button" value="Learn" class="button" onclick="xajax_learnAndShowConcept();return false;" /> <span id="conceptlink"></span><span id="Loading" style="display:none">Loading...</span></div> <div id="layer" style="display:none"> <div id="layerContent" style="display:none"></div> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-31 09:21:48
|
Revision: 477 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=477&view=rev Author: sknappe Date: 2008-01-31 01:21:34 -0800 (Thu, 31 Jan 2008) Log Message: ----------- several best concepts are shown Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-31 08:32:43 UTC (rev 476) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-31 09:21:34 UTC (rev 477) @@ -79,7 +79,7 @@ sleep($sleeptime); // see what we have learned so far - $concept=$this->client->getCurrentlyBestConcept($this->id); + $concepts=$this->client->getCurrentlyBestConcepts($this->id,3); $running=$this->client->isAlgorithmRunning($this->id); $seconds = $i * $sleeptime; @@ -89,7 +89,7 @@ $this->client->stop($this->id); } - return $concept; + return $concepts->item; } function getTriples($label) @@ -238,5 +238,5 @@ $sc=new DLLearnerConnection(); $ids=$sc->getIDs(); $sc=new DLLearnerConnection($ids[0],$ids[1]); -$triples=$sc->getTriples("tgzt");*/ +$triples=$sc->getConceptFromExamples(array("http://dbpedia.org/resource/Angela_Merkel"),array("http://dbpedia.org/resource/Joschka_Fischer"));*/ ?> Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-31 08:32:43 UTC (rev 476) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-31 09:21:34 UTC (rev 477) @@ -295,6 +295,7 @@ function learnConcept() { + $concept=""; if (isset($_SESSION['positive'])) { $posArray=array(); @@ -309,10 +310,14 @@ $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); - $concept=$sc->getConceptFromExamples($posArray,$negArray); + $concepts=$sc->getConceptFromExamples($posArray,$negArray); - $_SESSION['lastLearnedConcept']=$concept; - $concept="<a href=\"\" onclick=\"xajax_getAndShowSubjectsFromConcept();return false;\" />".$concept."</a>"; + $_SESSION['lastLearnedConcept']=$concepts; + $concept.="<table border=0>\n"; + foreach ($concepts as $con){ + $concept.="<tr><td><a href=\"\" onclick=\"xajax_getAndShowSubjectsFromConcept('".$con."');return false;\" />".$con."</a></td></tr>"; + } + $concept.="</table>"; } else $concept="You must choose at least one positive example."; @@ -322,13 +327,13 @@ return $objResponse; } -function getSubjectsFromConcept() +function getSubjectsFromConcept($concept) { $content=""; try{ require_once("DLLearnerConnection.php"); $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); - $subjects=$sc->getSubjectsFromConcept($_SESSION['lastLearnedConcept']); + $subjects=$sc->getSubjectsFromConcept($concept); foreach ($subjects as $subject) { $content.="<a href=\"\" onclick=\"xajax_getAndShowArticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; @@ -370,10 +375,10 @@ return $objResponse; } -function getAndShowSubjectsFromConcept() +function getAndShowSubjectsFromConcept($concept) { $objResponse = new xajaxResponse(); - $objResponse->call('xajax_getSubjectsFromConcept'); + $objResponse->call('xajax_getSubjectsFromConcept',$concept); $objResponse->call('xajax_showSubjectsFromConcept'); return $objResponse; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-05 11:34:02
|
Revision: 491 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=491&view=rev Author: sknappe Date: 2008-02-05 03:34:00 -0800 (Tue, 05 Feb 2008) Log Message: ----------- verz?\195?\182gerungstest Added Paths: ----------- trunk/src/dbpedia-navigator/indextest.php trunk/src/dbpedia-navigator/xajaxtest.php Added: trunk/src/dbpedia-navigator/indextest.php =================================================================== --- trunk/src/dbpedia-navigator/indextest.php (rev 0) +++ trunk/src/dbpedia-navigator/indextest.php 2008-02-05 11:34:00 UTC (rev 491) @@ -0,0 +1,58 @@ +<?php +ini_set('error_reporting',E_ALL); + +require("xajaxtest.php"); + +?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <title>DBpedia Navigator</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> + <link rel="stylesheet" href="default.css"/> + <?php $xajax->printJavascript('xajax/'); ?> + </head> + <body> + +<!-- <h1>DBpedia Navigator</h1> --> +<img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> +<div id="layer" style="display:none"> + <div id="layerContent" style="display:none"></div> +</div> + +<div id="wrapper"> + <div id="leftSidebar"> + + <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 --> + + </div><!-- END leftSidebar --> + + <div id="content"> + <div class="box"> + <div class="boxtitle" id="ArticleTitle">Welcome</div> + <div class="boxcontent" id="article"> + <div id="articlecontent" style="display:block"> + <br /><br /> + Welcome to the DBpedia Navigator interface! DBpedia Navigator allows you to search DBpedia + and uses the background knowledge in DBpedia to suggest possible interesting navigation + links. + </div> + <div id="loadingArticle" style="display:none"><img src="ajax-loader.gif" alt="Loading..."/></div> + </div> <!-- boxcontent --> + </div> <!-- box --> + </div><!-- content --> + + <!-- <div id="clear"></div> --> + +</div><!-- wrapper --> + </body> +</html> + \ No newline at end of file Added: trunk/src/dbpedia-navigator/xajaxtest.php =================================================================== --- trunk/src/dbpedia-navigator/xajaxtest.php (rev 0) +++ trunk/src/dbpedia-navigator/xajaxtest.php 2008-02-05 11:34:00 UTC (rev 491) @@ -0,0 +1,16 @@ +<?php +require_once ("xajax/xajax_core/xajax.inc.php"); +$xajax = new xajax(); +$xajax->configureMany(array('debug'=>true)); +$xajax->registerFunction('learnConcept'); +$xajax->processRequest(); + +function learnConcept() +{ + $client=new SoapClient("main.wsdl"); + $id=$client->generateID(); + $objResponse=new xajaxResponse(); + $objResponse->append("articlecontent","innerHTML","Test"); + return $objResponse; +} +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-05 15:38:41
|
Revision: 495 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=495&view=rev Author: sknappe Date: 2008-02-05 07:38:39 -0800 (Tue, 05 Feb 2008) Log Message: ----------- deleted test files, no longer necessary Removed Paths: ------------- trunk/src/dbpedia-navigator/indextest.php trunk/src/dbpedia-navigator/xajaxtest.php Deleted: trunk/src/dbpedia-navigator/indextest.php =================================================================== --- trunk/src/dbpedia-navigator/indextest.php 2008-02-05 11:43:54 UTC (rev 494) +++ trunk/src/dbpedia-navigator/indextest.php 2008-02-05 15:38:39 UTC (rev 495) @@ -1,56 +0,0 @@ -<?php -ini_set('error_reporting',E_ALL); - -require("xajaxtest.php"); - -?> -<!DOCTYPE html - PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - <head> - <title>DBpedia Navigator</title> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> - <link rel="stylesheet" href="default.css"/> - <?php $xajax->printJavascript('xajax/'); ?> - </head> - <body> - -<!-- <h1>DBpedia Navigator</h1> --> -<img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> -<div id="layer" style="display:none"> - <div id="layerContent" style="display:none"></div> -</div> - -<div id="wrapper"> - <div id="leftSidebar"> - - <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 --> - - </div><!-- END leftSidebar --> - - <div id="content"> - <div class="box"> - <div class="boxtitle" id="ArticleTitle">Welcome</div> - <div class="boxcontent" id="article"> - <div id="articlecontent" style="display:block"> - <br /><br /> - Verz\xF6gerung - </div> - <div id="loadingArticle" style="display:none"><img src="ajax-loader.gif" alt="Loading..."/></div> - </div> <!-- boxcontent --> - </div> <!-- box --> - </div><!-- content --> - - <!-- <div id="clear"></div> --> - -</div><!-- wrapper --> - </body> -</html> - \ No newline at end of file Deleted: trunk/src/dbpedia-navigator/xajaxtest.php =================================================================== --- trunk/src/dbpedia-navigator/xajaxtest.php 2008-02-05 11:43:54 UTC (rev 494) +++ trunk/src/dbpedia-navigator/xajaxtest.php 2008-02-05 15:38:39 UTC (rev 495) @@ -1,17 +0,0 @@ -<?php -require_once ("xajax/xajax_core/xajax.inc.php"); -$xajax = new xajax(); -$xajax->configureMany(array('debug'=>true)); -$xajax->registerFunction('learnConcept'); -$xajax->processRequest(); - -function learnConcept() -{ - $start=microtime(true); - $client=new SoapClient("main.wsdl"); - $id=$client->generateID(); - $objResponse=new xajaxResponse(); - $objResponse->append("articlecontent","innerHTML",microtime(true)-$start); - return $objResponse; -} -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |