You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(120) |
Sep
(36) |
Oct
(116) |
Nov
(17) |
Dec
(44) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(143) |
Feb
(192) |
Mar
(74) |
Apr
(84) |
May
(105) |
Jun
(64) |
Jul
(49) |
Aug
(120) |
Sep
(159) |
Oct
(156) |
Nov
(51) |
Dec
(28) |
2009 |
Jan
(17) |
Feb
(55) |
Mar
(33) |
Apr
(57) |
May
(54) |
Jun
(28) |
Jul
(6) |
Aug
(16) |
Sep
(38) |
Oct
(30) |
Nov
(26) |
Dec
(52) |
2010 |
Jan
(7) |
Feb
(91) |
Mar
(65) |
Apr
(2) |
May
(14) |
Jun
(25) |
Jul
(38) |
Aug
(48) |
Sep
(80) |
Oct
(70) |
Nov
(75) |
Dec
(77) |
2011 |
Jan
(68) |
Feb
(53) |
Mar
(51) |
Apr
(35) |
May
(65) |
Jun
(101) |
Jul
(29) |
Aug
(230) |
Sep
(95) |
Oct
(49) |
Nov
(110) |
Dec
(63) |
2012 |
Jan
(41) |
Feb
(42) |
Mar
(25) |
Apr
(46) |
May
(51) |
Jun
(44) |
Jul
(45) |
Aug
(29) |
Sep
(12) |
Oct
(9) |
Nov
(17) |
Dec
(2) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(7) |
Apr
(16) |
May
(54) |
Jun
(27) |
Jul
(11) |
Aug
(5) |
Sep
(85) |
Oct
(27) |
Nov
(37) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(29) |
Mar
(5) |
Apr
(3) |
May
(22) |
Jun
(3) |
Jul
(4) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <sk...@us...> - 2008-02-27 12:45:06
|
Revision: 652 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=652&view=rev Author: sknappe Date: 2008-02-27 04:32:58 -0800 (Wed, 27 Feb 2008) Log Message: ----------- modified style of menu a bit Modified Paths: -------------- trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-02-27 12:03:57 UTC (rev 651) +++ trunk/src/dbpedia-navigator/index.php 2008-02-27 12:32:58 UTC (rev 652) @@ -119,17 +119,19 @@ <div class="box" id="NavigationBox"> <div class="boxtitle">Navigate</div> <div class="boxcontent"> - <div id="treeboxbox_tree" style="width:250; height:218;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"> - <script> + <div id="treeboxbox_tree" style="height:218px;overflow:auto;"> + </div> + </div> <!-- boxcontent --> + </div> <!-- box --> + <script> tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); tree.setImagePath("<?php print $path;?>images/csh_bluebooks/"); + tree.enableCheckBoxes(1); tree.setXMLAutoLoading("processTreeMenu.php"); tree.loadXML("processTreeMenu.php?id=0"); - </script> - </div> - </div> <!-- boxcontent --> - </div> <!-- box --> - + </script> + + <div class="box" id="credits"> <p>DBpedia Navigator is powered by ... <br /> <a href="http://dl-learner.org">DL-Learner</a><br /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-27 12:05:23
|
Revision: 651 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=651&view=rev Author: sknappe Date: 2008-02-27 04:03:57 -0800 (Wed, 27 Feb 2008) Log Message: ----------- implemented a new tree menu (not yet finished) 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/images/csh_bluebooks/ trunk/src/dbpedia-navigator/images/csh_bluebooks/Thumbs.db trunk/src/dbpedia-navigator/images/csh_bluebooks/blank.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/book.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/book_titel.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/but_cut.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/folderClosed.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/folderOpen.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/iconCheckAll.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/iconCheckDis.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/iconCheckGray.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/iconChecked.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/iconSafe.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/iconText.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/iconUncheckAll.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/iconUncheckDis.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/leaf.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/line1.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/line1_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/line2.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/line2_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/line3.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/line3_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/line4.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/line4_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/lock.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/minus.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/minus2.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/minus2_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/minus3.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/minus3_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/minus4.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/minus4_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/minus5.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/minus5_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/plus.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/plus2.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/plus2_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/plus3.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/plus3_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/plus4.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/plus4_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/plus5.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/plus5_rtl.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/radio_off.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/radio_on.gif trunk/src/dbpedia-navigator/images/csh_bluebooks/tombs.gif trunk/src/dbpedia-navigator/processTreeMenu.php trunk/src/dbpedia-navigator/treemenu/ trunk/src/dbpedia-navigator/treemenu/dhtmlxcommon.js trunk/src/dbpedia-navigator/treemenu/dhtmlxtree.css trunk/src/dbpedia-navigator/treemenu/dhtmlxtree.js Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 11:39:21 UTC (rev 650) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-27 12:03:57 UTC (rev 651) @@ -137,7 +137,7 @@ $queryID=$this->client->sparqlQueryThreaded($this->id,$this->ksID,$query); $running=true; $i = 1; - $sleeptime = 1; + $sleeptime = 0.5; do { // sleep a while sleep($sleeptime); @@ -180,8 +180,7 @@ function getSubjectsFromConcept($concept) { $query="SELECT DISTINCT ?subject\n". - "WHERE { ?subject a <".$concept.">}\n". - "LIMIT 10"; + "WHERE { ?subject a <".$concept.">}\n"; $result=json_decode($this->getSparqlResult($query),true); if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result."); $ret=array(); @@ -191,6 +190,19 @@ return $ret; } + function getYagoSubCategories($category) + { + $query="SELECT DISTINCT ?subject\n". + "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#subClassOf> <".$category.">}\n"; + $result=json_decode($this->getSparqlResult($query),true); + if (count($result['results']['bindings'])==0) throw new Exception("Your query brought no result."); + $ret=array(); + foreach ($result['results']['bindings'] as $results){ + $ret[]=$results['subject']['value']; + } + return $ret; + } + public function loadWSDLfiles($wsdluri){ $main=DLLearnerConnection::getwsdl($wsdluri); $other=DLLearnerConnection::getOtherWSDL($main); Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-27 11:39:21 UTC (rev 650) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-27 12:03:57 UTC (rev 651) @@ -430,16 +430,14 @@ require_once("DLLearnerConnection.php"); $sc=new DLLearnerConnection($id,$ksID); $subjects=$sc->getSubjectsFromConcept($concept); - foreach ($subjects as $subject) - { - $content.="<a href=\"\" onclick=\"xajax_getarticle('".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($subject, "/"), 1)))."</a><br/>"; - } + $content.=getResultsTable($subjects); } catch (Exception $e){ $content=$e->getMessage(); } $objResponse = new xajaxResponse(); - $objResponse->assign("searchcontent", "innerHTML", $content); + $objResponse->assign("articlecontent", "innerHTML", $content); + $objResponse->assign("ArticleTitle", "innerHTML", "Search Results"); return $objResponse; } @@ -459,6 +457,37 @@ // Helper Functions. // /////////////////////// +function getResultsTable($results) +{ + $ret="<p>Your search brought ".count($results)." results.</p><br/>"; + $i=0; + $display="block"; + while($i*30<count($results)) + { + $ret.="<div id='results".$i."' style='display:".$display."'>Seite ".($i+1)."<br/><br/>"; + for ($j=0;($j<30)&&(($i*30+$j)<count($results));$j++) + { + $result=$results[$i*30+$j]; + $ret.=" <a href=\"\" onclick=\"xajax_getarticle('".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."',-2);return false;\">".urldecode(str_replace("_"," ",substr (strrchr ($result, "/"), 1)))."</a><br/>"; + } + $ret.="</div>"; + $i++; + $display="none"; + } + $ret.="<br/><p style='width:100%;text-align:center;'>"; + for ($k=0;$k<$i;$k++){ + $ret.="<a href=\"\" onClick=\"showdiv('results".($k)."');"; + for ($l=0;$l<$i;$l++) + { + if ($l!=$k) $ret.="hidediv('results".$l."');"; + } + $ret.="return false;\">".($k+1)."</a>"; + if ($k!=($i-1)) $ret.=" | "; + } + $ret.="</p>"; + return $ret; +} + function setRunning($id,$running) { if(!is_dir("temp")) mkdir("temp"); @@ -517,7 +546,7 @@ } function formatClassArray($ar) { - $string = formatClass($ar[0]); + $string = formatClass($ar[0]['value']); for($i=1; $i<count($ar); $i++) { $string .= ', ' . formatClass($ar[$i]['value']); } Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/Thumbs.db =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/Thumbs.db ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/blank.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/blank.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/book.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/book.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/book_titel.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/book_titel.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/but_cut.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/but_cut.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/folderClosed.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/folderClosed.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/folderOpen.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/folderOpen.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconCheckAll.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconCheckAll.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconCheckDis.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconCheckDis.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconCheckGray.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconCheckGray.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconChecked.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconChecked.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconSafe.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconSafe.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconText.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconText.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconUncheckAll.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconUncheckAll.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconUncheckDis.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/iconUncheckDis.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/leaf.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/leaf.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/line1.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/line1.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/line1_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/line1_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/line2.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/line2.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/line2_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/line2_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/line3.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/line3.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/line3_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/line3_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/line4.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/line4.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/line4_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/line4_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/lock.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/lock.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus2.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus2.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus2_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus2_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus3.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus3.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus3_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus3_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus4.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus4.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus4_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus4_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus5.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus5.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus5_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/minus5_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus2.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus2.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus2_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus2_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus3.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus3.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus3_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus3_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus4.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus4.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus4_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus4_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus5.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus5.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus5_rtl.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/plus5_rtl.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/radio_off.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/radio_off.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/radio_on.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/radio_on.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/src/dbpedia-navigator/images/csh_bluebooks/tombs.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/csh_bluebooks/tombs.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-02-27 11:39:21 UTC (rev 650) +++ trunk/src/dbpedia-navigator/index.php 2008-02-27 12:03:57 UTC (rev 651) @@ -18,14 +18,15 @@ $settings=new Settings(); //what happens onLoad -$onload=""; +$onLoad="onLoad=\""; if (isset($_GET['resource'])){ - $onLoad.="onLoad=\"xajax_getarticle('".$_GET['resource']."',-1);return false;\""; + $onLoad.="xajax_getarticle('".$_GET['resource']."',-1);"; unset($_GET['resource']); } else if (isset($_SESSION['currentArticle'])){ - $onLoad.="onLoad=\"xajax_getarticle('',".$_SESSION['currentArticle'].");return false;\""; + $onLoad.="xajax_getarticle('',".$_SESSION['currentArticle'].");"; } +$onLoad.="\""; require("ajax.php"); @@ -39,10 +40,13 @@ <title>DBpedia Navigator</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <link rel="stylesheet" href="<?php print $path;?>default.css"/> + <link rel="stylesheet" type="text/css" href="<?php print $path;?>treemenu/dhtmlxtree.css"> <?php $xajax->printJavascript($path.'xajax/'); ?> <script src="http://maps.google.com/maps?file=api&v=2&key=<?php print $settings->googleMapsKey;?>" type="text/javascript"></script> - <script type="text/javascript"> + <script src="<?php print $path;?>treemenu/dhtmlxcommon.js"></script> + <script src="<?php print $path;?>treemenu/dhtmlxtree.js"></script> + <script type="text/javascript"> showLoading = function() { xajax.$('Loading').style.display='inline'; }; @@ -111,6 +115,20 @@ <div id="searchcontent" style="display:block"></div> </div> <!-- boxcontent --> </div> <!-- box --> + + <div class="box" id="NavigationBox"> + <div class="boxtitle">Navigate</div> + <div class="boxcontent"> + <div id="treeboxbox_tree" style="width:250; height:218;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"> + <script> + tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); + tree.setImagePath("<?php print $path;?>images/csh_bluebooks/"); + tree.setXMLAutoLoading("processTreeMenu.php"); + tree.loadXML("processTreeMenu.php?id=0"); + </script> + </div> + </div> <!-- boxcontent --> + </div> <!-- box --> <div class="box" id="credits"> <p>DBpedia Navigator is powered by ... <br /> Added: trunk/src/dbpedia-navigator/processTreeMenu.php =================================================================== --- trunk/src/dbpedia-navigator/processTreeMenu.php (rev 0) +++ trunk/src/dbpedia-navigator/processTreeMenu.php 2008-02-27 12:03:57 UTC (rev 651) @@ -0,0 +1,21 @@ +<?php header("Content-type:text/xml"); print("<?xml version=\"1.0\"?>"); +if (isset($_GET["id"])) + $url_var=$_GET["id"]; +else + $url_var=0; + + + +print("<tree id='".$url_var."'>"); + if (!$url_var) print("<item child=\"1\" id=\"http://dbpedia.org/class/yago/Entity100001740\" text=\"Entity\"><userdata name='ud_block'>ud_data</userdata></item>"); + else{ + require_once("DLLearnerConnection.php"); + $sc=new DLLearnerConnection(); + $ids=$sc->getIDs(); + $sc=new DLLearnerConnection($ids[0],$ids[1]); + $categories=$sc->getYagoSubCategories($url_var); + foreach ($categories as $category) + print("<item child=\"1\" id=\"".$category."\" text=\"".substr (strrchr ($category, "/"), 1)."\"><userdata name='ud_block'>ud_data</userdata></item>"); + } +print("</tree>"); +?> Added: trunk/src/dbpedia-navigator/treemenu/dhtmlxcommon.js =================================================================== --- trunk/src/dbpedia-navigator/treemenu/dhtmlxcommon.js (rev 0) +++ trunk/src/dbpedia-navigator/treemenu/dhtmlxcommon.js 2008-02-27 12:03:57 UTC (rev 651) @@ -0,0 +1,51 @@ +//v.1.6 build 71114 + +/* +Copyright DHTMLX LTD. http://www.dhtmlx.com +You allowed to use this component or parts of it under GPL terms +To use it on other terms or get Professional edition of the component please contact us at sa...@dh... +*/ + +function dtmlXMLLoaderObject(funcObject, dhtmlObject,async,rSeed){this.xmlDoc="";if (typeof(async)!= "undefined") + this.async = async;else this.async = true;this.onloadAction=funcObject||null;this.mainObject=dhtmlObject||null;this.waitCall=null;this.rSeed=rSeed||false;return this};dtmlXMLLoaderObject.prototype.waitLoadFunction=function(dhtmlObject){var once=true;this.check=function (){if ((dhtmlObject)&&(dhtmlObject.onloadAction!=null)){if ((!dhtmlObject.xmlDoc.readyState)||(dhtmlObject.xmlDoc.readyState == 4)){if (!once)return;once=false;dhtmlObject.onloadAction(dhtmlObject.mainObject,null,null,null,dhtmlObject);if (dhtmlObject.waitCall){dhtmlObject.waitCall();dhtmlObject.waitCall=null}}}};return this.check};dtmlXMLLoaderObject.prototype.getXMLTopNode=function(tagName,oldObj){if (this.xmlDoc.responseXML){var temp=this.xmlDoc.responseXML.getElementsByTagName(tagName);var z=temp[0]}else + var z=this.xmlDoc.documentElement;if (z){this._retry=false;return z};if ((_isIE)&&(!this._retry)){var xmlString=this.xmlDoc.responseText;var oldObj=this.xmlDoc;this._retry=true;this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");this.xmlDoc.async=false;this.xmlDoc["loadXM"+"L"](xmlString);return this.getXMLTopNode(tagName,oldObj)};dhtmlxError.throwError("LoadXML","Incorrect XML",[(oldObj||this.xmlDoc),this.mainObject]);return document.createElement("DIV")};dtmlXMLLoaderObject.prototype.loadXMLString=function(xmlString){if (_isKHTML){var z=document.createElement('div');z.innerHTML = xmlString;this.xmlDoc=z;z.responseXML=z}else + {try + {var parser = new DOMParser();this.xmlDoc = parser.parseFromString(xmlString,"text/xml")}catch(e){this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");this.xmlDoc.async=this.async;this.xmlDoc["loadXM"+"L"](xmlString)}};this.onloadAction(this.mainObject,null,null,null,this);if (this.waitCall){this.waitCall();this.waitCall=null}};dtmlXMLLoaderObject.prototype.loadXML=function(filePath,postMode,postVars,rpc){if (this.rSeed)filePath+=((filePath.indexOf("?")!=-1)?"&":"?")+"a_dhx_rSeed="+(new Date()).valueOf();this.filePath=filePath;if ((!_isIE)&&(window.XMLHttpRequest)) + this.xmlDoc = new XMLHttpRequest();else{if (document.implementation && document.implementation.createDocument){this.xmlDoc = document.implementation.createDocument("", "", null);this.xmlDoc.onload = new this.waitLoadFunction(this);this.xmlDoc.load(filePath);return}else + this.xmlDoc = new ActiveXObject("Microsoft.XMLHTTP")};this.xmlDoc.open(postMode?"POST":"GET",filePath,this.async);if (rpc){this.xmlDoc.setRequestHeader("User-Agent", "dhtmlxRPC v0.1 (" + navigator.userAgent + ")");this.xmlDoc.setRequestHeader("Content-type", "text/xml")}else + if (postMode)this.xmlDoc.setRequestHeader('Content-type','application/x-www-form-urlencoded');this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);this.xmlDoc.send(null||postVars)};dtmlXMLLoaderObject.prototype.destructor=function(){this.onloadAction=null;this.mainObject=null;this.xmlDoc=null;return null};function callerFunction(funcObject,dhtmlObject){this.handler=function(e){if (!e)e=window.event;funcObject(e,dhtmlObject);return true};return this.handler};function getAbsoluteLeft(htmlObject){var xPos = htmlObject.offsetLeft;var temp = htmlObject.offsetParent;while (temp != null){xPos += temp.offsetLeft;temp = temp.offsetParent};return xPos};function getAbsoluteTop(htmlObject) {var yPos = htmlObject.offsetTop;var temp = htmlObject.offsetParent;while (temp != null){yPos += temp.offsetTop;temp = temp.offsetParent};return yPos};function convertStringToBoolean(inputString){if (typeof(inputString)=="string") inputString=inputString.toLowerCase();switch(inputString){case "1": + case "true": + case "yes": + case "y": + case 1: + case true: + return true;break;default: return false}};function getUrlSymbol(str){if(str.indexOf("?")!=-1) + return "&" + else + return "?" + };function dhtmlDragAndDropObject(){if (window.dhtmlDragAndDrop)return window.dhtmlDragAndDrop;this.lastLanding=0;this.dragNode=0;this.dragStartNode=0;this.dragStartObject=0;this.tempDOMU=null;this.tempDOMM=null;this.waitDrag=0;window.dhtmlDragAndDrop=this;return this};dhtmlDragAndDropObject.prototype.removeDraggableItem=function(htmlNode){htmlNode.onmousedown=null;htmlNode.dragStarter=null;htmlNode.dragLanding=null};dhtmlDragAndDropObject.prototype.addDraggableItem=function(htmlNode,dhtmlObject){htmlNode.onmousedown=this.preCreateDragCopy;htmlNode.dragStarter=dhtmlObject;this.addDragLanding(htmlNode,dhtmlObject)};dhtmlDragAndDropObject.prototype.addDragLanding=function(htmlNode,dhtmlObject){htmlNode.dragLanding=dhtmlObject};dhtmlDragAndDropObject.prototype.preCreateDragCopy=function(e) + {if (window.dhtmlDragAndDrop.waitDrag){window.dhtmlDragAndDrop.waitDrag=0;document.body.onmouseup=window.dhtmlDragAndDrop.tempDOMU;document.body.onmousemove=window.dhtmlDragAndDrop.tempDOMM;return false};window.dhtmlDragAndDrop.waitDrag=1;window.dhtmlDragAndDrop.tempDOMU=document.body.onmouseup;window.dhtmlDragAndDrop.tempDOMM=document.body.onmousemove;window.dhtmlDragAndDrop.dragStartNode=this;window.dhtmlDragAndDrop.dragStartObject=this.dragStarter;document.body.onmouseup=window.dhtmlDragAndDrop.preCreateDragCopy;document.body.onmousemove=window.dhtmlDragAndDrop.callDrag;if ((e)&&(e.preventDefault)) {e.preventDefault();return false};return false};dhtmlDragAndDropObject.prototype.callDrag=function(e){if (!e)e=window.event;dragger=window.dhtmlDragAndDrop;if ((e.button==0)&&(_isIE)) return dragger.stopDrag();if (!dragger.dragNode){dragger.dragNode=dragger.dragStartObject._createDragNode(dragger.dragStartNode,e);if (!dragger.dragNode)return dragger.stopDrag();dragger.gldragNode=dragger.dragNode;document.body.appendChild(dragger.dragNode);document.body.onmouseup=dragger.stopDrag;dragger.waitDrag=0;dragger.dragNode.pWindow=window;dragger.initFrameRoute()};if (dragger.dragNode.parentNode!=window.document.body){var grd=dragger.gldragNode;if (dragger.gldragNode.old)grd=dragger.gldragNode.old;grd.parentNode.removeChild(grd);var oldBody=dragger.dragNode.pWindow;if (_isIE){var div=document.createElement("Div");div.innerHTML=dragger.dragNode.outerHTML;dragger.dragNode=div.childNodes[0]}else dragger.dragNode=dragger.dragNode.cloneNode(true);dragger.dragNode.pWindow=window;dragger.gldragNode.old=dragger.dragNode;document.body.appendChild(dragger.dragNode);oldBody.dhtmlDragAndDrop.dragNode=dragger.dragNode};dragger.dragNode.style.left=e.clientX+15+(dragger.fx?dragger.fx*(-1):0)+(document.body.scrollLeft||document.documentElement.scrollLeft)+"px";dragger.dragNode.style.top=e.clientY+3+(dragger.fy?dragger.fy*(-1):0)+(document.body.scrollTop||document.documentElement.scrollTop)+"px";if (!e.srcElement)var z=e.target;else z=e.srcElement;dragger.checkLanding(z,e)};dhtmlDragAndDropObject.prototype.calculateFramePosition=function(n){if (window.name){var el =parent.frames[window.name].frameElement.offsetParent;var fx=0;var fy=0;while (el){fx += el.offsetLeft;fy += el.offsetTop;el = el.offsetParent};if ((parent.dhtmlDragAndDrop)) {var ls=parent.dhtmlDragAndDrop.calculateFramePosition(1);fx+=ls.split('_')[0]*1;fy+=ls.split('_')[1]*1};if (n)return fx+"_"+fy;else this.fx=fx;this.fy=fy};return "0_0"};dhtmlDragAndDropObject.prototype.checkLanding=function(htmlObject,e){if ((htmlObject)&&(htmlObject.dragLanding)) {if (this.lastLanding)this.lastLanding.dragLanding._dragOut(this.lastLanding);this.lastLanding=htmlObject;this.lastLanding=this.lastLanding.dragLanding._dragIn(this.lastLanding,this.dragStartNode,e.clientX, e.clientY,e);this.lastLanding_scr=(_isIE?e.srcElement:e.target)}else {if ((htmlObject)&&(htmlObject.tagName!="BODY")) this.checkLanding(htmlObject.parentNode,e);else {if (this.lastLanding)this.lastLanding.dragLanding._dragOut(this.lastLanding,e.clientX, e.clientY,e);this.lastLanding=0;if (this._onNotFound)this._onNotFound()}}};dhtmlDragAndDropObject.prototype.stopDrag=function(e,mode){dragger=window.dhtmlDragAndDrop;if (!mode){dragger.stopFrameRoute();var temp=dragger.lastLanding;dragger.lastLanding=null;if (temp)temp.dragLanding._drag(dragger.dragStartNode,dragger.dragStartObject,temp,(_isIE?event.srcElement:e.target))};dragger.lastLanding=null;if ((dragger.dragNode)&&(dragger.dragNode.parentNode==document.body)) dragger.dragNode.parentNode.removeChild(dragger.dragNode);dragger.dragNode=0;dragger.gldragNode=0;dragger.fx=0;dragger.fy=0;dragger.dragStartNode=0;dragger.dragStartObject=0;document.body.onmouseup=dragger.tempDOMU;document.body.onmousemove=dragger.tempDOMM;dragger.tempDOMU=null;dragger.tempDOMM=null;dragger.waitDrag=0};dhtmlDragAndDropObject.prototype.stopFrameRoute=function(win){if (win)window.dhtmlDragAndDrop.stopDrag(1,1);for (var i=0;i<window.frames.length;i++)if ((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop)) + window.frames[i].dhtmlDragAndDrop.stopFrameRoute(window);if ((parent.dhtmlDragAndDrop)&&(parent!=window)&&(parent!=win)) + parent.dhtmlDragAndDrop.stopFrameRoute(window)};dhtmlDragAndDropObject.prototype.initFrameRoute=function(win,mode){if (win){window.dhtmlDragAndDrop.preCreateDragCopy();window.dhtmlDragAndDrop.dragStartNode=win.dhtmlDragAndDrop.dragStartNode;window.dhtmlDragAndDrop.dragStartObject=win.dhtmlDragAndDrop.dragStartObject;window.dhtmlDragAndDrop.dragNode=win.dhtmlDragAndDrop.dragNode;window.dhtmlDragAndDrop.gldragNode=win.dhtmlDragAndDrop.dragNode;window.document.body.onmouseup=window.dhtmlDragAndDrop.stopDrag;window.waitDrag=0;if (((!_isIE)&&(mode))&&((!_isFF)||(_FFrv<1.8))) + window.dhtmlDragAndDrop.calculateFramePosition()};if ((parent.dhtmlDragAndDrop)&&(parent!=window)&&(parent!=win)) + parent.dhtmlDragAndDrop.initFrameRoute(window);for (var i=0;i<window.frames.length;i++)if ((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop)) + window.frames[i].dhtmlDragAndDrop.initFrameRoute(window,((!win||mode)?1:0))};var _isFF=false;var _isIE=false;var _isOpera=false;var _isKHTML=false;var _isMacOS=false;if (navigator.userAgent.indexOf('Macintosh')!= -1) _isMacOS=true;if ((navigator.userAgent.indexOf('Safari')!= -1)||(navigator.userAgent.indexOf('Konqueror')!= -1)) + _isKHTML=true;else if (navigator.userAgent.indexOf('Opera')!= -1){_isOpera=true;_OperaRv=parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Opera')+6,3))}else if(navigator.appName.indexOf("Microsoft")!=-1) + _isIE=true;else {_isFF=true;var _FFrv=parseFloat(navigator.userAgent.split("rv:")[1]) + };function isIE(){if(navigator.appName.indexOf("Microsoft")!=-1) + if (navigator.userAgent.indexOf('Opera')== -1) + return true;return false};dtmlXMLLoaderObject.prototype.doXPath = function(xpathExp,docObj){if ((_isOpera)||(_isKHTML)) return this.doXPathOpera(xpathExp,docObj);if(_isIE){if(!docObj)if(!this.xmlDoc.nodeName)docObj = this.xmlDoc.responseXML + else + docObj = this.xmlDoc;return docObj.selectNodes(xpathExp)}else{var nodeObj = docObj;if(!docObj){if(!this.xmlDoc.nodeName){docObj = this.xmlDoc.responseXML + }else{docObj = this.xmlDoc}};if(docObj.nodeName.indexOf("document")!=-1){nodeObj = docObj}else{nodeObj = docObj;docObj = docObj.ownerDocument};var rowsCol = new Array();var col = docObj.evaluate(xpathExp, nodeObj, null, XPathResult.ANY_TYPE,null);var thisColMemb = col.iterateNext();while (thisColMemb){rowsCol[rowsCol.length] = thisColMemb;thisColMemb = col.iterateNext()};return rowsCol}};function _dhtmlxError(type,name,params){if (!this.catches)this.catches=new Array();return this};_dhtmlxError.prototype.catchError=function(type,func_name){this.catches[type]=func_name};_dhtmlxError.prototype.throwError=function(type,name,params){if (this.catches[type])return this.catches[type](type,name,params);if (this.catches["ALL"])return this.catches["ALL"](type,name,params);alert("Error type: " + arguments[0]+"\nDescription: " + arguments[1] );return null};window.dhtmlxError=new _dhtmlxError();dtmlXMLLoaderObject.prototype.doXPathOpera = function(xpathExp,docObj){var z=xpathExp.replace(/[\/]+/gi,"/").split('/');var obj=null;var i=1;if (!z.length)return [];if (z[0]==".")obj=[docObj];else if (z[0]==""){obj=this.xmlDoc.responseXML.getElementsByTagName(z[i].replace(/\[[^\]]*\]/g,""));i++}else return [];for (i;i<z.length;i++)obj=this._getAllNamedChilds(obj,z[i]);if (z[i-1].indexOf("[")!=-1) + obj=this._filterXPath(obj,z[i-1]);return obj};dtmlXMLLoaderObject.prototype._filterXPath = function(a,b){var c=new Array();var b=b.replace(/[^\[]*\[\@/g,"").replace(/[\[\]\@]*/g,"");for (var i=0;i<a.length;i++)if (a[i].getAttribute(b)) + c[c.length]=a[i];return c};dtmlXMLLoaderObject.prototype._getAllNamedChilds = function(a,b){var c=new Array();if (_isKHTML)b=b.toUpperCase();for (var i=0;i<a.length;i++)for (var j=0;j<a[i].childNodes.length;j++){if (_isKHTML){if (a[i].childNodes[j].tagName && a[i].childNodes[j].tagName.toUpperCase()==b) + c[c.length]=a[i].childNodes[j]}else + if (a[i].childNodes[j].tagName==b)c[c.length]=a[i].childNodes[j]};return c};function dhtmlXHeir(a,b){for (c in b)if (typeof(b[c])=="function") a[c]=b[c];return a};function dhtmlxEvent(el,event,handler){if (el.addEventListener)el.addEventListener(event,handler,false);else if (el.attachEvent)el.attachEvent("on"+event,handler)}; +//v.1.6 build 71114 + +/* +Copyright DHTMLX LTD. http://www.dhtmlx.com +You allowed to use this component or parts of it under GPL terms +To use it on other terms or get Professional edition of the component please contact us at sa...@dh... +*/ \ No newline at end of file Added: trunk/src/dbpedia-navigator/treemenu/dhtmlxtree.css =================================================================== --- trunk/src/dbpedia-navigator/treemenu/dhtmlxtree.css (rev 0) +++ trunk/src/dbpedia-navigator/treemenu/dhtmlxtree.css 2008-02-27 12:03:57 UTC (rev 651) @@ -0,0 +1,61 @@ +.defaultTreeTable{ + margin : 0px; + padding : 0px; + border : 0px; +} +.containerTableStyle { overflow : auto; position:relative; top:0; font-size : 12px;} +.containerTableStyleRTL span { direction: rtl; unicode-bidi: bidi-override; } +.containerTableStyleRTL { direction: rtl; overflow : auto; position:relative; top:0; font-size : 12px;} +.standartTreeRow{ font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-size : 12px; -moz-user-select: none; } +.selectedTreeRow{ background-color : navy; color:white; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-size : 12px; -moz-user-select: none; } +.dragAndDropRow{ background-color : navy; color:white; } +.standartTreeRow_lor{ text-decoration:underline; background-color : #FFFFF0; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-size : 12px; -moz-user-select: none; } +.selectedTreeRow_lor{ text-decoration:underline; background-color : navy; color:white; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-size : 12px; -moz-user-select: none; } + +.standartTreeImage{ width:18px; height:18px; overflow:hidden; border:0; padding:0; margin:0; +font-size:1px; } +.hiddenRow { width:1px; overflow:hidden; } +.dragSpanDiv,.dragSpanDiv td{ font-size : 12px; background-color:white; } + + +.selectionBox{ +background-color: #FFFFCC; +} +.selectionBar { + top:0; + background-color: Black; + position:absolute; + overflow:hidden; + height: 2px; + z-index : 11; +} + +.intreeeditRow{ + width:100%; font-size:8pt; height:16px; border:1px solid silver; padding:0; margin:0; + -moz-user-select: text; +} +.dhx_tree_textSign{ + font-size:8pt; + font-family:monospace; + width:21px; + color:black; + padding:0px; + margin:0px; + cursor:pointer; + text-align: center; +} +.dhx_tree_opacity{ + opacity:0; + -moz-opacity:0; + filter:alpha(opacity=0); +} +.dhx_bg_img_fix{ +width:18px; +height:18px; +background-repeat: no-repeat; +background-position: center; +background-position-x: center; +background-position-y: center; +} + + Added: trunk/src/dbpedia-navigator/treemenu/dhtmlxtree.js =================================================================== --- trunk/src/dbpedia-navigator/treemenu/dhtmlxtree.js (rev 0) +++ trunk/src/dbpedia-navigator/treemenu/dhtmlxtree.js 2008-02-27 12:03:57 UTC (rev 651) @@ -0,0 +1,188 @@ +//v.1.6 build 71114 + +/* +Copyright DHTMLX LTD. http://www.dhtmlx.com +You allowed to use this component or parts of it under GPL terms +To use it on other terms or get Professional edition of the component please contact us at sa...@dh... +*/ + + +function xmlPointer(data){this.d=data};xmlPointer.prototype={text:function(){if (!_isFF)return this.d.xml;var x = new XMLSerializer();return x.serializeToString(this.d)}, + get:function(name){return this.d.getAttribute(name)}, + exists:function(){return !!this.d }, + content:function(){return this.d.firstChild?this.d.firstChild.data:""}, + each:function(name,f,t,i){var a=this.d.childNodes;var c=new xmlPointer();if (a.length)for (i=i||0;i<a.length;i++)if (a[i].tagName==name){c.d=a[i];if(f.apply(t,[c,i])==-1) return}}, + get_all:function(){var a={};var b=this.d.attributes;for (var i=0;i<b.length;i++)a[b[i].name]=b[i].value;return a}, + sub:function(name){var a=this.d.childNodes;var c=new xmlPointer();if (a.length)for (var i=0;i<a.length;i++)if (a[i].tagName==name){c.d=a[i];return c}}, + up:function(name){return new xmlPointer(this.d.parentNode)}, + set:function(name,val){this.d.setAttribute(name,val)}, + clone:function(name){return new xmlPointer(this.d)}, + sub_exists:function(name){var a=this.d.childNodes;if (a.length)for (var i=0;i<a.length;i++)if (a[i].tagName==name)return true;return false}, + through:function(name,rule,v,f,t){var a=this.d.childNodes;if (a.length)for (var i=0;i<a.length;i++){if (a[i].tagName==name && a[i].getAttribute(rule)!=null && a[i].getAttribute(rule)!="" && (!v || a[i].getAttribute(rule)==v )) {var c=new xmlPointer(a[i]);f.apply(t,[c,i])};var w=this.d;this.d=a[i];this.through(name,rule,v,f,t);this.d=w}}};function dhtmlXTreeObject(htmlObject, width, height, rootId){if (_isIE)try {document.execCommand("BackgroundImageCache", false, true)}catch (e){};if (typeof(htmlObject)!="object") + this.parentObject=document.getElementById(htmlObject);else + this.parentObject=htmlObject;this._itim_dg=true;this.dlmtr=",";this.dropLower=false;this.enableIEImageFix();this.xmlstate=0;this.mytype="tree";this.smcheck=true;this.width=width;this.height=height;this.rootId=rootId;this.childCalc=null;this.def_img_x="18px";this.def_img_y="18px";this.def_line_img_x="18px";this.def_line_img_y="18px";this._dragged=new Array();this._selected=new Array();this.style_pointer="pointer";if (_isIE)this.style_pointer="hand";this._aimgs=true;this.htmlcA=" [";this.htmlcB="]";this.lWin=window;this.cMenu=0;this.mlitems=0;this.dadmode=0;this.slowParse=false;this.autoScroll=true;this.hfMode=0;this.nodeCut=new Array();this.XMLsource=0;this.XMLloadingWarning=0;this._idpull={};this._pullSize=0;this.treeLinesOn=true;this.tscheck=false;this.timgen=true;this.dpcpy=false;this._ld_id=null;this._oie_onXLE=[];this.imPath="treeGfx/";this.checkArray=new Array("iconUncheckAll.gif","iconCheckAll.gif","iconCheckGray.gif","iconUncheckDis.gif","iconCheckDis.gif","iconCheckDis.gif");this.radioArray=new Array("radio_off.gif","radio_on.gif","radio_on.gif","radio_off.gif","radio_on.gif","radio_on.gif");this.lineArray=new Array("line2.gif","line3.gif","line4.gif","blank.gif","blank.gif","line1.gif");this.minusArray=new Array("minus2.gif","minus3.gif","minus4.gif","minus.gif","minus5.gif");this.plusArray=new Array("plus2.gif","plus3.gif","plus4.gif","plus.gif","plus5.gif");this.imageArray=new Array("leaf.gif","folderOpen.gif","folderClosed.gif");this.cutImg= new Array(0,0,0);this.cutImage="but_cut.gif";this.dragger= new dhtmlDragAndDropObject();this.htmlNode=new dhtmlXTreeItemObject(this.rootId,"",0,this);this.htmlNode.htmlNode.childNodes[0].childNodes[0].style.display="none";this.htmlNode.htmlNode.childNodes[0].childNodes[0].childNodes[0].className="hiddenRow";this.allTree=this._createSelf();this.allTree.appendChild(this.htmlNode.htmlNode);if(_isFF)this.allTree.childNodes[0].width="100%";var self=this;this.allTree.onselectstart=new Function("return false;");if (_isMacOS)this.allTree.oncontextmenu = function(e){return self._doContClick(e||window.event)};this.allTree.onmousedown = function(e){return self._doContClick(e||window.event)};this.XMLLoader=new dtmlXMLLoaderObject(this._parseXMLTree,this,true,this.no_cashe);if (_isIE)this.preventIECashing(true);if (window.addEventListener)window.addEventListener("unload",function(){try{self.destructor()}catch(e){}},false);if (window.attachEvent)window.attachEvent("onunload",function(){try{self.destructor()}catch(e){}});this.dhx_Event();this._onEventSet={onMouseIn:function(){this.ehlt=true},onMouseOut:function(){this.ehlt=true},onSelect:function(){this._onSSCF=true}};return this};dhtmlXTreeObject.prototype.setDataMode=function(mode){this._datamode=mode};dhtmlXTreeObject.prototype._doContClick=function(ev){if (ev.button!=2){if(this._acMenu)this.cMenu._contextEnd();return true};var el=(_isIE?ev.srcElement:ev.target);while ((el)&&(el.tagName!="BODY")) {if (el.parentObject)break;el=el.parentNode};if ((!el)||(!el.parentObject)) return true;var obj=el.parentObject;this._acMenu=(obj.cMenu||this.cMenu);if (this._acMenu){el.contextMenuId=obj.id;el.contextMenu=this._acMenu;el.a=this._acMenu._contextStart;if (_isIE)ev.srcElement.oncontextmenu = function(){event.cancelBubble=true;return false};el.a(el,ev);el.a=null;ev.cancelBubble=true;return false};return true};dhtmlXTreeObject.prototype.enableIEImageFix=function(mode){if (!mode){this._getImg=function(id){return document.createElement((id==this.rootId)?"div":"img")};this._setSrc=function(a,b){a.src=b};this._getSrc=function(a){return a.src}}else {this._getImg=function(){var z=document.createElement("DIV");z.innerHTML=" ";z.className="dhx_bg_img_fix";return z};this._setSrc=function(a,b){a.style.backgroundImage="url("+b+")"};this._getSrc=function(a){var z=a.style.backgroundImage;return z.substr(4,z.length-5)}}};dhtmlXTreeObject.prototype.destructor=function(){for (var a in this._idpull){var z=this._idpull[a];if (!z)continue;z.parentObject=null;z.treeNod=null;z.childNodes=null;z.span=null;z.tr.nodem=null;z.tr=null;z.htmlNode.objBelong=null;z.htmlNode=null;this._idpull[a]=null};this.allTree.innerHTML="";this.XMLLoader.destructor();for(var a in this){this[a]=null}};function cObject(){return this};cObject.prototype= new Object;cObject.prototype.clone = function () {function _dummy(){};_dummy.prototype=this;return new _dummy()};function dhtmlXTreeItemObject(itemId,itemText,parentObject,treeObject,actionHandler,mode){this.htmlNode="";this.acolor="";this.scolor="";this.tr=0;this.childsCount=0;this.tempDOMM=0;this.tempDOMU=0;this.dragSpan=0;this.dragMove=0;this.span=0;this.closeble=1;this.childNodes=new Array();this.userData=new cObject();this.checkstate=0;this.treeNod=treeObject;this.label=itemText;this.parentObject=parentObject;this.actionHandler=actionHandler;this.images=new Array(treeObject.imageArray[0],treeObject.imageArray[1],treeObject.imageArray[2]);this.id=treeObject._globalIdStorageAdd(itemId,this);if (this.treeNod.checkBoxOff )this.htmlNode=this.treeNod._createItem(1,this,mode);else this.htmlNode=this.treeNod._createItem(0,this,mode);this.htmlNode.objBelong=this;return this};dhtmlXTreeObject.prototype._globalIdStorageAdd=function(itemId,itemObject){if (this._globalIdStorageFind(itemId,1,1)) {itemId=itemId +"_"+(new Date()).valueOf();return this._globalIdStorageAdd(itemId,itemObject)};this._idpull[itemId]=itemObject;this._pullSize++;return itemId};dhtmlXTreeObject.prototype._globalIdStorageSub=function(itemId){if (this._idpull[itemId]){this._unselectItem(this._idpull[itemId]);this._idpull[itemId]=null;this._pullSize--};if ((this._locker)&&(this._locker[itemId])) this._locker[itemId]=false};dhtmlXTreeObject.prototype._globalIdStorageFind=function(itemId,skipXMLSearch,skipParsing,isreparse){var z=this._idpull[itemId] + if (z){return z};return null};dhtmlXTreeObject.prototype._escape=function(str){switch(this.utfesc){case "none": + return str;break;case "utf8": + return encodeURI(str);break;default: + return escape(str);break}};dhtmlXTreeObject.prototype._drawNewTr=function(htmlObject,node) + {var tr =document.createElement('tr');var td1=document.createElement('td');var td2=document.createElement('td');td1.appendChild(document.createTextNode(" "));td2.colSpan=3;td2.appendChild(htmlObject);tr.appendChild(td1);tr.appendChild(td2);return tr};dhtmlXTreeObject.prototype.loadXMLString=function(xmlString,afterCall){var that=this;if (!this.parsCount)this.callEvent("onXLS",[that,null]);this.xmlstate=1;if (afterCall)this.XMLLoader.waitCall=afterCall;this.XMLLoader.loadXMLString(xmlString)};dhtmlXTreeObject.prototype.loadXML=function(file,afterCall){if (this._datamode && this._datamode!="xml")return this["load"+this._datamode.toUpperCase()](file,afterCall);var that=this;if (!this.parsCount)this.callEvent("onXLS",[that,this._ld_id]);this._ld_id=null;this.xmlstate=1;this.XMLLoader=new dtmlXMLLoaderObject(this._parseXMLTree,this,true,this.no_cashe);if (afterCall)this.XMLLoader.waitCall=afterCall;this.XMLLoader.loadXML(file)};dhtmlXTreeObject.prototype._attachChildNode=function(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs,beforeNode,afterNode){if (beforeNode && beforeNode.parentObject)parentObject=beforeNode.parentObject;if (((parentObject.XMLload==0)&&(this.XMLsource))&&(!this.XMLloadingWarning)) + {parentObject.XMLload=1;this._loadDynXML(parentObject.id)};var Count=parentObject.childsCount;var Nodes=parentObject.childNodes;if (afterNode){if (afterNode.tr.previousSibling.previousSibling){beforeNode=afterNode.tr.previousSibling.nodem}else + optionStr=optionStr.replace("TOP","")+",TOP"};if (beforeNode){var ik,jk;for (ik=0;ik<Count;ik++)if (Nodes[ik]==beforeNode){for (jk=Count;jk!=ik;jk--)Nodes[1+jk]=Nodes[jk];break};ik++;Count=ik};if (optionStr){var tempStr=optionStr.split(",");for (var i=0;i<tempStr.length;i++){switch(tempStr[i]) + {case "TOP": if (parentObject.childsCount>0){beforeNode=new Object;beforeNode.tr=parentObject.childNodes[0].tr.previousSibling};parentObject._has_top=true;for (ik=Count;ik>0;ik--)Nodes[ik]=Nodes[ik-1];Count=0;break}}};var n;if (!(n=this._idpull[itemId])|| n.span!=-1){n=Nodes[Count]=new dhtmlXTreeItemObject(itemId,itemText,parentObject,this,null,1);itemId = Nodes[Count].id;parentObject.childsCount++};if(!n.htmlNode){n.label=itemText;n.htmlNode=this._createItem((this.checkBoxOff?1:0),n);n.htmlNode.objBelong=n};if(image1)n.images[0]=image1;if(image2)n.images[1]=image2;if(image3)n.images[2]=image3;var tr=this._drawNewTr(n.htmlNode);if ((this.XMLloadingWarning)||(this._hAdI)) + n.htmlNode.parentNode.parentNode.style.display="none";if ((beforeNode)&&(beforeNode.tr.nextSibling)) + parentObject.htmlNode.childNodes[0].insertBefore(tr,beforeNode.tr.nextSibling);else + if (this.parsingOn==parentObject.id){this.parsedArray[this.parsedArray.length]=tr}else + parentObject.htmlNode.childNodes[0].appendChild(tr);if ((beforeNode)&&(!beforeNode.span)) beforeNode=null;if (this.XMLsource)if ((childs)&&(childs!=0)) n.XMLload=0;else n.XMLload=1;n.tr=tr;tr.nodem=n;if (parentObject.itemId==0)tr.childNodes[0].className="hiddenRow";if ((parentObject._r_logic)||(this._frbtr)) + this._setSrc(n.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0],this.imPath+this.radioArray[0]);if (optionStr){var tempStr=optionStr.split(",");for (var i=0;i<tempStr.length;i++){switch(tempStr[i]) + {case "SELECT": this.selectItem(itemId,false);break;case "CALL": this.selectItem(itemId,true);break;case "CHILD": n.XMLload=0;break;case "CHECKED": + if (this.XMLloadingWarning)this.setCheckList+=this.dlmtr+itemId;else + this.setCheck(itemId,1);break;case "HCHECKED": + this._setCheck(n,"unsure");break;case "OPEN": n.openMe=1;break}}};if (!this.XMLloadingWarning){if ((this._getOpenState(parentObject)<0)&&(!this._hAdI)) this.openItem(parentObject.id);if (beforeNode){this._correctPlus(beforeNode);this._correctLine(beforeNode)};this._correctPlus(parentObject);this._correctLine(parentObject);this._correctPlus(n);if (parentObject.childsCount>=2){this._correctPlus(Nodes[parentObject.childsCount-2]);this._correctLine(Nodes[parentObject.childsCount-2])};if (parentObject.childsCount!=2)this._correctPlus(Nodes[0]);if (this.tscheck)this._correctCheckStates(parentObject);if (this._onradh){if (this.xmlstate==1){var old=this.onXLE;this.onXLE=function(id){this._onradh(itemId);if (old)old(id)}}else + this._onradh(itemId)}};return n};dhtmlXTreeObject.prototype.insertNewItem=function(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children){var parentObject=this._globalIdStorageFind(parentId);if (!parentObject)return (-1);var nodez=this._attachChildNode(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children);return nodez};dhtmlXTreeObject.prototype.insertNewChild=function(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children){return this.insertNewItem(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,children)};dhtmlXTreeObject.prototype._parseXMLTree=function(a,b,c,d,xml){var p=new xmlPointer(xml.getXMLTopNode("tree"));a._parse(p);a._p=p};dhtmlXTreeObject.prototype._parseItem=function(c,temp,preNode,befNode){var id;if (this._srnd && (!this._idpull[id=c.get("id")] || !this._idpull[id].span)) + {this._addItemSRND(temp.id,id,c);return};var a=c.get_all();if ((typeof(this.waitUpdateXML)=="object")&&(!this.waitUpdateXML[a.id])){this._parse(c,a.id,1);return};var zST=[];if (a.select)zST.push("SELECT");if (a.top)zST.push("TOP");if (a.call)nodeAskingCall=a.id;if (a.checked==-1)zST.push("HCHECKED");else if (a.checked)zST.push("CHECKED");if (a.open)zST.push("OPEN");if (this.waitUpdateXML){if (this._globalIdStorageFind(a.id)) + var newNode=this.updateItem(a.id,a.text,a.im0,a.im1,a.im2,a.checked);else{if (this.npl==0)zST.push("TOP");else preNode=temp.childNodes[this.npl];var newNode=this._attachChildNode(temp,a.id,a.text,0,a.im0,a.im1,a.im2,zST.join(","),a.child,0,preNode);preNode=null}}else + var newNode=this._attachChildNode(temp,a.id,a.text,0,a.im0,a.im1,a.im2,zST.join(","),a.child,(befNode||0),preNode);if (a.tooltip)newNode.span.parentNode.parentNode.title=a.tooltip;if (a.style)if (newNode.span.style.cssText)newNode.span.style.cssText+=(";"+a.style);else + newNode.span.setAttribute("style",newNode.span.getAttribute("style")+";"+a.style);if (a.radio)newNode._r_logic=true;if (a.nocheckbox){newNode.span.parentNode.previousSibling.previousSibling.childNodes[0].style.display='none';newNode.nocheckbox=true};if (a.disabled){if (a.checked!=null)this._setCheck(newNode,convertStringToBoolean(a.checked));this.disableCheckbox(newNode,1)};newNode._acc=a.child||0;if (this.parserExtension)this.parserExtension._parseExtension(node.childNodes[i],this.parserExtension,a.id,parentId);this.setItemColor(newNode,a.aCol,a.sCol);if (a.locked=="1")this._lockItem(newNode,true,true);if ((a.imwidth)||(a.imheight)) this.setIconSize(a.imwidth,a.imheight,newNode);if ((a.closeable=="0")||(a.closeable=="1")) this.setItemCloseable(newNode,a.closeable);var zcall="";if (a.topoffset)this.setItemTopOffset(newNode,a.topoffset);if ((!this.slowParse)||(typeof(this.waitUpdateXML)=="object")){if (c.sub_exists("item")) + zcall=this._parse(c,a.id,1)};if (zcall!="")this.nodeAskingCall=zcall;c.each("userdata",function(u){this.setUserData(c.get("id"),u.get("name"),u.content())},this) + + + };dhtmlXTreeObject.prototype._parse=function(p,parentId,level,start){if (this._srnd && !this.parentObject.offsetHeight){var self=this;return window.setTimeout(function(){self._parse(p,parentId,level,start)},100)};if (!p.exists()) return;this.skipLock=true;this.parsCount=this.parsCount?(this.parsCount+1):1;this.XMLloadingWarning=1;this.nodeAskingCall="";if (!parentId){parentId=p.get("id");if (p.get("radio")) + this.htmlNode._r_logic=true;this.parsingOn=parentId;this.parsedArray=new Array();this.setCheckList=""};var temp=this._globalIdStorageFind(parentId);if (... [truncated message content] |
From: <jen...@us...> - 2008-02-27 11:39:23
|
Revision: 650 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=650&view=rev Author: jenslehmann Date: 2008-02-27 03:39:21 -0800 (Wed, 27 Feb 2008) Log Message: ----------- Subclipse Bug II Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/refinementoperators/ Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/operators/ Modified: trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-02-27 11:37:51 UTC (rev 649) +++ trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-02-27 11:39:21 UTC (rev 650) @@ -9,8 +9,8 @@ import org.dllearner.core.Score; import org.dllearner.core.owl.Description; import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.operators.PsiDown; -import org.dllearner.operators.PsiUp; +import org.dllearner.refinementoperators.PsiDown; +import org.dllearner.refinementoperators.PsiUp; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-27 11:37:51 UTC (rev 649) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-27 11:39:21 UTC (rev 650) @@ -43,7 +43,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.operators.RhoDown; +import org.dllearner.refinementoperators.RhoDown; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 11:37:51 UTC (rev 649) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 11:39:21 UTC (rev 650) @@ -42,7 +42,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.operators.RhoDown; +import org.dllearner.refinementoperators.RhoDown; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-27 11:37:51 UTC (rev 649) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-27 11:39:21 UTC (rev 650) @@ -32,7 +32,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.operators.RhoDown; +import org.dllearner.refinementoperators.RhoDown; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; Copied: trunk/src/dl-learner/org/dllearner/refinementoperators (from rev 649, trunk/src/dl-learner/org/dllearner/operators) Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/PsiDown.java 2008-02-27 11:37:51 UTC (rev 649) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java 2008-02-27 11:39:21 UTC (rev 650) @@ -1,4 +1,4 @@ -package org.dllearner.operators; +package org.dllearner.refinementoperators; import java.util.HashSet; import java.util.Iterator; Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/PsiUp.java 2008-02-27 11:37:51 UTC (rev 649) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java 2008-02-27 11:39:21 UTC (rev 650) @@ -1,4 +1,4 @@ -package org.dllearner.operators; +package org.dllearner.refinementoperators; import java.util.HashSet; import java.util.Iterator; Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/RhoDRDown.java 2008-02-27 11:37:51 UTC (rev 649) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2008-02-27 11:39:21 UTC (rev 650) @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -package org.dllearner.operators; +package org.dllearner.refinementoperators; import java.util.List; import java.util.Set; Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/RhoDown.java 2008-02-27 11:37:51 UTC (rev 649) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDown.java 2008-02-27 11:39:21 UTC (rev 650) @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -package org.dllearner.operators; +package org.dllearner.refinementoperators; import java.util.HashMap; import java.util.HashSet; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-27 11:37:54
|
Revision: 649 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=649&view=rev Author: jenslehmann Date: 2008-02-27 03:37:51 -0800 (Wed, 27 Feb 2008) Log Message: ----------- Subclipse Bug I Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/operators/PsiDown.java trunk/src/dl-learner/org/dllearner/operators/PsiUp.java trunk/src/dl-learner/org/dllearner/operators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/operators/RhoDown.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-02-27 11:27:52 UTC (rev 648) +++ trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-02-27 11:37:51 UTC (rev 649) @@ -9,8 +9,8 @@ import org.dllearner.core.Score; import org.dllearner.core.owl.Description; import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.refinementoperators.PsiDown; -import org.dllearner.refinementoperators.PsiUp; +import org.dllearner.operators.PsiDown; +import org.dllearner.operators.PsiUp; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-27 11:27:52 UTC (rev 648) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-27 11:37:51 UTC (rev 649) @@ -43,7 +43,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.refinementoperators.RhoDown; +import org.dllearner.operators.RhoDown; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 11:27:52 UTC (rev 648) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 11:37:51 UTC (rev 649) @@ -42,7 +42,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.refinementoperators.RhoDown; +import org.dllearner.operators.RhoDown; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-27 11:27:52 UTC (rev 648) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-27 11:37:51 UTC (rev 649) @@ -32,7 +32,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; -import org.dllearner.refinementoperators.RhoDown; +import org.dllearner.operators.RhoDown; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; Modified: trunk/src/dl-learner/org/dllearner/operators/PsiDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/PsiDown.java 2008-02-27 11:27:52 UTC (rev 648) +++ trunk/src/dl-learner/org/dllearner/operators/PsiDown.java 2008-02-27 11:37:51 UTC (rev 649) @@ -1,4 +1,4 @@ -package org.dllearner.refinementoperators; +package org.dllearner.operators; import java.util.HashSet; import java.util.Iterator; Modified: trunk/src/dl-learner/org/dllearner/operators/PsiUp.java =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/PsiUp.java 2008-02-27 11:27:52 UTC (rev 648) +++ trunk/src/dl-learner/org/dllearner/operators/PsiUp.java 2008-02-27 11:37:51 UTC (rev 649) @@ -1,4 +1,4 @@ -package org.dllearner.refinementoperators; +package org.dllearner.operators; import java.util.HashSet; import java.util.Iterator; Modified: trunk/src/dl-learner/org/dllearner/operators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/RhoDRDown.java 2008-02-27 11:27:52 UTC (rev 648) +++ trunk/src/dl-learner/org/dllearner/operators/RhoDRDown.java 2008-02-27 11:37:51 UTC (rev 649) @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -package org.dllearner.refinementoperators; +package org.dllearner.operators; import java.util.List; import java.util.Set; Modified: trunk/src/dl-learner/org/dllearner/operators/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/RhoDown.java 2008-02-27 11:27:52 UTC (rev 648) +++ trunk/src/dl-learner/org/dllearner/operators/RhoDown.java 2008-02-27 11:37:51 UTC (rev 649) @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -package org.dllearner.refinementoperators; +package org.dllearner.operators; import java.util.HashMap; import java.util.HashSet; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-27 11:27:56
|
Revision: 648 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=648&view=rev Author: jenslehmann Date: 2008-02-27 03:27:52 -0800 (Wed, 27 Feb 2008) Log Message: ----------- moved refinement operators to own package Added Paths: ----------- trunk/src/dl-learner/org/dllearner/operators/ trunk/src/dl-learner/org/dllearner/operators/PsiDown.java trunk/src/dl-learner/org/dllearner/operators/PsiUp.java trunk/src/dl-learner/org/dllearner/operators/RhoDRDown.java trunk/src/dl-learner/org/dllearner/operators/RhoDown.java Copied: trunk/src/dl-learner/org/dllearner/operators/PsiDown.java (from rev 639, trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiDown.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/PsiDown.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/operators/PsiDown.java 2008-02-27 11:27:52 UTC (rev 648) @@ -0,0 +1,245 @@ +package org.dllearner.refinementoperators; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import org.dllearner.algorithms.refinement.RefinementOperator; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.ObjectAllRestriction; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Nothing; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.Union; +import org.dllearner.core.owl.Negation; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectQuantorRestriction; +import org.dllearner.core.owl.Thing; +import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.utilities.ConceptComparator; + +/** + * Operatoren Psi-Down und Psi-Up müssen noch so umgeschrieben werden, dass sie + * nur konsistente Konzepte (mit korrekten parent-Links) enthalten. Dazu müssen + * alle verwendeten atomaren Konzepte geklont werden. + * + * Außerdem erscheint es ratsam weitere konzeptverkürzende Maßnahmen einzuführen, + * z.B. EXISTS r.A => BOTTOM für down bzw. TOP für up + * => Konzepte erreichen etwa eine Länge von 20 + * + * @author jl + * + */ +public class PsiDown implements RefinementOperator { + + ConceptComparator conceptComparator = new ConceptComparator(); + + PosNegLP learningProblem; + ReasoningService reasoningService; + + private TreeSet<Description> topSet; + + public PsiDown(PosNegLP learningProblem) { + this.learningProblem = learningProblem; + reasoningService = learningProblem.getReasoningService(); + + // Top-Menge erstellen + createTopSet(); + } + + private void createTopSet() { + topSet = new TreeSet<Description>(conceptComparator); + + // TOP OR TOP => Was soll mit Refinements passieren, die immer improper sind? + Union md = new Union(); + md.addChild(new Thing()); + md.addChild(new Thing()); + topSet.add(md); + + // allgemeinste Konzepte + topSet.addAll(reasoningService.getMoreSpecialConcepts(new Thing())); + + // negierte speziellste Konzepte + Set<Description> tmp = learningProblem.getReasoningService().getMoreGeneralConcepts(new Nothing()); + for(Description c : tmp) + topSet.add(new Negation(c)); + + // EXISTS r.TOP und ALL r.TOP für alle r + for(ObjectProperty r : reasoningService.getAtomicRoles()) { + topSet.add(new ObjectAllRestriction(r, new Thing())); + topSet.add(new ObjectSomeRestriction(r, new Thing())); + } + } + + @SuppressWarnings("unchecked") + public Set<Description> refine(Description concept) { + + Set<Description> refinements = new HashSet<Description>(); + Set<Description> tmp = new HashSet<Description>(); + + if (concept instanceof Thing) { + return (Set<Description>) topSet.clone(); + } else if (concept instanceof Nothing) { + // return new TreeSet<Concept>(conceptComparator); + return new HashSet<Description>(); + } else if (concept instanceof NamedClass) { + // beachte: die Funktion gibt bereits nur nicht-äquivalente Konzepte zurück + // beachte weiter: die zurückgegebenen Instanzen dürfen nicht verändert werden, + // da beim Caching der Subsumptionhierarchie (momentan) keine Kopien gemacht werden + // Bottom wird hier ggf. automatisch mit zurückgegeben + refinements.addAll(reasoningService.getMoreSpecialConcepts(concept)); + // negiertes atomares Konzept + } else if (concept instanceof Negation && concept.getChild(0) instanceof NamedClass) { + tmp.addAll(reasoningService.getMoreGeneralConcepts(concept.getChild(0))); + + // Top rausschmeissen + boolean containsTop = false; + Iterator<Description> it = tmp.iterator(); + while(it.hasNext()) { + Description c = it.next(); + if(c instanceof Thing) { + it.remove(); + containsTop = true; + } + } + if(containsTop) + refinements.add(new Nothing()); + + for(Description c : tmp) { + refinements.add(new Negation(c)); + } + } else if (concept instanceof Intersection) { + // eines der Elemente kann verfeinert werden + for(Description child : concept.getChildren()) { + + // Refinement für das Kind ausführen + tmp = refine(child); + + // neue MultiConjunction konstruieren + for(Description c : tmp) { + // TODO: müssen auch alle Konzepte geklont werden?? + // hier wird nur eine neue Liste erstellt + // => eigentlich muss nicht geklont werden (d.h. deep copy) da + // die Konzepte nicht verändert werden während des Algorithmus + List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); + // es muss genau die vorherige Reihenfolge erhalten bleiben + // (zumindest bis die Normalform definiert ist) + int index = newChildren.indexOf(child); + newChildren.add(index, c); + newChildren.remove(child); + Intersection mc = new Intersection(newChildren); + refinements.add(mc); + } + } + } else if (concept instanceof Union) { + // eines der Elemente kann verfeinert werden + for(Description child : concept.getChildren()) { + + // Refinement für das Kind ausführen + // tmp = refine(child); + tmp = refine(child); + // neue MultiConjunction konstruieren + for(Description c : tmp) { + List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); + // es muss genau die vorherige Reihenfolge erhalten bleiben + // (zumindest bis die Normalform definiert ist) + int index = newChildren.indexOf(child); + newChildren.add(index, c); + newChildren.remove(child); + Union md = new Union(newChildren); + refinements.add(md); + } + } + + // ein Element der Disjunktion kann weggelassen werden + for(Description child : concept.getChildren()) { + List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); + newChildren.remove(child); + // wenn nur ein Kind da ist, dann wird Disjunktion gleich weggelassen + if(newChildren.size()==1) + refinements.add(newChildren.get(0)); + else { + Union md = new Union(newChildren); + refinements.add(md); + } + } + + } else if (concept instanceof ObjectSomeRestriction) { + tmp = refine(concept.getChild(0)); + for(Description c : tmp) { + refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); + } + + // falls Kind Bottom ist, dann kann exists weggelassen werden + if(concept.getChild(0) instanceof Nothing) + refinements.add(new Nothing()); + + } else if (concept instanceof ObjectAllRestriction) { + tmp = refine(concept.getChild(0)); + for(Description c : tmp) { + refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); + } + + if(concept.getChild(0) instanceof Nothing) + refinements.add(new Nothing()); + + // falls es keine spezielleren atomaren Konzepte gibt, dann wird + // bottom angehangen => nur wenn es ein atomares Konzept (insbesondere != bottom) + // ist + // if(tmp.size()==0) { + // if(concept.getChild(0) instanceof AtomicConcept && tmp.size()==0) { + // refinements.add(new All(((Quantification)concept).getRole(),new Bottom())); + //} + } else + throw new RuntimeException(concept.toString()); + + // falls Konzept ungleich Bottom oder Top, dann kann ein Refinement von Top + // angehangen werden + if(concept instanceof Union || concept instanceof NamedClass || + concept instanceof Negation || concept instanceof ObjectSomeRestriction || concept instanceof ObjectAllRestriction) { + + // es wird AND TOP angehangen + Intersection mc = new Intersection(); + mc.addChild(concept); + mc.addChild(new Thing()); + refinements.add(mc); + } + + // Refinements werden jetzt noch bereinigt, d.h. Verschachtelungen von Konjunktionen + // werden entfernt; es wird eine neue Menge erzeugt, da die Transformationen die + // Ordnung des Konzepts ändern könnten + // TODO: eventuell geht das noch effizienter, da die meisten Refinement-Regeln Refinements + // von Child-Konzepten sind, die bereits geordnet sind, d.h. man könnte dort eventuell + // gleich absichern, dass alle neu hinzugefügten Refinements in geordneter Negationsnormalform + // sind + // SortedSet<Concept> returnSet = new TreeSet<Concept>(conceptComparator); + /* + + Set<Concept> returnSet = new HashSet<Concept>(); + for(Concept c : refinements) { + ConceptTransformation.cleanConcept(c); + // ConceptTransformation.transformToOrderedNegationNormalForm(c, conceptComparator); + returnSet.add(c); + } + + return returnSet; + */ + + // Zwischenschritt wird weggelassen - man muss nicht alle Konzepte cleanen, + // um dann nur eins davon auszuwählen + + return refinements; + + } + + public Set<Description> refine(Description concept, int maxLength, + List<Description> knownRefinements) { + throw new RuntimeException(); + } + +} Copied: trunk/src/dl-learner/org/dllearner/operators/PsiUp.java (from rev 639, trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiUp.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/PsiUp.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/operators/PsiUp.java 2008-02-27 11:27:52 UTC (rev 648) @@ -0,0 +1,221 @@ +package org.dllearner.refinementoperators; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import org.dllearner.algorithms.refinement.RefinementOperator; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.ObjectAllRestriction; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Nothing; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.Union; +import org.dllearner.core.owl.Negation; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectQuantorRestriction; +import org.dllearner.core.owl.Thing; +import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.utilities.ConceptComparator; + +public class PsiUp implements RefinementOperator { + + ConceptComparator conceptComparator = new ConceptComparator(); + + PosNegLP learningProblem; + ReasoningService reasoningService; + + private TreeSet<Description> bottomSet; + + public PsiUp(PosNegLP learningProblem) { + this.learningProblem = learningProblem; + reasoningService = learningProblem.getReasoningService(); + + // Top-Menge erstellen + createBottomSet(); + } + + private void createBottomSet() { + bottomSet = new TreeSet<Description>(conceptComparator); + + // BOTTOM AND BOTTOM + Intersection mc = new Intersection(); + mc.addChild(new Nothing()); + mc.addChild(new Nothing()); + bottomSet.add(mc); + + // speziellste Konzepte + bottomSet.addAll(reasoningService.getMoreGeneralConcepts(new Nothing())); + + // negierte allgemeinste Konzepte + Set<Description> tmp = reasoningService.getMoreSpecialConcepts(new Thing()); + for(Description c : tmp) + bottomSet.add(new Negation(c)); + + // EXISTS r.BOTTOM und ALL r.BOTTOM für alle r + for(ObjectProperty r : reasoningService.getAtomicRoles()) { + bottomSet.add(new ObjectAllRestriction(r, new Nothing())); + bottomSet.add(new ObjectSomeRestriction(r, new Nothing())); + } + } + + @SuppressWarnings("unchecked") + public Set<Description> refine(Description concept) { + + Set<Description> refinements = new HashSet<Description>(); + Set<Description> tmp = new HashSet<Description>(); + + if (concept instanceof Thing) { + return new TreeSet<Description>(conceptComparator); + } else if (concept instanceof Nothing) { + return (Set<Description>) bottomSet.clone(); + } else if (concept instanceof NamedClass) { + // Top darf hier mit dabei sein + refinements.addAll(reasoningService.getMoreGeneralConcepts(concept)); + + // negiertes atomares Konzept + } else if (concept instanceof Negation && concept.getChild(0) instanceof NamedClass) { + tmp.addAll(reasoningService.getMoreSpecialConcepts(concept.getChild(0))); + + // Bottom rausschmeissen + boolean containsBottom = false; + Iterator<Description> it = tmp.iterator(); + while(it.hasNext()) { + Description c = it.next(); + if(c instanceof Nothing) { + it.remove(); + containsBottom = true; + } + } + // es soll z.B. NOT male auch zu NOT BOTTOM d.h. zu TOP verfeinert + // werden können + if(containsBottom) + refinements.add(new Thing()); + + for(Description c : tmp) { + refinements.add(new Negation(c)); + } + } else if (concept instanceof Intersection) { + // eines der Elemente kann verfeinert werden + for(Description child : concept.getChildren()) { + + // Refinement für das Kind ausführen + tmp = refine(child); + + // neue MultiConjunction konstruieren + for(Description c : tmp) { + // TODO: müssen auch alle Konzepte geklont werden?? + // hier wird nur eine neue Liste erstellt + // => eigentlich muss nicht geklont werden (d.h. deep copy) da + // die Konzepte nicht verändert werden während des Algorithmus + List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); + // es muss genau die vorherige Reihenfolge erhalten bleiben + // (zumindest bis die Normalform definiert ist) + int index = newChildren.indexOf(child); + newChildren.add(index, c); + newChildren.remove(child); + Intersection mc = new Intersection(newChildren); + refinements.add(mc); + } + } + + // ein Element der Konjunktion kann weggelassen werden + for(Description child : concept.getChildren()) { + List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); + newChildren.remove(child); + if(newChildren.size()==1) + refinements.add(newChildren.get(0)); + else { + Intersection md = new Intersection(newChildren); + refinements.add(md); + } + } + } else if (concept instanceof Union) { + // eines der Elemente kann verfeinert werden + for(Description child : concept.getChildren()) { + + // Refinement für das Kind ausführen + // tmp = refine(child); + tmp = refine(child); + // neue MultiConjunction konstruieren + for(Description c : tmp) { + List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); + // es muss genau die vorherige Reihenfolge erhalten bleiben + // (zumindest bis die Normalform definiert ist) + int index = newChildren.indexOf(child); + newChildren.add(index, c); + newChildren.remove(child); + Union md = new Union(newChildren); + refinements.add(md); + } + } + } else if (concept instanceof ObjectSomeRestriction) { + tmp = refine(concept.getChild(0)); + for(Description c : tmp) { + refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); + } + + if(concept.getChild(0) instanceof Thing) + refinements.add(new Thing()); + + } else if (concept instanceof ObjectAllRestriction) { + tmp = refine(concept.getChild(0)); + for(Description c : tmp) { + refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); + } + + if(concept.getChild(0) instanceof Thing) + refinements.add(new Thing()); + + // falls es keine spezielleren atomaren Konzepte gibt, dann wird + // bottom angehangen => nur wenn es ein atomares Konzept (insbesondere != bottom) + // ist + // if(tmp.size()==0) { + // if(concept.getChild(0) instanceof AtomicConcept && tmp.size()==0) { + // refinements.add(new All(((Quantification)concept).getRole(),new Bottom())); + //} + } else + throw new RuntimeException(concept.toString()); + + if(concept instanceof Union || concept instanceof NamedClass || + concept instanceof Negation || concept instanceof ObjectSomeRestriction || concept instanceof ObjectAllRestriction) { + + // es wird OR BOTTOM angehangen + Union md = new Union(); + md.addChild(concept); + md.addChild(new Nothing()); + refinements.add(md); + } + + // Refinements werden jetzt noch bereinigt, d.h. Verschachtelungen von Konjunktionen + // werden entfernt; es wird eine neue Menge erzeugt, da die Transformationen die + // Ordnung des Konzepts ändern könnten + // TODO: eventuell geht das noch effizienter, da die meisten Refinement-Regeln Refinements + // von Child-Konzepten sind, die bereits geordnet sind, d.h. man könnte dort eventuell + // gleich absichern, dass alle neu hinzugefügten Refinements in geordneter Negationsnormalform + // sind + // SortedSet<Concept> returnSet = new TreeSet<Concept>(conceptComparator); + /* + Set<Concept> returnSet = new HashSet<Concept>(); + for(Concept c : refinements) { + ConceptTransformation.cleanConcept(c); + // ConceptTransformation.transformToOrderedNegationNormalForm(c, conceptComparator); + returnSet.add(c); + } + + return returnSet; + */ + return refinements; + } + + public Set<Description> refine(Description concept, int maxLength, + List<Description> knownRefinements) { + throw new RuntimeException(); + } + +} Added: trunk/src/dl-learner/org/dllearner/operators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/RhoDRDown.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/operators/RhoDRDown.java 2008-02-27 11:27:52 UTC (rev 648) @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.refinementoperators; + +import java.util.List; +import java.util.Set; + +import org.dllearner.algorithms.refinement.RefinementOperator; +import org.dllearner.core.owl.Description; + +/** + * A downward refinement operator, which makes use of domains + * and ranges of properties. The operator is currently under + * development. Its aim is to span a much "cleaner" and smaller search + * tree compared to RhoDown by omitting many class descriptions, + * which are obviously too weak, because they violate + * domain/range restrictions. + * + * @author Jens Lehmann + * + */ +public class RhoDRDown implements RefinementOperator { + + /* (non-Javadoc) + * @see org.dllearner.algorithms.refinement.RefinementOperator#refine(org.dllearner.core.owl.Description) + */ + public Set<Description> refine(Description concept) { + throw new RuntimeException(); + } + + /* (non-Javadoc) + * @see org.dllearner.algorithms.refinement.RefinementOperator#refine(org.dllearner.core.owl.Description, int, java.util.List) + */ + public Set<Description> refine(Description concept, int maxLength, + List<Description> knownRefinements) { + + return null; + } + +} Copied: trunk/src/dl-learner/org/dllearner/operators/RhoDown.java (from rev 644, trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/operators/RhoDown.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/operators/RhoDown.java 2008-02-27 11:27:52 UTC (rev 648) @@ -0,0 +1,766 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.refinementoperators; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.dllearner.algorithms.refinement.RefinementOperator; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.ObjectAllRestriction; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Nothing; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.Intersection; +import org.dllearner.core.owl.Union; +import org.dllearner.core.owl.Negation; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectPropertyExpression; +import org.dllearner.core.owl.ObjectQuantorRestriction; +import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.ValueRestriction; +import org.dllearner.utilities.ConceptComparator; +import org.dllearner.utilities.ConceptTransformation; + +/** + * Implementation of the downward refinement operator in the DL-Learner refinement + * based algorithm. + * + * See <a href="http://jens-lehmann.org/files/2007_alc_learning_algorithm.pdf" + * >http://jens-lehmann.org/files/2007_alc_learning_algorithm.pdf</a> for + * details. + * + * @author Jens Lehmann + * + */ +public class RhoDown implements RefinementOperator { + +// private PosNegLP learningProblem; + private ReasoningService rs; + + // gibt die Gr��e an bis zu der die Refinements des Top-Konzepts + // bereits berechnet worden => entspricht der max. L�nge der Menge M + private int topRefinementsLength = 0; + + // die Menge M im Refinement-Operator indiziert nach ihrer L�nge + Map<Integer,Set<Description>> m = new HashMap<Integer,Set<Description>>(); + + // Zerlegungen der Zahl n in Mengen + // Map<Integer,Set<IntegerCombo>> combos = new HashMap<Integer,Set<IntegerCombo>>(); + Map<Integer, List<List<Integer>>> combos = new HashMap<Integer, List<List<Integer>>>(); + // abspeichern von Kombinationen während diese rekursiv berechnet werden + // private List<List<Integer>> combosTmp; + + // Refinements des Top-Konzept indiziert nach Länge + Map<Integer, TreeSet<Description>> topRefinements = new HashMap<Integer, TreeSet<Description>>(); + Map<Integer, TreeSet<Description>> topRefinementsCumulative = new HashMap<Integer, TreeSet<Description>>(); + + // comparator für Konzepte + private ConceptComparator conceptComparator = new ConceptComparator(); + + // Statistik + public long mComputationTimeNs = 0; + public long topComputationTimeNs = 0; + + private boolean applyAllFilter = true; + private boolean applyExistsFilter = true; + private boolean useAllConstructor = true; + private boolean useExistsConstructor = true; + private boolean useNegation = true; + private boolean useBooleanDatatypes = true; + + // braucht man wirklich das learningProblem oder reicht der Reasoning-Service? + // TODO: conceptComparator könnte auch noch Parameter sein + public RhoDown(ReasoningService reasoningService, boolean applyAllFilter, boolean applyExistsFilter, boolean useAllConstructor, + boolean useExistsConstructor, boolean useNegation, boolean useBooleanDatatypes) { + this.rs = reasoningService; + this.applyAllFilter = applyAllFilter; + this.applyExistsFilter = applyExistsFilter; + this.useAllConstructor = useAllConstructor; + this.useExistsConstructor = useExistsConstructor; + this.useNegation = useNegation; + this.useBooleanDatatypes = useBooleanDatatypes; + +// this.learningProblem = learningProblem; +// rs = learningProblem.getReasoningService(); + } + + public Set<Description> refine(Description concept) { + throw new RuntimeException(); + // TODO Auto-generated method stub + // return null; + } + + // TODO: Methode muss effizienter werden + // Hauptproblem ist nicht die Berechnung von M und Top (siehe Benchmarks) + // => zuerst muss Objekterzeugung minimiert werden + // => als zweites wäre bei nicht ausreichendem Performancegewinn die Implementierung + // von Minimallänge eine Möglichkeit (alle Refinements, auch improper, müssten + // dann im Algorithmus gespeichert werden) + @SuppressWarnings("unchecked") + public SortedSet<Description> refine(Description concept, int maxLength, + List<Description> knownRefinements) { + + + + // Set<Concept> refinements = new HashSet<Concept>(); + SortedSet<Description> refinements = new TreeSet<Description>(conceptComparator); + Set<Description> tmp = new HashSet<Description>(); + // SortedSet<Concept> tmp = new TreeSet<Concept>(conceptComparator); + + if (concept instanceof Thing) { + + // ggf. Refinements von Top erweitern + if(maxLength>topRefinementsLength) + computeTopRefinements(maxLength); + // System.out.println(topRefinements); + refinements = (TreeSet<Description>) topRefinementsCumulative.get(maxLength).clone(); + // refinements = copyTopRefinements(maxLength); + // refinements = topRefinementsCumulative.get(maxLength); + + } else if (concept instanceof Nothing) { + // return new HashSet<Concept>(); + } else if (concept instanceof ValueRestriction) { + // value restrictions cannot be further refined + } else if (concept instanceof NamedClass) { + // Erkenntnisse aus Benchmarks: dieser Teil wird sehr häufig aufgerufen, + // allerdings lässt er sich kaum weiter verbessern (selbst ohne klonen + // der Konzepte im DIG-Reasoner, was durch das entfernen von Bottom notwendig + // ist und außerdem sicherer vor zukünftigen Bugs, wird es nicht wesentlich + // schneller) + + // beachte: die Funktion gibt bereits nur nicht-äquivalente Konzepte zurück + // TODO: der Cast auf SortedSet ist nur ein Hack und muss später geeignet + // behandelt werden + refinements = rs.getMoreSpecialConcepts(concept); + // refinements.addAll(learningProblem.getReasoningService().getMoreSpecialConcepts(concept)); + + // Bottom rausschmeißen (nicht im Operator vorgesehen) + // Iterator<Concept> it = refinements.iterator(); + // while(it.hasNext()) { + // Concept c = it.next(); + // if(c instanceof Bottom) + // it.remove(); + // } + // geht jetzt auch schneller durch conceptComparator + refinements.remove(new Nothing()); + + // negiertes atomares Konzept + } else if (concept instanceof Negation && concept.getChild(0) instanceof NamedClass) { + + tmp = rs.getMoreGeneralConcepts(concept.getChild(0)); + + //Iterator<Concept> it = tmp.iterator(); + //while(it.hasNext()) { + // Concept c = it.next(); + // if(c instanceof Top) + // it.remove(); + //} + + // tmp.remove(new Top()); + + for(Description c : tmp) { + if(!(c instanceof Thing)) + refinements.add(new Negation(c)); + } + + } else if (concept instanceof Intersection) { + + // eines der Elemente kann verfeinert werden + for(Description child : concept.getChildren()) { + + // Refinement für das Kind ausführen + // System.out.println("child: " + child); + // wenn man von maximaler Länge die Länge des Konzepts außer dem aktuell + // betrachteten Element abzieht, dann bekommt man neue maxLength + tmp = refine(child, maxLength - concept.getLength()+child.getLength(),null); + + // neue MultiConjunction konstruieren + for(Description c : tmp) { + // TODO: müssen auch alle Konzepte geklont werden?? + // hier wird nur eine neue Liste erstellt + // => eigentlich muss nicht geklont werden (d.h. deep copy) da + // die Konzepte nicht verändert werden während des Algorithmus + // => es muss geklont werden, da die top refinements nicht verändert + // werden dürfen + // List<Concept> newChildren = new LinkedList<Concept>(concept.getChildren()); + // TODO: Class Cast ist nur ein Hack + List<Description> newChildren = (List<Description>)((LinkedList)concept.getChildren()).clone(); + // es muss genau die vorherige Reihenfolge erhalten bleiben + // (zumindest bis die Normalform definiert ist) + // int index = newChildren.indexOf(child); + // newChildren.add(index, c); + // newChildren.remove(child); + // MultiConjunction mc = new MultiConjunction(newChildren); + + // Index muss jetzt nich mehr erhalten bleiben, da ohnehin + // neu sortiert wird + newChildren.add(c); + newChildren.remove(child); + Intersection mc = new Intersection(newChildren); + + // sicherstellten, dass Konzept in negation normal form ist + ConceptTransformation.cleanConceptNonRecursive(mc); + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); + + refinements.add(mc); + } + + } + + } else if (concept instanceof Union) { + // eines der Elemente kann verfeinert werden + for(Description child : concept.getChildren()) { + + // Refinement für das Kind ausführen + // tmp = refine(child); + tmp = refine(child, maxLength - concept.getLength()+child.getLength(),null); + + + + // neue MultiConjunction konstruieren + for(Description c : tmp) { + List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); + // es muss genau die vorherige Reihenfolge erhalten bleiben + // (zumindest bis die Normalform definiert ist) + // int index = newChildren.indexOf(child); + // newChildren.add(index, c); + newChildren.remove(child); + newChildren.add(c); + Union md = new Union(newChildren); + + // sicherstellten, dass Konzept in negation normal form ist + // ConceptTransformation.cleanConcept(md); // nicht notwendig, da kein Element einer + // Disjunktion auf eine Disjunktion abgebildet wird (nur Top und das ist nie + // in einer Disjunktion) + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(md, conceptComparator); + + + refinements.add(md); + } + + + } + + } else if (concept instanceof ObjectSomeRestriction) { + ObjectPropertyExpression role = ((ObjectQuantorRestriction)concept).getRole(); + + // rule 1: EXISTS r.D => EXISTS r.E + tmp = refine(concept.getChild(0), maxLength-2, null); + + for(Description c : tmp) { + refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); + } + + // rule 2: EXISTS r.D => EXISTS s.D or EXISTS r^-1.D => EXISTS s^-1.D + // currently inverse roles are not supported + ObjectProperty ar = (ObjectProperty) role; + Set<ObjectProperty> moreSpecialRoles = rs.getMoreSpecialRoles(ar); + for(ObjectProperty moreSpecialRole : moreSpecialRoles) { + refinements.add(new ObjectSomeRestriction(moreSpecialRole, concept.getChild(0))); + } + + } else if (concept instanceof ObjectAllRestriction) { + ObjectPropertyExpression role = ((ObjectQuantorRestriction)concept).getRole(); + + // rule 1: ALL r.D => ALL r.E + tmp = refine(concept.getChild(0), maxLength-2, null); + + for(Description c : tmp) { + refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); + } + + // rule 2: ALL r.D => ALL r.BOTTOM if D is a most specific atomic concept + // falls es keine spezielleren atomaren Konzepte gibt, dann wird + // bottom angehangen => nur wenn es ein atomares Konzept (insbesondere != bottom) + // ist + // if(tmp.size()==0) { + if(concept.getChild(0) instanceof NamedClass && tmp.size()==0) { + refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)concept).getRole(),new Nothing())); + } + + // rule 3: ALL r.D => ALL s.D or ALL r^-1.D => ALL s^-1.D + // currently inverse roles are not supported + ObjectProperty ar = (ObjectProperty) role; + Set<ObjectProperty> moreSpecialRoles = rs.getMoreSpecialRoles(ar); + for(ObjectProperty moreSpecialRole : moreSpecialRoles) { + refinements.add(new ObjectAllRestriction(moreSpecialRole, concept.getChild(0))); + } + + } + + // falls Konzept ungleich Bottom oder Top, dann kann ein Refinement von Top + // angehangen werden + if(concept instanceof Union || concept instanceof NamedClass || + concept instanceof Negation || concept instanceof ObjectQuantorRestriction + || concept instanceof ValueRestriction) { + // long someTimeNsStart = System.nanoTime(); + // someCount++; + // Refinement von Top anhängen + int topRefLength = maxLength - concept.getLength() - 1; //-1 wegen zusätzlichem UND + // es könnte passieren, das wir hier neue Refinements von Top berechnen müssen + if(topRefLength > topRefinementsLength) + computeTopRefinements(topRefLength); + if(topRefLength>0) { + // Set<Concept> topRefs = copyTopRefinements(topRefLength); + Set<Description> topRefs = topRefinementsCumulative.get(topRefLength); + for(Description c : topRefs) { + boolean skip = false; + + // falls Refinement von der Form ALL r ist, dann prüfen, ob + // ALL r nicht bereits vorkommt + if(applyAllFilter) { + if(c instanceof ObjectAllRestriction) { + for(Description child : concept.getChildren()) { + if(child instanceof ObjectAllRestriction) { + ObjectPropertyExpression r1 = ((ObjectAllRestriction)c).getRole(); + ObjectPropertyExpression r2 = ((ObjectAllRestriction)child).getRole(); + if(r1.toString().equals(r2.toString())) + skip = true; + } + } + } + } + + if(!skip) { + // MultiConjunction md = new MultiConjunction(concept.getChildren()); + Intersection mc = new Intersection(); + mc.addChild(concept); + mc.addChild(c); + + // Negationsnormalform herstellen + ConceptTransformation.cleanConceptNonRecursive(mc); + ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); + + refinements.add(mc); + } + } + } + // someTimeNs += System.nanoTime() - someTimeNsStart; + } + + + + // Refinements werden jetzt noch bereinigt, d.h. Verschachtelungen von Konjunktionen + // werden entfernt; es wird eine neue Menge erzeugt, da die Transformationen die + // Ordnung des Konzepts ändern könnten + // TODO: eventuell geht das noch effizienter, da die meisten Refinement-Regeln Refinements + // von Child-Konzepten sind, die bereits geordnet sind, d.h. man könnte dort eventuell + // gleich absichern, dass alle neu hinzugefügten Refinements in geordneter Negationsnormalform + // sind + /* + SortedSet<Concept> returnSet = new TreeSet<Concept>(conceptComparator); + for(Concept c : refinements) { + ConceptTransformation.cleanConcept(c); + ConceptTransformation.transformToOrderedNegationNormalForm(c, conceptComparator); + returnSet.add(c); + } + + return returnSet; + */ + // TODO: obiger Code kann noch nicht gelöscht werden (anderes Ergebnis); warum? + // => erstmal so implementieren, dass obiger Code nicht mehr gebraucht wird und + // im zweiten Schritt dann auf die nicht-rekursiven Methoden umsteigen + return refinements; + } + + + // TODO: Methode kann später entfernt werden, es muss nur + // sichergestellt werden, dass die refine-Methode an den + // kumulativen Top-Refinements nichts ändert + @SuppressWarnings("unused") + private SortedSet<Description> copyTopRefinements(int maxLength) { + // return topRefinementsCumulative.get(maxLength); + SortedSet<Description> ret = new TreeSet<Description>(conceptComparator); + for(Description c : topRefinementsCumulative.get(maxLength)) + ret.add(c); + return ret; + } + + + // TODO: später private + public void computeTopRefinements(int maxLength) { + long topComputationTimeStartNs = System.nanoTime(); + + // M erweiteren + computeM(maxLength); + + // berechnen aller möglichen Kombinationen für Disjunktion, + for(int i = topRefinementsLength+1; i <= maxLength; i++) { + combos.put(i,getCombos(i)); + topRefinements.put(i, new TreeSet<Description>(conceptComparator)); + // topRefinements.put(i, new HashSet<Concept>()); + + for(List<Integer> combo : combos.get(i)) { + /* + // für eine Kombo alle Konzeptkombinationen berechnen + Set<Set<Concept>> baseSet = new HashSet<Set<Concept>>(); + // boolean firstNonEmptyNumber = true; + for(Integer j : combo.getNumbers()) { + // initialisiert wird mit der passenden Menge m + //if(firstNonEmptyNumber || ) + // baseSet.add(m.get(j)); + // else { + baseSet = incCrossProduct(baseSet,m.get(j)); + //} + } + + // Disjunktionen erzeugen und hinzufügen + for(Set<Concept> children : baseSet) { + if(children.size() == 1) { + Iterator<Concept> it = children.iterator(); + Concept c = it.next(); + topRefinements.get(i).add(c); + } else { + topRefinements.get(i).add(new MultiDisjunction(children)); + } + } + */ + + /* neue Implementierung */ + + // Kombination besteht aus nur einer Zahl => einfach M benutzen + // if(combo.getNumbers().size()==1) { + if(combo.size()==1) { + topRefinements.get(i).addAll(m.get(i)); + // Kombination besteht aus mehreren Zahlen => Disjunktion erzeugen + } else { + Set<Union> baseSet = new HashSet<Union>(); + for(Integer j : combo) { // combo.getNumbers()) { + baseSet = incCrossProduct2(baseSet, m.get(j)); + } + + // Umwandlung aller Konzepte in Negationsnormalform + for(Description concept : baseSet) { + ConceptTransformation.transformToOrderedNegationNormalForm(concept, conceptComparator); + } + + if(applyExistsFilter) { + Iterator<Union> it = baseSet.iterator(); + while(it.hasNext()) { + Union md = it.next(); + boolean remove = false; + // falls Exists r für gleiche Rolle zweimal vorkommt, + // dann rausschmeißen + // Map<AtomicRole,Boolean> roleOccured = new HashMap<AtomicRole,Boolean>(); + Set<String> roles = new TreeSet<String>(); + for(Description c : md.getChildren()) { + if(c instanceof ObjectSomeRestriction) { + String role = ((ObjectSomeRestriction)c).getRole().getName(); + boolean roleExists = !roles.add(role); + // falls Rolle schon vorkommt, dann kann ganzes + // Refinement ignoriert werden (man könnte dann auch + // gleich abbrechen, aber das hat nur minimalste + // Auswirkungen auf Effizienz) + if(roleExists) + remove = true; + } + } + if(remove) + it.remove(); + + } + } + + topRefinements.get(i).addAll(baseSet); + } + } + + // neu berechnete Refinements kumulieren, damit sie schneller abgefragt werden können + // computeCumulativeTopRefinements(i); + TreeSet<Description> cumulativeRefinements = new TreeSet<Description>(conceptComparator); + // Set<Concept> cumulativeRefinements = new HashSet<Concept>(); + for(int j=1; j<=i; j++) { + cumulativeRefinements.addAll(topRefinements.get(j)); + } + topRefinementsCumulative.put(i, cumulativeRefinements); + } + + // neue Maximallänge eintragen + topRefinementsLength = maxLength; + + topComputationTimeNs += System.nanoTime() - topComputationTimeStartNs; + } + + // computation of the set M + private void computeM(int maxLength) { + long mComputationTimeStartNs = System.nanoTime(); + // System.out.println("compute M from " + (topRefinementsLength+1) + " up to " + maxLength); + + // initialise all not yet initialised lengths + // (avoids null pointers in some cases) + for(int i=topRefinementsLength+1; i<=maxLength; i++) { + m.put(i, new TreeSet<Description>(conceptComparator)); + } + + // Berechnung der Basiskonzepte in M + // TODO: Spezialfälle, dass zwischen Top und Bottom nichts liegt behandeln + if(topRefinementsLength==0 && maxLength>0) { + // Konzepte der Länge 1 = alle Konzepte, die in der Subsumptionhierarchie unter Top liegen + Set<Description> m1 = rs.getMoreSpecialConcepts(new Thing()); + m.put(1,m1); + } + + if(topRefinementsLength<2 && maxLength>1) { + // Konzepte der Länge 2 = Negation aller Konzepte, die über Bottom liegen + if(useNegation) { + Set<Description> m2tmp = rs.getMoreGeneralConcepts(new Nothing()); + Set<Description> m2 = new TreeSet<Description>(conceptComparator); + for(Description c : m2tmp) { + m2.add(new Negation(c)); + } + m.put(2,m2); + } + } + + if(topRefinementsLength<3 && maxLength>2) { + // Konzepte der Länge 3: EXISTS r.TOP + Set<Description> m3 = new TreeSet<Description>(conceptComparator); + if(useExistsConstructor) { + // previous operator: uses all roles + // for(AtomicRole r : Config.Refinement.allowedRoles) { + // m3.add(new Exists(r, new Top())); + //} + // new operator: only uses most general roles + for(ObjectProperty r : rs.getMostGeneralRoles()) { + m3.add(new ObjectSomeRestriction(r, new Thing())); + } + + } + + // boolean datatypes, e.g. testPositive = true + if(useBooleanDatatypes) { + Set<DatatypeProperty> booleanDPs = rs.getBooleanDatatypeProperties(); + for(DatatypeProperty dp : booleanDPs) { + m3.add(new BooleanValueRestriction(dp,true)); + m3.add(new BooleanValueRestriction(dp,false)); + } + } + + m.put(3,m3); + } + + if(maxLength>2) { + if(useAllConstructor) { + // Konzepte, die mit ALL r starten + // alle existierenden Konzepte durchgehen, die maximal 2 k�rzer als + // die maximale L�nge sind + // topRefinementsLength - 1, damit Konzepte der Länge mindestens + // topRefinementsLength + 1 erzeugt werden (ALL r) + for(int i=topRefinementsLength-1; i<=maxLength-2; i++) { + // i muss natürlich mindestens 1 sein + if(i>=1) { + + // alle Konzepte durchgehen + for(Description c : m.get(i)) { + // Fall wird jetzt weiter oben schon abgehandelt + // if(!m.containsKey(i+2)) + // m.put(i+2, new TreeSet<Concept>(conceptComparator)); + + // previous operator: uses all roles + // for(AtomicRole r : Config.Refinement.allowedRoles) { + // Mehrfacheinf�gen ist bei einer Menge kein Problem + // m.get(i+2).add(new All(r,c)); + // } + + for(ObjectProperty r : rs.getMostGeneralRoles()) { + m.get(i+2).add(new ObjectAllRestriction(r,c)); + } + } + } + } + } + } + + mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; + } + + + public static void summen(int zahl, int max, String bisher, int recDepth) + { + for(int j=0; j<recDepth; j++) + System.out.print(" "); + System.out.println("f("+zahl+","+max+",\""+bisher+"\")"); + + for (int i = Math.min(zahl, max); i >= 1; i--) + { + + String jetzt = bisher + i; + + if (zahl - i > 1) + { + jetzt += " + "; + // i wird hinzugefügt, d.h. + // - es muss nur noch zahl - i zerlegt werden + // - es darf keine größere Zahl als i mehr vorkommen + // (dadurch gehen keine Kombinationen verloren) + summen(zahl - i -1 , i, jetzt, recDepth+1); + } + // Fall zahl == i, d.h. es muss nicht weiter zerlegt werden + else if(zahl - i == 0){ + for(int j=0; j<recDepth; j++) + System.out.print(" "); + System.out.println(jetzt); + } + // durch die -1 Abzug für jedes Zwischenzeichen gibt es auch Fälle, in denen + // keine Lösung entsteht (zahl-i==1) + + } + } + + @SuppressWarnings("unchecked") + private LinkedList<Integer> cloneList(LinkedList<Integer> list) { + return (LinkedList<Integer>) list.clone(); + } + + /** + * + * Dadurch das max das Maximum der vorkommenden Zahl regelt, kommen + * keine doppelten Kombinationen vor. + * + * TODO: Implementierung mit Speicherung in Datenstruktur statt + * direkter Ausgabe; IntegerCombo wird hier gar nicht benötigt, da + * alle Elemente bereits in richtiger Reihenfolge vorliegen und + * es keine doppelten Nennungen gibt + * + * @param zahl Zu zerlegende Zahl. + * @param max Maximal in Summenzerlegung vorkommende Zahl. + * @param bisher + */ + private void zerlege(int zahl, int max, LinkedList<Integer> bisher, List<List<Integer>> combosTmp) { + + for (int i = Math.min(zahl, max); i >= 1; i--) + { + + LinkedList<Integer> newBisher = null; + // für i==0 wird aus Effizienzgründen die bisherige Liste genommen + if(i==0) { + newBisher = bisher; + newBisher.add(i); + // für zahl - i == 1 muss gar keine Liste erstellt werden, da dann keine + // Zerlegung mehr möglich ist + } else if(zahl - i != 1) { + newBisher = cloneList(bisher); + newBisher.add(i); + } + + + if (zahl - i > 1) + { + // i wird hinzugefügt, d.h. + // - es muss nur noch zahl - i - 1 zerlegt werden (-1 wegen OR-Symbol) + // - es darf keine größere Zahl als i mehr vorkommen + // (dadurch gehen keine Kombinationen verloren) + zerlege(zahl - i - 1, i, newBisher,combosTmp); + } + // Fall zahl == i, d.h. es muss nicht weiter zerlegt werden + else if(zahl - i == 0){ + combosTmp.add(newBisher); + } + + + } + + // numbers.add(bisher); + } + + // auf Notebook: Länge 70 in 17 Sekunden, Länge 50 in 800ms, Länge 30 in 15ms + // http://88.198.173.90/tud/forum/messages?topic=304392 + public List<List<Integer>> getCombos(int length) { + LinkedList<List<Integer>> combosTmp = new LinkedList<List<Integer>>(); + zerlege(length, length, new LinkedList<Integer>(), combosTmp); + return combosTmp; + } + + // neue Implementierung, die nicht mehr zur incompleteness führen soll, + // da die Konzepte in einer MultiDisjunction als Liste gespeichert werden + private Set<Union> incCrossProduct2(Set<Union> baseSet, Set<Description> newSet) { + Set<Union> retSet = new HashSet<Union>(); + + if(baseSet.isEmpty()) { + for(Description c : newSet) { + Union md = new Union(); + md.addChild(c); + retSet.add(md); + } + return retSet; + } + + for(Union md : baseSet) { + for(Description c : newSet) { + Union mdNew = new Union(md.getChildren()); + mdNew.addChild(c); + retSet.add(mdNew); + } + } + + return retSet; + } + + // incremental cross product + // es müssen Listen statt Sets verwendet werden + @SuppressWarnings({"unused"}) + private Set<Set<Description>> incCrossProduct(Set<Set<Description>> baseSet, Set<Description> newSet) { + Set<Set<Description>> retSet = new HashSet<Set<Description>>(); + + // falls erste Menge leer ist, dann wird Menge mit jeweils Singletons aus der + // zweiten Menge zurückgegeben => das müsste dem Fall entsprechen, dass das + // baseSet nur die leere Menge enthält + if(baseSet.isEmpty()) { + for(Description c : newSet) { + Set<Description> singleton = new HashSet<Description>(); + singleton.add(c); + retSet.add(singleton); + } + // retSet.add(newSet); + return retSet; + } + + for(Set<Description> set : baseSet) { + for(Description c : newSet) { + // neues Konzept zu alter Konzeptmenge hinzufügen, indem altes + // Konzept kopiert und ergänzt wird + // beachte: dadurch, dass die Konzepte nach ihrem Hash eingefügt werden, + // ist schon eine Ordnung vorgegeben und es entfallen viele Mengen + // z.B. ist {male,female} = {female,male} + // TODO: das ist allerdings auch gefährlich, denn es gilt auch + // {male,male,female} = {male,female} d.h. es entfallen auch gewünschte + // Lösungen! (Es könnte z.B. sein, dass die Lösung eine Disjunktion von + // 3 atomaren Konzepten ist, die nur über male erreichbar sind.) D.h. diese + // Implementierung führt zur incompleteness des Operators. + Set<Description> newConcept = new HashSet<Description>(set); + newConcept.add(c); + retSet.add(newConcept); + } + } + return retSet; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-27 11:24:58
|
Revision: 647 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=647&view=rev Author: jenslehmann Date: 2008-02-27 03:24:56 -0800 (Wed, 27 Feb 2008) Log Message: ----------- preparations for getting domain/range of object/datatype properties (requires conversion from OWL API descriptions to DL-Learner descriptions which is not yet implemented) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiDown.java trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiUp.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/ADC.java 2008-02-27 11:24:56 UTC (rev 647) @@ -5,7 +5,18 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.DescriptionVisitor; import org.dllearner.core.owl.KBElementVisitor; +import org.semanticweb.owl.model.OWLClass; +import org.semanticweb.owl.model.OWLDescriptionVisitor; +import org.semanticweb.owl.model.OWLObjectVisitor; +/** + * ADC stand for "automatically defined concept". It is used for + * concept invention in the Genetic Programming Algorithm. + * However, it is not used + * + * @author Jens Lehmann + * + */ public class ADC extends Description { /* @@ -53,6 +64,54 @@ visitor.visit(this); } + /* (non-Javadoc) + * @see org.semanticweb.owl.model.OWLDescription#accept(org.semanticweb.owl.model.OWLDescriptionVisitor) + */ + public void accept(OWLDescriptionVisitor arg0) { + // TODO Auto-generated method stub + + } + /* (non-Javadoc) + * @see org.semanticweb.owl.model.OWLDescription#asOWLClass() + */ + public OWLClass asOWLClass() { + // TODO Auto-generated method stub + return null; + } + /* (non-Javadoc) + * @see org.semanticweb.owl.model.OWLDescription#isAnonymous() + */ + public boolean isAnonymous() { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.semanticweb.owl.model.OWLDescription#isOWLNothing() + */ + public boolean isOWLNothing() { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.semanticweb.owl.model.OWLDescription#isOWLThing() + */ + public boolean isOWLThing() { + // TODO Auto-generated method stub + return false; + } + + /* (non-Javadoc) + * @see org.semanticweb.owl.model.OWLObject#accept(org.semanticweb.owl.model.OWLObjectVisitor) + */ + public void accept(OWLObjectVisitor arg0) { + // TODO Auto-generated method stub + + } + + + } Modified: trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-02-27 11:24:56 UTC (rev 647) @@ -9,6 +9,8 @@ import org.dllearner.core.Score; import org.dllearner.core.owl.Description; import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.refinementoperators.PsiDown; +import org.dllearner.refinementoperators.PsiUp; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; Deleted: trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiDown.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiDown.java 2008-02-27 11:24:56 UTC (rev 647) @@ -1,245 +0,0 @@ -package org.dllearner.algorithms.hybridgp; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import org.dllearner.algorithms.refinement.RefinementOperator; -import org.dllearner.core.ReasoningService; -import org.dllearner.core.owl.ObjectAllRestriction; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.Nothing; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.Union; -import org.dllearner.core.owl.Negation; -import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectQuantorRestriction; -import org.dllearner.core.owl.Thing; -import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.utilities.ConceptComparator; - -/** - * Operatoren Psi-Down und Psi-Up müssen noch so umgeschrieben werden, dass sie - * nur konsistente Konzepte (mit korrekten parent-Links) enthalten. Dazu müssen - * alle verwendeten atomaren Konzepte geklont werden. - * - * Außerdem erscheint es ratsam weitere konzeptverkürzende Maßnahmen einzuführen, - * z.B. EXISTS r.A => BOTTOM für down bzw. TOP für up - * => Konzepte erreichen etwa eine Länge von 20 - * - * @author jl - * - */ -public class PsiDown implements RefinementOperator { - - ConceptComparator conceptComparator = new ConceptComparator(); - - PosNegLP learningProblem; - ReasoningService reasoningService; - - private TreeSet<Description> topSet; - - public PsiDown(PosNegLP learningProblem) { - this.learningProblem = learningProblem; - reasoningService = learningProblem.getReasoningService(); - - // Top-Menge erstellen - createTopSet(); - } - - private void createTopSet() { - topSet = new TreeSet<Description>(conceptComparator); - - // TOP OR TOP => Was soll mit Refinements passieren, die immer improper sind? - Union md = new Union(); - md.addChild(new Thing()); - md.addChild(new Thing()); - topSet.add(md); - - // allgemeinste Konzepte - topSet.addAll(reasoningService.getMoreSpecialConcepts(new Thing())); - - // negierte speziellste Konzepte - Set<Description> tmp = learningProblem.getReasoningService().getMoreGeneralConcepts(new Nothing()); - for(Description c : tmp) - topSet.add(new Negation(c)); - - // EXISTS r.TOP und ALL r.TOP für alle r - for(ObjectProperty r : reasoningService.getAtomicRoles()) { - topSet.add(new ObjectAllRestriction(r, new Thing())); - topSet.add(new ObjectSomeRestriction(r, new Thing())); - } - } - - @SuppressWarnings("unchecked") - public Set<Description> refine(Description concept) { - - Set<Description> refinements = new HashSet<Description>(); - Set<Description> tmp = new HashSet<Description>(); - - if (concept instanceof Thing) { - return (Set<Description>) topSet.clone(); - } else if (concept instanceof Nothing) { - // return new TreeSet<Concept>(conceptComparator); - return new HashSet<Description>(); - } else if (concept instanceof NamedClass) { - // beachte: die Funktion gibt bereits nur nicht-äquivalente Konzepte zurück - // beachte weiter: die zurückgegebenen Instanzen dürfen nicht verändert werden, - // da beim Caching der Subsumptionhierarchie (momentan) keine Kopien gemacht werden - // Bottom wird hier ggf. automatisch mit zurückgegeben - refinements.addAll(reasoningService.getMoreSpecialConcepts(concept)); - // negiertes atomares Konzept - } else if (concept instanceof Negation && concept.getChild(0) instanceof NamedClass) { - tmp.addAll(reasoningService.getMoreGeneralConcepts(concept.getChild(0))); - - // Top rausschmeissen - boolean containsTop = false; - Iterator<Description> it = tmp.iterator(); - while(it.hasNext()) { - Description c = it.next(); - if(c instanceof Thing) { - it.remove(); - containsTop = true; - } - } - if(containsTop) - refinements.add(new Nothing()); - - for(Description c : tmp) { - refinements.add(new Negation(c)); - } - } else if (concept instanceof Intersection) { - // eines der Elemente kann verfeinert werden - for(Description child : concept.getChildren()) { - - // Refinement für das Kind ausführen - tmp = refine(child); - - // neue MultiConjunction konstruieren - for(Description c : tmp) { - // TODO: müssen auch alle Konzepte geklont werden?? - // hier wird nur eine neue Liste erstellt - // => eigentlich muss nicht geklont werden (d.h. deep copy) da - // die Konzepte nicht verändert werden während des Algorithmus - List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); - // es muss genau die vorherige Reihenfolge erhalten bleiben - // (zumindest bis die Normalform definiert ist) - int index = newChildren.indexOf(child); - newChildren.add(index, c); - newChildren.remove(child); - Intersection mc = new Intersection(newChildren); - refinements.add(mc); - } - } - } else if (concept instanceof Union) { - // eines der Elemente kann verfeinert werden - for(Description child : concept.getChildren()) { - - // Refinement für das Kind ausführen - // tmp = refine(child); - tmp = refine(child); - // neue MultiConjunction konstruieren - for(Description c : tmp) { - List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); - // es muss genau die vorherige Reihenfolge erhalten bleiben - // (zumindest bis die Normalform definiert ist) - int index = newChildren.indexOf(child); - newChildren.add(index, c); - newChildren.remove(child); - Union md = new Union(newChildren); - refinements.add(md); - } - } - - // ein Element der Disjunktion kann weggelassen werden - for(Description child : concept.getChildren()) { - List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); - newChildren.remove(child); - // wenn nur ein Kind da ist, dann wird Disjunktion gleich weggelassen - if(newChildren.size()==1) - refinements.add(newChildren.get(0)); - else { - Union md = new Union(newChildren); - refinements.add(md); - } - } - - } else if (concept instanceof ObjectSomeRestriction) { - tmp = refine(concept.getChild(0)); - for(Description c : tmp) { - refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); - } - - // falls Kind Bottom ist, dann kann exists weggelassen werden - if(concept.getChild(0) instanceof Nothing) - refinements.add(new Nothing()); - - } else if (concept instanceof ObjectAllRestriction) { - tmp = refine(concept.getChild(0)); - for(Description c : tmp) { - refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); - } - - if(concept.getChild(0) instanceof Nothing) - refinements.add(new Nothing()); - - // falls es keine spezielleren atomaren Konzepte gibt, dann wird - // bottom angehangen => nur wenn es ein atomares Konzept (insbesondere != bottom) - // ist - // if(tmp.size()==0) { - // if(concept.getChild(0) instanceof AtomicConcept && tmp.size()==0) { - // refinements.add(new All(((Quantification)concept).getRole(),new Bottom())); - //} - } else - throw new RuntimeException(concept.toString()); - - // falls Konzept ungleich Bottom oder Top, dann kann ein Refinement von Top - // angehangen werden - if(concept instanceof Union || concept instanceof NamedClass || - concept instanceof Negation || concept instanceof ObjectSomeRestriction || concept instanceof ObjectAllRestriction) { - - // es wird AND TOP angehangen - Intersection mc = new Intersection(); - mc.addChild(concept); - mc.addChild(new Thing()); - refinements.add(mc); - } - - // Refinements werden jetzt noch bereinigt, d.h. Verschachtelungen von Konjunktionen - // werden entfernt; es wird eine neue Menge erzeugt, da die Transformationen die - // Ordnung des Konzepts ändern könnten - // TODO: eventuell geht das noch effizienter, da die meisten Refinement-Regeln Refinements - // von Child-Konzepten sind, die bereits geordnet sind, d.h. man könnte dort eventuell - // gleich absichern, dass alle neu hinzugefügten Refinements in geordneter Negationsnormalform - // sind - // SortedSet<Concept> returnSet = new TreeSet<Concept>(conceptComparator); - /* - - Set<Concept> returnSet = new HashSet<Concept>(); - for(Concept c : refinements) { - ConceptTransformation.cleanConcept(c); - // ConceptTransformation.transformToOrderedNegationNormalForm(c, conceptComparator); - returnSet.add(c); - } - - return returnSet; - */ - - // Zwischenschritt wird weggelassen - man muss nicht alle Konzepte cleanen, - // um dann nur eins davon auszuwählen - - return refinements; - - } - - public Set<Description> refine(Description concept, int maxLength, - List<Description> knownRefinements) { - throw new RuntimeException(); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiUp.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiUp.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/PsiUp.java 2008-02-27 11:24:56 UTC (rev 647) @@ -1,221 +0,0 @@ -package org.dllearner.algorithms.hybridgp; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import org.dllearner.algorithms.refinement.RefinementOperator; -import org.dllearner.core.ReasoningService; -import org.dllearner.core.owl.ObjectAllRestriction; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.Nothing; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.Union; -import org.dllearner.core.owl.Negation; -import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectQuantorRestriction; -import org.dllearner.core.owl.Thing; -import org.dllearner.learningproblems.PosNegLP; -import org.dllearner.utilities.ConceptComparator; - -public class PsiUp implements RefinementOperator { - - ConceptComparator conceptComparator = new ConceptComparator(); - - PosNegLP learningProblem; - ReasoningService reasoningService; - - private TreeSet<Description> bottomSet; - - public PsiUp(PosNegLP learningProblem) { - this.learningProblem = learningProblem; - reasoningService = learningProblem.getReasoningService(); - - // Top-Menge erstellen - createBottomSet(); - } - - private void createBottomSet() { - bottomSet = new TreeSet<Description>(conceptComparator); - - // BOTTOM AND BOTTOM - Intersection mc = new Intersection(); - mc.addChild(new Nothing()); - mc.addChild(new Nothing()); - bottomSet.add(mc); - - // speziellste Konzepte - bottomSet.addAll(reasoningService.getMoreGeneralConcepts(new Nothing())); - - // negierte allgemeinste Konzepte - Set<Description> tmp = reasoningService.getMoreSpecialConcepts(new Thing()); - for(Description c : tmp) - bottomSet.add(new Negation(c)); - - // EXISTS r.BOTTOM und ALL r.BOTTOM für alle r - for(ObjectProperty r : reasoningService.getAtomicRoles()) { - bottomSet.add(new ObjectAllRestriction(r, new Nothing())); - bottomSet.add(new ObjectSomeRestriction(r, new Nothing())); - } - } - - @SuppressWarnings("unchecked") - public Set<Description> refine(Description concept) { - - Set<Description> refinements = new HashSet<Description>(); - Set<Description> tmp = new HashSet<Description>(); - - if (concept instanceof Thing) { - return new TreeSet<Description>(conceptComparator); - } else if (concept instanceof Nothing) { - return (Set<Description>) bottomSet.clone(); - } else if (concept instanceof NamedClass) { - // Top darf hier mit dabei sein - refinements.addAll(reasoningService.getMoreGeneralConcepts(concept)); - - // negiertes atomares Konzept - } else if (concept instanceof Negation && concept.getChild(0) instanceof NamedClass) { - tmp.addAll(reasoningService.getMoreSpecialConcepts(concept.getChild(0))); - - // Bottom rausschmeissen - boolean containsBottom = false; - Iterator<Description> it = tmp.iterator(); - while(it.hasNext()) { - Description c = it.next(); - if(c instanceof Nothing) { - it.remove(); - containsBottom = true; - } - } - // es soll z.B. NOT male auch zu NOT BOTTOM d.h. zu TOP verfeinert - // werden können - if(containsBottom) - refinements.add(new Thing()); - - for(Description c : tmp) { - refinements.add(new Negation(c)); - } - } else if (concept instanceof Intersection) { - // eines der Elemente kann verfeinert werden - for(Description child : concept.getChildren()) { - - // Refinement für das Kind ausführen - tmp = refine(child); - - // neue MultiConjunction konstruieren - for(Description c : tmp) { - // TODO: müssen auch alle Konzepte geklont werden?? - // hier wird nur eine neue Liste erstellt - // => eigentlich muss nicht geklont werden (d.h. deep copy) da - // die Konzepte nicht verändert werden während des Algorithmus - List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); - // es muss genau die vorherige Reihenfolge erhalten bleiben - // (zumindest bis die Normalform definiert ist) - int index = newChildren.indexOf(child); - newChildren.add(index, c); - newChildren.remove(child); - Intersection mc = new Intersection(newChildren); - refinements.add(mc); - } - } - - // ein Element der Konjunktion kann weggelassen werden - for(Description child : concept.getChildren()) { - List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); - newChildren.remove(child); - if(newChildren.size()==1) - refinements.add(newChildren.get(0)); - else { - Intersection md = new Intersection(newChildren); - refinements.add(md); - } - } - } else if (concept instanceof Union) { - // eines der Elemente kann verfeinert werden - for(Description child : concept.getChildren()) { - - // Refinement für das Kind ausführen - // tmp = refine(child); - tmp = refine(child); - // neue MultiConjunction konstruieren - for(Description c : tmp) { - List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); - // es muss genau die vorherige Reihenfolge erhalten bleiben - // (zumindest bis die Normalform definiert ist) - int index = newChildren.indexOf(child); - newChildren.add(index, c); - newChildren.remove(child); - Union md = new Union(newChildren); - refinements.add(md); - } - } - } else if (concept instanceof ObjectSomeRestriction) { - tmp = refine(concept.getChild(0)); - for(Description c : tmp) { - refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); - } - - if(concept.getChild(0) instanceof Thing) - refinements.add(new Thing()); - - } else if (concept instanceof ObjectAllRestriction) { - tmp = refine(concept.getChild(0)); - for(Description c : tmp) { - refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); - } - - if(concept.getChild(0) instanceof Thing) - refinements.add(new Thing()); - - // falls es keine spezielleren atomaren Konzepte gibt, dann wird - // bottom angehangen => nur wenn es ein atomares Konzept (insbesondere != bottom) - // ist - // if(tmp.size()==0) { - // if(concept.getChild(0) instanceof AtomicConcept && tmp.size()==0) { - // refinements.add(new All(((Quantification)concept).getRole(),new Bottom())); - //} - } else - throw new RuntimeException(concept.toString()); - - if(concept instanceof Union || concept instanceof NamedClass || - concept instanceof Negation || concept instanceof ObjectSomeRestriction || concept instanceof ObjectAllRestriction) { - - // es wird OR BOTTOM angehangen - Union md = new Union(); - md.addChild(concept); - md.addChild(new Nothing()); - refinements.add(md); - } - - // Refinements werden jetzt noch bereinigt, d.h. Verschachtelungen von Konjunktionen - // werden entfernt; es wird eine neue Menge erzeugt, da die Transformationen die - // Ordnung des Konzepts ändern könnten - // TODO: eventuell geht das noch effizienter, da die meisten Refinement-Regeln Refinements - // von Child-Konzepten sind, die bereits geordnet sind, d.h. man könnte dort eventuell - // gleich absichern, dass alle neu hinzugefügten Refinements in geordneter Negationsnormalform - // sind - // SortedSet<Concept> returnSet = new TreeSet<Concept>(conceptComparator); - /* - Set<Concept> returnSet = new HashSet<Concept>(); - for(Concept c : refinements) { - ConceptTransformation.cleanConcept(c); - // ConceptTransformation.transformToOrderedNegationNormalForm(c, conceptComparator); - returnSet.add(c); - } - - return returnSet; - */ - return refinements; - } - - public Set<Description> refine(Description concept, int maxLength, - List<Description> knownRefinements) { - throw new RuntimeException(); - } - -} Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-27 11:24:56 UTC (rev 647) @@ -26,7 +26,6 @@ import java.util.List; import java.util.Set; -import org.dllearner.algorithms.refinement.RhoDown; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; @@ -44,6 +43,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.refinementoperators.RhoDown; import org.dllearner.utilities.Files; import org.dllearner.utilities.Helper; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 11:24:56 UTC (rev 647) @@ -32,7 +32,6 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.dllearner.algorithms.refinement.RefinementOperator; -import org.dllearner.algorithms.refinement.RhoDown; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; @@ -43,6 +42,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.refinementoperators.RhoDown; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-27 11:24:56 UTC (rev 647) @@ -32,6 +32,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; +import org.dllearner.refinementoperators.RhoDown; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; import org.dllearner.utilities.Files; Deleted: trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-27 11:24:56 UTC (rev 647) @@ -1,765 +0,0 @@ -/** - * Copyright (C) 2007, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.algorithms.refinement; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.dllearner.core.ReasoningService; -import org.dllearner.core.owl.BooleanValueRestriction; -import org.dllearner.core.owl.DatatypeProperty; -import org.dllearner.core.owl.ObjectAllRestriction; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.Nothing; -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.ObjectSomeRestriction; -import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.Union; -import org.dllearner.core.owl.Negation; -import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectPropertyExpression; -import org.dllearner.core.owl.ObjectQuantorRestriction; -import org.dllearner.core.owl.Thing; -import org.dllearner.core.owl.ValueRestriction; -import org.dllearner.utilities.ConceptComparator; -import org.dllearner.utilities.ConceptTransformation; - -/** - * Implementation of the downward refinement operator in the DL-Learner refinement - * based algorithm. - * - * See <a href="http://jens-lehmann.org/files/2007_alc_learning_algorithm.pdf" - * >http://jens-lehmann.org/files/2007_alc_learning_algorithm.pdf</a> for - * details. - * - * @author Jens Lehmann - * - */ -public class RhoDown implements RefinementOperator { - -// private PosNegLP learningProblem; - private ReasoningService rs; - - // gibt die Gr��e an bis zu der die Refinements des Top-Konzepts - // bereits berechnet worden => entspricht der max. L�nge der Menge M - private int topRefinementsLength = 0; - - // die Menge M im Refinement-Operator indiziert nach ihrer L�nge - Map<Integer,Set<Description>> m = new HashMap<Integer,Set<Description>>(); - - // Zerlegungen der Zahl n in Mengen - // Map<Integer,Set<IntegerCombo>> combos = new HashMap<Integer,Set<IntegerCombo>>(); - Map<Integer, List<List<Integer>>> combos = new HashMap<Integer, List<List<Integer>>>(); - // abspeichern von Kombinationen während diese rekursiv berechnet werden - // private List<List<Integer>> combosTmp; - - // Refinements des Top-Konzept indiziert nach Länge - Map<Integer, TreeSet<Description>> topRefinements = new HashMap<Integer, TreeSet<Description>>(); - Map<Integer, TreeSet<Description>> topRefinementsCumulative = new HashMap<Integer, TreeSet<Description>>(); - - // comparator für Konzepte - private ConceptComparator conceptComparator = new ConceptComparator(); - - // Statistik - public long mComputationTimeNs = 0; - public long topComputationTimeNs = 0; - - private boolean applyAllFilter = true; - private boolean applyExistsFilter = true; - private boolean useAllConstructor = true; - private boolean useExistsConstructor = true; - private boolean useNegation = true; - private boolean useBooleanDatatypes = true; - - // braucht man wirklich das learningProblem oder reicht der Reasoning-Service? - // TODO: conceptComparator könnte auch noch Parameter sein - public RhoDown(ReasoningService reasoningService, boolean applyAllFilter, boolean applyExistsFilter, boolean useAllConstructor, - boolean useExistsConstructor, boolean useNegation, boolean useBooleanDatatypes) { - this.rs = reasoningService; - this.applyAllFilter = applyAllFilter; - this.applyExistsFilter = applyExistsFilter; - this.useAllConstructor = useAllConstructor; - this.useExistsConstructor = useExistsConstructor; - this.useNegation = useNegation; - this.useBooleanDatatypes = useBooleanDatatypes; - -// this.learningProblem = learningProblem; -// rs = learningProblem.getReasoningService(); - } - - public Set<Description> refine(Description concept) { - throw new RuntimeException(); - // TODO Auto-generated method stub - // return null; - } - - // TODO: Methode muss effizienter werden - // Hauptproblem ist nicht die Berechnung von M und Top (siehe Benchmarks) - // => zuerst muss Objekterzeugung minimiert werden - // => als zweites wäre bei nicht ausreichendem Performancegewinn die Implementierung - // von Minimallänge eine Möglichkeit (alle Refinements, auch improper, müssten - // dann im Algorithmus gespeichert werden) - @SuppressWarnings("unchecked") - public SortedSet<Description> refine(Description concept, int maxLength, - List<Description> knownRefinements) { - - - - // Set<Concept> refinements = new HashSet<Concept>(); - SortedSet<Description> refinements = new TreeSet<Description>(conceptComparator); - Set<Description> tmp = new HashSet<Description>(); - // SortedSet<Concept> tmp = new TreeSet<Concept>(conceptComparator); - - if (concept instanceof Thing) { - - // ggf. Refinements von Top erweitern - if(maxLength>topRefinementsLength) - computeTopRefinements(maxLength); - // System.out.println(topRefinements); - refinements = (TreeSet<Description>) topRefinementsCumulative.get(maxLength).clone(); - // refinements = copyTopRefinements(maxLength); - // refinements = topRefinementsCumulative.get(maxLength); - - } else if (concept instanceof Nothing) { - // return new HashSet<Concept>(); - } else if (concept instanceof ValueRestriction) { - // value restrictions cannot be further refined - } else if (concept instanceof NamedClass) { - // Erkenntnisse aus Benchmarks: dieser Teil wird sehr häufig aufgerufen, - // allerdings lässt er sich kaum weiter verbessern (selbst ohne klonen - // der Konzepte im DIG-Reasoner, was durch das entfernen von Bottom notwendig - // ist und außerdem sicherer vor zukünftigen Bugs, wird es nicht wesentlich - // schneller) - - // beachte: die Funktion gibt bereits nur nicht-äquivalente Konzepte zurück - // TODO: der Cast auf SortedSet ist nur ein Hack und muss später geeignet - // behandelt werden - refinements = rs.getMoreSpecialConcepts(concept); - // refinements.addAll(learningProblem.getReasoningService().getMoreSpecialConcepts(concept)); - - // Bottom rausschmeißen (nicht im Operator vorgesehen) - // Iterator<Concept> it = refinements.iterator(); - // while(it.hasNext()) { - // Concept c = it.next(); - // if(c instanceof Bottom) - // it.remove(); - // } - // geht jetzt auch schneller durch conceptComparator - refinements.remove(new Nothing()); - - // negiertes atomares Konzept - } else if (concept instanceof Negation && concept.getChild(0) instanceof NamedClass) { - - tmp = rs.getMoreGeneralConcepts(concept.getChild(0)); - - //Iterator<Concept> it = tmp.iterator(); - //while(it.hasNext()) { - // Concept c = it.next(); - // if(c instanceof Top) - // it.remove(); - //} - - // tmp.remove(new Top()); - - for(Description c : tmp) { - if(!(c instanceof Thing)) - refinements.add(new Negation(c)); - } - - } else if (concept instanceof Intersection) { - - // eines der Elemente kann verfeinert werden - for(Description child : concept.getChildren()) { - - // Refinement für das Kind ausführen - // System.out.println("child: " + child); - // wenn man von maximaler Länge die Länge des Konzepts außer dem aktuell - // betrachteten Element abzieht, dann bekommt man neue maxLength - tmp = refine(child, maxLength - concept.getLength()+child.getLength(),null); - - // neue MultiConjunction konstruieren - for(Description c : tmp) { - // TODO: müssen auch alle Konzepte geklont werden?? - // hier wird nur eine neue Liste erstellt - // => eigentlich muss nicht geklont werden (d.h. deep copy) da - // die Konzepte nicht verändert werden während des Algorithmus - // => es muss geklont werden, da die top refinements nicht verändert - // werden dürfen - // List<Concept> newChildren = new LinkedList<Concept>(concept.getChildren()); - // TODO: Class Cast ist nur ein Hack - List<Description> newChildren = (List<Description>)((LinkedList)concept.getChildren()).clone(); - // es muss genau die vorherige Reihenfolge erhalten bleiben - // (zumindest bis die Normalform definiert ist) - // int index = newChildren.indexOf(child); - // newChildren.add(index, c); - // newChildren.remove(child); - // MultiConjunction mc = new MultiConjunction(newChildren); - - // Index muss jetzt nich mehr erhalten bleiben, da ohnehin - // neu sortiert wird - newChildren.add(c); - newChildren.remove(child); - Intersection mc = new Intersection(newChildren); - - // sicherstellten, dass Konzept in negation normal form ist - ConceptTransformation.cleanConceptNonRecursive(mc); - ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); - - refinements.add(mc); - } - - } - - } else if (concept instanceof Union) { - // eines der Elemente kann verfeinert werden - for(Description child : concept.getChildren()) { - - // Refinement für das Kind ausführen - // tmp = refine(child); - tmp = refine(child, maxLength - concept.getLength()+child.getLength(),null); - - - - // neue MultiConjunction konstruieren - for(Description c : tmp) { - List<Description> newChildren = new LinkedList<Description>(concept.getChildren()); - // es muss genau die vorherige Reihenfolge erhalten bleiben - // (zumindest bis die Normalform definiert ist) - // int index = newChildren.indexOf(child); - // newChildren.add(index, c); - newChildren.remove(child); - newChildren.add(c); - Union md = new Union(newChildren); - - // sicherstellten, dass Konzept in negation normal form ist - // ConceptTransformation.cleanConcept(md); // nicht notwendig, da kein Element einer - // Disjunktion auf eine Disjunktion abgebildet wird (nur Top und das ist nie - // in einer Disjunktion) - ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(md, conceptComparator); - - - refinements.add(md); - } - - - } - - } else if (concept instanceof ObjectSomeRestriction) { - ObjectPropertyExpression role = ((ObjectQuantorRestriction)concept).getRole(); - - // rule 1: EXISTS r.D => EXISTS r.E - tmp = refine(concept.getChild(0), maxLength-2, null); - - for(Description c : tmp) { - refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); - } - - // rule 2: EXISTS r.D => EXISTS s.D or EXISTS r^-1.D => EXISTS s^-1.D - // currently inverse roles are not supported - ObjectProperty ar = (ObjectProperty) role; - Set<ObjectProperty> moreSpecialRoles = rs.getMoreSpecialRoles(ar); - for(ObjectProperty moreSpecialRole : moreSpecialRoles) { - refinements.add(new ObjectSomeRestriction(moreSpecialRole, concept.getChild(0))); - } - - } else if (concept instanceof ObjectAllRestriction) { - ObjectPropertyExpression role = ((ObjectQuantorRestriction)concept).getRole(); - - // rule 1: ALL r.D => ALL r.E - tmp = refine(concept.getChild(0), maxLength-2, null); - - for(Description c : tmp) { - refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)concept).getRole(),c)); - } - - // rule 2: ALL r.D => ALL r.BOTTOM if D is a most specific atomic concept - // falls es keine spezielleren atomaren Konzepte gibt, dann wird - // bottom angehangen => nur wenn es ein atomares Konzept (insbesondere != bottom) - // ist - // if(tmp.size()==0) { - if(concept.getChild(0) instanceof NamedClass && tmp.size()==0) { - refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)concept).getRole(),new Nothing())); - } - - // rule 3: ALL r.D => ALL s.D or ALL r^-1.D => ALL s^-1.D - // currently inverse roles are not supported - ObjectProperty ar = (ObjectProperty) role; - Set<ObjectProperty> moreSpecialRoles = rs.getMoreSpecialRoles(ar); - for(ObjectProperty moreSpecialRole : moreSpecialRoles) { - refinements.add(new ObjectAllRestriction(moreSpecialRole, concept.getChild(0))); - } - - } - - // falls Konzept ungleich Bottom oder Top, dann kann ein Refinement von Top - // angehangen werden - if(concept instanceof Union || concept instanceof NamedClass || - concept instanceof Negation || concept instanceof ObjectQuantorRestriction - || concept instanceof ValueRestriction) { - // long someTimeNsStart = System.nanoTime(); - // someCount++; - // Refinement von Top anhängen - int topRefLength = maxLength - concept.getLength() - 1; //-1 wegen zusätzlichem UND - // es könnte passieren, das wir hier neue Refinements von Top berechnen müssen - if(topRefLength > topRefinementsLength) - computeTopRefinements(topRefLength); - if(topRefLength>0) { - // Set<Concept> topRefs = copyTopRefinements(topRefLength); - Set<Description> topRefs = topRefinementsCumulative.get(topRefLength); - for(Description c : topRefs) { - boolean skip = false; - - // falls Refinement von der Form ALL r ist, dann prüfen, ob - // ALL r nicht bereits vorkommt - if(applyAllFilter) { - if(c instanceof ObjectAllRestriction) { - for(Description child : concept.getChildren()) { - if(child instanceof ObjectAllRestriction) { - ObjectPropertyExpression r1 = ((ObjectAllRestriction)c).getRole(); - ObjectPropertyExpression r2 = ((ObjectAllRestriction)child).getRole(); - if(r1.toString().equals(r2.toString())) - skip = true; - } - } - } - } - - if(!skip) { - // MultiConjunction md = new MultiConjunction(concept.getChildren()); - Intersection mc = new Intersection(); - mc.addChild(concept); - mc.addChild(c); - - // Negationsnormalform herstellen - ConceptTransformation.cleanConceptNonRecursive(mc); - ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc, conceptComparator); - - refinements.add(mc); - } - } - } - // someTimeNs += System.nanoTime() - someTimeNsStart; - } - - - - // Refinements werden jetzt noch bereinigt, d.h. Verschachtelungen von Konjunktionen - // werden entfernt; es wird eine neue Menge erzeugt, da die Transformationen die - // Ordnung des Konzepts ändern könnten - // TODO: eventuell geht das noch effizienter, da die meisten Refinement-Regeln Refinements - // von Child-Konzepten sind, die bereits geordnet sind, d.h. man könnte dort eventuell - // gleich absichern, dass alle neu hinzugefügten Refinements in geordneter Negationsnormalform - // sind - /* - SortedSet<Concept> returnSet = new TreeSet<Concept>(conceptComparator); - for(Concept c : refinements) { - ConceptTransformation.cleanConcept(c); - ConceptTransformation.transformToOrderedNegationNormalForm(c, conceptComparator); - returnSet.add(c); - } - - return returnSet; - */ - // TODO: obiger Code kann noch nicht gelöscht werden (anderes Ergebnis); warum? - // => erstmal so implementieren, dass obiger Code nicht mehr gebraucht wird und - // im zweiten Schritt dann auf die nicht-rekursiven Methoden umsteigen - return refinements; - } - - - // TODO: Methode kann später entfernt werden, es muss nur - // sichergestellt werden, dass die refine-Methode an den - // kumulativen Top-Refinements nichts ändert - @SuppressWarnings("unused") - private SortedSet<Description> copyTopRefinements(int maxLength) { - // return topRefinementsCumulative.get(maxLength); - SortedSet<Description> ret = new TreeSet<Description>(conceptComparator); - for(Description c : topRefinementsCumulative.get(maxLength)) - ret.add(c); - return ret; - } - - - // TODO: später private - public void computeTopRefinements(int maxLength) { - long topComputationTimeStartNs = System.nanoTime(); - - // M erweiteren - computeM(maxLength); - - // berechnen aller möglichen Kombinationen für Disjunktion, - for(int i = topRefinementsLength+1; i <= maxLength; i++) { - combos.put(i,getCombos(i)); - topRefinements.put(i, new TreeSet<Description>(conceptComparator)); - // topRefinements.put(i, new HashSet<Concept>()); - - for(List<Integer> combo : combos.get(i)) { - /* - // für eine Kombo alle Konzeptkombinationen berechnen - Set<Set<Concept>> baseSet = new HashSet<Set<Concept>>(); - // boolean firstNonEmptyNumber = true; - for(Integer j : combo.getNumbers()) { - // initialisiert wird mit der passenden Menge m - //if(firstNonEmptyNumber || ) - // baseSet.add(m.get(j)); - // else { - baseSet = incCrossProduct(baseSet,m.get(j)); - //} - } - - // Disjunktionen erzeugen und hinzufügen - for(Set<Concept> children : baseSet) { - if(children.size() == 1) { - Iterator<Concept> it = children.iterator(); - Concept c = it.next(); - topRefinements.get(i).add(c); - } else { - topRefinements.get(i).add(new MultiDisjunction(children)); - } - } - */ - - /* neue Implementierung */ - - // Kombination besteht aus nur einer Zahl => einfach M benutzen - // if(combo.getNumbers().size()==1) { - if(combo.size()==1) { - topRefinements.get(i).addAll(m.get(i)); - // Kombination besteht aus mehreren Zahlen => Disjunktion erzeugen - } else { - Set<Union> baseSet = new HashSet<Union>(); - for(Integer j : combo) { // combo.getNumbers()) { - baseSet = incCrossProduct2(baseSet, m.get(j)); - } - - // Umwandlung aller Konzepte in Negationsnormalform - for(Description concept : baseSet) { - ConceptTransformation.transformToOrderedNegationNormalForm(concept, conceptComparator); - } - - if(applyExistsFilter) { - Iterator<Union> it = baseSet.iterator(); - while(it.hasNext()) { - Union md = it.next(); - boolean remove = false; - // falls Exists r für gleiche Rolle zweimal vorkommt, - // dann rausschmeißen - // Map<AtomicRole,Boolean> roleOccured = new HashMap<AtomicRole,Boolean>(); - Set<String> roles = new TreeSet<String>(); - for(Description c : md.getChildren()) { - if(c instanceof ObjectSomeRestriction) { - String role = ((ObjectSomeRestriction)c).getRole().getName(); - boolean roleExists = !roles.add(role); - // falls Rolle schon vorkommt, dann kann ganzes - // Refinement ignoriert werden (man könnte dann auch - // gleich abbrechen, aber das hat nur minimalste - // Auswirkungen auf Effizienz) - if(roleExists) - remove = true; - } - } - if(remove) - it.remove(); - - } - } - - topRefinements.get(i).addAll(baseSet); - } - } - - // neu berechnete Refinements kumulieren, damit sie schneller abgefragt werden können - // computeCumulativeTopRefinements(i); - TreeSet<Description> cumulativeRefinements = new TreeSet<Description>(conceptComparator); - // Set<Concept> cumulativeRefinements = new HashSet<Concept>(); - for(int j=1; j<=i; j++) { - cumulativeRefinements.addAll(topRefinements.get(j)); - } - topRefinementsCumulative.put(i, cumulativeRefinements); - } - - // neue Maximallänge eintragen - topRefinementsLength = maxLength; - - topComputationTimeNs += System.nanoTime() - topComputationTimeStartNs; - } - - // computation of the set M - private void computeM(int maxLength) { - long mComputationTimeStartNs = System.nanoTime(); - // System.out.println("compute M from " + (topRefinementsLength+1) + " up to " + maxLength); - - // initialise all not yet initialised lengths - // (avoids null pointers in some cases) - for(int i=topRefinementsLength+1; i<=maxLength; i++) { - m.put(i, new TreeSet<Description>(conceptComparator)); - } - - // Berechnung der Basiskonzepte in M - // TODO: Spezialfälle, dass zwischen Top und Bottom nichts liegt behandeln - if(topRefinementsLength==0 && maxLength>0) { - // Konzepte der Länge 1 = alle Konzepte, die in der Subsumptionhierarchie unter Top liegen - Set<Description> m1 = rs.getMoreSpecialConcepts(new Thing()); - m.put(1,m1); - } - - if(topRefinementsLength<2 && maxLength>1) { - // Konzepte der Länge 2 = Negation aller Konzepte, die über Bottom liegen - if(useNegation) { - Set<Description> m2tmp = rs.getMoreGeneralConcepts(new Nothing()); - Set<Description> m2 = new TreeSet<Description>(conceptComparator); - for(Description c : m2tmp) { - m2.add(new Negation(c)); - } - m.put(2,m2); - } - } - - if(topRefinementsLength<3 && maxLength>2) { - // Konzepte der Länge 3: EXISTS r.TOP - Set<Description> m3 = new TreeSet<Description>(conceptComparator); - if(useExistsConstructor) { - // previous operator: uses all roles - // for(AtomicRole r : Config.Refinement.allowedRoles) { - // m3.add(new Exists(r, new Top())); - //} - // new operator: only uses most general roles - for(ObjectProperty r : rs.getMostGeneralRoles()) { - m3.add(new ObjectSomeRestriction(r, new Thing())); - } - - } - - // boolean datatypes, e.g. testPositive = true - if(useBooleanDatatypes) { - Set<DatatypeProperty> booleanDPs = rs.getBooleanDatatypeProperties(); - for(DatatypeProperty dp : booleanDPs) { - m3.add(new BooleanValueRestriction(dp,true)); - m3.add(new BooleanValueRestriction(dp,false)); - } - } - - m.put(3,m3); - } - - if(maxLength>2) { - if(useAllConstructor) { - // Konzepte, die mit ALL r starten - // alle existierenden Konzepte durchgehen, die maximal 2 k�rzer als - // die maximale L�nge sind - // topRefinementsLength - 1, damit Konzepte der Länge mindestens - // topRefinementsLength + 1 erzeugt werden (ALL r) - for(int i=topRefinementsLength-1; i<=maxLength-2; i++) { - // i muss natürlich mindestens 1 sein - if(i>=1) { - - // alle Konzepte durchgehen - for(Description c : m.get(i)) { - // Fall wird jetzt weiter oben schon abgehandelt - // if(!m.containsKey(i+2)) - // m.put(i+2, new TreeSet<Concept>(conceptComparator)); - - // previous operator: uses all roles - // for(AtomicRole r : Config.Refinement.allowedRoles) { - // Mehrfacheinf�gen ist bei einer Menge kein Problem - // m.get(i+2).add(new All(r,c)); - // } - - for(ObjectProperty r : rs.getMostGeneralRoles()) { - m.get(i+2).add(new ObjectAllRestriction(r,c)); - } - } - } - } - } - } - - mComputationTimeNs += System.nanoTime() - mComputationTimeStartNs; - } - - - public static void summen(int zahl, int max, String bisher, int recDepth) - { - for(int j=0; j<recDepth; j++) - System.out.print(" "); - System.out.println("f("+zahl+","+max+",\""+bisher+"\")"); - - for (int i = Math.min(zahl, max); i >= 1; i--) - { - - String jetzt = bisher + i; - - if (zahl - i > 1) - { - jetzt += " + "; - // i wird hinzugefügt, d.h. - // - es muss nur noch zahl - i zerlegt werden - // - es darf keine größere Zahl als i mehr vorkommen - // (dadurch gehen keine Kombinationen verloren) - summen(zahl - i -1 , i, jetzt, recDepth+1); - } - // Fall zahl == i, d.h. es muss nicht weiter zerlegt werden - else if(zahl - i == 0){ - for(int j=0; j<recDepth; j++) - System.out.print(" "); - System.out.println(jetzt); - } - // durch die -1 Abzug für jedes Zwischenzeichen gibt es auch Fälle, in denen - // keine Lösung entsteht (zahl-i==1) - - } - } - - @SuppressWarnings("unchecked") - private LinkedList<Integer> cloneList(LinkedList<Integer> list) { - return (LinkedList<Integer>) list.clone(); - } - - /** - * - * Dadurch das max das Maximum der vorkommenden Zahl regelt, kommen - * keine doppelten Kombinationen vor. - * - * TODO: Implementierung mit Speicherung in Datenstruktur statt - * direkter Ausgabe; IntegerCombo wird hier gar nicht benötigt, da - * alle Elemente bereits in richtiger Reihenfolge vorliegen und - * es keine doppelten Nennungen gibt - * - * @param zahl Zu zerlegende Zahl. - * @param max Maximal in Summenzerlegung vorkommende Zahl. - * @param bisher - */ - private void zerlege(int zahl, int max, LinkedList<Integer> bisher, List<List<Integer>> combosTmp) { - - for (int i = Math.min(zahl, max); i >= 1; i--) - { - - LinkedList<Integer> newBisher = null; - // für i==0 wird aus Effizienzgründen die bisherige Liste genommen - if(i==0) { - newBisher = bisher; - newBisher.add(i); - // für zahl - i == 1 muss gar keine Liste erstellt werden, da dann keine - // Zerlegung mehr möglich ist - } else if(zahl - i != 1) { - newBisher = cloneList(bisher); - newBisher.add(i); - } - - - if (zahl - i > 1) - { - // i wird hinzugefügt, d.h. - // - es muss nur noch zahl - i - 1 zerlegt werden (-1 wegen OR-Symbol) - // - es darf keine größere Zahl als i mehr vorkommen - // (dadurch gehen keine Kombinationen verloren) - zerlege(zahl - i - 1, i, newBisher,combosTmp); - } - // Fall zahl == i, d.h. es muss nicht weiter zerlegt werden - else if(zahl - i == 0){ - combosTmp.add(newBisher); - } - - - } - - // numbers.add(bisher); - } - - // auf Notebook: Länge 70 in 17 Sekunden, Länge 50 in 800ms, Länge 30 in 15ms - // http://88.198.173.90/tud/forum/messages?topic=304392 - public List<List<Integer>> getCombos(int length) { - LinkedList<List<Integer>> combosTmp = new LinkedList<List<Integer>>(); - zerlege(length, length, new LinkedList<Integer>(), combosTmp); - return combosTmp; - } - - // neue Implementierung, die nicht mehr zur incompleteness führen soll, - // da die Konzepte in einer MultiDisjunction als Liste gespeichert werden - private Set<Union> incCrossProduct2(Set<Union> baseSet, Set<Description> newSet) { - Set<Union> retSet = new HashSet<Union>(); - - if(baseSet.isEmpty()) { - for(Description c : newSet) { - Union md = new Union(); - md.addChild(c); - retSet.add(md); - } - return retSet; - } - - for(Union md : baseSet) { - for(Description c : newSet) { - Union mdNew = new Union(md.getChildren()); - mdNew.addChild(c); - retSet.add(mdNew); - } - } - - return retSet; - } - - // incremental cross product - // es müssen Listen statt Sets verwendet werden - @SuppressWarnings({"unused"}) - private Set<Set<Description>> incCrossProduct(Set<Set<Description>> baseSet, Set<Description> newSet) { - Set<Set<Description>> retSet = new HashSet<Set<Description>>(); - - // falls erste Menge leer ist, dann wird Menge mit jeweils Singletons aus der - // zweiten Menge zurückgegeben => das müsste dem Fall entsprechen, dass das - // baseSet nur die leere Menge enthält - if(baseSet.isEmpty()) { - for(Description c : newSet) { - Set<Description> singleton = new HashSet<Description>(); - singleton.add(c); - retSet.add(singleton); - } - // retSet.add(newSet); - return retSet; - } - - for(Set<Description> set : baseSet) { - for(Description c : newSet) { - // neues Konzept zu alter Konzeptmenge hinzufügen, indem altes - // Konzept kopiert und ergänzt wird - // beachte: dadurch, dass die Konzepte nach ihrem Hash eingefügt werden, - // ist schon eine Ordnung vorgegeben und es entfallen viele Mengen - // z.B. ist {male,female} = {female,male} - // TODO: das ist allerdings auch gefährlich, denn es gilt auch - // {male,male,female} = {male,female} d.h. es entfallen auch gewünschte - // Lösungen! (Es könnte z.B. sein, dass die Lösung eine Disjunktion von - // 3 atomaren Konzepten ist, die nur über male erreichbar sind.) D.h. diese - // Implementierung führt zur incompleteness des Operators. - Set<Description> newConcept = new HashSet<Description>(set); - newConcept.add(c); - retSet.add(newConcept); - } - } - return retSet; - } - -} Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-27 11:24:56 UTC (rev 647) @@ -25,6 +25,7 @@ import java.util.SortedSet; import org.dllearner.core.owl.Constant; +import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; @@ -96,6 +97,14 @@ public Map<String, String> getPrefixes(); + public Description getDomain(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; + + public Description getDomain(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + + public Description getRange(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException; + + public DataRange getRange(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + // currently, we do not require that datatype properties can be returned; // the main reason is that DIG does not distinguish between datatype and // object properties (of course one could implement it but it is not easy) Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-27 11:24:56 UTC (rev 647) @@ -28,6 +28,7 @@ import java.util.Map.Entry; import org.dllearner.core.owl.Constant; +import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; @@ -193,6 +194,22 @@ throw new ReasoningMethodUnsupportedException(); } + public Description getDomain(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Description getDomain(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Description getRange(ObjectProperty objectProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public DataRange getRange(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + public Set<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-27 10:21:24 UTC (rev 646) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-27 11:24:56 UTC (rev 647) @@ -205,6 +205,7 @@ owlDatatypeProperties.addAll(ontology.getReferencedDataProperties()); owlIndividuals.addAll(ontology.getReferencedIndividuals()); + // TODO: this obviously works only for exactly one knowledge source OWLOntologyFormat format = manager.getOntologyFormat(ontology); if(format instanceof NamespaceOWLOntologyFormat) { prefixes = ((NamespaceOWLOntologyFormat)format).getNamespacesByPrefixMap(); @@ -533,6 +534,23 @@ } @Override + public Description getDomain(ObjectProperty objectProperty) { + OWLObjectProperty prop = getOWLAPIDescription(objectProperty); + try { + // TODO: look up why OWL API return a two dimensional set here + // instead of only one description (probably there can be several + // domain axiom for one property and the inner set is a conjunction + // of descriptions (?)) + OWLDescription d = reasoner.getDomains(prop).iterator().next().iterator().next(); +// OWLAPIDescriptionConvertVisitor.getOWLDescription(d); + } catch (OWLReasonerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + @Override public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) { OWLObjectProperty prop = getOWLAPIDescription(atomicRole); Map<Individual, SortedSet<Individual>> map = new TreeMap<Individual, SortedSet<Individual>>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-27 10:21:26
|
Revision: 646 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=646&view=rev Author: jenslehmann Date: 2008-02-27 02:21:24 -0800 (Wed, 27 Feb 2008) Log Message: ----------- - added methods (in ReasonerComponent) for getting namespaces of underlying knowledge sources - use toString(baseURI,prefixes) to get a string representation of axioms/concepts using those prefixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 09:49:18 UTC (rev 645) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 10:21:24 UTC (rev 646) @@ -236,10 +236,18 @@ int loop = 0; algorithmStartTime = System.nanoTime(); + long lastPrintTime = 0; + long currentTime; while(!solutionFound && !stop) { - printStatistics(false); + // print statistics at most once a second + currentTime = System.nanoTime(); + if(currentTime - lastPrintTime > 1000000000) { + printStatistics(false); + lastPrintTime = currentTime; + logger.debug("--- loop " + loop + " started ---"); + } // chose best node according to heuristics bestNode = candidates.last(); @@ -275,7 +283,7 @@ // Anzahl Schleifendurchläufe loop++; - logger.debug("--- loop " + loop + " finished ---"); + } Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-27 09:49:18 UTC (rev 645) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-27 10:21:24 UTC (rev 646) @@ -92,10 +92,10 @@ public Set<ObjectProperty> getAtomicRoles(); -// public String getBaseURI; -// -// public Map<String, String> getPrefixes(); + public String getBaseURI(); + public Map<String, String> getPrefixes(); + // currently, we do not require that datatype properties can be returned; // the main reason is that DIG does not distinguish between datatype and // object properties (of course one could implement it but it is not easy) Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-02-27 09:49:18 UTC (rev 645) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-02-27 10:21:24 UTC (rev 646) @@ -779,4 +779,18 @@ return reasonerURL; } + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getBaseURI() + */ + public String getBaseURI() { + return null; + } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getPrefixes() + */ + public Map<String, String> getPrefixes() { + return null; + } + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-27 09:49:18 UTC (rev 645) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-27 10:21:24 UTC (rev 646) @@ -394,4 +394,18 @@ System.out.println(reasoner.instanceCheck(d, i)); } + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getBaseURI() + */ + public String getBaseURI() { + return rc.getBaseURI(); + } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getPrefixes() + */ + public Map<String, String> getPrefixes() { + return rc.getPrefixes(); + } + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-02-27 09:49:18 UTC (rev 645) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-02-27 10:21:24 UTC (rev 646) @@ -1,5 +1,6 @@ package org.dllearner.reasoning; +import java.util.Map; import java.util.Set; import java.util.HashSet; import java.util.SortedSet; @@ -168,4 +169,18 @@ // TODO Auto-generated method stub } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getBaseURI() + */ + public String getBaseURI() { + return rc.getBaseURI(); + } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getPrefixes() + */ + public Map<String, String> getPrefixes() { + return rc.getPrefixes(); + } } Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-27 09:49:18 UTC (rev 645) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-27 10:21:24 UTC (rev 646) @@ -93,12 +93,14 @@ import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.model.OWLOntologyChangeException; import org.semanticweb.owl.model.OWLOntologyCreationException; +import org.semanticweb.owl.model.OWLOntologyFormat; import org.semanticweb.owl.model.OWLOntologyManager; import org.semanticweb.owl.model.OWLOntologyStorageException; import org.semanticweb.owl.model.OWLTypedConstant; import org.semanticweb.owl.model.OWLUntypedConstant; import org.semanticweb.owl.model.UnknownOWLOntologyException; import org.semanticweb.owl.util.SimpleURIMapper; +import org.semanticweb.owl.vocab.NamespaceOWLOntologyFormat; /** * Mapping to OWL API reasoner interface. The OWL API currently @@ -138,6 +140,10 @@ Set<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); SortedSet<Individual> individuals = new TreeSet<Individual>(); + // namespaces + private Map<String, String> prefixes = new TreeMap<String,String>(); + private String baseURI; + public OWLAPIReasoner(Set<KnowledgeSource> sources) { this.sources = sources; } @@ -198,6 +204,14 @@ owlObjectProperties.addAll(ontology.getReferencedObjectProperties()); owlDatatypeProperties.addAll(ontology.getReferencedDataProperties()); owlIndividuals.addAll(ontology.getReferencedIndividuals()); + + OWLOntologyFormat format = manager.getOntologyFormat(ontology); + if(format instanceof NamespaceOWLOntologyFormat) { + prefixes = ((NamespaceOWLOntologyFormat)format).getNamespacesByPrefixMap(); + prefixes.remove(""); + baseURI = prefixes.get(""); + } + } catch (OWLOntologyCreationException e) { e.printStackTrace(); } catch (URISyntaxException e) { @@ -268,8 +282,6 @@ factory = manager.getOWLDataFactory(); - - // try { // if(reasoner.isDefined(factory.getOWLIndividual(URI.create("http://example.com/father#female")))) // System.out.println("DEFINED."); @@ -858,4 +870,18 @@ return intDatatypeProperties; } + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getBaseURI() + */ + public String getBaseURI() { + return baseURI; + } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getPrefixes() + */ + public Map<String, String> getPrefixes() { + return prefixes; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-02-27 09:49:24
|
Revision: 645 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=645&view=rev Author: kurzum Date: 2008-02-27 01:49:18 -0800 (Wed, 27 Feb 2008) Log Message: ----------- added reasoner = fastInstanceChecker; to command collection Modified Paths: -------------- trunk/examples/commandcollection.txt Modified: trunk/examples/commandcollection.txt =================================================================== --- trunk/examples/commandcollection.txt 2008-02-27 09:31:41 UTC (rev 644) +++ trunk/examples/commandcollection.txt 2008-02-27 09:49:18 UTC (rev 645) @@ -13,13 +13,14 @@ // reasoner settings reasoner = dig; +reasoner = fastInstanceChecker; digReasonerURL = "http://localhost:8081"; useRetrievalForClassification = true; refinement.useDIGMultiInstanceChecks = twoChecks; // algorithm settings algorithm = refinement; -algorithm = refexamples +algorithm = refexamples; refinement.horizontalExpansionFactor = 0.6; refinement.quiet = false; refinement.useTooWeakList = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-27 09:31:45
|
Revision: 644 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=644&view=rev Author: jenslehmann Date: 2008-02-27 01:31:41 -0800 (Wed, 27 Feb 2008) Log Message: ----------- - several fixes for datatype learning - datatype learning turned off by default, because DIG 1.1 does not support the necessary reasoning methods Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-27 09:24:04 UTC (rev 643) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-27 09:31:41 UTC (rev 644) @@ -164,8 +164,8 @@ options.add(CommonConfigOptions.useNegation()); options.add(CommonConfigOptions.useBooleanDatatypes()); DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples"); - noisePercentage.setLowerLimit(0.0); - noisePercentage.setUpperLimit(1.0); + noisePercentage.setLowerLimit(0); + noisePercentage.setUpperLimit(100); options.add(noisePercentage); return options; } @@ -228,12 +228,13 @@ */ @Override public void init() { + if(searchTreeFile == null) searchTreeFile = new File(defaultSearchTreeFile); if(writeSearchTree) Files.clearFile(searchTreeFile); - + // adjust heuristic ExampleBasedHeuristic algHeuristic; @@ -243,8 +244,7 @@ if(learningProblem instanceof PosOnlyDefinitionLP) { throw new RuntimeException("does not work with positive examples only yet"); } - algHeuristic = null; - // algHeuristic = new FlexibleHeuristic(learningProblem.getNegativeExamples().size(), learningProblem.getPercentPerLengthUnit()); + algHeuristic = new FlexibleHeuristic(((PosNegLP)learningProblem).getNegativeExamples().size(), ((PosNegLP)learningProblem).getPercentPerLengthUnit()); } // compute used concepts/roles from allowed/ignored Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 09:24:04 UTC (rev 643) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-27 09:31:41 UTC (rev 644) @@ -210,6 +210,7 @@ } public void start() { + // calculate quality threshold required for a solution allowedMisclassifications = (int) Math.round(noise * nrOfExamples); @@ -559,7 +560,7 @@ tooWeakList.add(refinement); } else { // Lösung gefunden - if(quality == 0) { + if(quality >= 0 && quality<allowedMisclassifications) { solutionFound = true; solutions.add(refinement); } @@ -609,8 +610,11 @@ long algorithmRuntime = System.nanoTime() - algorithmStartTime; if(!finalStats) { + ExampleBasedNode bestNode = candidatesStable.last(); + double accuracy = 100 * ((bestNode.getCoveredPositives().size() + + nrOfNegativeExamples - bestNode.getCoveredNegatives().size())/(double)nrOfExamples); // Refinementoperator auf Konzept anwenden - String bestNodeString = "currently best node: " + candidatesStable.last(); + String bestNodeString = "currently best node: " + bestNode + " accuracy: " + df.format(accuracy) + "%"; // searchTree += bestNodeString + "\n"; System.out.println(bestNodeString); String expandedNodeString = "next expanded node: " + candidates.last(); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-27 09:24:04 UTC (rev 643) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-27 09:31:41 UTC (rev 644) @@ -67,7 +67,7 @@ private boolean useAllConstructor = true; private boolean useExistsConstructor = true; private boolean useNegation = true; - private boolean useBooleanDatatypes = true; + private boolean useBooleanDatatypes = false; private boolean quiet = false; Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-27 09:24:04 UTC (rev 643) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-27 09:31:41 UTC (rev 644) @@ -318,7 +318,8 @@ // falls Konzept ungleich Bottom oder Top, dann kann ein Refinement von Top // angehangen werden if(concept instanceof Union || concept instanceof NamedClass || - concept instanceof Negation || concept instanceof ObjectSomeRestriction || concept instanceof ObjectAllRestriction) { + concept instanceof Negation || concept instanceof ObjectQuantorRestriction + || concept instanceof ValueRestriction) { // long someTimeNsStart = System.nanoTime(); // someCount++; // Refinement von Top anhängen Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-27 09:24:04 UTC (rev 643) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-27 09:31:41 UTC (rev 644) @@ -324,7 +324,7 @@ } } catch (InvalidConfigOptionValueException e) { - // e.printStackTrace(); + e.printStackTrace(); System.exit(0); } Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-27 09:24:04 UTC (rev 643) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-27 09:31:41 UTC (rev 644) @@ -92,6 +92,10 @@ public Set<ObjectProperty> getAtomicRoles(); +// public String getBaseURI; +// +// public Map<String, String> getPrefixes(); + // currently, we do not require that datatype properties can be returned; // the main reason is that DIG does not distinguish between datatype and // object properties (of course one could implement it but it is not easy) Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-27 09:24:04 UTC (rev 643) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-27 09:31:41 UTC (rev 644) @@ -119,6 +119,10 @@ } + public static String getName() { + return "fast instance checker"; + } + /* * (non-Javadoc) * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-26 18:13:32
|
Revision: 642 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=642&view=rev Author: jenslehmann Date: 2008-02-26 10:13:23 -0800 (Tue, 26 Feb 2008) Log Message: ----------- - datatype TBox reasoning using OWL API - description comparator updated to include boolean datatypes - refinement operator rho extended to include boolean datatypes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-26 18:13:23 UTC (rev 642) @@ -30,6 +30,8 @@ import java.util.TreeSet; import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.BooleanValueRestriction; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Nothing; @@ -538,8 +540,8 @@ if(topRefinementsLength<3 && maxLength>2) { // Konzepte der Länge 3: EXISTS r.TOP + Set<Description> m3 = new TreeSet<Description>(conceptComparator); if(useExistsConstructor) { - Set<Description> m3 = new TreeSet<Description>(conceptComparator); // previous operator: uses all roles // for(AtomicRole r : Config.Refinement.allowedRoles) { // m3.add(new Exists(r, new Top())); @@ -548,17 +550,19 @@ for(ObjectProperty r : rs.getMostGeneralRoles()) { m3.add(new ObjectSomeRestriction(r, new Thing())); } - m.put(3,m3); + } // boolean datatypes, e.g. testPositive = true if(useBooleanDatatypes) { -// Set<Description> m3 = new TreeSet<Description>(conceptComparator); - // TODO: code for getting boolean datatypes -// m.put(3,m3); - // TODO: do not use put here because we overwrite the - // EXISTS quantor stuff + Set<DatatypeProperty> booleanDPs = rs.getBooleanDatatypeProperties(); + for(DatatypeProperty dp : booleanDPs) { + m3.add(new BooleanValueRestriction(dp,true)); + m3.add(new BooleanValueRestriction(dp,false)); + } } + + m.put(3,m3); } if(maxLength>2) { Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-02-26 18:13:23 UTC (rev 642) @@ -27,6 +27,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -405,6 +406,42 @@ return reasoner.getAtomicRoles(); } + public Set<DatatypeProperty> getDatatypeProperties() { + try { + return reasoner.getDatatypeProperties(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Set<DatatypeProperty> getBooleanDatatypeProperties() { + try { + return reasoner.getBooleanDatatypeProperties(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Set<DatatypeProperty> getIntDatatypeProperties() { + try { + return reasoner.getIntDatatypeProperties(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + + public Set<DatatypeProperty> getDoubleDatatypeProperties() { + try { + return reasoner.getDoubleDatatypeProperties(); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + return null; + } + } + public SortedSet<Individual> getIndividuals() { return reasoner.getIndividuals(); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java 2008-02-26 18:13:23 UTC (rev 642) @@ -27,6 +27,8 @@ */ public class BooleanValueRestriction extends DatatypeValueRestriction { + private boolean booleanValue; + /** * TODO: Internally a typed constant with datatype boolean and * strings "true" or "false" is created. This is a clean way to @@ -42,6 +44,11 @@ */ public BooleanValueRestriction(DatatypeProperty restrictedPropertyExpression, Boolean value) { super(restrictedPropertyExpression, new TypedConstant(value.toString(), Datatype.BOOLEAN)); + booleanValue = value; } + public boolean getBooleanValue() { + return booleanValue; + } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-26 18:13:23 UTC (rev 642) @@ -49,8 +49,7 @@ */ @Override public int getArity() { - // TODO Auto-generated method stub - return 0; + return 2; } /* (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-02-26 18:13:23 UTC (rev 642) @@ -31,6 +31,7 @@ public ValueRestriction(PropertyExpression propertyExpression, KBElement value) { super(propertyExpression); + this.value = value; } public KBElement getValue() { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-26 18:13:23 UTC (rev 642) @@ -258,7 +258,16 @@ } return true; } else if (description instanceof BooleanValueRestriction) { - + DatatypeProperty dp = ((BooleanValueRestriction)description).getRestrictedPropertyExpresssion(); + boolean value = ((BooleanValueRestriction)description).getBooleanValue(); + + if(value) { + // check whether the individual is in the set of individuals mapped + // to true by this datatype property + return bd.get(dp).contains(individual); + } else { + return !bd.get(dp).contains(individual); + } } throw new ReasoningMethodUnsupportedException("Instance check for description " Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIDescriptionConvertVisitor.java 2008-02-26 18:13:23 UTC (rev 642) @@ -25,9 +25,12 @@ import java.util.Stack; import org.dllearner.algorithms.gp.ADC; +import org.dllearner.core.owl.Constant; +import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypeExactCardinalityRestriction; import org.dllearner.core.owl.DatatypeMaxCardinalityRestriction; import org.dllearner.core.owl.DatatypeMinCardinalityRestriction; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.DatatypeSomeRestriction; import org.dllearner.core.owl.DatatypeValueRestriction; import org.dllearner.core.owl.Description; @@ -43,11 +46,16 @@ import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.ObjectValueRestriction; import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.TypedConstant; import org.dllearner.core.owl.Union; +import org.dllearner.core.owl.UntypedConstant; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.model.OWLConstant; import org.semanticweb.owl.model.OWLDataFactory; +import org.semanticweb.owl.model.OWLDataProperty; +import org.semanticweb.owl.model.OWLDataType; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLObjectProperty; @@ -171,7 +179,7 @@ */ public void visit(ObjectMinCardinalityRestriction description) { // TODO Auto-generated method stub - + throw new Error("OWLAPIDescriptionConverter: not implemented"); } /* (non-Javadoc) @@ -179,7 +187,7 @@ */ public void visit(ObjectExactCardinalityRestriction description) { // TODO Auto-generated method stub - + throw new Error("OWLAPIDescriptionConverter: not implemented"); } /* (non-Javadoc) @@ -187,7 +195,7 @@ */ public void visit(ObjectMaxCardinalityRestriction description) { // TODO Auto-generated method stub - + throw new Error("OWLAPIDescriptionConverter: not implemented"); } /* (non-Javadoc) @@ -195,15 +203,34 @@ */ public void visit(ObjectValueRestriction description) { // TODO Auto-generated method stub - + throw new Error("OWLAPIDescriptionConverter: not implemented"); } /* (non-Javadoc) * @see org.dllearner.core.owl.DescriptionVisitor#visit(org.dllearner.core.owl.DatatypeValueRestriction) */ public void visit(DatatypeValueRestriction description) { - // TODO Auto-generated method stub - + // convert OWL constant to OWL API constant + Constant c = description.getValue(); + OWLConstant constant; + if(c instanceof TypedConstant) { + Datatype dt = ((TypedConstant)c).getDatatype(); + OWLDataType odt = convertDatatype(dt); + constant = factory.getOWLTypedConstant(c.getLiteral(), odt); + } else { + UntypedConstant uc = (UntypedConstant) c; + if(uc.hasLang()) { + constant = factory.getOWLUntypedConstant(uc.getLiteral(), uc.getLang()); + } else { + constant = factory.getOWLUntypedConstant(uc.getLiteral()); + } + } + + // get datatype property + DatatypeProperty dtp = description.getRestrictedPropertyExpresssion(); + OWLDataProperty prop = factory.getOWLDataProperty(URI.create(dtp.getName())); + + stack.push(factory.getOWLDataValueRestriction(prop, constant)); } /* (non-Javadoc) @@ -218,7 +245,7 @@ */ public void visit(ADC description) { // TODO Auto-generated method stub - + throw new Error("OWLAPIDescriptionConverter: not implemented"); } /* (non-Javadoc) @@ -226,7 +253,7 @@ */ public void visit(DatatypeMinCardinalityRestriction description) { // TODO Auto-generated method stub - + throw new Error("OWLAPIDescriptionConverter: not implemented"); } /* (non-Javadoc) @@ -234,7 +261,7 @@ */ public void visit(DatatypeExactCardinalityRestriction description) { // TODO Auto-generated method stub - + throw new Error("OWLAPIDescriptionConverter: not implemented"); } /* (non-Javadoc) @@ -242,7 +269,7 @@ */ public void visit(DatatypeMaxCardinalityRestriction description) { // TODO Auto-generated method stub - + throw new Error("OWLAPIDescriptionConverter: not implemented"); } /* (non-Javadoc) @@ -250,7 +277,18 @@ */ public void visit(DatatypeSomeRestriction description) { // TODO Auto-generated method stub + throw new Error("OWLAPIDescriptionConverter: not implemented"); + } + + public OWLDataType convertDatatype(Datatype datatype) { + if(datatype.equals(Datatype.BOOLEAN)) + return factory.getOWLDataType(Datatype.BOOLEAN.getURI()); + else if(datatype.equals(Datatype.INT)) + return factory.getOWLDataType(Datatype.INT.getURI()); + else if(datatype.equals(Datatype.DOUBLE)) + return factory.getOWLDataType(Datatype.DOUBLE.getURI()); + throw new Error("OWLAPIDescriptionConverter: datatype not implemented"); } - + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-26 18:13:23 UTC (rev 642) @@ -419,7 +419,7 @@ @Override public boolean subsumes(Description superConcept, Description subConcept) { try { - return reasoner.isSubClassOf(getOWLAPIDescription(subConcept), getOWLAPIDescription(superConcept)); + return reasoner.isSubClassOf(OWLAPIDescriptionConvertVisitor.getOWLDescription(subConcept), OWLAPIDescriptionConvertVisitor.getOWLDescription(superConcept)); } catch (OWLReasonerException e) { e.printStackTrace(); throw new Error("Subsumption Error in OWL API."); Modified: trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/utilities/ConceptComparator.java 2008-02-26 18:13:23 UTC (rev 642) @@ -3,6 +3,7 @@ import java.util.Comparator; import java.util.Set; +import org.dllearner.core.owl.BooleanValueRestriction; import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Nothing; @@ -51,6 +52,9 @@ // Ordnung für atomare Konzepte: Stringvergleich // Ordnung für atomare Rollen: Stringvergleich public int compare(Description concept1, Description concept2) { + // classes higher up are in the source code have lower value + // (they appear first in class descriptions, because sorted sets + // usually use an ascending order) if(concept1 instanceof Nothing) { if(concept2 instanceof Nothing) return 0; @@ -100,6 +104,17 @@ return roleCompare; } else return -1; + } else if(concept1 instanceof BooleanValueRestriction) { + if(concept2.getChildren().size()<1 || concept2 instanceof Negation || concept2 instanceof ObjectQuantorRestriction) { + return 1; + } else if(concept2 instanceof BooleanValueRestriction) { + int cmp = rc.compare(((BooleanValueRestriction)concept1).getRestrictedPropertyExpresssion(), ((BooleanValueRestriction)concept2).getRestrictedPropertyExpresssion()); + if(cmp == 0) + return compare(concept1.getChild(0), concept2.getChild(0)); + else + return cmp; + } else + return -1; } else if(concept1 instanceof Intersection) { if(concept2.getChildren().size()<2) return 1; Modified: trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java 2008-02-26 13:25:32 UTC (rev 641) +++ trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java 2008-02-26 18:13:23 UTC (rev 642) @@ -21,33 +21,47 @@ import java.util.Comparator; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.ObjectProperty; -import org.dllearner.core.owl.ObjectPropertyExpression; +import org.dllearner.core.owl.ObjectPropertyInverse; +import org.dllearner.core.owl.PropertyExpression; /** - * Compares two object properties. + * Compares two property expressions. The order is: + * datatype properties first, then inverse object properties, then + * object properties. For equal types, the URI or toString (inverses) + * is used to fix an order. * * @author Jens Lehmann * */ -public class RoleComparator implements Comparator<ObjectPropertyExpression> { +public class RoleComparator implements Comparator<PropertyExpression> { - public int compare(ObjectPropertyExpression r1, ObjectPropertyExpression r2) { + public int compare(PropertyExpression r1, PropertyExpression r2) { if(r1 instanceof ObjectProperty) { if(r2 instanceof ObjectProperty) { - return r1.getName().compareTo(r2.getName()); - // zweite Rolle ist invers + return ((ObjectProperty)r1).getName().compareTo(((ObjectProperty)r2).getName()); + // second role is inverse or datatype property } else { return -1; } - // 1. Rolle ist invers - } else { - if(r1 instanceof ObjectProperty) { + // first property is an inverse object property + } else if(r1 instanceof ObjectPropertyInverse){ + if(r2 instanceof ObjectProperty) { return 1; + } else if(r2 instanceof ObjectPropertyInverse){ + return r1.toString().compareTo(r2.toString()); } else { - return r1.getName().compareTo(r2.getName()); + return -1; } + // r1 is datatype property + } else { + if(r2 instanceof DatatypeProperty) { + return ((DatatypeProperty)r1).getName().compareTo(((DatatypeProperty)r2).getName()); + } else { + return 1; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-26 13:25:40
|
Revision: 641 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=641&view=rev Author: jenslehmann Date: 2008-02-26 05:25:32 -0800 (Tue, 26 Feb 2008) Log Message: ----------- implemented datatype ABox reasoning/querying using OWL API Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-26 10:47:09 UTC (rev 640) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-26 13:25:32 UTC (rev 641) @@ -24,6 +24,7 @@ import java.util.Set; import java.util.SortedSet; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; @@ -71,6 +72,8 @@ public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) throws ReasoningMethodUnsupportedException; + public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException; + public boolean instanceCheck(Description concept, Individual individual) throws ReasoningMethodUnsupportedException; // mehrere instance checks für ein Konzept - spart bei DIG Anfragen Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-26 10:47:09 UTC (rev 640) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-26 13:25:32 UTC (rev 641) @@ -23,8 +23,11 @@ import java.util.Map; import java.util.Set; import java.util.SortedSet; +import java.util.TreeMap; import java.util.TreeSet; +import java.util.Map.Entry; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; @@ -75,6 +78,75 @@ throw new ReasoningMethodUnsupportedException(); } + public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) + throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + // convenience method to get int value mappings of a datatype property + public Map<Individual, SortedSet<Integer>> getIntDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); + Map<Individual, SortedSet<Integer>> ret = new TreeMap<Individual, SortedSet<Integer>>(); + for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { + SortedSet<Constant> values = e.getValue(); + SortedSet<Integer> valuesInt = new TreeSet<Integer>(); + for(Constant c : values) { + int v = Integer.parseInt(c.getLiteral()); + valuesInt.add(v); + } + ret.put(e.getKey(),valuesInt); + } + return ret; + } + + // convenience method to get double value mappings of a datatype property + public Map<Individual, SortedSet<Double>> getDoubleDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); + Map<Individual, SortedSet<Double>> ret = new TreeMap<Individual, SortedSet<Double>>(); + for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { + SortedSet<Constant> values = e.getValue(); + SortedSet<Double> valuesDouble = new TreeSet<Double>(); + for(Constant c : values) { + double v = Double.parseDouble(c.getLiteral()); + valuesDouble.add(v); + } + ret.put(e.getKey(),valuesDouble); + } + return ret; + } + + // convenience method to get boolean value mappings of a datatype property + public Map<Individual, SortedSet<Boolean>> getBooleanDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); + Map<Individual, SortedSet<Boolean>> ret = new TreeMap<Individual, SortedSet<Boolean>>(); + for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { + SortedSet<Constant> values = e.getValue(); + SortedSet<Boolean> valuesBoolean = new TreeSet<Boolean>(); + for(Constant c : values) { + boolean v = Boolean.parseBoolean(c.getLiteral()); + valuesBoolean.add(v); + } + ret.put(e.getKey(),valuesBoolean); + } + return ret; + } + + // convenience method returning those values which have value "true" for this + // datatype property + public SortedSet<Individual> getTrueDatatypeMembers(DatatypeProperty datatypeProperty) throws ReasoningMethodUnsupportedException { + Map<Individual, SortedSet<Constant>> mapping = getDatatypeMembers(datatypeProperty); + SortedSet<Individual> ret = new TreeSet<Individual>(); + for(Entry<Individual, SortedSet<Constant>> e : mapping.entrySet()) { + SortedSet<Constant> values = e.getValue(); + for(Constant c : values) { + boolean v = Boolean.parseBoolean(c.getLiteral()); + if(v == true) + ret.add(e.getKey()); + } + } + return ret; + } + public boolean instanceCheck(Description concept, Individual individual) throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2008-02-26 10:47:09 UTC (rev 640) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2008-02-26 13:25:32 UTC (rev 641) @@ -27,7 +27,7 @@ * @author Jens Lehmann * */ -public class DatatypeProperty implements Property, NamedKBElement { +public class DatatypeProperty implements Comparable<DatatypeProperty>, Property, NamedKBElement { protected String name; @@ -46,14 +46,23 @@ return name; } - /* (non-Javadoc) - * @see org.dllearner.core.dl.KBElement#toString(java.lang.String, java.util.Map) - */ + @Override + public String toString() { + return toString(null, null); + } + public String toString(String baseURI, Map<String, String> prefixes) { return "\"" + Helper.getAbbreviatedString(name, baseURI, prefixes) + "\""; } public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int compareTo(DatatypeProperty o) { + return name.compareTo(o.name); } } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-26 10:47:09 UTC (rev 640) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-26 13:25:32 UTC (rev 641) @@ -36,6 +36,7 @@ import org.dllearner.core.ReasoningService; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.owl.BooleanValueRestriction; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -56,24 +57,24 @@ import org.dllearner.parser.ParseException; /** - * Reasoner for fast instance checks. It works by completely dematerialising the knowledge - * base to speed up later reasoning requests. It then continues by only considering one - * model of the knowledge base (TODO: more explanation), which is neither correct nor - * complete, but sufficient in many cases. A big advantage of the algorithm is that it - * does not need even need to perform any set modifications (union, intersection, difference), - * so it avoids any Java object creation, which makes it extremely fast compared to standard + * Reasoner for fast instance checks. It works by completely dematerialising the + * knowledge base to speed up later reasoning requests. It then continues by + * only considering one model of the knowledge base (TODO: more explanation), + * which is neither correct nor complete, but sufficient in many cases. A big + * advantage of the algorithm is that it does not need even need to perform any + * set modifications (union, intersection, difference), so it avoids any Java + * object creation, which makes it extremely fast compared to standard * reasoners. * * Note: This algorithm works only on concepts in negation normal form! * * @author Jens Lehmann - * + * */ public class FastInstanceChecker extends ReasonerComponent { - private static Logger logger = Logger - .getLogger(FastInstanceChecker.class); - + private static Logger logger = Logger.getLogger(FastInstanceChecker.class); + private Set<NamedClass> atomicConcepts; private Set<ObjectProperty> atomicRoles; private Set<DatatypeProperty> datatypeProperties; @@ -81,26 +82,36 @@ private Set<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); private Set<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); private SortedSet<Individual> individuals; - + private ReasoningService rs; private OWLAPIReasoner rc; private Set<KnowledgeSource> sources; - + // we use sorted sets (map indices) here, because they have only log(n) // complexity for checking whether an element is contained in them // instances of classes - private Map<NamedClass,SortedSet<Individual>> classInstancesPos = new TreeMap<NamedClass,SortedSet<Individual>>(); - private Map<NamedClass,SortedSet<Individual>> classInstancesNeg = new TreeMap<NamedClass,SortedSet<Individual>>(); - // object property mappings - private Map<ObjectProperty,Map<Individual,SortedSet<Individual>>> opPos = new TreeMap<ObjectProperty,Map<Individual,SortedSet<Individual>>>(); + private Map<NamedClass, SortedSet<Individual>> classInstancesPos = new TreeMap<NamedClass, SortedSet<Individual>>(); + private Map<NamedClass, SortedSet<Individual>> classInstancesNeg = new TreeMap<NamedClass, SortedSet<Individual>>(); + // object property mappings + private Map<ObjectProperty, Map<Individual, SortedSet<Individual>>> opPos = new TreeMap<ObjectProperty, Map<Individual, SortedSet<Individual>>>(); + // datatype property mappings + // (for booleans we assume that just one mapping exists, e.g. + // hasValue(object,true) and hasValue(object,false) will + // lead to undefined behaviour (they are logical contradictions) + private Map<DatatypeProperty, SortedSet<Individual>> bd = new TreeMap<DatatypeProperty, SortedSet<Individual>>(); + // for int and double we assume that a property can have several values, + // althoug this should be rare, + // e.g. hasValue(object,2) and hasValue(object,3) + private Map<DatatypeProperty, Map<Individual, SortedSet<Double>>> dd = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Double>>>(); + private Map<DatatypeProperty, Map<Individual, SortedSet<Integer>>> id = new TreeMap<DatatypeProperty, Map<Individual, SortedSet<Integer>>>(); - // TODO: datatype properties - public FastInstanceChecker(Set<KnowledgeSource> sources) { this.sources = sources; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.config.ConfigEntry) */ @Override @@ -108,7 +119,9 @@ } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.Component#init() */ @Override @@ -118,121 +131,152 @@ try { atomicConcepts = rc.getAtomicConcepts(); - datatypeProperties = rc.getDatatypeProperties(); + datatypeProperties = rc.getDatatypeProperties(); booleanDatatypeProperties = rc.getBooleanDatatypeProperties(); doubleDatatypeProperties = rc.getDoubleDatatypeProperties(); intDatatypeProperties = rc.getIntDatatypeProperties(); atomicRoles = rc.getAtomicRoles(); - individuals = rc.getIndividuals(); - } catch (ReasoningMethodUnsupportedException e) { - throw new ComponentInitException("Underlying reasoner does not support all necessary reasoning methods.", e); - } + individuals = rc.getIndividuals(); - rs = new ReasoningService(rc); - - // TODO: some code taken from Helper.createFlatABox, but pasted here because additional things need to - // be done (maybe this can be merge again with the FastRetrievalReasoner later) - long dematStartTime = System.currentTimeMillis(); + rs = new ReasoningService(rc); - for (NamedClass atomicConcept : rs.getAtomicConcepts()) { - classInstancesPos.put(atomicConcept, rs.retrieval(atomicConcept)); - Negation negatedAtomicConcept = new Negation(atomicConcept); - classInstancesNeg.put(atomicConcept, rs.retrieval(negatedAtomicConcept)); - } + // TODO: some code taken from Helper.createFlatABox, but pasted here + // because additional things need to + // be done (maybe this can be merge again with the + // FastRetrievalReasoner later) + long dematStartTime = System.currentTimeMillis(); - for (ObjectProperty atomicRole : rs.getAtomicRoles()) { - opPos.put(atomicRole, rc.getRoleMembers(atomicRole)); + for (NamedClass atomicConcept : rs.getAtomicConcepts()) { + classInstancesPos.put(atomicConcept, rs.retrieval(atomicConcept)); + Negation negatedAtomicConcept = new Negation(atomicConcept); + classInstancesNeg.put(atomicConcept, rs.retrieval(negatedAtomicConcept)); + } + + for (ObjectProperty atomicRole : atomicRoles) { + opPos.put(atomicRole, rc.getRoleMembers(atomicRole)); + } + + for (DatatypeProperty dp : booleanDatatypeProperties) { + bd.put(dp, rc.getTrueDatatypeMembers(dp)); + } + + for (DatatypeProperty dp : intDatatypeProperties) { + id.put(dp, rc.getIntDatatypeMembers(dp)); + } + + for (DatatypeProperty dp : doubleDatatypeProperties) { + dd.put(dp, rc.getDoubleDatatypeMembers(dp)); + } + + long dematDuration = System.currentTimeMillis() - dematStartTime; + logger.info("TBox dematerialised in " + dematDuration + " ms"); + + } catch (ReasoningMethodUnsupportedException e) { + throw new ComponentInitException( + "Underlying reasoner does not support all necessary reasoning methods.", e); } - - long dematDuration = System.currentTimeMillis() - dematStartTime; - logger.info("TBox dematerialised in " + dematDuration + " ms"); - } @Override - public boolean instanceCheck(Description description, Individual individual) throws ReasoningMethodUnsupportedException { - if(description instanceof NamedClass) { - return classInstancesPos.get((NamedClass)description).contains(individual); - } else if(description instanceof Negation) { + public boolean instanceCheck(Description description, Individual individual) + throws ReasoningMethodUnsupportedException { + if (description instanceof NamedClass) { + return classInstancesPos.get((NamedClass) description).contains(individual); + } else if (description instanceof Negation) { Description child = description.getChild(0); - if(child instanceof NamedClass) { - return classInstancesNeg.get((NamedClass)child).contains(individual); + if (child instanceof NamedClass) { + return classInstancesNeg.get((NamedClass) child).contains(individual); } else { - throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Description needs to be in negation normal form."); + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + + " unsupported. Description needs to be in negation normal form."); } - } else if(description instanceof Thing) { + } else if (description instanceof Thing) { return true; - } else if(description instanceof Nothing) { + } else if (description instanceof Nothing) { return false; - } else if(description instanceof Union) { - // if the individual is instance of any of the subdescription of + } else if (description instanceof Union) { + // if the individual is instance of any of the subdescription of // the union, we return true List<Description> children = description.getChildren(); - for(Description child : children) { - if(instanceCheck(child, individual)) + for (Description child : children) { + if (instanceCheck(child, individual)) return true; } return false; - } else if(description instanceof Intersection) { - // if the individual is instance of all of the subdescription of - // the union, we return true + } else if (description instanceof Intersection) { + // if the individual is instance of all of the subdescription of + // the union, we return true List<Description> children = description.getChildren(); - for(Description child : children) { - if(!instanceCheck(child, individual)) + for (Description child : children) { + if (!instanceCheck(child, individual)) return false; } return true; - } else if(description instanceof ObjectSomeRestriction) { - ObjectPropertyExpression ope = ((ObjectSomeRestriction)description).getRole(); - if(!(ope instanceof ObjectProperty)) - throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Inverse object properties not supported."); + } else if (description instanceof ObjectSomeRestriction) { + ObjectPropertyExpression ope = ((ObjectSomeRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); ObjectProperty op = (ObjectProperty) ope; Description child = description.getChild(0); - Map<Individual,SortedSet<Individual>> mapping = opPos.get(op);; - if(mapping == null) { - logger.warn("Instance check of a description with an undefinied property (" + op + ")."); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + ; + if (mapping == null) { + logger.warn("Instance check of a description with an undefinied property (" + op + + ")."); return false; } SortedSet<Individual> roleFillers = opPos.get(op).get(individual); - if(roleFillers == null) + if (roleFillers == null) return false; - for(Individual roleFiller : roleFillers) { - if(instanceCheck(child, roleFiller)) + for (Individual roleFiller : roleFillers) { + if (instanceCheck(child, roleFiller)) return true; } return false; - } else if(description instanceof ObjectAllRestriction) { - ObjectPropertyExpression ope = ((ObjectAllRestriction)description).getRole(); - if(!(ope instanceof ObjectProperty)) - throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Inverse object properties not supported."); + } else if (description instanceof ObjectAllRestriction) { + ObjectPropertyExpression ope = ((ObjectAllRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); ObjectProperty op = (ObjectProperty) ope; Description child = description.getChild(0); - Map<Individual,SortedSet<Individual>> mapping = opPos.get(op);; - if(mapping == null) { - logger.warn("Instance check of a description with an undefinied property (" + op + ")."); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + ; + if (mapping == null) { + logger.warn("Instance check of a description with an undefinied property (" + op + + ")."); return true; } SortedSet<Individual> roleFillers = opPos.get(op).get(individual); - if(roleFillers == null) + if (roleFillers == null) return true; - for(Individual roleFiller : roleFillers) { - if(!instanceCheck(child, roleFiller)) + for (Individual roleFiller : roleFillers) { + if (!instanceCheck(child, roleFiller)) return false; } return true; + } else if (description instanceof BooleanValueRestriction) { + } - - throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported."); - } - - /* (non-Javadoc) + + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported."); + } + + /* + * (non-Javadoc) + * * @see org.dllearner.core.Reasoner#getAtomicConcepts() */ public Set<NamedClass> getAtomicConcepts() { return atomicConcepts; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.Reasoner#getAtomicRoles() */ public Set<ObjectProperty> getAtomicRoles() { @@ -242,38 +286,44 @@ @Override public Set<DatatypeProperty> getDatatypeProperties() { return datatypeProperties; - } - + } + @Override public Set<DatatypeProperty> getBooleanDatatypeProperties() { return booleanDatatypeProperties; - } - + } + @Override public Set<DatatypeProperty> getDoubleDatatypeProperties() { return doubleDatatypeProperties; - } - + } + @Override public Set<DatatypeProperty> getIntDatatypeProperties() { return intDatatypeProperties; - } - - /* (non-Javadoc) + } + + /* + * (non-Javadoc) + * * @see org.dllearner.core.Reasoner#getIndividuals() */ public SortedSet<Individual> getIndividuals() { return individuals; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.Reasoner#getReasonerType() */ public ReasonerType getReasonerType() { return ReasonerType.FAST_INSTANCE_CHECKER; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.Reasoner#prepareSubsumptionHierarchy(java.util.Set) */ public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) { @@ -283,34 +333,37 @@ @Override public SubsumptionHierarchy getSubsumptionHierarchy() { return rs.getSubsumptionHierarchy(); - } - + } + @Override public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { rs.prepareRoleHierarchy(allowedRoles); - } - + } + @Override public ObjectPropertyHierarchy getRoleHierarchy() { return rs.getRoleHierarchy(); } - + @Override public boolean subsumes(Description superConcept, Description subConcept) { -// Negation neg = new Negation(subConcept); -// Intersection c = new Intersection(neg,superConcept); -// return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); + // Negation neg = new Negation(subConcept); + // Intersection c = new Intersection(neg,superConcept); + // return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); return rs.subsumes(superConcept, subConcept); - } - + } + /** * Test method for fast instance checker. - * @param args No arguments supported. - * @throws ComponentInitException - * @throws ParseException - * @throws ReasoningMethodUnsupportedException + * + * @param args + * No arguments supported. + * @throws ComponentInitException + * @throws ParseException + * @throws ReasoningMethodUnsupportedException */ - public static void main(String[] args) throws ComponentInitException, ParseException, ReasoningMethodUnsupportedException { + public static void main(String[] args) throws ComponentInitException, ParseException, + ReasoningMethodUnsupportedException { ComponentManager cm = ComponentManager.getInstance(); OWLFile owl = cm.knowledgeSource(OWLFile.class); String owlFile = new File("examples/family/father.owl").toURI().toString(); @@ -319,7 +372,7 @@ ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, owl); cm.reasoningService(reasoner); reasoner.init(); - + KBParser.internalNamespace = "http://example.com/father#"; String query = "(male AND EXISTS hasChild.TOP)"; Description d = KBParser.parseConcept(query); Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-26 10:47:09 UTC (rev 640) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-26 13:25:32 UTC (rev 641) @@ -43,6 +43,7 @@ import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.owl.AssertionalAxiom; import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.Constant; import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Description; @@ -68,7 +69,9 @@ import org.dllearner.core.owl.TerminologicalAxiom; import org.dllearner.core.owl.Thing; import org.dllearner.core.owl.TransitiveObjectPropertyAxiom; +import org.dllearner.core.owl.TypedConstant; import org.dllearner.core.owl.Union; +import org.dllearner.core.owl.UntypedConstant; import org.dllearner.kb.OWLFile; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.RoleComparator; @@ -78,6 +81,7 @@ import org.semanticweb.owl.model.AddAxiom; import org.semanticweb.owl.model.OWLAxiom; import org.semanticweb.owl.model.OWLClass; +import org.semanticweb.owl.model.OWLConstant; import org.semanticweb.owl.model.OWLDataFactory; import org.semanticweb.owl.model.OWLDataProperty; import org.semanticweb.owl.model.OWLDataRange; @@ -91,6 +95,8 @@ import org.semanticweb.owl.model.OWLOntologyCreationException; import org.semanticweb.owl.model.OWLOntologyManager; import org.semanticweb.owl.model.OWLOntologyStorageException; +import org.semanticweb.owl.model.OWLTypedConstant; +import org.semanticweb.owl.model.OWLUntypedConstant; import org.semanticweb.owl.model.UnknownOWLOntologyException; import org.semanticweb.owl.util.SimpleURIMapper; @@ -537,8 +543,47 @@ } return map; } - + @Override + public Map<Individual, SortedSet<Constant>> getDatatypeMembers(DatatypeProperty datatypeProperty) { + OWLDataProperty prop = getOWLAPIDescription(datatypeProperty); + Map<Individual, SortedSet<Constant>> map = new TreeMap<Individual, SortedSet<Constant>>(); + for(Individual i : individuals) { + OWLIndividual ind = factory.getOWLIndividual(URI.create(i.getName())); + + // get all related values via OWL API + Set<OWLConstant> constants = null; + try { + constants = reasoner.getRelatedValues(ind, prop); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + + // convert data back to DL-Learner structures + SortedSet<Constant> is = new TreeSet<Constant>(); + for(OWLConstant oi : constants) { + // for typed constants we have to figure out the correct + // data type and value + if(oi instanceof OWLTypedConstant) { + Datatype dt = convertDatatype(((OWLTypedConstant)oi).getDataType()); + is.add(new TypedConstant(oi.getLiteral(),dt)); + // for untyped constants we have to figure out the value + // and language tag (if any) + } else { + OWLUntypedConstant ouc = (OWLUntypedConstant) oi; + if(ouc.hasLang()) + is.add(new UntypedConstant(ouc.getLiteral(), ouc.getLang())); + else + is.add(new UntypedConstant(ouc.getLiteral())); + } + } + // only add individuals using the datatype property + if(is.size()>0) + map.put(i, is); + } + return map; + } + // OWL API often returns a set of sets of classes, where each inner // set consists of equivalent classes; this method picks one class // from each inner set to flatten the set of sets @@ -618,10 +663,26 @@ } } + public static Datatype convertDatatype(OWLDataType dataType) { + URI uri = dataType.getURI(); + if(uri.equals(Datatype.BOOLEAN.getURI())) + return Datatype.BOOLEAN; + else if(uri.equals(Datatype.DOUBLE.getURI())) + return Datatype.DOUBLE; + else if(uri.equals(Datatype.INT.getURI())) + return Datatype.INT; + + throw new Error("Unsupported datatype " + dataType + ". Please inform a DL-Learner developer to add it."); + } + private static OWLObjectProperty getOWLAPIDescription(ObjectProperty role) { return staticFactory.getOWLObjectProperty(URI.create(role.getName())); } + private static OWLDataProperty getOWLAPIDescription(DatatypeProperty datatypeProperty) { + return staticFactory.getOWLDataProperty(URI.create(datatypeProperty.getName())); + } + @Deprecated public static OWLDescription getOWLAPIDescription(Description concept) { if (concept instanceof NamedClass) { @@ -773,4 +834,28 @@ } } + /** + * @return the booleanDatatypeProperties + */ + @Override + public Set<DatatypeProperty> getBooleanDatatypeProperties() { + return booleanDatatypeProperties; + } + + /** + * @return the doubleDatatypeProperties + */ + @Override + public Set<DatatypeProperty> getDoubleDatatypeProperties() { + return doubleDatatypeProperties; + } + + /** + * @return the intDatatypeProperties + */ + @Override + public Set<DatatypeProperty> getIntDatatypeProperties() { + return intDatatypeProperties; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-26 10:47:11
|
Revision: 640 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=640&view=rev Author: jenslehmann Date: 2008-02-26 02:47:09 -0800 (Tue, 26 Feb 2008) Log Message: ----------- added ability to query which datatype properties have one of a specified set of datatypes (double, boolean, int) as ranges in an OWL 1.1 ontology Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-26 10:47:09 UTC (rev 640) @@ -94,6 +94,12 @@ // object properties (of course one could implement it but it is not easy) public Set<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException; + public Set<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException; + + public Set<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException; + + public Set<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException; + public SortedSet<Individual> getIndividuals(); } Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-26 10:47:09 UTC (rev 640) @@ -124,5 +124,17 @@ public Set<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException { throw new ReasoningMethodUnsupportedException(); } + + public Set<DatatypeProperty> getBooleanDatatypeProperties() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Set<DatatypeProperty> getDoubleDatatypeProperties() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + + public Set<DatatypeProperty> getIntDatatypeProperties() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-26 10:47:09 UTC (rev 640) @@ -30,7 +30,7 @@ DOUBLE ("http://www.w3.org/2001/XMLSchema#double"), INT ("http://www.w3.org/2001/XMLSchema#int"), - BOOLEAN ("http://www.w3.org/2001/XMLSchema#Boolean"); + BOOLEAN ("http://www.w3.org/2001/XMLSchema#boolean"); private URI uri; Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-26 10:47:09 UTC (rev 640) @@ -166,6 +166,8 @@ // define properties including domain and range String kbString = "DPDOMAIN(" + getURI2("charge") + ") = " + getURI2("Atom") + ".\n"; kbString += "DPRANGE(" + getURI2("charge") + ") = DOUBLE.\n"; + kbString += "DPDOMAIN(" + getURI2("amesTestPositive") + ") = " + getURI2("Compound") + ".\n"; + kbString += "DPRANGE(" + getURI2("amesTestPositive") + ") = BOOLEAN.\n"; kbString += "OPDOMAIN(" + getURI2("hasAtom") + ") = " + getURI2("Compound") + ".\n"; kbString += "OPRANGE(" + getURI2("hasAtom") + ") = " + getURI2("Atom") + ".\n"; kbString += "OPDOMAIN(" + getURI2("hasBond") + ") = " + getURI2("Compound") + ".\n"; Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-26 10:47:09 UTC (rev 640) @@ -25,6 +25,7 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeMap; +import java.util.TreeSet; import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; @@ -76,6 +77,9 @@ private Set<NamedClass> atomicConcepts; private Set<ObjectProperty> atomicRoles; private Set<DatatypeProperty> datatypeProperties; + private Set<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); + private Set<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); + private Set<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); private SortedSet<Individual> individuals; private ReasoningService rs; @@ -112,10 +116,18 @@ rc = new OWLAPIReasoner(sources); rc.init(); - atomicConcepts = rc.getAtomicConcepts(); - datatypeProperties = rc.getDatatypeProperties(); - atomicRoles = rc.getAtomicRoles(); - individuals = rc.getIndividuals(); + try { + atomicConcepts = rc.getAtomicConcepts(); + datatypeProperties = rc.getDatatypeProperties(); + booleanDatatypeProperties = rc.getBooleanDatatypeProperties(); + doubleDatatypeProperties = rc.getDoubleDatatypeProperties(); + intDatatypeProperties = rc.getIntDatatypeProperties(); + atomicRoles = rc.getAtomicRoles(); + individuals = rc.getIndividuals(); + } catch (ReasoningMethodUnsupportedException e) { + throw new ComponentInitException("Underlying reasoner does not support all necessary reasoning methods.", e); + } + rs = new ReasoningService(rc); // TODO: some code taken from Helper.createFlatABox, but pasted here because additional things need to @@ -232,6 +244,21 @@ return datatypeProperties; } + @Override + public Set<DatatypeProperty> getBooleanDatatypeProperties() { + return booleanDatatypeProperties; + } + + @Override + public Set<DatatypeProperty> getDoubleDatatypeProperties() { + return doubleDatatypeProperties; + } + + @Override + public Set<DatatypeProperty> getIntDatatypeProperties() { + return intDatatypeProperties; + } + /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getIndividuals() */ Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-26 07:13:31 UTC (rev 639) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-26 10:47:09 UTC (rev 640) @@ -43,6 +43,7 @@ import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.owl.AssertionalAxiom; import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.EquivalentClassesAxiom; @@ -79,6 +80,8 @@ import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLDataFactory; import org.semanticweb.owl.model.OWLDataProperty; +import org.semanticweb.owl.model.OWLDataRange; +import org.semanticweb.owl.model.OWLDataType; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLIndividual; import org.semanticweb.owl.model.OWLNamedObject; @@ -124,7 +127,9 @@ Set<NamedClass> atomicConcepts = new TreeSet<NamedClass>(conceptComparator); Set<ObjectProperty> atomicRoles = new TreeSet<ObjectProperty>(roleComparator); Set<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); -// Set<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); + Set<DatatypeProperty> booleanDatatypeProperties = new TreeSet<DatatypeProperty>(); + Set<DatatypeProperty> doubleDatatypeProperties = new TreeSet<DatatypeProperty>(); + Set<DatatypeProperty> intDatatypeProperties = new TreeSet<DatatypeProperty>(); SortedSet<Individual> individuals = new TreeSet<Individual>(); public OWLAPIReasoner(Set<KnowledgeSource> sources) { @@ -275,12 +280,19 @@ for(OWLObjectProperty owlProperty : owlObjectProperties) atomicRoles.add(new ObjectProperty(owlProperty.getURI().toString())); for(OWLDataProperty owlProperty : owlDatatypeProperties) { - // empty ranges are returned for ames test positive -// Set<OWLDataRange> ranges = owlProperty.getRanges(allImports); -// System.out.println(owlProperty); -// System.out.println(ranges); - datatypeProperties.add(new DatatypeProperty(owlProperty.getURI().toString())); - System.exit(0); + DatatypeProperty dtp = new DatatypeProperty(owlProperty.getURI().toString()); + Set<OWLDataRange> ranges = owlProperty.getRanges(allImports); + OWLDataRange range = ranges.iterator().next(); + if(range.isDataType()) { + URI uri = ((OWLDataType)range).getURI(); + if(uri.equals(Datatype.BOOLEAN.getURI())) + booleanDatatypeProperties.add(dtp); + else if(uri.equals(Datatype.DOUBLE.getURI())) + doubleDatatypeProperties.add(dtp); + else if(uri.equals(Datatype.INT.getURI())) + intDatatypeProperties.add(dtp); + } + datatypeProperties.add(dtp); } for(OWLIndividual owlIndividual : owlIndividuals) individuals.add(new Individual(owlIndividual.getURI().toString())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-26 07:13:35
|
Revision: 639 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=639&view=rev Author: jenslehmann Date: 2008-02-25 23:13:31 -0800 (Mon, 25 Feb 2008) Log Message: ----------- - fixed parser problem reported by Maria - Web Service now throws parse exceptions when input strings cannot be parsed correctly Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/parser/KBParser.java trunk/src/dl-learner/org/dllearner/parser/kb.jj trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/php-examples/Reasoning.php Added Paths: ----------- trunk/src/dl-learner/org/dllearner/server/jaxws/ParseExceptionBean.java Modified: trunk/src/dl-learner/org/dllearner/parser/KBParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-25 17:58:40 UTC (rev 638) +++ trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-26 07:13:31 UTC (rev 639) @@ -19,8 +19,15 @@ } public static Description parseConcept(String string) throws ParseException { - KBParser parser = new KBParser(new StringReader(string)); - return parser.Concept(); + // when just parsing the string as concept, we have no guarantee + // that the parser uses all symbols, e.g. a AND b returns just a + // because the brackets were forgotten; + // so instead we create an equivalent class axiom and return its + // right hand side + String eq = "tmp = " + string + "."; + KBParser parser = new KBParser(new StringReader(eq)); + EquivalentClassesAxiom eqAxiom = parser.TBoxEquiv(); + return eqAxiom.getConcept2(); } public static KB parseKBFile(String content) throws IOException, ParseException { @@ -668,39 +675,6 @@ finally { jj_save(5, xla); } } - final private boolean jj_3_1() { - if (jj_3R_2()) return true; - if (jj_scan_token(22)) return true; - if (jj_3R_3()) return true; - if (jj_scan_token(23)) return true; - if (jj_scan_token(COMMAND_END)) return true; - return false; - } - - final private boolean jj_3R_14() { - if (jj_scan_token(20)) return true; - if (jj_3R_20()) return true; - if (jj_3R_4()) return true; - if (jj_scan_token(COMMAND_END)) return true; - if (jj_3R_2()) return true; - return false; - } - - final private boolean jj_3R_17() { - if (jj_3R_21()) return true; - return false; - } - - final private boolean jj_3R_4() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_17()) { - jj_scanpos = xsp; - if (jj_3R_18()) return true; - } - return false; - } - final private boolean jj_3R_13() { if (jj_scan_token(19)) return true; if (jj_3R_20()) return true; @@ -901,6 +875,39 @@ return false; } + final private boolean jj_3_1() { + if (jj_3R_2()) return true; + if (jj_scan_token(22)) return true; + if (jj_3R_3()) return true; + if (jj_scan_token(23)) return true; + if (jj_scan_token(COMMAND_END)) return true; + return false; + } + + final private boolean jj_3R_14() { + if (jj_scan_token(20)) return true; + if (jj_3R_20()) return true; + if (jj_3R_4()) return true; + if (jj_scan_token(COMMAND_END)) return true; + if (jj_3R_2()) return true; + return false; + } + + final private boolean jj_3R_17() { + if (jj_3R_21()) return true; + return false; + } + + final private boolean jj_3R_4() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_17()) { + jj_scanpos = xsp; + if (jj_3R_18()) return true; + } + return false; + } + public KBParserTokenManager token_source; SimpleCharStream jj_input_stream; public Token token, jj_nt; Modified: trunk/src/dl-learner/org/dllearner/parser/kb.jj =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-25 17:58:40 UTC (rev 638) +++ trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-26 07:13:31 UTC (rev 639) @@ -48,8 +48,15 @@ } public static Description parseConcept(String string) throws ParseException { - KBParser parser = new KBParser(new StringReader(string)); - return parser.Concept(); + // when just parsing the string as concept, we have no guarantee + // that the parser uses all symbols, e.g. a AND b returns just a + // because the brackets were forgotten; + // so instead we create an equivalent class axiom and return its + // right hand side + String eq = "tmp = " + string + "."; + KBParser parser = new KBParser(new StringReader(eq)); + EquivalentClassesAxiom eqAxiom = parser.TBoxEquiv(); + return eqAxiom.getConcept2(); } public static KB parseKBFile(String content) throws IOException, ParseException { Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-02-25 17:58:40 UTC (rev 638) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-02-26 07:13:31 UTC (rev 639) @@ -460,31 +460,20 @@ } @WebMethod - public String[] retrieval(int id, String conceptString) throws ClientNotKnownException { + public String[] retrieval(int id, String conceptString) throws ClientNotKnownException, ParseException { ClientState state = getState(id); // call parser to parse concept Description concept = null; - try { - concept = KBParser.parseConcept(conceptString); - } catch (ParseException e) { - e.printStackTrace(); - } + concept = KBParser.parseConcept(conceptString); Set<Individual> individuals = state.getReasoningService().retrieval(concept); return Datastructures.sortedSet2StringListIndividuals(individuals); } @WebMethod - public int getConceptLength(String conceptString) { + public int getConceptLength(String conceptString) throws ParseException { // call parser to parse concept - Description concept = null; - try { - System.out.println(conceptString); - concept = KBParser.parseConcept(conceptString); - } catch (ParseException e) { - e.printStackTrace(); - } - return concept.getLength(); - } + return KBParser.parseConcept(conceptString).getLength(); + } @WebMethod public String[] getAtomicRoles(int id) throws ClientNotKnownException { Added: trunk/src/dl-learner/org/dllearner/server/jaxws/ParseExceptionBean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/jaxws/ParseExceptionBean.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/server/jaxws/ParseExceptionBean.java 2008-02-26 07:13:31 UTC (rev 639) @@ -0,0 +1,41 @@ + +package org.dllearner.server.jaxws; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * This class was generated by the JAXWS SI. + * JAX-WS RI 2.0_02-b08-fcs + * Generated source version: 2.0_02 + * + */ +@XmlRootElement(name = "ParseException", namespace = "http://server.dllearner.org/") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "ParseException", namespace = "http://server.dllearner.org/") +public class ParseExceptionBean { + + private String message; + + /** + * + * @return + * returns String + */ + public String getMessage() { + return this.message; + } + + /** + * + * @param message + * the value for the message property + */ + public void setMessage(String message) { + this.message = message; + } + +} Modified: trunk/src/php-examples/Reasoning.php =================================================================== --- trunk/src/php-examples/Reasoning.php 2008-02-25 17:58:40 UTC (rev 638) +++ trunk/src/php-examples/Reasoning.php 2008-02-26 07:13:31 UTC (rev 639) @@ -47,7 +47,7 @@ // create a concept in internal DL-Learner syntax // ( = all female persons having at least one child) -$concept = '"http://example.com/father#female" AND EXISTS "http://example.com/father#hasChild".TOP'; +$concept = '("http://example.com/father#female" AND EXISTS "http://example.com/father#hasChild".TOP)'; $instances = $client->retrieval($id, $concept); // print instances This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-25 17:58:43
|
Revision: 638 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=638&view=rev Author: tonytacker Date: 2008-02-25 09:58:40 -0800 (Mon, 25 Feb 2008) Log Message: ----------- first try to save config, add method toConfString in ConfigEntry Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java Modified: trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-02-24 19:29:04 UTC (rev 637) +++ trunk/src/dl-learner/org/dllearner/core/config/BooleanConfigOption.java 2008-02-25 17:58:40 UTC (rev 638) @@ -50,4 +50,12 @@ return true; } + /* (non-Javadoc) + * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) + */ + @Override + public String getValueFormatting(Boolean value) { + return value.toString(); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2008-02-24 19:29:04 UTC (rev 637) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigEntry.java 2008-02-25 17:58:40 UTC (rev 638) @@ -52,4 +52,12 @@ return value; } + /** + * Get a string to save into a configuration file. + * + * @return a formatted string + */ + public String toConfString(String componentName) { + return componentName.toString() + "." + option.getName() + " = " + option.getValueFormatting(value); + } } Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-02-24 19:29:04 UTC (rev 637) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-02-25 17:58:40 UTC (rev 638) @@ -85,4 +85,6 @@ return "option name: " + name + "\ndescription: " + description + "\nvalues: " + getAllowedValuesDescription() + "\ndefault value: " + defaultValue + "\n"; } + public abstract String getValueFormatting(T value); + } Modified: trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-02-24 19:29:04 UTC (rev 637) +++ trunk/src/dl-learner/org/dllearner/core/config/DoubleConfigOption.java 2008-02-25 17:58:40 UTC (rev 638) @@ -97,4 +97,14 @@ return str; } + /* + * (non-Javadoc) + * + * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) + */ + @Override + public String getValueFormatting(Double value) { + return value.toString(); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-02-24 19:29:04 UTC (rev 637) +++ trunk/src/dl-learner/org/dllearner/core/config/IntegerConfigOption.java 2008-02-25 17:58:40 UTC (rev 638) @@ -19,38 +19,39 @@ */ package org.dllearner.core.config; - /** * A configuration option, which allows values of type integer. A minimum and * maximum value of the argument can optionally be specified. * * @author Jens Lehmann - * + * */ public class IntegerConfigOption extends ConfigOption<Integer> { private int lowerLimit = Integer.MIN_VALUE; private int upperLimit = Integer.MAX_VALUE; - + public IntegerConfigOption(String name, String description) { super(name, description); } - + public IntegerConfigOption(String name, String description, int defaultValue) { super(name, description, defaultValue); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) */ @Override public boolean isValidValue(Integer value) { - if(value >= lowerLimit && value <= upperLimit) + if (value >= lowerLimit && value <= upperLimit) return true; else - return false; + return false; } - + /** * @return the The lowest possible value for this configuration option. */ @@ -59,7 +60,8 @@ } /** - * @param lowerLimit The lowest possible value for this configuration option. + * @param lowerLimit + * The lowest possible value for this configuration option. */ public void setLowerLimit(int lowerLimit) { this.lowerLimit = lowerLimit; @@ -73,13 +75,16 @@ } /** - * @param upperLimit The highest possible value for this configuration option. + * @param upperLimit + * The highest possible value for this configuration option. */ public void setUpperLimit(int upperLimit) { this.upperLimit = upperLimit; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) */ @Override @@ -90,11 +95,20 @@ @Override public String getAllowedValuesDescription() { String str = getClass().toString(); - if(lowerLimit != Integer.MIN_VALUE) + if (lowerLimit != Integer.MIN_VALUE) str += " min " + lowerLimit; - if(upperLimit != Integer.MAX_VALUE) + if (upperLimit != Integer.MAX_VALUE) str += " max " + upperLimit; return str; - } - + } + + /* + * (non-Javadoc) + * + * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) + */ + @Override + public String getValueFormatting(Integer value) { + return value.toString(); + } } Modified: trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-02-24 19:29:04 UTC (rev 637) +++ trunk/src/dl-learner/org/dllearner/core/config/StringConfigOption.java 2008-02-25 17:58:40 UTC (rev 638) @@ -23,37 +23,38 @@ import java.util.Set; import java.util.TreeSet; - /** * A configuration option, which allows values of type String. Optionally a set * of allowed strings can be set. By default all strings are allowed. * * @author Jens Lehmann - * + * */ public class StringConfigOption extends ConfigOption<String> { private Set<String> allowedValues = new TreeSet<String>();; - + public StringConfigOption(String name, String description) { super(name, description); } - + public StringConfigOption(String name, String description, String defaultValue) { super(name, description, defaultValue); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) */ @Override public boolean isValidValue(String value) { - if(allowedValues.size() == 0 || allowedValues.contains(value)) + if (allowedValues.size() == 0 || allowedValues.contains(value)) return true; else return false; - } - + } + /** * @return the allowedValues */ @@ -62,7 +63,8 @@ } /** - * @param allowedValues the allowedValues to set + * @param allowedValues + * the allowedValues to set */ public void setAllowedValues(Set<String> allowedValues) { this.allowedValues = allowedValues; @@ -71,8 +73,10 @@ public void setAllowedValues(String[] allowedValues) { this.allowedValues = new TreeSet<String>(Arrays.asList(allowedValues)); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) */ @Override @@ -80,4 +84,14 @@ return (object instanceof String); } + /* + * (non-Javadoc) + * + * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) + */ + @Override + public String getValueFormatting(String value) { + return value.toString(); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-02-24 19:29:04 UTC (rev 637) +++ trunk/src/dl-learner/org/dllearner/core/config/StringSetConfigOption.java 2008-02-25 17:58:40 UTC (rev 638) @@ -21,20 +21,21 @@ import java.util.Set; - /** * A set of strings. * * @author Jens Lehmann - * + * */ public class StringSetConfigOption extends ConfigOption<Set<String>> { public StringSetConfigOption(String name, String description) { super(name, description); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#isValidValue(java.lang.Object) */ @Override @@ -42,21 +43,33 @@ return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.ConfigOption#checkType(java.lang.Object) */ @Override public boolean checkType(Object object) { - if(!(object instanceof Set)) + if (!(object instanceof Set)) return false; - + Set<?> set = (Set<?>) object; - for(Object element : set) { - if(!(element instanceof String)) + for (Object element : set) { + if (!(element instanceof String)) return false; } - + return true; } + /* + * (non-Javadoc) + * + * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) + */ + @Override + public String getValueFormatting(Set<String> value) { + return value.toString(); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java 2008-02-24 19:29:04 UTC (rev 637) +++ trunk/src/dl-learner/org/dllearner/core/config/StringTupleListConfigOption.java 2008-02-25 17:58:40 UTC (rev 638) @@ -24,8 +24,8 @@ import org.dllearner.utilities.StringTuple; /** - * A list if string tuples, for instance for specifying several - * parameters or replacement rules. + * A list if string tuples, for instance for specifying several parameters or + * replacement rules. * * @author Jens Lehmann */ @@ -34,29 +34,34 @@ public StringTupleListConfigOption(String name, String description) { this(name, description, null); } - - public StringTupleListConfigOption(String name, String description, List<StringTuple> defaultValue) { + + public StringTupleListConfigOption(String name, String description, + List<StringTuple> defaultValue) { super(name, description, defaultValue); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.config.ConfigOption#checkType(java.lang.Object) */ @Override public boolean checkType(Object object) { - if(!(object instanceof List)) + if (!(object instanceof List)) return false; - + List<?> set = (List<?>) object; - for(Object element : set) { - if(!(element instanceof StringTuple)) + for (Object element : set) { + if (!(element instanceof StringTuple)) return false; } - + return true; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.dllearner.core.config.ConfigOption#isValidValue(java.lang.Object) */ @Override @@ -64,4 +69,14 @@ return true; } + /* + * (non-Javadoc) + * + * @see org.dllearner.core.config.ConfigOption#getValueFormatting(java.lang.Object) + */ + @Override + public String getValueFormatting(List<StringTuple> value) { + return value.toString(); + } + } Added: trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigSave.java 2008-02-25 17:58:40 UTC (rev 638) @@ -0,0 +1,125 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +//import java.io.File; +//import java.net.URL; +import java.util.List; //import java.util.Map; +//import java.util.SortedSet; +//import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; //import org.dllearner.core.KnowledgeSource; +//import org.dllearner.core.LearningProblemUnsupportedException; +//import org.dllearner.learningproblems.PosOnlyDefinitionLP; +//import org.dllearner.parser.ConfParser; +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigOption; + +//import org.dllearner.cli.ConfFileOption; +//import org.dllearner.cli.Start; +//import org.dllearner.core.config.*; + +/** + * Open a config file. + * + * @author Tilo Hielscher + */ +public class ConfigSave { + + // private File file; + private Config config; + + // private StartGUI startGUI; + + /** + * set config and startGUI + * + * @param config + * @param startGUI + */ + public ConfigSave(Config config, StartGUI startGUI) { + this.config = config; + // this.startGUI = startGUI; + } + + /** + * parse to file + */ + public void startParser() { + // KNOWLEDGE SOURCE + if (config.getKnowledgeSource() != null) { + // System.out.println("knowledge_source: " + + // config.getKnowledgeSource().getClass()); + // KBFile or OWLFile + if (config.getKnowledgeSource().getClass().toString().endsWith("KBFile") + || config.getKnowledgeSource().getClass().toString().endsWith("OWLFile")) { + // url + String url = (String) config.getComponentManager().getConfigOptionValue( + config.getKnowledgeSource(), "url"); + if (url != null) { + System.out.println("import(\"" + url + "\");"); + } + // filename + String filename = (String) config.getComponentManager().getConfigOptionValue( + config.getKnowledgeSource(), "filename"); + if (filename != null) { + System.out.println("import(\"" + filename + "\");"); + } + } + // sparql + if (config.getKnowledgeSource().getClass().toString().endsWith("SparqlKnowledgeSource")) { + String url = (String) config.getComponentManager().getConfigOptionValue( + config.getKnowledgeSource(), "url"); + if (url != null) { + System.out.println("import(\"" + url + "\",\"SPARQL\");"); + // widgets + String prefix = "sparql"; + Component component = config.getKnowledgeSource(); + + Class<? extends Component> componentOption = component.getClass(); // config.getKnowledgeSource().getClass(); + List<ConfigOption<?>> optionList; + optionList = ComponentManager.getConfigOptions(componentOption); + // System.out.println(optionList); + // System.out.println(config.getComponentManager().getConfigOptionValue(component, + // optionName)); + for (int i = 0; i < optionList.size(); i++) { + // if + // (optionList.get(i).getClass().toString().contains("IntegerConfigOption")) + // { + // widgetPanel = new WidgetPanelInteger(config, + // component, oldComponent, componentOption, + // optionList.get(i)); + // System.out.println(optionList.get(i)); + System.out.println(prefix + + "." + + optionList.get(i).getName() + + " = " + + config.getComponentManager().getConfigOptionValue(component, + optionList.get(i).getName())); + System.out.println(config.getComponentManager().getKnowledgeSources() + .get(0)); + // } + } + } + } + } + } + +} Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-24 19:29:04 UTC (rev 637) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-25 17:58:40 UTC (rev 638) @@ -48,6 +48,7 @@ private Config config = new Config(); private ConfigLoad configLoad = new ConfigLoad(config, this);; + private ConfigSave configSave = new ConfigSave(config, this);; private KnowledgeSourcePanel tab0; private ReasonerPanel tab1; @@ -142,6 +143,7 @@ // save config file if (e.getSource() == saveItem) { System.out.println("saveItem was pressed"); + configSave.startParser(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-24 19:29:09
|
Revision: 637 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=637&view=rev Author: jenslehmann Date: 2008-02-24 11:29:04 -0800 (Sun, 24 Feb 2008) Log Message: ----------- - prepared reasoner datatype support - implemented getRoleMembers in OWL API reasoner - now fully DIG 1.1 compliant - discovered another bug in OWL API export (adds an empty prefix) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java trunk/src/dl-learner/org/dllearner/core/Reasoner.java trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/ReasoningService.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-24 17:49:30 UTC (rev 636) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-24 19:29:04 UTC (rev 637) @@ -550,6 +550,15 @@ } m.put(3,m3); } + + // boolean datatypes, e.g. testPositive = true + if(useBooleanDatatypes) { +// Set<Description> m3 = new TreeSet<Description>(conceptComparator); + // TODO: code for getting boolean datatypes +// m.put(3,m3); + // TODO: do not use put here because we overwrite the + // EXISTS quantor stuff + } } if(maxLength>2) { Modified: trunk/src/dl-learner/org/dllearner/core/Reasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-24 17:49:30 UTC (rev 636) +++ trunk/src/dl-learner/org/dllearner/core/Reasoner.java 2008-02-24 19:29:04 UTC (rev 637) @@ -24,6 +24,7 @@ import java.util.Set; import java.util.SortedSet; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -88,5 +89,11 @@ public Set<ObjectProperty> getAtomicRoles(); + // currently, we do not require that datatype properties can be returned; + // the main reason is that DIG does not distinguish between datatype and + // object properties (of course one could implement it but it is not easy) + public Set<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException; + public SortedSet<Individual> getIndividuals(); + } Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-24 17:49:30 UTC (rev 636) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2008-02-24 19:29:04 UTC (rev 637) @@ -25,6 +25,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -120,4 +121,8 @@ throw new ReasoningMethodUnsupportedException(); } + public Set<DatatypeProperty> getDatatypeProperties() throws ReasoningMethodUnsupportedException { + throw new ReasoningMethodUnsupportedException(); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningService.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-02-24 17:49:30 UTC (rev 636) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningService.java 2008-02-24 19:29:04 UTC (rev 637) @@ -486,6 +486,7 @@ // Reasoning-Resultate // zur�ckgegeben werden k�nnten private void handleExceptions(ReasoningMethodUnsupportedException e) { + e.printStackTrace(); throw new Error("Reasoning method not supported."); } Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-24 17:49:30 UTC (rev 636) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-24 19:29:04 UTC (rev 637) @@ -196,8 +196,10 @@ } // disjoint classes axioms - DisjointClassesAxiom disjointAtomTypes = getDisjointClassesAxiom(atomTypes); - kb.addAxiom(disjointAtomTypes); + // OWL API is also buggy here, it adds a strange unused prefix + // and cannot parser its own generated file +// DisjointClassesAxiom disjointAtomTypes = getDisjointClassesAxiom(atomTypes); +// kb.addAxiom(disjointAtomTypes); // all different axiom (UNA) // exporting differentIndividuals axioms is broken in OWL API @@ -443,6 +445,7 @@ return new DoubleDatatypePropertyAssertion(dp, ind, value); } + @SuppressWarnings({"unused"}) private static DisjointClassesAxiom getDisjointClassesAxiom(Set<String> classes) { Set<Description> descriptions = new HashSet<Description>(); for(String namedClass : classes) Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-24 17:49:30 UTC (rev 636) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-24 19:29:04 UTC (rev 637) @@ -35,6 +35,7 @@ import org.dllearner.core.ReasoningService; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; @@ -59,8 +60,8 @@ * model of the knowledge base (TODO: more explanation), which is neither correct nor * complete, but sufficient in many cases. A big advantage of the algorithm is that it * does not need even need to perform any set modifications (union, intersection, difference), - * so it avoids any object creation, which makes it very fast compared to standard - * reasoners (TODO: maybe add some benchmarks once it is implemented). + * so it avoids any Java object creation, which makes it extremely fast compared to standard + * reasoners. * * Note: This algorithm works only on concepts in negation normal form! * @@ -74,10 +75,11 @@ private Set<NamedClass> atomicConcepts; private Set<ObjectProperty> atomicRoles; + private Set<DatatypeProperty> datatypeProperties; private SortedSet<Individual> individuals; private ReasoningService rs; - private ReasonerComponent rc; + private OWLAPIReasoner rc; private Set<KnowledgeSource> sources; // we use sorted sets (map indices) here, because they have only log(n) @@ -94,7 +96,6 @@ this.sources = sources; } - /* (non-Javadoc) * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.config.ConfigEntry) */ @@ -109,17 +110,10 @@ @Override public void init() throws ComponentInitException { rc = new OWLAPIReasoner(sources); - // DIG will only be used to get the role pairs; - // outside the constructor, OWL API will be used because - // it is fast than DIG - DIGReasoner rcDIG = new DIGReasoner(sources); - try { - rc.init(); - rcDIG.init(); - } catch (ComponentInitException e1) { - e1.printStackTrace(); - } + rc.init(); + atomicConcepts = rc.getAtomicConcepts(); + datatypeProperties = rc.getDatatypeProperties(); atomicRoles = rc.getAtomicRoles(); individuals = rc.getIndividuals(); rs = new ReasoningService(rc); @@ -135,7 +129,7 @@ } for (ObjectProperty atomicRole : rs.getAtomicRoles()) { - opPos.put(atomicRole, rcDIG.getRoleMembers(atomicRole)); + opPos.put(atomicRole, rc.getRoleMembers(atomicRole)); } long dematDuration = System.currentTimeMillis() - dematStartTime; @@ -233,6 +227,11 @@ return atomicRoles; } + @Override + public Set<DatatypeProperty> getDatatypeProperties() { + return datatypeProperties; + } + /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getIndividuals() */ Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-24 17:49:30 UTC (rev 636) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-24 19:29:04 UTC (rev 637) @@ -27,6 +27,7 @@ import java.util.Comparator; import java.util.HashSet; import java.util.LinkedList; +import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeMap; @@ -42,6 +43,7 @@ import org.dllearner.core.config.StringConfigOption; import org.dllearner.core.owl.AssertionalAxiom; import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.DatatypeProperty; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.EquivalentClassesAxiom; import org.dllearner.core.owl.FunctionalObjectPropertyAxiom; @@ -76,6 +78,7 @@ import org.semanticweb.owl.model.OWLAxiom; import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLDataFactory; +import org.semanticweb.owl.model.OWLDataProperty; import org.semanticweb.owl.model.OWLDescription; import org.semanticweb.owl.model.OWLIndividual; import org.semanticweb.owl.model.OWLNamedObject; @@ -120,6 +123,8 @@ // primitives Set<NamedClass> atomicConcepts = new TreeSet<NamedClass>(conceptComparator); Set<ObjectProperty> atomicRoles = new TreeSet<ObjectProperty>(roleComparator); + Set<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); +// Set<DatatypeProperty> datatypeProperties = new TreeSet<DatatypeProperty>(); SortedSet<Individual> individuals = new TreeSet<Individual>(); public OWLAPIReasoner(Set<KnowledgeSource> sources) { @@ -164,7 +169,8 @@ } }; Set<OWLClass> classes = new TreeSet<OWLClass>(namedObjectComparator); - Set<OWLObjectProperty> properties = new TreeSet<OWLObjectProperty>(namedObjectComparator); + Set<OWLObjectProperty> owlObjectProperties = new TreeSet<OWLObjectProperty>(namedObjectComparator); + Set<OWLDataProperty> owlDatatypeProperties = new TreeSet<OWLDataProperty>(namedObjectComparator); Set<OWLIndividual> owlIndividuals = new TreeSet<OWLIndividual>(namedObjectComparator); Set<OWLOntology> allImports = new HashSet<OWLOntology>(); @@ -178,7 +184,8 @@ OWLOntology ontology = manager.loadOntologyFromPhysicalURI(url.toURI()); allImports.addAll(manager.getImportsClosure(ontology)); classes.addAll(ontology.getReferencedClasses()); - properties.addAll(ontology.getReferencedObjectProperties()); + owlObjectProperties.addAll(ontology.getReferencedObjectProperties()); + owlDatatypeProperties.addAll(ontology.getReferencedDataProperties()); owlIndividuals.addAll(ontology.getReferencedIndividuals()); } catch (OWLOntologyCreationException e) { e.printStackTrace(); @@ -202,7 +209,8 @@ allImports.add(ontology); atomicConcepts.addAll(kb.findAllAtomicConcepts()); atomicRoles.addAll(kb.findAllAtomicRoles()); - individuals.addAll(kb.findAllIndividuals()); + individuals.addAll(kb.findAllIndividuals()); + // TODO: add method to find datatypes } } @@ -264,11 +272,18 @@ // read in primitives for(OWLClass owlClass : classes) atomicConcepts.add(new NamedClass(owlClass.getURI().toString())); - for(OWLObjectProperty owlProperty : properties) + for(OWLObjectProperty owlProperty : owlObjectProperties) atomicRoles.add(new ObjectProperty(owlProperty.getURI().toString())); + for(OWLDataProperty owlProperty : owlDatatypeProperties) { + // empty ranges are returned for ames test positive +// Set<OWLDataRange> ranges = owlProperty.getRanges(allImports); +// System.out.println(owlProperty); +// System.out.println(ranges); + datatypeProperties.add(new DatatypeProperty(owlProperty.getURI().toString())); + System.exit(0); + } for(OWLIndividual owlIndividual : owlIndividuals) individuals.add(new Individual(owlIndividual.getURI().toString())); - } /* (non-Javadoc) @@ -285,6 +300,11 @@ return atomicRoles; } + @Override + public Set<DatatypeProperty> getDatatypeProperties() { + return datatypeProperties; + } + /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getIndividuals() */ @@ -482,6 +502,31 @@ } } + @Override + public Map<Individual, SortedSet<Individual>> getRoleMembers(ObjectProperty atomicRole) { + OWLObjectProperty prop = getOWLAPIDescription(atomicRole); + Map<Individual, SortedSet<Individual>> map = new TreeMap<Individual, SortedSet<Individual>>(); + for(Individual i : individuals) { + OWLIndividual ind = factory.getOWLIndividual(URI.create(i.getName())); + + // get all related individuals via OWL API + Set<OWLIndividual> inds = null; + try { + inds = reasoner.getRelatedIndividuals(ind, prop); + } catch (OWLReasonerException e) { + e.printStackTrace(); + } + + // convert data back to DL-Learner structures + SortedSet<Individual> is = new TreeSet<Individual>(); + for(OWLIndividual oi : inds) + is.add(new Individual(oi.getURI().toString())); + map.put(i, is); + } + return map; + } + + // OWL API often returns a set of sets of classes, where each inner // set consists of equivalent classes; this method picks one class // from each inner set to flatten the set of sets @@ -561,8 +606,7 @@ } } - @Deprecated - public static OWLObjectProperty getOWLAPIDescription(ObjectProperty role) { + private static OWLObjectProperty getOWLAPIDescription(ObjectProperty role) { return staticFactory.getOWLObjectProperty(URI.create(role.getName())); } Modified: trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java 2008-02-24 17:49:30 UTC (rev 636) +++ trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java 2008-02-24 19:29:04 UTC (rev 637) @@ -24,15 +24,31 @@ OWLOntology ontology = manager.createOntology(ontologyURI); OWLDataFactory factory = manager.getOWLDataFactory(); + // create a set of two individuals OWLIndividual a = factory.getOWLIndividual(URI.create(ontologyURI + "#a")); OWLIndividual b = factory.getOWLIndividual(URI.create(ontologyURI + "#b")); Set<OWLIndividual> inds = new HashSet<OWLIndividual>(); inds.add(a); inds.add(b); + // create a set of two classes + OWLClass c = factory.getOWLClass(URI.create(ontologyURI + "#c")); + OWLClass d = factory.getOWLClass(URI.create(ontologyURI + "#d")); + Set<OWLClass> classes = new HashSet<OWLClass>(); + classes.add(c); + classes.add(d); + + // state that a and b are different OWLAxiom axiom = factory.getOWLDifferentIndividualsAxiom(inds); AddAxiom addAxiom = new AddAxiom(ontology, axiom); manager.applyChange(addAxiom); + + // state that c and d are disjoint + OWLAxiom axiom2 = factory.getOWLDisjointClassesAxiom(classes); + AddAxiom addAxiom2 = new AddAxiom(ontology, axiom2); + manager.applyChange(addAxiom2); + + // save ontology manager.saveOntology(ontology); } catch (OWLException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-24 17:49:34
|
Revision: 636 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=636&view=rev Author: jenslehmann Date: 2008-02-24 09:49:30 -0800 (Sun, 24 Feb 2008) Log Message: ----------- minor parser modifications Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/parser/KBParser.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java Added: trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-24 17:49:30 UTC (rev 636) @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +import java.net.URI; +import java.util.Map; + +/** + * @author Jens Lehmann + * + */ +public enum Datatype implements DataRange { + + DOUBLE ("http://www.w3.org/2001/XMLSchema#double"), + INT ("http://www.w3.org/2001/XMLSchema#int"), + BOOLEAN ("http://www.w3.org/2001/XMLSchema#Boolean"); + + private URI uri; + + private Datatype(String uriString) { + uri = URI.create(uriString); + } + + public URI getURI() { + return uri; + } + + @Override + public String toString() { + return uri.toString(); + } + + public int getLength() { + return 1; + } + + public String toString(String baseURI, Map<String, String> prefixes) { + return uri.toString(); + } + + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } +} Modified: trunk/src/dl-learner/org/dllearner/parser/KBParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-24 17:47:44 UTC (rev 635) +++ trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-24 17:49:30 UTC (rev 636) @@ -379,15 +379,15 @@ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 44: jj_consume_token(44); - range = new Datatype(Datatype.Type.DOUBLE); + range = Datatype.DOUBLE; break; case 45: jj_consume_token(45); - range = new Datatype(Datatype.Type.BOOLEAN); + range = Datatype.BOOLEAN; break; case 46: jj_consume_token(46); - range = new Datatype(Datatype.Type.INT); + range = Datatype.INT; break; default: jj_la1[8] = jj_gen; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-24 17:48:02
|
Revision: 635 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=635&view=rev Author: jenslehmann Date: 2008-02-24 09:47:44 -0800 (Sun, 24 Feb 2008) Log Message: ----------- - boolean hasValue restrictions - Datatype now implemented as enum (easier programmatic access) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java trunk/src/dl-learner/org/dllearner/parser/kb.jj Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-24 17:47:44 UTC (rev 635) @@ -42,6 +42,7 @@ import org.dllearner.core.owl.ObjectPropertyExpression; import org.dllearner.core.owl.ObjectQuantorRestriction; import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.ValueRestriction; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.ConceptTransformation; @@ -143,7 +144,8 @@ } else if (concept instanceof Nothing) { // return new HashSet<Concept>(); -// } else if (concept instanceof ) + } else if (concept instanceof ValueRestriction) { + // value restrictions cannot be further refined } else if (concept instanceof NamedClass) { // Erkenntnisse aus Benchmarks: dieser Teil wird sehr häufig aufgerufen, // allerdings lässt er sich kaum weiter verbessern (selbst ohne klonen Modified: trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanDataRange.java 2008-02-24 17:47:44 UTC (rev 635) @@ -28,7 +28,7 @@ * @author Jens Lehmann * */ -public class BooleanDataRange extends DataRange { +public class BooleanDataRange implements DataRange { private boolean isTrue; Added: trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java 2008-02-24 17:47:44 UTC (rev 635) @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +/** + * Convenience class for boolean value restrictions. + * + * @author Jens Lehmann + * + */ +public class BooleanValueRestriction extends DatatypeValueRestriction { + + /** + * TODO: Internally a typed constant with datatype boolean and + * strings "true" or "false" is created. This is a clean way to + * implement boolean value restrictions. However, if they are + * created millions of times during the run of an algorithm, + * this may cause unnecessary delays. + * Possible Solution: It may be good to create a BooleanConstant + * class, which just holds the boolean value and only performs + * operations when requested. + * + * @param restrictedPropertyExpression + * @param value + */ + public BooleanValueRestriction(DatatypeProperty restrictedPropertyExpression, Boolean value) { + super(restrictedPropertyExpression, new TypedConstant(value.toString(), Datatype.BOOLEAN)); + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DataRange.java 2008-02-24 17:47:44 UTC (rev 635) @@ -23,6 +23,6 @@ * @author Jens Lehmann * */ -public abstract class DataRange implements PropertyRange { +public interface DataRange extends PropertyRange { } Deleted: trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-24 17:47:44 UTC (rev 635) @@ -1,82 +0,0 @@ -/** - * Copyright (C) 2007-2008, Jens Lehmann - * - * This file is part of DL-Learner. - * - * DL-Learner is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * DL-Learner is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ -package org.dllearner.core.owl; - -import java.net.URI; -import java.util.Map; - -/** - * Enumeration of possible types wrapped in a class such that - * it is a valid data range. - * - * @author Jens Lehmann - * - */ -public class Datatype extends DataRange { - - public enum Type { DOUBLE, INT, BOOLEAN }; - - private Type type; - - private static final String xsd = "http://www.w3.org/2001/XMLSchema#"; - - public Datatype(Type type) { - this.type = type; - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.KBElement#accept(org.dllearner.core.owl.KBElementVisitor) - */ - public void accept(KBElementVisitor visitor) { - visitor.visit(this); - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.KBElement#getLength() - */ - public int getLength() { - return 1; - } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) - */ - public String toString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; - } - - public URI getURI() { - switch(type) { - case DOUBLE: return URI.create(xsd + "double"); - case INT: return URI.create(xsd + "int"); - case BOOLEAN: return URI.create(xsd + "Boolean"); - default: throw new Error("Unknown tpye " + type + "."); - } - } - - /** - * @return the type - */ - public Type getType() { - return type; - } - -} Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-24 17:47:44 UTC (rev 635) @@ -67,6 +67,10 @@ return restrictedPropertyExpression.toString(baseURI, prefixes) + " = " + value.toString(baseURI, prefixes); } + public DatatypeProperty getRestrictedPropertyExpresssion() { + return (DatatypeProperty) restrictedPropertyExpression; + } + @Override public Constant getValue() { return (Constant) value; Modified: trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleDataRange.java 2008-02-24 17:47:44 UTC (rev 635) @@ -25,6 +25,6 @@ * @author Jens Lehmann * */ -public abstract class DoubleDataRange extends DataRange { +public interface DoubleDataRange extends DataRange { } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleMaxValue.java 2008-02-24 17:47:44 UTC (rev 635) @@ -28,7 +28,7 @@ * @author Jens Lehmann * */ -public class DoubleMaxValue extends DoubleDataRange { +public class DoubleMaxValue implements DoubleDataRange { private double value; Modified: trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/DoubleMinValue.java 2008-02-24 17:47:44 UTC (rev 635) @@ -28,7 +28,7 @@ * @author Jens Lehmann * */ -public class DoubleMinValue extends DoubleDataRange { +public class DoubleMinValue implements DoubleDataRange { private double value; Modified: trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java 2008-02-24 17:47:44 UTC (rev 635) @@ -47,7 +47,7 @@ * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ public String toString(String baseURI, Map<String, String> prefixes) { - return literal + datatype.toString(baseURI, prefixes); + return literal + "^^" + datatype; } /** Modified: trunk/src/dl-learner/org/dllearner/parser/kb.jj =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-24 16:27:53 UTC (rev 634) +++ trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-24 17:47:44 UTC (rev 635) @@ -227,9 +227,9 @@ DatatypePropertyRangeAxiom DatatypePropertyRangeAxiom() : {DatatypeProperty op; DataRange range; } { ( "DPRANGE" | "DATATYPEPROPERTYRANGE") "(" op=DatatypeProperty() ")" "=" - ( "DOUBLE" { range = new Datatype(Datatype.Type.DOUBLE); } - | "BOOLEAN" { range = new Datatype(Datatype.Type.BOOLEAN); } - | "INTEGER" { range = new Datatype(Datatype.Type.INT); } ) + ( "DOUBLE" { range = Datatype.DOUBLE; } + | "BOOLEAN" { range = Datatype.BOOLEAN; } + | "INTEGER" { range = Datatype.INT; } ) <COMMAND_END> { return new DatatypePropertyRangeAxiom(op, range); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-24 16:28:42
|
Revision: 634 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=634&view=rev Author: jenslehmann Date: 2008-02-24 08:27:53 -0800 (Sun, 24 Feb 2008) Log Message: ----------- aligned core OWL structures closer to OWL 1.1 structure spec Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Property.java trunk/src/dl-learner/org/dllearner/core/owl/PropertyExpression.java trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -25,4 +25,27 @@ */ public abstract class CardinalityRestriction extends Restriction { + int cardinality; + PropertyRange propertyRange; + + public CardinalityRestriction(PropertyExpression propertyExpression, PropertyRange propertyRange, int cardinality) { + super(propertyExpression); + this.propertyRange = propertyRange; + this.cardinality = cardinality; + } + + /** + * @return the cardinality + */ + public int getCardinality() { + return cardinality; + } + + /** + * @return the propertyRange + */ + public PropertyRange getPropertyRange() { + return propertyRange; + } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeCardinalityRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeCardinalityRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -25,4 +25,9 @@ */ public abstract class DatatypeCardinalityRestriction extends CardinalityRestriction { + public DatatypeCardinalityRestriction(DatatypeProperty datatypeProperty, + DataRange dataRange, int cardinality) { + super(datatypeProperty, dataRange, cardinality); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -27,6 +27,17 @@ */ public class DatatypeExactCardinalityRestriction extends DatatypeCardinalityRestriction { + /** + * @param datatypeProperty + * @param dataRange + * @param cardinality + */ + public DatatypeExactCardinalityRestriction(DatatypeProperty datatypeProperty, + DataRange dataRange, int cardinality) { + super(datatypeProperty, dataRange, cardinality); + // TODO Auto-generated constructor stub + } + /* (non-Javadoc) * @see org.dllearner.core.owl.Concept#getArity() */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -27,6 +27,17 @@ */ public class DatatypeMaxCardinalityRestriction extends DatatypeCardinalityRestriction { + /** + * @param datatypeProperty + * @param dataRange + * @param cardinality + */ + public DatatypeMaxCardinalityRestriction(DatatypeProperty datatypeProperty, + DataRange dataRange, int cardinality) { + super(datatypeProperty, dataRange, cardinality); + // TODO Auto-generated constructor stub + } + /* (non-Javadoc) * @see org.dllearner.core.owl.Concept#getArity() */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -27,6 +27,17 @@ */ public class DatatypeMinCardinalityRestriction extends DatatypeCardinalityRestriction { + /** + * @param datatypeProperty + * @param dataRange + * @param cardinality + */ + public DatatypeMinCardinalityRestriction(DatatypeProperty datatypeProperty, + DataRange dataRange, int cardinality) { + super(datatypeProperty, dataRange, cardinality); + // TODO Auto-generated constructor stub + } + /* (non-Javadoc) * @see org.dllearner.core.owl.Concept#getArity() */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2008-02-24 16:27:53 UTC (rev 634) @@ -27,7 +27,7 @@ * @author Jens Lehmann * */ -public class DatatypeProperty extends PropertyExpression implements Property, NamedKBElement { +public class DatatypeProperty implements Property, NamedKBElement { protected String name; Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -25,4 +25,11 @@ */ public abstract class DatatypeQuantorRestriction extends QuantorRestriction { + /** + * @param propertyExpression + */ + public DatatypeQuantorRestriction(DatatypeProperty datatypeProperty) { + super(datatypeProperty); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -32,8 +32,13 @@ */ public class DatatypeSomeRestriction extends DatatypeQuantorRestriction { + /** + * @param datatypeProperty + */ + public DatatypeSomeRestriction(DatatypeProperty datatypeProperty) { + super(datatypeProperty); + } - /* (non-Javadoc) * @see org.dllearner.core.owl.Description#getArity() */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -31,26 +31,53 @@ */ public class DatatypeValueRestriction extends ValueRestriction { -// public DatatypeValueRestriction(DatatypeProperty) + public DatatypeValueRestriction(DatatypeProperty restrictedPropertyExpression, Constant value) { + super(restrictedPropertyExpression, value); + } /* (non-Javadoc) - * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + * @see org.dllearner.core.owl.Description#toManchesterSyntaxString() */ @Override - public void accept(DescriptionVisitor visitor) { - visitor.visit(this); - } - - public void accept(KBElementVisitor visitor) { - visitor.visit(this); + public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + // TODO Auto-generated method stub + return null; } /* (non-Javadoc) - * @see org.dllearner.core.owl.Description#toManchesterSyntaxString() + * @see org.dllearner.core.owl.Description#getArity() */ @Override - public String toManchesterSyntaxString(String baseURI, Map<String,String> prefixes) { + public int getArity() { // TODO Auto-generated method stub - return null; + return 0; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#getLength() + */ + public int getLength() { + return 1 + restrictedPropertyExpression.getLength() + value.getLength(); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) + */ + public String toString(String baseURI, Map<String, String> prefixes) { + return restrictedPropertyExpression.toString(baseURI, prefixes) + " = " + value.toString(baseURI, prefixes); + } + + @Override + public Constant getValue() { + return (Constant) value; } + + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } + + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -35,12 +35,12 @@ } public String toString(String baseURI, Map<String,String> prefixes) { - return "ALL " + role + "." + children.get(0).toString(baseURI, prefixes); + return "ALL " + restrictedPropertyExpression.toString(baseURI, prefixes) + "." + children.get(0).toString(baseURI, prefixes); } @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return role.toString(baseURI, prefixes) + " some " + children.get(0).toManchesterSyntaxString(baseURI, prefixes); + return restrictedPropertyExpression.toString(baseURI, prefixes) + " some " + children.get(0).toManchesterSyntaxString(baseURI, prefixes); } /* (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -6,6 +6,7 @@ protected int number; public ObjectCardinalityRestriction(int number, ObjectPropertyExpression role, Description c) { + super(role, c, number); addChild(c); this.role = role; this.number = number; Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java 2008-02-24 16:27:53 UTC (rev 634) @@ -27,7 +27,7 @@ * @author Jens Lehmann * */ -public abstract class ObjectPropertyExpression extends PropertyExpression implements KBElement { +public abstract class ObjectPropertyExpression implements PropertyExpression { protected String name; Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -1,20 +1,42 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.core.owl; +/** + * + * @author Jens Lehmann + * + */ public abstract class ObjectQuantorRestriction extends QuantorRestriction { - ObjectPropertyExpression role; - public ObjectQuantorRestriction(ObjectPropertyExpression role, Description c) { - this.role = role; + super(role); addChild(c); } public ObjectPropertyExpression getRole() { - return role; + return (ObjectPropertyExpression) restrictedPropertyExpression; } public int getLength() { - return 1 + role.getLength() + getChild(0).getLength(); + return 1 + restrictedPropertyExpression.getLength() + getChild(0).getLength(); } @Override Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -34,12 +34,12 @@ } public String toString(String baseURI, Map<String,String> prefixes) { - return "EXISTS " + role.toString(baseURI, prefixes) + "." + children.get(0).toString(baseURI, prefixes); + return "EXISTS " + restrictedPropertyExpression.toString(baseURI, prefixes) + "." + children.get(0).toString(baseURI, prefixes); } @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return role.toString(baseURI, prefixes) + " only " + children.get(0).toManchesterSyntaxString(baseURI, prefixes); + return restrictedPropertyExpression.toString(baseURI, prefixes) + " only " + children.get(0).toManchesterSyntaxString(baseURI, prefixes); } /* (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -30,16 +30,11 @@ */ public class ObjectValueRestriction extends ValueRestriction { - /* (non-Javadoc) - * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) + /** + * @param property */ - @Override - public void accept(DescriptionVisitor visitor) { - visitor.visit(this); - } - - public void accept(KBElementVisitor visitor) { - visitor.visit(this); + public ObjectValueRestriction(Property property, Individual value) { + super(property, value); } /* (non-Javadoc) @@ -49,5 +44,43 @@ public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { // TODO Auto-generated method stub return null; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.Description#getArity() + */ + @Override + public int getArity() { + // TODO Auto-generated method stub + return 0; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#getLength() + */ + public int getLength() { + // TODO Auto-generated method stub + return 0; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) + */ + public String toString(String baseURI, Map<String, String> prefixes) { + // TODO Auto-generated method stub + return null; } + + public Individual getIndividual() { + return (Individual) value; + } + + @Override + public void accept(DescriptionVisitor visitor) { + visitor.visit(this); + } + + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Property.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Property.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/Property.java 2008-02-24 16:27:53 UTC (rev 634) @@ -23,6 +23,6 @@ * @author Jens Lehmann * */ -public interface Property extends NamedKBElement { +public interface Property extends PropertyExpression, NamedKBElement { } Modified: trunk/src/dl-learner/org/dllearner/core/owl/PropertyExpression.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/PropertyExpression.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/PropertyExpression.java 2008-02-24 16:27:53 UTC (rev 634) @@ -23,6 +23,6 @@ * @author Jens Lehmann * */ -public abstract class PropertyExpression implements KBElement { +public interface PropertyExpression extends KBElement { } Modified: trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -25,4 +25,8 @@ */ public abstract class QuantorRestriction extends Restriction { + public QuantorRestriction(PropertyExpression restrictedPropertyExpression) { + super(restrictedPropertyExpression); + } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -20,10 +20,21 @@ package org.dllearner.core.owl; /** + * A restriction always acts along a property expression. + * * @author Jens Lehmann * */ public abstract class Restriction extends Description { + + PropertyExpression restrictedPropertyExpression; + + public Restriction(PropertyExpression restrictedPropertyExpression) { + this.restrictedPropertyExpression = restrictedPropertyExpression; + } - + public PropertyExpression getRestrictedPropertyExpression() { + return restrictedPropertyExpression; + } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2008-02-24 16:27:53 UTC (rev 634) @@ -19,37 +19,22 @@ */ package org.dllearner.core.owl; -import java.util.Map; - /** + * + * * @author Jens Lehmann * */ -public abstract class ValueRestriction extends Description { +public abstract class ValueRestriction extends Restriction { - /* (non-Javadoc) - * @see org.dllearner.core.owl.Concept#getArity() - */ - @Override - public int getArity() { - // TODO Auto-generated method stub - return 0; + KBElement value; + + public ValueRestriction(PropertyExpression propertyExpression, KBElement value) { + super(propertyExpression); } - /* (non-Javadoc) - * @see org.dllearner.core.owl.KBElement#getLength() - */ - public int getLength() { - // TODO Auto-generated method stub - return 0; + public KBElement getValue() { + return value; } - - /* (non-Javadoc) - * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) - */ - public String toString(String baseURI, Map<String, String> prefixes) { - // TODO Auto-generated method stub - return null; - } - + } Modified: trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java 2008-02-24 08:45:08 UTC (rev 633) +++ trunk/src/dl-learner/org/dllearner/utilities/RoleComparator.java 2008-02-24 16:27:53 UTC (rev 634) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.utilities; import java.util.Comparator; @@ -5,6 +24,12 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyExpression; +/** + * Compares two object properties. + * + * @author Jens Lehmann + * + */ public class RoleComparator implements Comparator<ObjectPropertyExpression> { public int compare(ObjectPropertyExpression r1, ObjectPropertyExpression r2) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-24 08:45:18
|
Revision: 633 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=633&view=rev Author: jenslehmann Date: 2008-02-24 00:45:08 -0800 (Sun, 24 Feb 2008) Log Message: ----------- - preparations for boolean data type support in refinement operator - added literals/constants in OWL framework - improved package Javadoc Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/KBElementVisitor.java trunk/src/dl-learner/org/dllearner/core/owl/package.html trunk/src/dl-learner/org/dllearner/gui/package.html Added Paths: ----------- trunk/src/dl-learner/org/dllearner/cli/package.html trunk/src/dl-learner/org/dllearner/core/config/package.html trunk/src/dl-learner/org/dllearner/core/owl/Constant.java trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java trunk/src/dl-learner/org/dllearner/core/owl/UntypedConstant.java trunk/src/dl-learner/org/dllearner/core/package.html trunk/src/dl-learner/org/dllearner/kb/package.html trunk/src/dl-learner/org/dllearner/learningproblems/package.html trunk/src/dl-learner/org/dllearner/prolog/package.html trunk/src/dl-learner/org/dllearner/test/package.html Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-23 21:13:06 UTC (rev 632) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-02-24 08:45:08 UTC (rev 633) @@ -103,7 +103,8 @@ private boolean improveSubsumptionHierarchy = true; private boolean useAllConstructor = true; private boolean useExistsConstructor = true; - private boolean useNegation = true; + private boolean useNegation = true; + private boolean useBooleanDatatypes = true; private double noisePercentage = 0.0; // Variablen zur Einstellung der Protokollierung @@ -161,6 +162,7 @@ options.add(CommonConfigOptions.useAllConstructor()); options.add(CommonConfigOptions.useExistsConstructor()); options.add(CommonConfigOptions.useNegation()); + options.add(CommonConfigOptions.useBooleanDatatypes()); DoubleConfigOption noisePercentage = new DoubleConfigOption("noisePercentage", "the (approximated) percentage of noise within the examples"); noisePercentage.setLowerLimit(0.0); noisePercentage.setUpperLimit(1.0); @@ -215,6 +217,8 @@ useNegation = (Boolean) entry.getValue(); } else if(name.equals("noisePercentage")) { noisePercentage = (Double) entry.getValue(); + } else if(name.equals("useBooleanDatatypes")) { + useBooleanDatatypes = (Boolean) entry.getValue(); } } @@ -281,7 +285,8 @@ applyExistsFilter, useAllConstructor, useExistsConstructor, - useNegation + useNegation, + useBooleanDatatypes ); // create an algorithm object and pass all configuration Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-23 21:13:06 UTC (rev 632) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-24 08:45:08 UTC (rev 633) @@ -67,6 +67,7 @@ private boolean useAllConstructor = true; private boolean useExistsConstructor = true; private boolean useNegation = true; + private boolean useBooleanDatatypes = true; private boolean quiet = false; @@ -208,6 +209,7 @@ options.add(CommonConfigOptions.useAllConstructor()); options.add(CommonConfigOptions.useExistsConstructor()); options.add(CommonConfigOptions.useNegation()); + options.add(CommonConfigOptions.useBooleanDatatypes()); return options; } @@ -258,6 +260,8 @@ useExistsConstructor = (Boolean) entry.getValue(); } else if(name.equals("useNegation")) { useNegation = (Boolean) entry.getValue(); + } else if(name.equals("useBooleanDatatypes")) { + useBooleanDatatypes = (Boolean) entry.getValue(); } } @@ -284,7 +288,7 @@ } // this.learningProblem2 = learningProblem2; - operator = new RhoDown(rs, applyAllFilter, applyExistsFilter, useAllConstructor, useExistsConstructor, useNegation); + operator = new RhoDown(rs, applyAllFilter, applyExistsFilter, useAllConstructor, useExistsConstructor, useNegation, useBooleanDatatypes); // candidate sets entsprechend der gewählten Heuristik initialisieren candidates = new TreeSet<Node>(nodeComparator); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-23 21:13:06 UTC (rev 632) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/RhoDown.java 2008-02-24 08:45:08 UTC (rev 633) @@ -89,18 +89,20 @@ private boolean applyExistsFilter = true; private boolean useAllConstructor = true; private boolean useExistsConstructor = true; - private boolean useNegation = true; + private boolean useNegation = true; + private boolean useBooleanDatatypes = true; // braucht man wirklich das learningProblem oder reicht der Reasoning-Service? // TODO: conceptComparator könnte auch noch Parameter sein public RhoDown(ReasoningService reasoningService, boolean applyAllFilter, boolean applyExistsFilter, boolean useAllConstructor, - boolean useExistsConstructor, boolean useNegation) { + boolean useExistsConstructor, boolean useNegation, boolean useBooleanDatatypes) { this.rs = reasoningService; this.applyAllFilter = applyAllFilter; this.applyExistsFilter = applyExistsFilter; this.useAllConstructor = useAllConstructor; this.useExistsConstructor = useExistsConstructor; this.useNegation = useNegation; + this.useBooleanDatatypes = useBooleanDatatypes; // this.learningProblem = learningProblem; // rs = learningProblem.getReasoningService(); @@ -141,6 +143,7 @@ } else if (concept instanceof Nothing) { // return new HashSet<Concept>(); +// } else if (concept instanceof ) } else if (concept instanceof NamedClass) { // Erkenntnisse aus Benchmarks: dieser Teil wird sehr häufig aufgerufen, // allerdings lässt er sich kaum weiter verbessern (selbst ohne klonen Added: trunk/src/dl-learner/org/dllearner/cli/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/package.html (rev 0) +++ trunk/src/dl-learner/org/dllearner/cli/package.html 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,7 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head></head> +<body bgcolor="white"> +<p>DL-Learner command line interface.</p> +</body> +</html> \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-02-23 21:13:06 UTC (rev 632) +++ trunk/src/dl-learner/org/dllearner/core/config/CommonConfigOptions.java 2008-02-24 08:45:08 UTC (rev 633) @@ -82,4 +82,8 @@ public static BooleanConfigOption useNegation() { return new BooleanConfigOption("useNegation", "specifies whether negation is used in the learning algorothm"); } + + public static BooleanConfigOption useBooleanDatatypes() { + return new BooleanConfigOption("useBooleanDatatypes", "specifies whether boolean datatypes are used in the learning algorothm"); + } } Added: trunk/src/dl-learner/org/dllearner/core/config/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/package.html (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/config/package.html 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,8 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head></head> +<body bgcolor="white"> +<p>Classes for managing the configuration options of DL-Learner +components.</p> +</body> +</html> \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/core/owl/Constant.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Constant.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/Constant.java 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +/** + * A constant value. + * + * @author Jens Lehmann + * + */ +public abstract class Constant implements KBElement { + + String literal; + + public Constant(String literal) { + this.literal = literal; + } + + /** + * @return the literal + */ + public String getLiteral() { + return literal; + } +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-23 21:13:06 UTC (rev 632) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2008-02-24 08:45:08 UTC (rev 633) @@ -22,11 +22,17 @@ import java.util.Map; /** + * Examples for datatype value restrictions: + * Male AND hasAge HASVALUE 18 + * Male AND hasDriverLicense HASVALUE true + * * @author Jens Lehmann * */ public class DatatypeValueRestriction extends ValueRestriction { +// public DatatypeValueRestriction(DatatypeProperty) + /* (non-Javadoc) * @see org.dllearner.core.owl.Description#accept(org.dllearner.core.owl.DescriptionVisitor) */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/KBElementVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/KBElementVisitor.java 2008-02-23 21:13:06 UTC (rev 632) +++ trunk/src/dl-learner/org/dllearner/core/owl/KBElementVisitor.java 2008-02-24 08:45:08 UTC (rev 633) @@ -39,4 +39,8 @@ void visit(KB kb); + void visit(TypedConstant typedConstant); + + void visit(UntypedConstant untypedConstant); + } Added: trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/TypedConstant.java 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,67 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +import java.util.Map; + +/** + * A constant which has an explicitly assigned datatype. + * + * @author Jens Lehmann + * + */ +public class TypedConstant extends Constant { + + private Datatype datatype; + + public TypedConstant(String literal, Datatype datatype) { + super(literal); + this.datatype = datatype; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#getLength() + */ + public int getLength() { + return 1; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) + */ + public String toString(String baseURI, Map<String, String> prefixes) { + return literal + datatype.toString(baseURI, prefixes); + } + + /** + * @return the datatype + */ + public Datatype getDatatype() { + return datatype; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#accept(org.dllearner.core.owl.KBElementVisitor) + */ + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } + +} Added: trunk/src/dl-learner/org/dllearner/core/owl/UntypedConstant.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/UntypedConstant.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/UntypedConstant.java 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,85 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +import java.util.Map; + +/** + * An untyped constant is a string which has not been assigned + * a datatype and can have an optional language tag. + * + * @author Jens Lehmann + * + */ +public class UntypedConstant extends Constant { + + private String lang; + private boolean hasLang = false; + + public UntypedConstant(String literal) { + super(literal); + } + + public UntypedConstant(String literal, String lang) { + super(literal); + this.lang = lang; + hasLang = true; + } + + + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#getLength() + */ + public int getLength() { + return 1; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) + */ + public String toString(String baseURI, Map<String, String> prefixes) { + if(hasLang) + return literal + "@" + lang; + else + return literal; + } + + /** + * @return the lang + */ + public String getLang() { + return lang; + } + + /** + * @return the hasLang + */ + public boolean hasLang() { + return hasLang; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#accept(org.dllearner.core.owl.KBElementVisitor) + */ + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/package.html 2008-02-23 21:13:06 UTC (rev 632) +++ trunk/src/dl-learner/org/dllearner/core/owl/package.html 2008-02-24 08:45:08 UTC (rev 633) @@ -2,6 +2,8 @@ <html> <head></head> <body bgcolor="white"> -<p>Classes for representing OWL constructs.</p> +<p>Classes/Interfaces for representing OWL constructs - see +the <a href="http://www.w3.org/TR/owl11-syntax">OWL 1.1 Structural +Specification</a> for details.</p> </body> </html> \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/core/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/core/package.html (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/package.html 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,7 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head></head> +<body bgcolor="white"> +<p>Core structure of DL-Learner including the definition of component types and a component manager.</p> +</body> +</html> \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/gui/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/package.html 2008-02-23 21:13:06 UTC (rev 632) +++ trunk/src/dl-learner/org/dllearner/gui/package.html 2008-02-24 08:45:08 UTC (rev 633) @@ -2,6 +2,6 @@ <html> <head></head> <body bgcolor="white"> -<p>Classes to generate a Graphical User Interface for DL-Learner.</p> +<p>Graphical user interface for DL-Learner.</p> </body> </html> \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/kb/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/package.html (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/package.html 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,8 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head></head> +<body bgcolor="white"> +<p>DL-Learner knowledge sources, which can be used as background +knowledge in learning problems.</p> +</body> +</html> \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/learningproblems/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/package.html (rev 0) +++ trunk/src/dl-learner/org/dllearner/learningproblems/package.html 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,7 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head></head> +<body bgcolor="white"> +<p>Supported DL-Learner learning problems.</p> +</body> +</html> \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/prolog/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/prolog/package.html (rev 0) +++ trunk/src/dl-learner/org/dllearner/prolog/package.html 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,7 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head></head> +<body bgcolor="white"> +<p>Prolog syntax structures.</p> +</body> +</html> \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/test/package.html =================================================================== --- trunk/src/dl-learner/org/dllearner/test/package.html (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/package.html 2008-02-24 08:45:08 UTC (rev 633) @@ -0,0 +1,7 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head></head> +<body bgcolor="white"> +<p>DL-Learner tests for performance, bug reports etc.</p> +</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-02-23 21:13:15
|
Revision: 632 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=632&view=rev Author: jenslehmann Date: 2008-02-23 13:13:06 -0800 (Sat, 23 Feb 2008) Log Message: ----------- - added support for two axiom types: different individuals and disjoint classes - detected bug in OWL API different individuals export Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java trunk/src/dl-learner/org/dllearner/core/owl/TerminologicalAxiomVisitor.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/DifferentIndividualsAxiom.java trunk/src/dl-learner/org/dllearner/core/owl/DisjointClassesAxiom.java trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java 2008-02-23 09:10:40 UTC (rev 631) +++ trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java 2008-02-23 21:13:06 UTC (rev 632) @@ -35,4 +35,6 @@ public void visit(BooleanDatatypePropertyAssertion axiom); + public void visit(DifferentIndividualsAxiom axiom); + } Added: trunk/src/dl-learner/org/dllearner/core/owl/DifferentIndividualsAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DifferentIndividualsAxiom.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/DifferentIndividualsAxiom.java 2008-02-23 21:13:06 UTC (rev 632) @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +import java.util.Map; +import java.util.Set; + +/** + * @author Jens Lehmann + * + */ +public class DifferentIndividualsAxiom extends AssertionalAxiom { + + private Set<Individual> individuals; + + public DifferentIndividualsAxiom(Set<Individual> individuals) { + this.individuals = individuals; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#getLength() + */ + public int getLength() { + return individuals.size() + 1; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) + */ + public String toString(String baseURI, Map<String, String> prefixes) { + // TODO Auto-generated method stub + return null; + } + + public Set<Individual> getIndividuals() { + return individuals; + } + + @Override + public void accept(AxiomVisitor visitor) { + visitor.visit(this); + } + + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } + +} Added: trunk/src/dl-learner/org/dllearner/core/owl/DisjointClassesAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DisjointClassesAxiom.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/DisjointClassesAxiom.java 2008-02-23 21:13:06 UTC (rev 632) @@ -0,0 +1,71 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +import java.util.Map; +import java.util.Set; + +/** + * @author Jens Lehmann + * + */ +public class DisjointClassesAxiom extends TerminologicalAxiom { + + private Set<Description> descriptions; + + public DisjointClassesAxiom(Set<Description> descriptions) { + this.descriptions = descriptions; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#getLength() + */ + public int getLength() { + int length = 1; + for(Description d : descriptions) + length += d.getLength(); + return length; + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) + */ + public String toString(String baseURI, Map<String, String> prefixes) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void accept(AxiomVisitor visitor) { + visitor.visit(this); + } + + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } + + /** + * @return the descriptions + */ + public Set<Description> getDescriptions() { + return descriptions; + } + +} Modified: trunk/src/dl-learner/org/dllearner/core/owl/TerminologicalAxiomVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/TerminologicalAxiomVisitor.java 2008-02-23 09:10:40 UTC (rev 631) +++ trunk/src/dl-learner/org/dllearner/core/owl/TerminologicalAxiomVisitor.java 2008-02-23 21:13:06 UTC (rev 632) @@ -29,4 +29,5 @@ public void visit(SubClassAxiom axiom); + public void visit(DisjointClassesAxiom axiom); } Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-23 09:10:40 UTC (rev 631) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-23 21:13:06 UTC (rev 632) @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -33,6 +34,9 @@ import java.util.TreeSet; import org.dllearner.core.owl.BooleanDatatypePropertyAssertion; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.DifferentIndividualsAxiom; +import org.dllearner.core.owl.DisjointClassesAxiom; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.ClassAssertionAxiom; @@ -96,10 +100,14 @@ private static int bondNr = 0; private static int structureNr = 0; + // list of all individuals in the knowlege base +// private static Set<String> individuals = new TreeSet<String>(); // list of all compounds private static Set<String> compounds = new TreeSet<String>(); // compounds with positive ames test private static Set<String> compoundsAmes = new TreeSet<String>(); + // list of all bonds + private static Set<String> bonds = new TreeSet<String>(); // list of all "hasProperty" test private static Set<String> tests = new TreeSet<String>(); @@ -187,9 +195,17 @@ } } - // TODO: disjoint classes axioms - // TODO: all different axiom (UNA) + // disjoint classes axioms + DisjointClassesAxiom disjointAtomTypes = getDisjointClassesAxiom(atomTypes); + kb.addAxiom(disjointAtomTypes); + // all different axiom (UNA) + // exporting differentIndividuals axioms is broken in OWL API +// individuals.addAll(compounds); +// individuals.addAll(bonds); +// DifferentIndividualsAxiom una = getDifferentIndividualsAxiom(individuals); +// kb.addAxiom(una); + duration = System.nanoTime() - startTime; time = Helper.prettyPrintNanoSeconds(duration, false, false); System.out.println("OK (" + time + ")."); @@ -294,6 +310,7 @@ String bondType = head.getArgument(3).toPLString(); String bondClass = "Bond-" + bondType; String bondInstance = "bond" + bondNr; + bonds.add(bondInstance); ObjectPropertyAssertion op = getRoleAssertion("hasBond", compoundName, "bond" + bondNr); axioms.add(op); // make Bond-X subclass of Bond if that hasn't been done already @@ -426,6 +443,21 @@ return new DoubleDatatypePropertyAssertion(dp, ind, value); } + private static DisjointClassesAxiom getDisjointClassesAxiom(Set<String> classes) { + Set<Description> descriptions = new HashSet<Description>(); + for(String namedClass : classes) + descriptions.add(new NamedClass(namedClass)); + return new DisjointClassesAxiom(descriptions); + } + + @SuppressWarnings({"unused"}) + private static DifferentIndividualsAxiom getDifferentIndividualsAxiom(Set<String> individuals) { + Set<Individual> inds = new HashSet<Individual>(); + for(String i : individuals) + inds.add(new Individual(i)); + return new DifferentIndividualsAxiom(inds); + } + private static Individual getIndividual(String name) { return new Individual(ontologyURI + "#" + name); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-23 09:10:40 UTC (rev 631) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-23 21:13:06 UTC (rev 632) @@ -31,9 +31,13 @@ import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypePropertyDomainAxiom; import org.dllearner.core.owl.DatatypePropertyRangeAxiom; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.DifferentIndividualsAxiom; +import org.dllearner.core.owl.DisjointClassesAxiom; import org.dllearner.core.owl.DoubleDatatypePropertyAssertion; import org.dllearner.core.owl.EquivalentClassesAxiom; import org.dllearner.core.owl.FunctionalObjectPropertyAxiom; +import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.InverseObjectPropertyAxiom; import org.dllearner.core.owl.KB; import org.dllearner.core.owl.ObjectPropertyAssertion; @@ -294,4 +298,28 @@ addAxiom(axiomOWLAPI); } + /* (non-Javadoc) + * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.DifferentIndividualsAxiom) + */ + public void visit(DifferentIndividualsAxiom axiom) { + Set<Individual> individuals = axiom.getIndividuals(); + Set<OWLIndividual> owlAPIIndividuals = new HashSet<OWLIndividual>(); + for(Individual individual : individuals) + owlAPIIndividuals.add(factory.getOWLIndividual(URI.create(individual.getName()))); + OWLAxiom axiomOWLAPI = factory.getOWLDifferentIndividualsAxiom(owlAPIIndividuals); + addAxiom(axiomOWLAPI); + } + + /* (non-Javadoc) + * @see org.dllearner.core.owl.TerminologicalAxiomVisitor#visit(org.dllearner.core.owl.DisjointClassesAxiom) + */ + public void visit(DisjointClassesAxiom axiom) { + Set<Description> descriptions = axiom.getDescriptions(); + Set<OWLDescription> owlAPIDescriptions = new HashSet<OWLDescription>(); + for(Description description : descriptions) + owlAPIDescriptions.add(getOWLDescription(description)); + OWLAxiom axiomOWLAPI = factory.getOWLDisjointClassesAxiom(owlAPIDescriptions); + addAxiom(axiomOWLAPI); + } + } Added: trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/OWLAPIBugDemo.java 2008-02-23 21:13:06 UTC (rev 632) @@ -0,0 +1,42 @@ +package org.dllearner.test; + +import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.model.*; +import org.semanticweb.owl.util.SimpleURIMapper; + +import java.io.File; +import java.net.URI; +import java.util.HashSet; +import java.util.Set; + +public class OWLAPIBugDemo { + + public static void main(String[] args) { + try { + + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + URI ontologyURI = URI.create("http://www.examples.com/test"); + File f = new File("test.owl"); + URI physicalURI = f.toURI(); + SimpleURIMapper mapper = new SimpleURIMapper(ontologyURI, physicalURI); + manager.addURIMapper(mapper); + + OWLOntology ontology = manager.createOntology(ontologyURI); + OWLDataFactory factory = manager.getOWLDataFactory(); + + OWLIndividual a = factory.getOWLIndividual(URI.create(ontologyURI + "#a")); + OWLIndividual b = factory.getOWLIndividual(URI.create(ontologyURI + "#b")); + Set<OWLIndividual> inds = new HashSet<OWLIndividual>(); + inds.add(a); + inds.add(b); + + OWLAxiom axiom = factory.getOWLDifferentIndividualsAxiom(inds); + AddAxiom addAxiom = new AddAxiom(ontology, axiom); + manager.applyChange(addAxiom); + manager.saveOntology(ontology); + } + catch (OWLException e) { + e.printStackTrace(); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-23 09:10:53
|
Revision: 631 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=631&view=rev Author: jenslehmann Date: 2008-02-23 01:10:40 -0800 (Sat, 23 Feb 2008) Log Message: ----------- carcinogenesis mapping extended Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/KB.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/KB.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/KB.java 2008-02-22 21:58:43 UTC (rev 630) +++ trunk/src/dl-learner/org/dllearner/core/owl/KB.java 2008-02-23 09:10:40 UTC (rev 631) @@ -8,6 +8,7 @@ public class KB implements KBElement { + // private Set<Axiom> axioms = new HashSet<Axiom>(); private Set<AssertionalAxiom> abox = new HashSet<AssertionalAxiom>(); private Set<TerminologicalAxiom> tbox = new HashSet<TerminologicalAxiom>(); private Set<PropertyAxiom> rbox = new HashSet<PropertyAxiom>(); @@ -239,6 +240,23 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); - } + } + + /** + * Returns all axioms in the ontology. Note that calling this + * method is not efficient for large knowledge bases, since + * internally all axioms are separated into ABox, RBox, and + * TBox, which means that a union of these sets is computed + * and returned here. + * + * @return All axioms in the ontology. + */ + public Set<Axiom> getAxioms() { + Set<Axiom> axioms = new HashSet<Axiom>(); + axioms.addAll(abox); + axioms.addAll(rbox); + axioms.addAll(tbox); + return axioms; + } } Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-22 21:58:43 UTC (rev 630) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-23 09:10:40 UTC (rev 631) @@ -24,6 +24,7 @@ import java.io.IOException; import java.net.URI; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -82,14 +83,27 @@ // mapping of symbols to names of chemical elements private static Map<String, String> chemElements; - // types of atoms and bonds + // structures in newgroups.pl + private static Set<String> newGroups = new TreeSet<String>(); + + // types of atoms, bonds, and structures private static Set<String> atomTypes = new TreeSet<String>(); private static Set<String> bondTypes = new TreeSet<String>(); + private static Set<String> structureTypes = new TreeSet<String>(); // we need a counter for bonds, because they are instances in OWL // but not in Prolog private static int bondNr = 0; + private static int structureNr = 0; + // list of all compounds + private static Set<String> compounds = new TreeSet<String>(); + // compounds with positive ames test + private static Set<String> compoundsAmes = new TreeSet<String>(); + + // list of all "hasProperty" test + private static Set<String> tests = new TreeSet<String>(); + /** * @param args * No arguments supported. @@ -100,8 +114,8 @@ public static void main(String[] args) throws FileNotFoundException, IOException, ParseException { - String[] files = new String[] { "ames.pl", "atoms.pl", "bonds.pl", "gentoxprops.pl", - "ind_nos.pl", "ind_pos.pl", "newgroups.pl", + String[] files = new String[] { "newgroups.pl", "ames.pl", "atoms.pl", "bonds.pl", "gentoxprops.pl", + "ind_nos.pl", "ind_pos.pl", // "train.b" => not a pure Prolog file but Progol/Aleph specific }; File owlFile = new File("examples/carcinogenesis/pte.owl"); @@ -133,6 +147,7 @@ // prepare mapping KB kb = new KB(); createChemElementsMapping(); + createNewGroups(); // create subclasses of atom NamedClass atomClass = getAtomicConcept("Atom"); for (String element : chemElements.values()) { @@ -161,6 +176,20 @@ for (Axiom axiom : axioms) kb.addAxiom(axiom); } + // special handling for ames test (we assume the ames test + // was performed on all compounds but only the positive ones + // are in ames.pl [the rest is negative in Prolog by CWA], so + // we add negative test results here) + for(String compound : compounds) { + if(!compoundsAmes.contains(compound)) { + BooleanDatatypePropertyAssertion ames = getBooleanDatatypePropertyAssertion(compound, "amesTestPositive", false); + kb.addAxiom(ames); + } + } + + // TODO: disjoint classes axioms + // TODO: all different axiom (UNA) + duration = System.nanoTime() - startTime; time = Helper.prettyPrintNanoSeconds(duration, false, false); System.out.println("OK (" + time + ")."); @@ -210,7 +239,7 @@ // on "Testing Status of Agents at NTP" } - private static List<Axiom> mapClause(Clause clause) { + private static List<Axiom> mapClause(Clause clause) throws IOException, ParseException { List<Axiom> axioms = new LinkedList<Axiom>(); Atom head = clause.getHead(); String headName = head.getName(); @@ -228,7 +257,7 @@ String compoundName = head.getArgument(0).toPLString(); BooleanDatatypePropertyAssertion ames = getBooleanDatatypePropertyAssertion(compoundName, "amesTestPositive", true); axioms.add(ames); - + compoundsAmes.add(compoundName); } else if (headName.equals("atm")) { String compoundName = head.getArgument(0).toPLString(); String atomName = head.getArgument(1).toPLString(); @@ -237,7 +266,8 @@ double charge = Double.parseDouble(head.getArgument(4).toPLString()); // make the compound an instance of the Compound class ClassAssertionAxiom cmpAxiom = getConceptAssertion("Compound", compoundName); - axioms.add(cmpAxiom); + axioms.add(cmpAxiom); + compounds.add(compoundName); // relate compound and atom ObjectPropertyAssertion ra = getRoleAssertion("hasAtom", compoundName, atomName); axioms.add(ra); @@ -282,12 +312,55 @@ ObjectPropertyAssertion op2 = getRoleAssertion("inBond", bondInstance, atom2Name); axioms.add(op1); axioms.add(op2); + } else if (headName.equals("has_property")) { + String compoundName = head.getArgument(0).toPLString(); + String testName = head.getArgument(1).toPLString(); + boolean testResult = Boolean.parseBoolean(head.getArgument(2).toPLString()); + // create a new datatype property if it does not exist already + if(!tests.contains(testName)) { + String axiom1 = "DPDOMAIN(" + getURI2(testName) + ") = " + getURI2("Compound") + ".\n"; + String axiom2 = "DPRANGE(" + getURI2(testName) + ") = BOOLEAN.\n"; + KB kb = KBParser.parseKBFile(axiom1 + axiom2); + axioms.addAll(kb.getAxioms()); + } + // create an axiom with the test result + DatatypePropertyAssertion dpa = getBooleanDatatypePropertyAssertion(compoundName, testName, + testResult); + axioms.add(dpa); + // either parse this or ashby_alert - not both - ashby_alert contains + // all information in ind already + } else if (headName.equals("ind")) { + String compoundName = head.getArgument(0).toPLString(); + String structureName = head.getArgument(1).toPLString(); + int count = Integer.parseInt(head.getArgument(2).toPLString()); + // upper case first letter + String structureClass = structureName.substring(0,1).toUpperCase() + structureName.substring(1);; + String structureInstance = structureName + "-" + structureNr; + + if (!bondTypes.contains(structureClass)) { + NamedClass subClass = getAtomicConcept(structureClass); + SubClassAxiom sc = new SubClassAxiom(subClass, getAtomicConcept("Structure")); + axioms.add(sc); + structureTypes.add(structureClass); + } + + for(int i=0; i<count; i++) { + ObjectPropertyAssertion op = getRoleAssertion("hasStructure", compoundName, structureInstance); + axioms.add(op); + // make e.g. halide10-382 instance of Bond-3 + ClassAssertionAxiom ca = getConceptAssertion(structureClass, structureInstance); + axioms.add(ca); + structureNr++; + } + } else if (headName.equals("ashby_alert")) { + // ... currently ignored ... + } else if (newGroups.contains(headName)) { } else { // print clauses which are not supported yet System.out.println("unsupported clause"); System.out.println(clause.toPLString()); System.out.println(clause); -// System.exit(0); + System.exit(0); } return axioms; } @@ -419,4 +492,19 @@ chemElements.put("v", "Vanadium"); chemElements.put("zn", "Zinc"); } + + private static void createNewGroups() { + String[] groups = new String[] {"six_ring", "non_ar_6c_ring", + "ketone", "amine", "alcohol", "ether", "ar_halide", + "five_ring", "non_ar_5c_ring", "alkyl_halide", + "methyl", "non_ar_hetero_5_ring", "nitro", "sulfo", + "methoxy", "amine", "aldehyde", "sulfide", + "non_ar_hetero_6_ring", "phenol", "carboxylic_acid", + "ester", "imine", + }; + + List<String> list = Arrays.asList(groups); + newGroups.addAll(list); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-22 21:58:49
|
Revision: 630 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=630&view=rev Author: jenslehmann Date: 2008-02-22 13:58:43 -0800 (Fri, 22 Feb 2008) Log Message: ----------- added support for boolean datatype restrictions Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/core/owl/BooleanDatatypePropertyAssertion.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java 2008-02-22 17:05:52 UTC (rev 629) +++ trunk/src/dl-learner/org/dllearner/core/owl/AssertionalAxiomVisitor.java 2008-02-22 21:58:43 UTC (rev 630) @@ -33,4 +33,6 @@ public void visit(DoubleDatatypePropertyAssertion axiom); + public void visit(BooleanDatatypePropertyAssertion axiom); + } Added: trunk/src/dl-learner/org/dllearner/core/owl/BooleanDatatypePropertyAssertion.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanDatatypePropertyAssertion.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanDatatypePropertyAssertion.java 2008-02-22 21:58:43 UTC (rev 630) @@ -0,0 +1,54 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.core.owl; + +import java.util.Map; + +/** + * @author Jens Lehmann + * + */ +public class BooleanDatatypePropertyAssertion extends DatatypePropertyAssertion { + + private boolean value; + + public BooleanDatatypePropertyAssertion(DatatypeProperty datatypeProperty, Individual individual, boolean value) { + super(datatypeProperty, individual); + this.value = value; + } + + public String toString(String baseURI, Map<String, String> prefixes) { + return datatypeProperty.toString(baseURI, prefixes) + "(" + individual.toString(baseURI, prefixes) + "," + value +")"; + } + + public boolean getValue() { + return value; + } + + @Override + public void accept(AxiomVisitor visitor) { + visitor.visit(this); + } + + public void accept(KBElementVisitor visitor) { + visitor.visit(this); + } + +} Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-22 17:05:52 UTC (rev 629) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-22 21:58:43 UTC (rev 630) @@ -31,6 +31,7 @@ import java.util.Set; import java.util.TreeSet; +import org.dllearner.core.owl.BooleanDatatypePropertyAssertion; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.ClassAssertionAxiom; @@ -88,7 +89,7 @@ // we need a counter for bonds, because they are instances in OWL // but not in Prolog private static int bondNr = 0; - + /** * @param args * No arguments supported. @@ -216,13 +217,27 @@ // Body body = clause.getBody(); // ArrayList<Literal> literals = body.getLiterals(); // handle: atm(compound,atom,element,atomtype,charge) - if (headName.equals("atm")) { - + + // Ames-Test: http://en.wikipedia.org/wiki/Ames_test + // problem: the file apparently mentions only positive + // tests (why is it different from the other tests e.g. in + // gentoxprops.pl?) => we need to add negative axioms for the + // remaining stuff or use closed world assumption in the + // TBox dematerialisation later on + if(headName.equals("ames")) { String compoundName = head.getArgument(0).toPLString(); + BooleanDatatypePropertyAssertion ames = getBooleanDatatypePropertyAssertion(compoundName, "amesTestPositive", true); + axioms.add(ames); + + } else if (headName.equals("atm")) { + String compoundName = head.getArgument(0).toPLString(); String atomName = head.getArgument(1).toPLString(); String elementName = head.getArgument(2).toPLString(); String type = head.getArgument(3).toPLString(); double charge = Double.parseDouble(head.getArgument(4).toPLString()); + // make the compound an instance of the Compound class + ClassAssertionAxiom cmpAxiom = getConceptAssertion("Compound", compoundName); + axioms.add(cmpAxiom); // relate compound and atom ObjectPropertyAssertion ra = getRoleAssertion("hasAtom", compoundName, atomName); axioms.add(ra); @@ -272,6 +287,7 @@ System.out.println("unsupported clause"); System.out.println(clause.toPLString()); System.out.println(clause); +// System.exit(0); } return axioms; } @@ -323,6 +339,13 @@ return new ObjectPropertyAssertion(ar, ind1, ind2); } + private static BooleanDatatypePropertyAssertion getBooleanDatatypePropertyAssertion( + String individual, String datatypeProperty, boolean value) { + Individual ind = getIndividual(individual); + DatatypeProperty dp = getDatatypeProperty(datatypeProperty); + return new BooleanDatatypePropertyAssertion(dp, ind, value); + } + private static DoubleDatatypePropertyAssertion getDoubleDatatypePropertyAssertion( String individual, String datatypeProperty, double value) { Individual ind = getIndividual(individual); Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-22 17:05:52 UTC (rev 629) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-22 21:58:43 UTC (rev 630) @@ -25,6 +25,7 @@ import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.AxiomVisitor; +import org.dllearner.core.owl.BooleanDatatypePropertyAssertion; import org.dllearner.core.owl.ClassAssertionAxiom; import org.dllearner.core.owl.DataRange; import org.dllearner.core.owl.Datatype; @@ -146,6 +147,19 @@ addAxiom(axiomOWLAPI); } + /* (non-Javadoc) + * @see org.dllearner.core.owl.AssertionalAxiomVisitor#visit(org.dllearner.core.owl.BooleanDatatypePropertyAssertion) + */ + public void visit(BooleanDatatypePropertyAssertion axiom) { + OWLIndividual i = factory.getOWLIndividual(URI.create(axiom.getIndividual().getName())); + OWLDataProperty dp = factory.getOWLDataProperty(URI.create(axiom.getDatatypeProperty().getName())); + Boolean value = axiom.getValue(); + OWLDataType booleanType = factory.getOWLDataType(XSDVocabulary.BOOLEAN.getURI()); + OWLTypedConstant valueConstant = factory.getOWLTypedConstant(value.toString(), booleanType); + OWLAxiom axiomOWLAPI = factory.getOWLDataPropertyAssertionAxiom(i, dp, valueConstant); + addAxiom(axiomOWLAPI); + } + /* * (non-Javadoc) * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-22 17:05:56
|
Revision: 629 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=629&view=rev Author: jenslehmann Date: 2008-02-22 09:05:52 -0800 (Fri, 22 Feb 2008) Log Message: ----------- finished KBparser range support Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/parser/KBParser.java Modified: trunk/src/dl-learner/org/dllearner/parser/KBParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-22 17:05:19 UTC (rev 628) +++ trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-22 17:05:52 UTC (rev 629) @@ -68,6 +68,11 @@ case 36: case 37: case 38: + case 39: + case 40: + case 41: + case 42: + case 43: ; break; default: @@ -113,6 +118,17 @@ rBoxAxiom = DatatypePropertyDomainAxiom(); kb.addRBoxAxiom(rBoxAxiom); break; + case 39: + case 40: + case 41: + rBoxAxiom = ObjectPropertyRangeAxiom(); + kb.addRBoxAxiom(rBoxAxiom); + break; + case 42: + case 43: + rBoxAxiom = DatatypePropertyRangeAxiom(); + kb.addRBoxAxiom(rBoxAxiom); + break; default: jj_la1[1] = jj_gen; if (jj_2_3(2147483647)) { @@ -661,11 +677,6 @@ return false; } - final private boolean jj_3R_22() { - if (jj_scan_token(STRING)) return true; - return false; - } - final private boolean jj_3R_14() { if (jj_scan_token(20)) return true; if (jj_3R_20()) return true; @@ -874,6 +885,11 @@ return false; } + final private boolean jj_3R_22() { + if (jj_scan_token(STRING)) return true; + return false; + } + final private boolean jj_3_2() { Token xsp; xsp = jj_scanpos; @@ -905,7 +921,7 @@ jj_la1_0 = new int[] {0xf07f3200,0xf0000000,0x40000,0xc000000,0x0,0x0,0x0,0x0,0x0,0x203200,0x1f0000,0x200200,0x200200,0x200200,0x200200,}; } private static void jj_la1_1() { - jj_la1_1 = new int[] {0x7d,0x7d,0x0,0x2,0x1c,0x60,0x380,0xc00,0x7000,0x0,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_1 = new int[] {0xffd,0xffd,0x0,0x2,0x1c,0x60,0x380,0xc00,0x7000,0x0,0x0,0x0,0x0,0x0,0x0,}; } final private JJCalls[] jj_2_rtns = new JJCalls[6]; private boolean jj_rescan = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-22 17:05:23
|
Revision: 628 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=628&view=rev Author: jenslehmann Date: 2008-02-22 09:05:19 -0800 (Fri, 22 Feb 2008) Log Message: ----------- improved object/datatype property domain/range support Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyRangeAxiom.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyRangeAxiom.java trunk/src/dl-learner/org/dllearner/core/owl/Property.java trunk/src/dl-learner/org/dllearner/core/owl/PropertyRangeAxiom.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/parser/kb.jj trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/core/owl/Datatype.java 2008-02-22 17:05:19 UTC (rev 628) @@ -19,6 +19,7 @@ */ package org.dllearner.core.owl; +import java.net.URI; import java.util.Map; /** @@ -34,6 +35,8 @@ private Type type; + private static final String xsd = "http://www.w3.org/2001/XMLSchema#"; + public Datatype(Type type) { this.type = type; } @@ -60,6 +63,15 @@ return null; } + public URI getURI() { + switch(type) { + case DOUBLE: return URI.create(xsd + "double"); + case INT: return URI.create(xsd + "int"); + case BOOLEAN: return URI.create(xsd + "Boolean"); + default: throw new Error("Unknown tpye " + type + "."); + } + } + /** * @return the type */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyRangeAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyRangeAxiom.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyRangeAxiom.java 2008-02-22 17:05:19 UTC (rev 628) @@ -38,6 +38,11 @@ return range.getLength() + 2; } + @Override + public DataRange getRange() { + return (DataRange) range; + } + /* (non-Javadoc) * @see org.dllearner.core.owl.KBElement#toString(java.lang.String, java.util.Map) */ Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java 2008-02-22 17:05:19 UTC (rev 628) @@ -30,7 +30,7 @@ * @author Jens Lehmann * */ -public class ObjectProperty extends ObjectPropertyExpression implements Property, NamedKBElement, Comparable<ObjectProperty> { +public class ObjectProperty extends ObjectPropertyExpression implements Property, Comparable<ObjectProperty> { public ObjectProperty(String name) { super(name); Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyRangeAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyRangeAxiom.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyRangeAxiom.java 2008-02-22 17:05:19 UTC (rev 628) @@ -28,12 +28,10 @@ public class ObjectPropertyRangeAxiom extends PropertyRangeAxiom { - public ObjectPropertyRangeAxiom(ObjectProperty property, Description domain) { - super(property, domain); + public ObjectPropertyRangeAxiom(ObjectProperty property, Description range) { + super(property, range); } - - /* (non-Javadoc) * @see org.dllearner.core.owl.KBElement#getLength() */ @@ -49,6 +47,11 @@ return null; } + @Override + public Description getRange() { + return (Description) range; + } + /* (non-Javadoc) * @see org.dllearner.core.owl.Axiom#accept(org.dllearner.core.owl.AxiomVisitor) */ @@ -62,6 +65,7 @@ */ public void accept(KBElementVisitor visitor) { visitor.visit(this); - } + } + } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Property.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Property.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/core/owl/Property.java 2008-02-22 17:05:19 UTC (rev 628) @@ -23,6 +23,6 @@ * @author Jens Lehmann * */ -public interface Property extends KBElement { +public interface Property extends NamedKBElement { } Modified: trunk/src/dl-learner/org/dllearner/core/owl/PropertyRangeAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/PropertyRangeAxiom.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/core/owl/PropertyRangeAxiom.java 2008-02-22 17:05:19 UTC (rev 628) @@ -36,5 +36,9 @@ public Property getProperty() { return property; } + + public PropertyRange getRange() { + return range; + } } Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-22 17:05:19 UTC (rev 628) @@ -140,7 +140,14 @@ kb.addAxiom(sc); } // define properties including domain and range - String kbString = "DPDOMAIN(" + getURI2("charge") + ") = " + getURI2("Atom") + "."; + String kbString = "DPDOMAIN(" + getURI2("charge") + ") = " + getURI2("Atom") + ".\n"; + kbString += "DPRANGE(" + getURI2("charge") + ") = DOUBLE.\n"; + kbString += "OPDOMAIN(" + getURI2("hasAtom") + ") = " + getURI2("Compound") + ".\n"; + kbString += "OPRANGE(" + getURI2("hasAtom") + ") = " + getURI2("Atom") + ".\n"; + kbString += "OPDOMAIN(" + getURI2("hasBond") + ") = " + getURI2("Compound") + ".\n"; + kbString += "OPRANGE(" + getURI2("hasBond") + ") = " + getURI2("Bond") + ".\n"; + kbString += "OPDOMAIN(" + getURI2("inBond") + ") = " + getURI2("Bond") + ".\n"; + kbString += "OPRANGE(" + getURI2("inBond") + ") = " + getURI2("Atom") + ".\n"; KB kb2 = KBParser.parseKBFile(kbString); kb.addKB(kb2); @@ -169,9 +176,11 @@ File confTrainFile = new File("examples/carcinogenesis/train.conf"); Files.clearFile(confTrainFile); String confHeader = "import(\"pte.owl\");\n\n"; - confHeader += "refinement.writeSearchTree = true;"; - confHeader += "refinement.searchTreeFile = \"log/carcinogenesis/searchTree.log\""; - confHeader += "reasoner = owlAPI;\n"; + confHeader += "reasoner = fastInstanceChecker;\n"; + confHeader += "algorithm = refexamples;\n"; +// confHeader += "refinement.writeSearchTree = true;"; +// confHeader += "refinement.searchTreeFile = \"log/carcinogenesis/searchTree.log\""; + confHeader += "\n\n"; Files.appendFile(confTrainFile, confHeader); // generating training examples Modified: trunk/src/dl-learner/org/dllearner/parser/kb.jj =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-22 17:05:19 UTC (rev 628) @@ -126,7 +126,11 @@ | rBoxAxiom = ObjectPropertyDomainAxiom() { kb.addRBoxAxiom(rBoxAxiom); } | rBoxAxiom = DatatypePropertyDomainAxiom() - { kb.addRBoxAxiom(rBoxAxiom); } + { kb.addRBoxAxiom(rBoxAxiom); } + | rBoxAxiom = ObjectPropertyRangeAxiom() + { kb.addRBoxAxiom(rBoxAxiom); } + | rBoxAxiom = DatatypePropertyRangeAxiom() + { kb.addRBoxAxiom(rBoxAxiom); } // da Konfigurationsoptionen ausgeschlossen sind, reicht es bis zum "=" zu suchen | LOOKAHEAD(Concept() "=") equality = TBoxEquiv() { kb.addTBoxAxiom(equality); } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-22 17:05:19 UTC (rev 628) @@ -108,9 +108,14 @@ */ @Override public void init() throws ComponentInitException { - rc = new DIGReasoner(sources); + rc = new OWLAPIReasoner(sources); + // DIG will only be used to get the role pairs; + // outside the constructor, OWL API will be used because + // it is fast than DIG + DIGReasoner rcDIG = new DIGReasoner(sources); try { rc.init(); + rcDIG.init(); } catch (ComponentInitException e1) { e1.printStackTrace(); } @@ -130,7 +135,7 @@ } for (ObjectProperty atomicRole : rs.getAtomicRoles()) { - opPos.put(atomicRole, rs.getRoleMembers(atomicRole)); + opPos.put(atomicRole, rcDIG.getRoleMembers(atomicRole)); } long dematDuration = System.currentTimeMillis() - dematStartTime; Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-02-22 17:05:19 UTC (rev 628) @@ -16,8 +16,6 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.FlatABox; import org.dllearner.core.owl.Individual; -import org.dllearner.core.owl.Intersection; -import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyHierarchy; import org.dllearner.core.owl.SubsumptionHierarchy; Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-22 15:18:56 UTC (rev 627) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-22 17:05:19 UTC (rev 628) @@ -26,6 +26,8 @@ import org.dllearner.core.owl.Axiom; import org.dllearner.core.owl.AxiomVisitor; import org.dllearner.core.owl.ClassAssertionAxiom; +import org.dllearner.core.owl.DataRange; +import org.dllearner.core.owl.Datatype; import org.dllearner.core.owl.DatatypePropertyDomainAxiom; import org.dllearner.core.owl.DatatypePropertyRangeAxiom; import org.dllearner.core.owl.DoubleDatatypePropertyAssertion; @@ -250,26 +252,32 @@ * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.ObjectPropertyDomainAxiom) */ public void visit(ObjectPropertyDomainAxiom objectPropertyDomainAxiom) { - // TODO Auto-generated method stub - + OWLDescription d = getOWLDescription(objectPropertyDomainAxiom.getDomain()); + OWLObjectProperty op = factory.getOWLObjectProperty(URI.create(objectPropertyDomainAxiom.getProperty().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLObjectPropertyDomainAxiom(op, d); + addAxiom(axiomOWLAPI); } /* (non-Javadoc) * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.DatatypePropertyRangeAxiom) */ public void visit(DatatypePropertyRangeAxiom axiom) { - // TODO Auto-generated method stub - + DataRange dr = axiom.getRange(); + Datatype dt = (Datatype) dr; + OWLDataType odt = factory.getOWLDataType(dt.getURI()); + OWLDataProperty dp = factory.getOWLDataProperty(URI.create(axiom.getProperty().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLDataPropertyRangeAxiom(dp, odt); + addAxiom(axiomOWLAPI); } /* (non-Javadoc) * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.ObjectPropertyRangeAxiom) */ public void visit(ObjectPropertyRangeAxiom axiom) { - // TODO Auto-generated method stub - + OWLDescription d = getOWLDescription(axiom.getRange()); + OWLObjectProperty op = factory.getOWLObjectProperty(URI.create(axiom.getProperty().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLObjectPropertyRangeAxiom(op, d); + addAxiom(axiomOWLAPI); } - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |