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: <ku...@us...> - 2008-07-30 06:53:40
|
Revision: 1025 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1025&view=rev Author: kurzum Date: 2008-07-30 06:53:34 +0000 (Wed, 30 Jul 2008) Log Message: ----------- more comments, renamed some simple functions, which is responsible for the changes in the most classes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlEndpoint.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/test/JenaQueryToResultSpeedTest.java trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQuery.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -99,7 +99,7 @@ // query.extraDebugInfo=uri.toString(); String JSON = cache.executeSparqlQuery(query); - ResultSet rs = SparqlQuery.JSONtoResultSet(JSON); + ResultSet rs = SparqlQuery.convertJSONtoResultSet(JSON); List<ResultBinding> l = ResultSetFormatter.toList(rs); Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/TypedSparqlQueryClasses.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -65,7 +65,7 @@ SparqlQuery query = new SparqlQuery(sparqlQueryString, configuration.getSparqlEndpoint()); // query.extraDebugInfo=uri.toString(); - ResultSet rs = SparqlQuery.JSONtoResultSet(cache.executeSparqlQuery(query)); + ResultSet rs = SparqlQuery.convertJSONtoResultSet(cache.executeSparqlQuery(query)); List<ResultBinding> l = ResultSetFormatter.toList(rs); for (ResultBinding resultBinding : l) { Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -82,18 +82,29 @@ this("cache"); } */ + /** + * A Persistant cache is stored in the folder cachePersistant. + * It has longer freshness 365 days and is mainly usefull for developing + * @return a Cache onject + */ public static Cache getPersistentCache(){ Cache c = new Cache("cachePersistant"); c.setFreshnessInDays(365); return c; } + /** + * @return the default cache object + */ public static Cache getDefaultCache(){ Cache c = new Cache("cache"); - return c; } + /** + * the default cachedir normally is "cache". + * @return Default Cache Dir + */ public static String getDefaultCacheDir(){ return "cache"; } @@ -146,17 +157,20 @@ * * @param sparqlQuery * SPARQL query to check. - * @return Query result or null if no result has been found or it is + * @return Query result as JSON or null if no result has been found or it is * outdated. */ @SuppressWarnings({"unchecked"}) private String getCacheEntry(String sparqlQuery) { + String filename = getFilename(sparqlQuery); File file = new File(filename); // return null (indicating no result) if file does not exist - if(!file.exists()) + if(!file.exists()) { return null; + } + LinkedList<Object> entry = null; try { @@ -221,10 +235,7 @@ // check whether the given timestamp is fresh private boolean checkFreshness(long timestamp) { - if ((System.currentTimeMillis() - timestamp) <= (freshnessSeconds * 1000)) - return true; - else - return false; + return ((System.currentTimeMillis() - timestamp) <= (freshnessSeconds * 1000)); } /** @@ -242,7 +253,7 @@ JamonMonitorLogger.increaseCount(Cache.class, "TotalQueries"); JamonMonitorLogger.getTimeMonitor(Cache.class, "ReadTime").start(); - String result = getCacheEntry(query.getQueryString()); + String result = getCacheEntry(query.getSparqlQueryString()); JamonMonitorLogger.getTimeMonitor(Cache.class, "ReadTime").stop(); if (result != null) { @@ -250,8 +261,8 @@ query.setRunning(false); SparqlQuery.writeToSparqlLog("***********\nJSON retrieved from cache"); - SparqlQuery.writeToSparqlLog(query.getQueryString()); - SparqlQuery.writeToSparqlLog(query.getEndpoint().getURL().toString()); + SparqlQuery.writeToSparqlLog(query.getSparqlQueryString()); + SparqlQuery.writeToSparqlLog(query.getSparqlEndpoint().getURL().toString()); SparqlQuery.writeToSparqlLog("JSON: "+result); JamonMonitorLogger.increaseCount(Cache.class, "SuccessfulHits"); @@ -261,16 +272,15 @@ query.send(); String json = query.getJson(); if (json!=null){ - addToCache(query.getQueryString(), json); + addToCache(query.getSparqlQueryString(), json); SparqlQuery.writeToSparqlLog("result added to cache: "+json); result=json; //query.setJson(result); - } - else { + } else { json=""; result=""; - logger.warn(Cache.class.getSimpleName()+"empty result: "+query.getQueryString()); - SparqlQuery.writeToSparqlLog("empty result for : "+query.getQueryString()); + logger.warn(Cache.class.getSimpleName()+"empty result: "+query.getSparqlQueryString()); + SparqlQuery.writeToSparqlLog("empty result for : "+query.getSparqlQueryString()); } //return json; @@ -279,6 +289,10 @@ return result; } + /** + * Changes how long cached results will stay fresh (default 15 days). + * @param days number of days + */ public void setFreshnessInDays(int days){ freshnessSeconds = days * 24 * 60 * 60; } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -47,22 +47,22 @@ private final SparqlEndpoint sparqlEndpoint; /** - * @param c a cache object - * @param se the Endpoint the sparql queries will be send to + * @param cache a cache object + * @param sparqlEndpoint the Endpoint the sparql queries will be send to */ - public SPARQLTasks(final Cache c, final SparqlEndpoint se) { + public SPARQLTasks(final Cache cache, final SparqlEndpoint sparqlEndpoint) { super(); - this.cache = c; - this.sparqlEndpoint = se; + this.cache = cache; + this.sparqlEndpoint = sparqlEndpoint; } /** - * @param se the Endpoint the sparql queries will be send to + * @param sparqlEndpoint the Endpoint the sparql queries will be send to */ - public SPARQLTasks(final SparqlEndpoint se) { + public SPARQLTasks(final SparqlEndpoint sparqlEndpoint) { super(); this.cache = null; - this.sparqlEndpoint = se; + this.sparqlEndpoint = sparqlEndpoint; } /** @@ -117,8 +117,6 @@ * @see conceptRewrite(String descriptionKBSyntax, SparqlEndpoint se, Cache * c, boolean simple ) * @param description - * @param sparqlEndpoint - * @param cache * @param simple * @return */ @@ -175,10 +173,10 @@ * empty set on some endpoints. returns all direct subclasses of String * concept * - * @param concept + * @param concept An URI string with no quotes * @return SortedSet of direct subclasses as String */ - private SortedSet<String> getDirectSubClasses(final String concept) { + private SortedSet<String> getDirectSubClasses(String concept) { String sparqlQueryString; SortedSet<String> subClasses = new TreeSet<String>(); @@ -212,25 +210,31 @@ * QUALITY: buggy because role doesn't work sometimes get subject with fixed * role and object * - * @param role - * @param object - * @param resultLimit - * @return + * @param role An URI string with no quotes + * @param object An URI string with no quotes + * @param sparqlResultLimit Limits the ResultSet size + * @return SortedSet with the resulting subjects */ public SortedSet<String> retrieveDISTINCTSubjectsForRoleAndObject( - String role, String object, int resultLimit) { + String role, String object, int sparqlResultLimit) { String sparqlQueryString = "SELECT DISTINCT * WHERE { \n " + "?subject " + "<" + role + "> " + "<" + object + "> \n" + "} " - + limit(resultLimit); + + limit(sparqlResultLimit); return queryAsSet(sparqlQueryString, "subject"); } + /** + * @param subject An URI string with no quotes + * @param role An URI string with no quotes + * @param sparqlResultLimit Limits the ResultSet size + * @return + */ public SortedSet<String> retrieveObjectsForSubjectAndRole(String subject, - String role, int resultLimit) { + String role, int sparqlResultLimit) { String sparqlQueryString = "SELECT DISTINCT * WHERE { \n " + "<" + subject + "> " + "<" + role + "> " + " ?object \n" + "} LIMIT " - + resultLimit; + + sparqlResultLimit; return queryAsSet(sparqlQueryString, "object"); } @@ -238,14 +242,14 @@ /** * all instances for a SKOS concept. * - * @param skosConcept - * @param resultLimit + * @param skosConcept An URI string with no quotes + * @param sparqlResultLimit Limits the ResultSet size * @return */ public SortedSet<String> retrieveInstancesForSKOSConcept( - String skosConcept, int resultLimit) { + String skosConcept, int sparqlResultLimit) { return queryPatternAsSet("?subject", "?predicate", "<" + skosConcept - + ">", "subject", resultLimit); + + ">", "subject", sparqlResultLimit); // return // retrieveDISTINCTSubjectsForRoleAndObject("http://www.w3.org/2004/02/skos/core#subject", } @@ -253,8 +257,8 @@ /** * get all instances for a concept. * - * @param conceptKBSyntax - * @param sparqlResultLimit + * @param conceptKBSyntax A description string in KBSyntax + * @param sparqlResultLimit Limits the ResultSet size * @return */ public SortedSet<String> retrieveInstancesForConcept( @@ -273,8 +277,8 @@ /** * get all instances for a concept including RDFS Reasoning. * - * @param conceptKBSyntax - * @param sparqlResultLimit + * @param conceptKBSyntax A description string in KBSyntax + * @param sparqlResultLimit Limits the ResultSet size * @return */ public SortedSet<String> retrieveInstancesForConceptIncludingSubclasses( @@ -295,15 +299,15 @@ /** * get all direct Classes of an instance. * - * @param instance - * @param resultLimit + * @param instance An URI string with no quotes + * @param sparqlResultLimit Limits the ResultSet size * @return */ public SortedSet<String> getClassesForInstance(String instance, - int resultLimit) { + int sparqlResultLimit) { String sparqlQueryString = "SELECT ?subject WHERE { \n " + "<" + instance - + ">" + " a " + "?subject " + "\n" + "} " + limit(resultLimit); + + ">" + " a " + "?subject " + "\n" + "} " + limit(sparqlResultLimit); return queryAsSet(sparqlQueryString, "subject"); } @@ -329,13 +333,15 @@ } /** - * query a pattern with a standard SPARQL query usage (?subject, ?predicate, + * //QUALITY rethink + * query a pattern with a standard SPARQL query. + * usage (?subject, <http://something>, * <http://something> , subject ). * - * @param subject - * @param predicate - * @param object - * @param var + * @param subject An URI string with no quotes + * @param predicate An URI string with no quotes + * @param object An URI string with no quotes + * @param var The single * @return */ public SortedSet<String> queryPatternAsSet(String subject, @@ -349,15 +355,15 @@ /** * little higher level, executes query ,returns all resources for a variable. * - * @param sparqlQueryString - * @param var + * @param sparqlQueryString The query + * @param var The single variable used in the query * @return */ public SortedSet<String> queryAsSet(String sparqlQueryString, String var) { ResultSet rs = null; try { String jsonString = query(sparqlQueryString); - rs = SparqlQuery.JSONtoResultSet(jsonString); + rs = SparqlQuery.convertJSONtoResultSet(jsonString); } catch (Exception e) { logger.warn(e.getMessage()); @@ -368,18 +374,18 @@ /** * low level, executes query returns ResultSet. * - * @param sparqlQueryString + * @param sparqlQueryString The query * @return jena ResultSet */ public ResultSet queryAsResultSet(String sparqlQueryString) { - return SparqlQuery.JSONtoResultSet(query(sparqlQueryString)); + return SparqlQuery.convertJSONtoResultSet(query(sparqlQueryString)); } /** * low level, executes query returns JSON. * - * @param sparqlQueryString + * @param sparqlQueryString The query * @return */ public String query(String sparqlQueryString) { Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlEndpoint.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlEndpoint.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlEndpoint.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -25,7 +25,7 @@ /** * One sparql endpoint configuration, - * made to comply with Jena + * made to comply with Jena. * * @author Sebastian Hellmann * @@ -42,7 +42,7 @@ this.namedGraphURIs=new LinkedList<String>(); } - public SparqlEndpoint(URL u,List<String> defaultGraphURIs,List<String> namedGraphURIs) { + public SparqlEndpoint(URL u, List<String> defaultGraphURIs, List<String> namedGraphURIs) { this.url = u; this.defaultGraphURIs=defaultGraphURIs; this.namedGraphURIs=namedGraphURIs; @@ -86,57 +86,59 @@ name = name.toUpperCase(); - if (name.equals("DBPEDIA")) - return EndpointDBpedia(); - if (name.equals("LOCALDBPEDIA")) - return EndpointLOCALDBpedia(); - if (name.equals("LOCALJOSECKI")) - return EndpointlocalJoseki(); - if (name.equals("GOVTRACK")) - return EndpointGovTrack(); - if (name.equals("SPARQLETTE")) - return EndpointSparqlette(); - if (name.equals("SWCONFERENCE")) - return EndpointSWConference(); - if (name.equals("REVYU")) - return EndpointRevyu(); - if (name.equals("MYOPENLINK")) - return EndpointMyOpenlink(); - if (name.equals("FACTBOOK")) - return EndpointWorldFactBook(); - if (name.equals("DBLP")) - return EndpointDBLP(); - if (name.equals("MUSICBRAINZ")) - return EndpointMusicbrainz(); - return null; + if (name.equals("DBPEDIA")) { + return getEndpointDBpedia(); + } else if (name.equals("LOCALDBPEDIA")) { + return getEndpointLOCALDBpedia(); + } else if (name.equals("LOCALJOSECKI")) { + return getEndpointlocalJoseki(); + } else if (name.equals("GOVTRACK")) { + return getEndpointGovTrack(); + } else if (name.equals("SPARQLETTE")) { + return getEndpointSparqlette(); + } else if (name.equals("SWCONFERENCE")) { + return getEndpointSWConference(); + } else if (name.equals("REVYU")) { + return getEndpointRevyu(); + } else if (name.equals("MYOPENLINK")) { + return getEndpointMyOpenlink(); + } else if (name.equals("FACTBOOK")) { + return getEndpointWorldFactBook(); + } else if (name.equals("DBLP")) { + return getEndpointDBLP(); + } else if (name.equals("MUSICBRAINZ")) { + return getEndpointMusicbrainz(); + } else { + return null; + } } - public static LinkedList<SparqlEndpoint> listEndpoints() { + public static List<SparqlEndpoint> listEndpoints() { LinkedList<SparqlEndpoint> ll =new LinkedList<SparqlEndpoint>(); - ll.add(EndpointDBLP()); - ll.add(EndpointDBpedia()); - ll.add(EndpointDOAPspace()); - ll.add(EndpointGovTrack()); - ll.add(EndpointJamendo()); - ll.add(EndpointJohnPeel()); - ll.add(EndpointlocalJoseki()); - ll.add(EndpointMagnaTune()); - ll.add(EndpointMusicbrainz()); - ll.add(EndpointMyOpenlink()); - ll.add(EndpointRevyu()); - ll.add(EndpointSWConference()); - ll.add(EndpointUSCensus()); - ll.add(EndpointWorldFactBook()); - ll.add(EndpointRiese()); - ll.add(EndpointTalisBlogs()); - ll.add(EndpointSWSchool()); - ll.add(EndpointSparqlette()); - ll.add(EndpointLOCALDBpedia()); + ll.add(getEndpointDBLP()); + ll.add(getEndpointDBpedia()); + ll.add(getEndpointDOAPspace()); + ll.add(getEndpointGovTrack()); + ll.add(getEndpointJamendo()); + ll.add(getEndpointJohnPeel()); + ll.add(getEndpointlocalJoseki()); + ll.add(getEndpointMagnaTune()); + ll.add(getEndpointMusicbrainz()); + ll.add(getEndpointMyOpenlink()); + ll.add(getEndpointRevyu()); + ll.add(getEndpointSWConference()); + ll.add(getEndpointUSCensus()); + ll.add(getEndpointWorldFactBook()); + ll.add(getEndpointRiese()); + ll.add(getEndpointTalisBlogs()); + ll.add(getEndpointSWSchool()); + ll.add(getEndpointSparqlette()); + ll.add(getEndpointLOCALDBpedia()); return ll; } - public static SparqlEndpoint EndpointDBpedia() { + public static SparqlEndpoint getEndpointDBpedia() { URL u = null; try { u = new URL("http://dbpedia.openlinksw.com:8890/sparql"); @@ -148,7 +150,7 @@ return new SparqlEndpoint(u, defaultGraphURIs, new LinkedList<String>()); } - public static SparqlEndpoint EndpointLOCALDBpedia() { + public static SparqlEndpoint getEndpointLOCALDBpedia() { URL u = null; try { u = new URL("http://139.18.2.37:8890/sparql"); @@ -160,7 +162,7 @@ return new SparqlEndpoint(u, defaultGraphURIs, new LinkedList<String>()); } - public static SparqlEndpoint EndpointlocalJoseki() { + public static SparqlEndpoint getEndpointlocalJoseki() { URL u = null; try { u = new URL("http://localhost:2020/books"); @@ -170,7 +172,7 @@ return new SparqlEndpoint(u, new LinkedList<String>(), new LinkedList<String>()); } - public static SparqlEndpoint EndpointWorldFactBook() { + public static SparqlEndpoint getEndpointWorldFactBook() { URL u = null; try { u = new URL("http://www4.wiwiss.fu-berlin.de/factbook/sparql"); @@ -181,7 +183,7 @@ } - public static SparqlEndpoint EndpointGovTrack() { + public static SparqlEndpoint getEndpointGovTrack() { URL u = null; try { u = new URL("http://www.rdfabout.com/sparql"); @@ -191,7 +193,7 @@ return new SparqlEndpoint(u, new LinkedList<String>(), new LinkedList<String>()); } - public static SparqlEndpoint EndpointRevyu() { + public static SparqlEndpoint getEndpointRevyu() { URL u = null; try { u = new URL("http://revyu.com/sparql"); @@ -201,7 +203,7 @@ return new SparqlEndpoint(u, new LinkedList<String>(), new LinkedList<String>()); } - public static SparqlEndpoint EndpointMyOpenlink() { + public static SparqlEndpoint getEndpointMyOpenlink() { URL u = null; try { u = new URL("http://myopenlink.net:8890/sparql/"); @@ -214,7 +216,7 @@ } - public static SparqlEndpoint EndpointDOAPspace() { + public static SparqlEndpoint getEndpointDOAPspace() { URL u = null; try { u = new URL("http://doapspace.org/sparql"); @@ -226,7 +228,7 @@ } - public static SparqlEndpoint EndpointJohnPeel() { + public static SparqlEndpoint getEndpointJohnPeel() { URL u = null; try { u = new URL("http://dbtune.org:3030/sparql/"); @@ -240,7 +242,7 @@ - public static SparqlEndpoint EndpointSWConference() { + public static SparqlEndpoint getEndpointSWConference() { URL u = null; try { u = new URL("http://data.semanticweb.org:8080/openrdf-sesame/repositories/SWC"); @@ -275,7 +277,7 @@ return new SpecificSparqlEndpoint(u, "dbtune.org", m); }*/ - public static SparqlEndpoint EndpointJamendo() { + public static SparqlEndpoint getEndpointJamendo() { URL u = null; try { u = new URL("http://dbtune.org:2105/sparql/"); @@ -287,7 +289,7 @@ - public static SparqlEndpoint EndpointMagnaTune() { + public static SparqlEndpoint getEndpointMagnaTune() { URL u = null; try { u = new URL("http://dbtune.org:2020/sparql/"); @@ -298,7 +300,7 @@ } - public static SparqlEndpoint EndpointMusicbrainz() { + public static SparqlEndpoint getEndpointMusicbrainz() { URL u = null; try { u = new URL("http://dbtune.org/musicbrainz/sparql"); @@ -308,7 +310,7 @@ return new SparqlEndpoint(u); } - public static SparqlEndpoint EndpointRiese() { + public static SparqlEndpoint getEndpointRiese() { URL u = null; try { u = new URL("http://riese.joanneum.at:3020/"); @@ -319,7 +321,7 @@ } - public static SparqlEndpoint EndpointUSCensus() { + public static SparqlEndpoint getEndpointUSCensus() { URL u = null; try { u = new URL("http://www.rdfabout.com/sparql"); @@ -337,7 +339,7 @@ /* * it only has 4 classes */ - public static SparqlEndpoint EndpointDBLP() { + public static SparqlEndpoint getEndpointDBLP() { URL u = null; try { u = new URL("http://www4.wiwiss.fu-berlin.de/dblp/sparql"); @@ -348,7 +350,7 @@ } - public static SparqlEndpoint EndpointTalisBlogs() { + public static SparqlEndpoint getEndpointTalisBlogs() { URL u = null; try { u = new URL("http://api.talis.com/stores/talisians/services/sparql"); @@ -358,7 +360,7 @@ return new SparqlEndpoint(u); } - public static SparqlEndpoint EndpointSparqlette() { + public static SparqlEndpoint getEndpointSparqlette() { URL u = null; try { u = new URL("http://www.wasab.dk/morten/2005/04/sparqlette/"); @@ -370,7 +372,7 @@ - public static SparqlEndpoint EndpointSWSchool() { + public static SparqlEndpoint getEndpointSWSchool() { URL u = null; try { u = new URL("http://sparql.semantic-web.at/snorql/"); Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -118,7 +118,7 @@ .getLogger(SparqlKnowledgeSource.class); /** - * sets the ConfigOptions for this KnowledgeSource + * sets the ConfigOptions for this KnowledgeSource. * * @return */ @@ -195,7 +195,7 @@ * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.ConfigEntry) */ @Override - @SuppressWarnings( { "unchecked" }) + @SuppressWarnings({ "unchecked" }) public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { String option = entry.getOptionName(); @@ -348,9 +348,10 @@ String filename = System.currentTimeMillis() + ".nt"; String basedir = "cache" + File.separator; try { - if (!new File(basedir).exists()) + if (!new File(basedir).exists()) { new File(basedir).mkdir(); - + } + FileWriter fw = new FileWriter( new File(basedir + filename), true); fw.write(ont); @@ -441,7 +442,7 @@ return dumpFile; } - public boolean getUseCache(){ + public boolean isUseCache(){ return useCache; } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -49,50 +49,48 @@ private boolean wasExecuted = false; - private String queryString; + private String sparqlQueryString; private QueryEngineHTTP queryExecution; - private SparqlEndpoint endpoint; + private SparqlEndpoint sparqlEndpoint; private String json = null; /** * Standard constructor. * - * @param queryString - * @param endpoint + * @param sparqlQueryString A SPARQL query string + * @param sparqlEndpoint An Endpoint object */ - public SparqlQuery(String queryString, SparqlEndpoint endpoint) { + public SparqlQuery(String sparqlQueryString, SparqlEndpoint sparqlEndpoint) { // QUALITY there seems to be a bug in ontowiki - this.queryString = queryString.replaceAll("\n", " "); - this.endpoint = endpoint; + this.sparqlQueryString = sparqlQueryString.replaceAll("\n", " "); + this.sparqlEndpoint = sparqlEndpoint; } /** * Sends a SPARQL query using the Jena library. main format is JSON, use * method getasjson * - * @return nothing */ - public void send() { wasExecuted = true; // isRunning = true; ResultSet rs; writeToSparqlLog("***********\nNew Query:"); - writeToSparqlLog(queryString); - writeToSparqlLog(endpoint.getURL().toString()); + writeToSparqlLog(sparqlQueryString); + writeToSparqlLog(sparqlEndpoint.getURL().toString()); - String service = endpoint.getURL().toString(); + String service = sparqlEndpoint.getURL().toString(); // Jena access to SPARQL endpoint - queryExecution = new QueryEngineHTTP(service, queryString); - for (String dgu : endpoint.getDefaultGraphURIs()) { + queryExecution = new QueryEngineHTTP(service, sparqlQueryString); + for (String dgu : sparqlEndpoint.getDefaultGraphURIs()) { queryExecution.addDefaultGraph(dgu); } - for (String ngu : endpoint.getNamedGraphURIs()) { + for (String ngu : sparqlEndpoint.getNamedGraphURIs()) { queryExecution.addNamedGraph(ngu); } @@ -108,12 +106,12 @@ rs = queryExecution.execSelect(); JamonMonitorLogger.getTimeMonitor(SparqlQuery.class, "httpTime").stop(); - logger.debug("query length: " + queryString.length() + " | ENDPOINT: " - + endpoint.getURL().toString()); + logger.debug("query length: " + sparqlQueryString.length() + " | ENDPOINT: " + + sparqlEndpoint.getURL().toString()); // writeToSparqlLog("query: "+queryString+ " | ENDPOINT: // "+endpoint.getURL().toString()); - json = SparqlQuery.getAsJSON(rs); + json = SparqlQuery.convertResultSetToJSON(rs); writeToSparqlLog("JSON: " + json); @@ -121,90 +119,129 @@ } + /** + * Stops the execution of the query. + */ public void stop() { queryExecution.abort(); isRunning = false; } - public String getQueryString() { - return queryString; + /** + * Gets the String representation of the SPARQL query. + * @return sparqlQueryString + */ + public String getSparqlQueryString() { + return sparqlQueryString; } - public SparqlEndpoint getEndpoint() { - return endpoint; + /** + * @return sparqlEndpoint object + */ + public SparqlEndpoint getSparqlEndpoint() { + return sparqlEndpoint; } + /** + * + * @return boolean + */ public boolean isRunning() { return isRunning; } + /** + * @return the Jena QueryEngineHTTP + */ public QueryEngineHTTP getExecution() { return queryExecution; } + /** + * insert a result, e.g. from the cache + * @param json a jsonString + */ public void setJson(String json) { this.wasExecuted = true; this.json = json; } + /** + * @param running s.e. + */ public void setRunning(boolean running) { this.isRunning = running; } /** * returns the Result of the query as JSON string executes the query if it - * wasn't executed before + * wasn't executed before. * - * @return + * @return a JSON string */ public String getJson() { - if (wasExecuted == false) { + if (!wasExecuted) { this.send(); } return json; } /** - * makes a ResultSet from the Json String, depends on getJSON + * makes a ResultSet from the Json String, depends on getJSON. * - * @return + * @return a Jena ResultSet */ public ResultSet getResultSet() { - if (getJson() == null) { - return null; + return (getJson() == null) ? null : convertJSONtoResultSet(json); + + /*if (getJson() == null) { + return null; } else - return JSONtoResultSet(json); + return JSONtoResultSet(json);*/ } /** - * makes an XML String from the Json String, depends on getJSON + * makes an XML String from the Json String, depends on getJSON. * - * @return + * @return An XML String */ public String getXMLString() { - if (getJson() == null) { + return (getJson() == null) ? null : convertJSONtoXML(json); + + /*if (getJson() == null) { return null; } else - return JSONtoXML(json); + return JSONtoXML(json);*/ } + /** + * Special log for debugging SPARQL query execution. + * It lives here: "log/sparql.txt" + * if the directory doesn't exist, there could be an error. + * @param s the String to log + */ public static void writeToSparqlLog(String s) { try { + // FileWriter fw = new FileWriter("log/sparql.txt", true); fw.write(s + "\n"); fw.flush(); fw.close(); } catch (Exception e) { e.printStackTrace(); + // make the e object more special FileNotFound?? + //new File("log").mkdir(); + //writeToSparqlLog(s); } } + /** * Converts Jena result set to XML. - * + * @param resultSet a Jena ResultSet * @return String xml */ - public static String getAsXMLString(ResultSet resultSet) { + public static String convertResultSetToXMLString(ResultSet resultSet) { // if (rs == null) // this.send(); return ResultSetFormatter.asXMLString(resultSet); @@ -217,14 +254,14 @@ * The result set to transform. * @return JSON representation of the result set. */ - public static String getAsJSON(ResultSet resultSet) { + public static String convertResultSetToJSON(ResultSet resultSet) { // if (rs == null) // this.send(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ResultSetFormatter.outputAsJSON(baos, resultSet); // possible Jena bug: Jena modifies the result set during // JSON transformation, so we need to get it back - resultSet = JSONtoResultSet(baos.toString()); + resultSet = convertJSONtoResultSet(baos.toString()); try { return baos.toString("UTF-8"); } catch (UnsupportedEncodingException e) { @@ -240,7 +277,7 @@ * A JSON representation if a SPARQL query result. * @return A Jena ResultSet. */ - public static ResultSet JSONtoResultSet(String json) { + public static ResultSet convertJSONtoResultSet(String json) { ByteArrayInputStream bais = new ByteArrayInputStream(json .getBytes(Charset.forName("UTF-8"))); // System.out.println("JSON " + json); @@ -254,7 +291,7 @@ * A JSON representation if a SPARQL query result. * @return A Jena ResultSet. */ - public static String JSONtoXML(String json) { - return getAsXMLString(JSONtoResultSet(json)); + public static String convertJSONtoXML(String json) { + return convertResultSetToXMLString(convertJSONtoResultSet(json)); } } Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -111,28 +111,18 @@ // String resultString=""; // System.out.println(time()); // System.out.println(System.currentTimeMillis()); - String[] a = new String[2]; - int x1=0; - try { - while(true) - a[x1++]=""; - } catch (Exception e) { - e.printStackTrace(); - - } - System.exit(0); // parameters if (local) { url = "http://139.18.2.37:8890/sparql"; sparqlTasks = new SPARQLTasks(Cache.getPersistentCache(), - SparqlEndpoint.EndpointLOCALDBpedia()); + SparqlEndpoint.getEndpointLOCALDBpedia()); } else { url = "http://dbpedia.openlinksw.com:8890/sparql"; sparqlTasks = new SPARQLTasks(Cache.getPersistentCache(), - SparqlEndpoint.EndpointDBpedia()); + SparqlEndpoint.getEndpointDBpedia()); } //System.out.println(sparqlTasks.getDomain( Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLExtractionEvaluation.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -61,12 +61,12 @@ SimpleClock total =new SimpleClock(); String url=""; if(local){ - se = SparqlEndpoint.EndpointLOCALDBpedia(); + se = SparqlEndpoint.getEndpointLOCALDBpedia(); url = "http://139.18.2.37:8890/sparql"; }else{ - se = SparqlEndpoint.EndpointDBpedia(); + se = SparqlEndpoint.getEndpointDBpedia(); url= "http://dbpedia.openlinksw.com:8890/sparql"; } @@ -187,7 +187,7 @@ " \n} LIMIT "+1000+" \n "; // String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); + ResultSet rs =SparqlQuery.convertJSONtoResultSet(JSON); if(rs==null); //JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); //return SetManipulation.fuzzyShrink(rsc.getStringListForVariable("concept"),number); Modified: trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/scripts/SPARQLMassLearning.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -97,7 +97,7 @@ static void roles(){ - se = SparqlEndpoint.EndpointDBpedia(); + se = SparqlEndpoint.getEndpointDBpedia(); //se = SparqlEndpoint.EndpointUSCensus(); SortedSet<String> roles = new TreeSet<String>(); roles.add("http://dbpedia.org/property/birthPlace"); @@ -143,7 +143,7 @@ } static void DBpedia(){ - se = SparqlEndpoint.EndpointLOCALDBpedia(); + se = SparqlEndpoint.getEndpointLOCALDBpedia(); //concepts.add("(EXISTS \"monarch\".TOP AND EXISTS \"predecessor\".(\"Knight\" OR \"Secretary\"))"); SortedSet<String> concepts = new TreeSet<String>(); @@ -257,7 +257,7 @@ String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); + ResultSet rs =SparqlQuery.convertJSONtoResultSet(JSON); if(rs==null); //JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); //return SetManipulation.fuzzyShrink(rsc.getStringListForVariable("concept"),number); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -599,7 +599,7 @@ Thread sparqlThread = new Thread() { @Override public void run() { - if (ks.getUseCache()){ + if (ks.isUseCache()){ state.getQuery(id).setRunning(true); Cache cache=new Cache(ks.getCacheDir()); cache.executeSparqlQuery(state.getQuery(id)); @@ -623,7 +623,7 @@ Component component = state.getComponent(componentID); SparqlKnowledgeSource ks=(SparqlKnowledgeSource)component; SparqlQuery sparql=ks.sparqlQuery(query); - if (ks.getUseCache()){ + if (ks.isUseCache()){ Cache cache=new Cache(ks.getCacheDir()); return cache.executeSparqlQuery(sparql); } Modified: trunk/src/dl-learner/org/dllearner/test/JenaQueryToResultSpeedTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/JenaQueryToResultSpeedTest.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/test/JenaQueryToResultSpeedTest.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -50,7 +50,7 @@ public static void testJenaAsXML(int howOften, String queryString){ - SparqlEndpoint sse = SparqlEndpoint.EndpointDBpedia(); + SparqlEndpoint sse = SparqlEndpoint.getEndpointDBpedia(); SparqlQuery sqJena = new SparqlQuery(queryString, sse); // first query is not counted sqJena.send(); @@ -72,7 +72,7 @@ } public static void testJenaAsList(int howOften, String queryString){ - SparqlEndpoint sse = SparqlEndpoint.EndpointDBpedia(); + SparqlEndpoint sse = SparqlEndpoint.getEndpointDBpedia(); SparqlQuery sqJena = new SparqlQuery(queryString, sse); // first query is not counted //sqJena.getAsList(); @@ -96,7 +96,7 @@ } public static void testJenaAsJSON(int howOften, String queryString){ - SparqlEndpoint sse = SparqlEndpoint.EndpointDBpedia(); + SparqlEndpoint sse = SparqlEndpoint.getEndpointDBpedia(); SparqlQuery sqJena = new SparqlQuery(queryString, sse); // first query is not counted sqJena.send(); @@ -119,7 +119,7 @@ } public static void testJenaAsJSONandBack(int howOften, String queryString){ - SparqlEndpoint sse = SparqlEndpoint.EndpointDBpedia(); + SparqlEndpoint sse = SparqlEndpoint.getEndpointDBpedia(); SparqlQuery sqJena = new SparqlQuery(queryString, sse); // first query is not counted sqJena.send(); @@ -131,7 +131,7 @@ // System.out.println(sqJena.getAsJSON()); sqJena.send(); String json = sqJena.getJson(); - SparqlQuery.JSONtoResultSet(json); + SparqlQuery.convertJSONtoResultSet(json); p("Jena as JSON and back needed: " + (System.currentTimeMillis() - tmp)); tmp = System.currentTimeMillis(); @@ -145,7 +145,7 @@ public static void compareResults(String queryString) { - SparqlEndpoint sse = SparqlEndpoint.EndpointDBpedia(); + SparqlEndpoint sse = SparqlEndpoint.getEndpointDBpedia(); SparqlQuery sqJena = new SparqlQuery(queryString, sse); // SparqlQueryConventional sqConv=new SparqlQueryConventional(sse); Modified: trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java 2008-07-29 14:30:25 UTC (rev 1024) +++ trunk/src/dl-learner/org/dllearner/test/SparqlEndpointTest.java 2008-07-30 06:53:34 UTC (rev 1025) @@ -1,7 +1,7 @@ package org.dllearner.test; import java.util.HashSet; -import java.util.LinkedList; +import java.util.List; import java.util.Set; import java.util.SortedSet; @@ -36,7 +36,7 @@ //SELECT DISTINCT ?c WHERE {[] a ?c }LIMIT 100 - LinkedList<SparqlEndpoint> ll = SparqlEndpoint.listEndpoints(); + List<SparqlEndpoint> ll = SparqlEndpoint.listEndpoints(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-07-29 14:30:29
|
Revision: 1024 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1024&view=rev Author: kurzum Date: 2008-07-29 14:30:25 +0000 (Tue, 29 Jul 2008) Log Message: ----------- some comments, some improvements Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java trunk/src/dl-learner/org/dllearner/cli/QuickStart.java trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2008-07-29 12:42:52 UTC (rev 1023) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2008-07-29 14:30:25 UTC (rev 1024) @@ -238,8 +238,8 @@ // unterzogen und dann ein neues Programm erstellt if(Math.random()<0.5) { pt = crossover(p1.getTree(), p2.getTree()); - result[0] = createProgram(learningProblem, pt[0],p1.getAdc()); - result[1] = createProgram(learningProblem, pt[1],p2.getAdc()); + result[0] = createProgram(learningProblem, pt[0], p1.getAdc()); + result[1] = createProgram(learningProblem, pt[1], p2.getAdc()); } else { pt = crossover(p1.getAdc(), p2.getAdc()); result[0] = createProgram(learningProblem, p1.getTree(),pt[0]); Modified: trunk/src/dl-learner/org/dllearner/cli/QuickStart.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/QuickStart.java 2008-07-29 12:42:52 UTC (rev 1023) +++ trunk/src/dl-learner/org/dllearner/cli/QuickStart.java 2008-07-29 14:30:25 UTC (rev 1024) @@ -119,7 +119,7 @@ } catch (Exception e) { System.out.println("Not a number"); } - ; + }// end while if (number) { try { Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java 2008-07-29 12:42:52 UTC (rev 1023) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java 2008-07-29 14:30:25 UTC (rev 1024) @@ -40,31 +40,38 @@ */ public class SPARQLTasks { - private static final Logger logger = Logger.getLogger(SPARQLTasks.class); + private static Logger logger = Logger.getLogger(SPARQLTasks.class); private final Cache cache; private final SparqlEndpoint sparqlEndpoint; - public SPARQLTasks(final Cache cache, final SparqlEndpoint sparqlEndpoint) { + /** + * @param c a cache object + * @param se the Endpoint the sparql queries will be send to + */ + public SPARQLTasks(final Cache c, final SparqlEndpoint se) { super(); - this.cache = cache; - this.sparqlEndpoint = sparqlEndpoint; + this.cache = c; + this.sparqlEndpoint = se; } - public SPARQLTasks(final SparqlEndpoint sparqlEndpoint) { + /** + * @param se the Endpoint the sparql queries will be send to + */ + public SPARQLTasks(final SparqlEndpoint se) { super(); this.cache = null; - this.sparqlEndpoint = sparqlEndpoint; + this.sparqlEndpoint = se; } /** * QUALITY: doesn't seem optimal, check! get all superclasses up to a * certain depth 1 means direct superclasses depth * - * @param superClasses - * @param maxdepth - * @return + * @param oneClass the class for which the superclasses will be retrieved + * @param maxdepth how far the RDF graph will be explored (1 means only direct SuperClasses) + * @return a Sorted String Set of all ClassNames, including the starting class */ public SortedSet<String> getSuperClasses(final String oneClass, final int maxdepth) { @@ -73,7 +80,7 @@ superClasses.add(oneClass); SortedSet<String> ret = new TreeSet<String>(); SortedSet<String> tmpset = new TreeSet<String>(); - String SPARQLquery = ""; + String sparqlQuery = ""; // ret.addAll(superClasses); // logger.debug(superClasses); @@ -81,14 +88,14 @@ for (String oneSuperClass : superClasses) { // tmp = oneSuperClass.replace("\"", ""); - SPARQLquery = "SELECT * WHERE { \n" + sparqlQuery = "SELECT * WHERE { \n" + "<" + oneSuperClass + "> " + "<http://www.w3.org/2000/01/rdf-schema#subClassOf> ?superclass. \n" + "}"; - tmpset.addAll(queryAsSet(SPARQLquery, "superclass")); + tmpset.addAll(queryAsSet(sparqlQuery, "superclass")); }// end inner for ret.addAll(tmpset); @@ -103,7 +110,8 @@ } /** - * gets a SortedSet of all subclasses QUALITY: maybe it is better to have a + * gets a SortedSet of all subclasses. + * QUALITY: maybe it is better to have a * parameter int depth, to choose a depth of subclass interference * * @see conceptRewrite(String descriptionKBSyntax, SparqlEndpoint se, Cache @@ -138,8 +146,7 @@ } else { - logger - .warn("Retrieval auf all subclasses via SPARQL is cost intensive and might take a while"); + logger.warn("Retrieval auf all subclasses via SPARQL is cost intensive and might take a while"); SortedSet<String> tmpSet = new TreeSet<String>(); while (!remainingClasses.isEmpty()) { @@ -173,14 +180,14 @@ */ private SortedSet<String> getDirectSubClasses(final String concept) { - String SPARQLquery; + String sparqlQueryString; SortedSet<String> subClasses = new TreeSet<String>(); ResultSet resultSet; - SPARQLquery = "SELECT * \n " + "WHERE { \n" + " ?subject ?predicate <" + sparqlQueryString = "SELECT * \n " + "WHERE { \n" + " ?subject ?predicate <" + concept + "> \n" + "}\n"; - resultSet = queryAsResultSet(SPARQLquery); + resultSet = queryAsResultSet(sparqlQueryString); @SuppressWarnings("unchecked") List<ResultBinding> bindings = ResultSetFormatter.toList(resultSet); @@ -200,6 +207,8 @@ } /** + * Retrieves all resource for a fixed role and object. + * These instances are distinct. * QUALITY: buggy because role doesn't work sometimes get subject with fixed * role and object * @@ -210,39 +219,39 @@ */ public SortedSet<String> retrieveDISTINCTSubjectsForRoleAndObject( String role, String object, int resultLimit) { - String SPARQLquery = "SELECT DISTINCT * WHERE { \n " + "?subject " + String sparqlQueryString = "SELECT DISTINCT * WHERE { \n " + "?subject " + "<" + role + "> " + "<" + object + "> \n" + "} " + limit(resultLimit); - return queryAsSet(SPARQLquery, "subject"); + return queryAsSet(sparqlQueryString, "subject"); } public SortedSet<String> retrieveObjectsForSubjectAndRole(String subject, String role, int resultLimit) { - String SPARQLquery = "SELECT DISTINCT * WHERE { \n " + "<" + subject + String sparqlQueryString = "SELECT DISTINCT * WHERE { \n " + "<" + subject + "> " + "<" + role + "> " + " ?object \n" + "} LIMIT " + resultLimit; - return queryAsSet(SPARQLquery, "object"); + return queryAsSet(sparqlQueryString, "object"); } /** - * all instances for a SKOS concept + * all instances for a SKOS concept. * - * @param SKOSconcept + * @param skosConcept * @param resultLimit * @return */ public SortedSet<String> retrieveInstancesForSKOSConcept( - String SKOSconcept, int resultLimit) { - return queryPatternAsSet("?subject", "?predicate", "<" + SKOSconcept + String skosConcept, int resultLimit) { + return queryPatternAsSet("?subject", "?predicate", "<" + skosConcept + ">", "subject", resultLimit); // return // retrieveDISTINCTSubjectsForRoleAndObject("http://www.w3.org/2004/02/skos/core#subject", } /** - * get all instances for a concept + * get all instances for a concept. * * @param conceptKBSyntax * @param sparqlResultLimit @@ -251,18 +260,18 @@ public SortedSet<String> retrieveInstancesForConcept( String conceptKBSyntax, int sparqlResultLimit) { - String SPARQLquery = ""; + String sparqlQueryString = ""; try { - SPARQLquery = SparqlQueryDescriptionConvertVisitor.getSparqlQuery( + sparqlQueryString = SparqlQueryDescriptionConvertVisitor.getSparqlQuery( conceptKBSyntax, sparqlResultLimit); } catch (Exception e) { logger.warn(e.getMessage()); } - return queryAsSet(SPARQLquery, "subject"); + return queryAsSet(sparqlQueryString, "subject"); } /** - * get all instances for a concept including RDFS Reasoning + * get all instances for a concept including RDFS Reasoning. * * @param conceptKBSyntax * @param sparqlResultLimit @@ -271,20 +280,20 @@ public SortedSet<String> retrieveInstancesForConceptIncludingSubclasses( String conceptKBSyntax, int sparqlResultLimit) { - String SPARQLquery = ""; + String sparqlQueryString = ""; try { - SPARQLquery = SparqlQueryDescriptionConvertVisitor + sparqlQueryString = SparqlQueryDescriptionConvertVisitor .getSparqlQueryIncludingSubclasses(conceptKBSyntax, sparqlResultLimit, this, true); } catch (Exception e) { logger.warn(e.getMessage()); } - return queryAsSet(SPARQLquery, "subject"); + return queryAsSet(sparqlQueryString, "subject"); } /** - * get all direct Classes of an instance + * get all direct Classes of an instance. * * @param instance * @param resultLimit @@ -293,35 +302,35 @@ public SortedSet<String> getClassesForInstance(String instance, int resultLimit) { - String SPARQLquery = "SELECT ?subject WHERE { \n " + "<" + instance + String sparqlQueryString = "SELECT ?subject WHERE { \n " + "<" + instance + ">" + " a " + "?subject " + "\n" + "} " + limit(resultLimit); - return queryAsSet(SPARQLquery, "subject"); + return queryAsSet(sparqlQueryString, "subject"); } public SortedSet<String> getDomain(String role, int resultLimit) { - String SPARQLquery = "SELECT DISTINCT ?domain " + "WHERE { \n" + String sparqlQueryString = "SELECT DISTINCT ?domain " + "WHERE { \n" + "?domain <" + role + "> " + " ?o. \n" + "?domain a []\n." + "FILTER (!isLiteral(?domain))." + "}\n" + limit(resultLimit); - return queryAsSet(SPARQLquery, "domain"); + return queryAsSet(sparqlQueryString, "domain"); } public SortedSet<String> getRange(String role, int resultLimit) { - String SPARQLquery = "SELECT DISTINCT ?range " + "WHERE { \n" + "?s <" + String sparqlQueryString = "SELECT DISTINCT ?range " + "WHERE { \n" + "?s <" + role + "> " + " ?range. \n" + "?range a [].\n" + "FILTER (!isLiteral(?range))." + "}\n" + limit(resultLimit); - return queryAsSet(SPARQLquery, "range"); + return queryAsSet(sparqlQueryString, "range"); } /** * query a pattern with a standard SPARQL query usage (?subject, ?predicate, - * <http:something> , subject ) + * <http://something> , subject ). * * @param subject * @param predicate @@ -331,24 +340,24 @@ */ public SortedSet<String> queryPatternAsSet(String subject, String predicate, String object, String var, int resultLimit) { - String SPARQLquery = "SELECT ?subject WHERE { \n " + " " + subject + String sparqlQueryString = "SELECT ?subject WHERE { \n " + " " + subject + " " + predicate + " " + object + " \n" + "} " + limit(resultLimit); - return queryAsSet(SPARQLquery, var); + return queryAsSet(sparqlQueryString, var); } /** - * little higher level, executes query ,returns all resources for a variable + * little higher level, executes query ,returns all resources for a variable. * - * @param SPARQLquery + * @param sparqlQueryString * @param var * @return */ - public SortedSet<String> queryAsSet(String SPARQLquery, String var) { + public SortedSet<String> queryAsSet(String sparqlQueryString, String var) { ResultSet rs = null; try { - String JSON = query(SPARQLquery); - rs = SparqlQuery.JSONtoResultSet(JSON); + String jsonString = query(sparqlQueryString); + rs = SparqlQuery.JSONtoResultSet(jsonString); } catch (Exception e) { logger.warn(e.getMessage()); @@ -357,37 +366,37 @@ } /** - * low level, executes query returns ResultSet + * low level, executes query returns ResultSet. * - * @param SPARQLquery + * @param sparqlQueryString * @return jena ResultSet */ - public ResultSet queryAsResultSet(String SPARQLquery) { - return SparqlQuery.JSONtoResultSet(query(SPARQLquery)); + public ResultSet queryAsResultSet(String sparqlQueryString) { + return SparqlQuery.JSONtoResultSet(query(sparqlQueryString)); } /** - * low level, executes query returns JSON + * low level, executes query returns JSON. * - * @param SPARQLquery + * @param sparqlQueryString * @return */ - public String query(String SPARQLquery) { - String JSON; + public String query(String sparqlQueryString) { + String jsonString; if (cache == null) { - SparqlQuery sq = new SparqlQuery(SPARQLquery, sparqlEndpoint); + SparqlQuery sq = new SparqlQuery(sparqlQueryString, sparqlEndpoint); sq.send(); - JSON = sq.getJson(); + jsonString = sq.getJson(); } else { - JSON = cache.executeSparqlQuery(new SparqlQuery(SPARQLquery, + jsonString = cache.executeSparqlQuery(new SparqlQuery(sparqlQueryString, sparqlEndpoint)); } - return JSON; + return jsonString; } private String limit(int resultLimit) { - return (resultLimit > 0) ? " LIMIT " + resultLimit : ""; + return (resultLimit > 0) ? (" LIMIT " + resultLimit) : ""; } public static SortedSet<String> getStringListForVariable(ResultSet rs, Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-07-29 12:42:52 UTC (rev 1023) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-07-29 14:30:25 UTC (rev 1024) @@ -2,7 +2,7 @@ * 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 Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-07-29 12:42:52 UTC (rev 1023) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-07-29 14:30:25 UTC (rev 1024) @@ -55,6 +55,8 @@ import org.dllearner.utilities.examples.AutomaticPositiveExampleFinderSPARQL; public class SKOS7030 { + + public int test = 0; private static SPARQLTasks sparqlTasks; @@ -104,12 +106,23 @@ * @param args */ public static void main(String[] args) { + initLogger(); logger.info("Start"); // String resultString=""; // System.out.println(time()); // System.out.println(System.currentTimeMillis()); - - initLogger(); + String[] a = new String[2]; + int x1=0; + try { + while(true) + a[x1++]=""; + } catch (Exception e) { + e.printStackTrace(); + + } + + System.exit(0); + // parameters if (local) { @@ -236,7 +249,6 @@ // create logger (a simple logger which outputs // its messages to the console) FileAppender fileAppender = null; - ; try { fileAppender = new FileAppender(layout, "log/progress/skos" + time() + ".txt", false); @@ -462,6 +474,7 @@ return 0; } + public boolean equals(ResultCompare o2) { return this.concept.equals(o2.concept); } @@ -511,10 +524,13 @@ } + /** + * + */ public static void recordConceptClasses() { - String result = ""; - String result1 = "\n\n ***********Entity*****\n"; - String result2 = "\n\n ***********OR*****\n"; + StringBuffer result =new StringBuffer(); + StringBuffer result1 =new StringBuffer("\n\n ***********Entity*****\n"); + StringBuffer result2 =new StringBuffer("\n\n ***********OR*****\n"); int result1count = 1; int result2count = 1; List<EvaluatedDescription> conceptresults = la @@ -524,24 +540,24 @@ for (EvaluatedDescription description : conceptresults) { if (x < 50) { x++; - result += description + "\n"; + result.append(description + "\n"); } if (!description.toString().contains("Entity")) { - result1 += description + "\n"; + result1.append(description + "\n"); result1count++; } if (!description.toString().contains("OR")) { - result2 += description + "\n"; + result2.append(description + "\n"); result2count++; } } - result += "full size: " + conceptresults.size() + ""; - result += result1 + " size: " + result1count + "\n"; - result += result2 + " size: " + result2count + "\n"; + result.append("full size: " + conceptresults.size()); + result.append(result1.toString() + " size: " + result1count + "\n"); + result.append(result2.toString() + " size: " + result2count + "\n"); Files.createFile(new File("results/descriptions/concepts" + time() - + ".txt"), result); + + ".txt"), result.toString()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Jen...@us...> - 2008-07-29 12:42:54
|
Revision: 1023 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1023&view=rev Author: JensLehmann Date: 2008-07-29 12:42:52 +0000 (Tue, 29 Jul 2008) Log Message: ----------- fixed Prot?\195?\169g?\195?\169 ant task Modified Paths: -------------- trunk/build.xml Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2008-07-29 11:50:56 UTC (rev 1022) +++ trunk/build.xml 2008-07-29 12:42:52 UTC (rev 1023) @@ -299,8 +299,9 @@ </copy> <javac srcdir="${source}" destdir="${temp}" - classpath="jarfile" - debug="on" /> + debug="on"> + <classpath refid="classpath"/> + </javac> <jar destfile="${protege_dir}/dl-learner.jar" manifest="${temp}/META-INF/MANIFEST.MF"> <fileset dir="${temp}" /> </jar> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Jen...@us...> - 2008-07-29 11:50:58
|
Revision: 1022 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1022&view=rev Author: JensLehmann Date: 2008-07-29 11:50:56 +0000 (Tue, 29 Jul 2008) Log Message: ----------- added EvaluatedDescription support to ROLearner Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/test/ComponentTest.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-07-29 08:24:15 UTC (rev 1021) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-07-29 11:50:56 UTC (rev 1022) @@ -40,6 +40,7 @@ import org.dllearner.utilities.Helper; import org.dllearner.utilities.owl.ConceptComparator; import org.dllearner.utilities.owl.ConceptTransformation; +import org.dllearner.utilities.owl.EvaluatedDescriptionComparator; public class ROLearner extends LearningAlgorithm { @@ -100,6 +101,8 @@ private Comparator<Node> nodeComparator; private NodeComparatorStable nodeComparatorStable = new NodeComparatorStable(); private ConceptComparator conceptComparator = new ConceptComparator(); + // comparator for evaluated descriptions + private EvaluatedDescriptionComparator edComparator = new EvaluatedDescriptionComparator(); DecimalFormat df = new DecimalFormat(); private PosNegLP learningProblem; @@ -1047,6 +1050,21 @@ return new EvaluatedDescription(candidatesStable.last().getConcept(), getSolutionScore()); } + public SortedSet<EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions() { + int count = 0; + SortedSet<Node> rev = candidatesStable.descendingSet(); + SortedSet<EvaluatedDescription> cbd = new TreeSet<EvaluatedDescription>(edComparator); + for(Node eb : rev) { + cbd.add(new EvaluatedDescription(eb.getConcept(), getSolutionScore(eb.getConcept()))); + // return a maximum of 200 elements (we need a maximum, because the + // candidate set can be very large) + if(count > 200) + return cbd; + count++; + } + return cbd; + } + public void printBestSolutions(int nrOfSolutions){ if(!logLevel.equalsIgnoreCase("TRACE")){return;} if(nrOfSolutions==0)nrOfSolutions=solutions.size(); Modified: trunk/src/dl-learner/org/dllearner/test/ComponentTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/ComponentTest.java 2008-07-29 08:24:15 UTC (rev 1021) +++ trunk/src/dl-learner/org/dllearner/test/ComponentTest.java 2008-07-29 11:50:56 UTC (rev 1022) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-07-29 08:24:26
|
Revision: 1021 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1021&view=rev Author: kurzum Date: 2008-07-29 08:24:15 +0000 (Tue, 29 Jul 2008) Log Message: ----------- some comments Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java trunk/src/dl-learner/org/dllearner/utilities/datastructures/SetManipulation.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java 2008-07-28 17:50:10 UTC (rev 1020) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SPARQLTasks.java 2008-07-29 08:24:15 UTC (rev 1021) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007, Sebastian Hellmann + * + * 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.kb.sparql; import java.util.LinkedList; @@ -11,72 +30,78 @@ import com.hp.hpl.jena.query.ResultSetFormatter; import com.hp.hpl.jena.sparql.core.ResultBinding; + +/** + * @author Sebastian Hellmann + * Convenience class for SPARQL queries + * initialized with a SparqlEndpoint. + * A Cache can also be used to further improve query time. + * Some methods allow basic reasoning + */ public class SPARQLTasks { - - //@SuppressWarnings("unused") - //LOGGER: SPARQLTasks - private static Logger logger = Logger - .getLogger(SPARQLTasks.class); - private Cache c; - private SparqlEndpoint se; - - public SPARQLTasks(Cache c, SparqlEndpoint se) { + + private static final Logger logger = Logger.getLogger(SPARQLTasks.class); + + private final Cache cache; + + private final SparqlEndpoint sparqlEndpoint; + + public SPARQLTasks(final Cache cache, final SparqlEndpoint sparqlEndpoint) { super(); - this.c = c; - this.se = se; + this.cache = cache; + this.sparqlEndpoint = sparqlEndpoint; } - - public SPARQLTasks( SparqlEndpoint se) { + + public SPARQLTasks(final SparqlEndpoint sparqlEndpoint) { super(); - this.c = null; - this.se = se; + this.cache = null; + this.sparqlEndpoint = sparqlEndpoint; } - - - - + /** - * QUALITY: doesn't seem optimal, check! - * get all superclasses up to a certain depth - * 1 means direct superclasses - * depth + * QUALITY: doesn't seem optimal, check! get all superclasses up to a + * certain depth 1 means direct superclasses depth + * * @param superClasses - * @param depth + * @param maxdepth * @return */ - public SortedSet<String> getSuperClasses(String oneClass, int depth) { + public SortedSet<String> getSuperClasses(final String oneClass, + final int maxdepth) { + int depth = maxdepth; SortedSet<String> superClasses = new TreeSet<String>(); superClasses.add(oneClass); SortedSet<String> ret = new TreeSet<String>(); SortedSet<String> tmpset = new TreeSet<String>(); - //ret.addAll(superClasses); - //logger.debug(superClasses); - - String SPARQLquery = ""; - for (; depth != 0 ; depth--) { + // ret.addAll(superClasses); + // logger.debug(superClasses); + + for (; depth != 0; depth--) { for (String oneSuperClass : superClasses) { - - //tmp = oneSuperClass.replace("\"", ""); - SPARQLquery = "SELECT * WHERE { \n" + "<" + oneSuperClass + "> " - + "<http://www.w3.org/2000/01/rdf-schema#subClassOf> ?superclass. \n" - + "}"; - + + // tmp = oneSuperClass.replace("\"", ""); + SPARQLquery = "SELECT * WHERE { \n" + + "<" + + oneSuperClass + + "> " + + "<http://www.w3.org/2000/01/rdf-schema#subClassOf> ?superclass. \n" + + "}"; + tmpset.addAll(queryAsSet(SPARQLquery, "superclass")); - - } + + }// end inner for ret.addAll(tmpset); - //logger.debug(ret); + // logger.debug(ret); superClasses.clear(); superClasses.addAll(tmpset); tmpset.clear(); - } - //logger.debug(concept); - //logger.debug(query); - return ret; + }// end outer for + // logger.debug(concept); + // logger.debug(query); + return ret; } - - + /** * gets a SortedSet of all subclasses QUALITY: maybe it is better to have a * parameter int depth, to choose a depth of subclass interference @@ -84,13 +109,13 @@ * @see conceptRewrite(String descriptionKBSyntax, SparqlEndpoint se, Cache * c, boolean simple ) * @param description - * @param se - * @param c + * @param sparqlEndpoint + * @param cache * @param simple * @return */ - public SortedSet<String> getSubClasses(String description, boolean simple) { - + public SortedSet<String> getSubClasses(final String description, + final boolean simple) { // ResultSet rs = null; // System.out.println(description); SortedSet<String> alreadyQueried = new TreeSet<String>(); @@ -100,7 +125,8 @@ LinkedList<String> remainingClasses = new LinkedList<String>(); // collect remaining classes - remainingClasses.addAll(getDirectSubClasses(description.replaceAll("\"", ""))); + remainingClasses.addAll(getDirectSubClasses(description.replaceAll( + "\"", ""))); // remainingClasses.addAll(alreadyQueried); @@ -109,12 +135,14 @@ if (simple) { alreadyQueried.addAll(remainingClasses); - return alreadyQueried; + } else { - logger.warn("Retrieval auf all subclasses via SPARQL is cost intensive and might take a while"); - while (remainingClasses.size() != 0) { - SortedSet<String> tmpSet = new TreeSet<String>(); + logger + .warn("Retrieval auf all subclasses via SPARQL is cost intensive and might take a while"); + SortedSet<String> tmpSet = new TreeSet<String>(); + while (!remainingClasses.isEmpty()) { + String tmp = remainingClasses.removeFirst(); alreadyQueried.add(tmp); @@ -124,11 +152,12 @@ remainingClasses.add(string); }// if }// for + tmpSet.clear(); }// while }// else } catch (Exception e) { - + logger.error(e.getStackTrace()); } return alreadyQueried; @@ -136,252 +165,245 @@ /** * QUALITY: workaround for a sparql glitch {?a owl:subclassOf ?b} returns an - * empty set on some entpoints. returns all direct subclasses of String + * empty set on some endpoints. returns all direct subclasses of String * concept * * @param concept * @return SortedSet of direct subclasses as String */ - private SortedSet<String> getDirectSubClasses(String concept) { - String SPARQLquery = "SELECT * \n"; - SPARQLquery += "WHERE {\n"; - SPARQLquery += " ?subject ?predicate <" + concept + "> \n"; - SPARQLquery += "}\n"; + private SortedSet<String> getDirectSubClasses(final String concept) { - ResultSet rs = queryAsResultSet(SPARQLquery); - + String SPARQLquery; SortedSet<String> subClasses = new TreeSet<String>(); + ResultSet resultSet; + + SPARQLquery = "SELECT * \n " + "WHERE { \n" + " ?subject ?predicate <" + + concept + "> \n" + "}\n"; + + resultSet = queryAsResultSet(SPARQLquery); + @SuppressWarnings("unchecked") - List<ResultBinding> l = ResultSetFormatter.toList(rs); - String p = "", s = ""; - for (ResultBinding resultBinding : l) { + List<ResultBinding> bindings = ResultSetFormatter.toList(resultSet); + String subject = ""; + String predicate = ""; - s = ((resultBinding.get("subject").toString())); - p = ((resultBinding.get("predicate").toString())); - if (p.equalsIgnoreCase("http://www.w3.org/2000/01/rdf-schema#subClassOf")) { - subClasses.add(s); + for (ResultBinding resultBinding : bindings) { + + subject = ((resultBinding.get("subject").toString())); + predicate = ((resultBinding.get("predicate").toString())); + if (predicate + .equalsIgnoreCase("http://www.w3.org/2000/01/rdf-schema#subClassOf")) { + subClasses.add(subject); } } return subClasses; } /** - * QUALITY: buggy because role doesn't work sometimes - * get subject with fixed role and object + * QUALITY: buggy because role doesn't work sometimes get subject with fixed + * role and object + * * @param role * @param object * @param resultLimit * @return */ - public SortedSet<String> retrieveDISTINCTSubjectsForRoleAndObject(String role, String object,int resultLimit) { - String SPARQLquery = - "SELECT DISTINCT * WHERE { \n " + - "?subject " + - "<"+role+"> " + - "<" + object + "> \n" + - "} "+limit(resultLimit); - - return queryAsSet(SPARQLquery, "subject"); + public SortedSet<String> retrieveDISTINCTSubjectsForRoleAndObject( + String role, String object, int resultLimit) { + String SPARQLquery = "SELECT DISTINCT * WHERE { \n " + "?subject " + + "<" + role + "> " + "<" + object + "> \n" + "} " + + limit(resultLimit); + + return queryAsSet(SPARQLquery, "subject"); } - - public SortedSet<String> retrieveObjectsForSubjectAndRole(String subject, String role, int resultLimit) { - String SPARQLquery = - "SELECT DISTINCT * WHERE { \n " + - "<" +subject+ "> "+ - "<"+role+"> " + - " ?object \n" + - "} LIMIT "+resultLimit; - - return queryAsSet(SPARQLquery, "object"); + + public SortedSet<String> retrieveObjectsForSubjectAndRole(String subject, + String role, int resultLimit) { + String SPARQLquery = "SELECT DISTINCT * WHERE { \n " + "<" + subject + + "> " + "<" + role + "> " + " ?object \n" + "} LIMIT " + + resultLimit; + + return queryAsSet(SPARQLquery, "object"); } - + /** * all instances for a SKOS concept + * * @param SKOSconcept * @param resultLimit * @return */ - public SortedSet<String> retrieveInstancesForSKOSConcept(String SKOSconcept,int resultLimit) { - return queryPatternAsSet("?subject", "?predicate", "<"+SKOSconcept+">", "subject", resultLimit); - //return retrieveDISTINCTSubjectsForRoleAndObject("http://www.w3.org/2004/02/skos/core#subject", + public SortedSet<String> retrieveInstancesForSKOSConcept( + String SKOSconcept, int resultLimit) { + return queryPatternAsSet("?subject", "?predicate", "<" + SKOSconcept + + ">", "subject", resultLimit); + // return + // retrieveDISTINCTSubjectsForRoleAndObject("http://www.w3.org/2004/02/skos/core#subject", } - - - + /** * get all instances for a concept + * * @param conceptKBSyntax * @param sparqlResultLimit * @return */ - public SortedSet<String> retrieveInstancesForConcept (String conceptKBSyntax,int sparqlResultLimit) { - - String SPARQLquery = ""; - try{ - SPARQLquery = SparqlQueryDescriptionConvertVisitor - .getSparqlQuery(conceptKBSyntax,sparqlResultLimit); - }catch (Exception e) {e.printStackTrace();} - return queryAsSet(SPARQLquery, "subject"); + public SortedSet<String> retrieveInstancesForConcept( + String conceptKBSyntax, int sparqlResultLimit) { + + String SPARQLquery = ""; + try { + SPARQLquery = SparqlQueryDescriptionConvertVisitor.getSparqlQuery( + conceptKBSyntax, sparqlResultLimit); + } catch (Exception e) { + logger.warn(e.getMessage()); + } + return queryAsSet(SPARQLquery, "subject"); } - + /** * get all instances for a concept including RDFS Reasoning + * * @param conceptKBSyntax * @param sparqlResultLimit * @return */ - public SortedSet<String> retrieveInstancesForConceptIncludingSubclasses (String conceptKBSyntax,int sparqlResultLimit) { - - String SPARQLquery = ""; - try{ + public SortedSet<String> retrieveInstancesForConceptIncludingSubclasses( + String conceptKBSyntax, int sparqlResultLimit) { + + String SPARQLquery = ""; + try { SPARQLquery = SparqlQueryDescriptionConvertVisitor - .getSparqlQueryIncludingSubclasses(conceptKBSyntax,sparqlResultLimit,this,true); - - }catch (Exception e) {e.printStackTrace();} - return queryAsSet(SPARQLquery, "subject"); + .getSparqlQueryIncludingSubclasses(conceptKBSyntax, + sparqlResultLimit, this, true); + + } catch (Exception e) { + logger.warn(e.getMessage()); + } + return queryAsSet(SPARQLquery, "subject"); } - - - - + /** * get all direct Classes of an instance + * * @param instance * @param resultLimit * @return */ - public SortedSet<String> getClassesForInstance(String instance, int resultLimit) { - - String SPARQLquery = "SELECT ?subject WHERE { \n " + - "<" + instance + ">"+ - " a " + - "?subject " + - "\n" + - "} "+limit(resultLimit); - - return queryAsSet(SPARQLquery, "subject"); + public SortedSet<String> getClassesForInstance(String instance, + int resultLimit) { + + String SPARQLquery = "SELECT ?subject WHERE { \n " + "<" + instance + + ">" + " a " + "?subject " + "\n" + "} " + limit(resultLimit); + + return queryAsSet(SPARQLquery, "subject"); } - - - public SortedSet<String> getDomain(String role,int resultLimit){ - - String SPARQLquery = "" + - "SELECT DISTINCT ?domain " + - "WHERE { \n" + - "?domain <" + role + "> " + " ?o. \n" + - "?domain a []\n." + - "FILTER (!isLiteral(?domain))." + - "}\n" + limit(resultLimit); - + public SortedSet<String> getDomain(String role, int resultLimit) { + + String SPARQLquery = "SELECT DISTINCT ?domain " + "WHERE { \n" + + "?domain <" + role + "> " + " ?o. \n" + "?domain a []\n." + + "FILTER (!isLiteral(?domain))." + "}\n" + limit(resultLimit); + return queryAsSet(SPARQLquery, "domain"); - - + } - - - public SortedSet<String> getRange(String role,int resultLimit){ - - String SPARQLquery = "" + - "SELECT DISTINCT ?range " + - "WHERE { \n" + - "?s <" + role + "> " + " ?range. \n" + - "?range a [].\n" + - "FILTER (!isLiteral(?range))." + - "}\n" + limit(resultLimit); + public SortedSet<String> getRange(String role, int resultLimit) { + + String SPARQLquery = "SELECT DISTINCT ?range " + "WHERE { \n" + "?s <" + + role + "> " + " ?range. \n" + "?range a [].\n" + + "FILTER (!isLiteral(?range))." + "}\n" + limit(resultLimit); + return queryAsSet(SPARQLquery, "range"); - + } - - - + /** - * query a pattern with a standard SPARQL query - * usage (?subject, ?predicate, <http:something> , subject ) + * query a pattern with a standard SPARQL query usage (?subject, ?predicate, + * <http:something> , subject ) + * * @param subject * @param predicate * @param object * @param var * @return */ - public SortedSet<String> queryPatternAsSet(String subject, String predicate, String object, String var, int resultLimit){ - String SPARQLquery = "SELECT ?subject WHERE { \n " + - " " + subject + - " " + predicate + - " " + object + - " \n" + - "} "+limit(resultLimit); - return queryAsSet( SPARQLquery, var); - } - - - /** - * little higher level, executes query ,returns all resources for a variable + public SortedSet<String> queryPatternAsSet(String subject, + String predicate, String object, String var, int resultLimit) { + String SPARQLquery = "SELECT ?subject WHERE { \n " + " " + subject + + " " + predicate + " " + object + " \n" + "} " + + limit(resultLimit); + return queryAsSet(SPARQLquery, var); + } + + /** + * little higher level, executes query ,returns all resources for a variable + * * @param SPARQLquery * @param var * @return */ - public SortedSet<String> queryAsSet(String SPARQLquery, String var){ - ResultSet rs = null; - try { + public SortedSet<String> queryAsSet(String SPARQLquery, String var) { + ResultSet rs = null; + try { String JSON = query(SPARQLquery); rs = SparqlQuery.JSONtoResultSet(JSON); } catch (Exception e) { - e.printStackTrace(); + logger.warn(e.getMessage()); } - return getStringListForVariable(rs,var); - } - - + return getStringListForVariable(rs, var); + } + /** * low level, executes query returns ResultSet + * * @param SPARQLquery * @return jena ResultSet */ - public ResultSet queryAsResultSet(String SPARQLquery){ + public ResultSet queryAsResultSet(String SPARQLquery) { return SparqlQuery.JSONtoResultSet(query(SPARQLquery)); - + } - + /** - * low level, executes query returns JSON + * low level, executes query returns JSON + * * @param SPARQLquery * @return */ - public String query(String SPARQLquery){ - if(c==null){ - SparqlQuery sq = new SparqlQuery(SPARQLquery,se); -// sq.extraDebugInfo+=se.getURL(); + public String query(String SPARQLquery) { + String JSON; + if (cache == null) { + SparqlQuery sq = new SparqlQuery(SPARQLquery, sparqlEndpoint); sq.send(); - String JSON = sq.getJson(); - return JSON; - }else{ - return c.executeSparqlQuery(new SparqlQuery(SPARQLquery,se)); + JSON = sq.getJson(); + } else { + JSON = cache.executeSparqlQuery(new SparqlQuery(SPARQLquery, + sparqlEndpoint)); } - + return JSON; } - - private String limit(int resultLimit){ - if(resultLimit>0)return " LIMIT "+resultLimit; - return ""; + + private String limit(int resultLimit) { + return (resultLimit > 0) ? " LIMIT " + resultLimit : ""; } - - - public static SortedSet<String> getStringListForVariable(ResultSet rs, String var){ + + public static SortedSet<String> getStringListForVariable(ResultSet rs, + String var) { SortedSet<String> result = new TreeSet<String>(); - - //String s=ResultSetFormatter.asXMLString(this.rs); + + // String s=ResultSetFormatter.asXMLString(this.rs); @SuppressWarnings("unchecked") - List<ResultBinding> l = ResultSetFormatter.toList(rs); - + List<ResultBinding> l = ResultSetFormatter.toList(rs); + for (ResultBinding resultBinding : l) { result.add(resultBinding.get(var).toString()); } - + return result; - + } } Modified: trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-07-28 17:50:10 UTC (rev 1020) +++ trunk/src/dl-learner/org/dllearner/scripts/SKOS7030.java 2008-07-29 08:24:15 UTC (rev 1021) @@ -1,5 +1,26 @@ +/** + * 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.scripts; +import java.io.File; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -13,6 +34,7 @@ import org.apache.log4j.SimpleLayout; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.ComponentManager; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; @@ -26,6 +48,7 @@ import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegLP; import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.Files; import org.dllearner.utilities.JamonMonitorLogger; import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL; @@ -34,156 +57,192 @@ public class SKOS7030 { private static SPARQLTasks sparqlTasks; - + + private static LearningAlgorithm la; + + private static final long wash = 1216800000000L; + + private boolean stable = true; + + // private static long wash = 1216901570168 + private static Logger logger = Logger.getRootLogger(); - static boolean local = true; - static String url = ""; - - //LEARNING - static int recursiondepth=1; - static boolean closeAfterRecursion=true; - static boolean randomizeCache=false; - static double noise=15; + + static boolean local = true; + + static String url = ""; + + // LEARNING + static int recursiondepth = 1; + + static boolean closeAfterRecursion = true; + + static boolean randomizeCache = false; + + static double noise = 15; + static int maxExecutionTimeInSeconds = 30; + static int guaranteeXgoodDescriptions = 40; - - - //examples - static int sparqlResultSize=2000; - static double percentOfSKOSSet=0.2; - static double negfactor=1.0; + + // examples + static int sparqlResultSize = 2000; + + static double percentOfSKOSSet = 0.2; + + static double negfactor = 1.0; + SortedSet<String> posExamples = new TreeSet<String>(); + SortedSet<String> fullPositiveSet = new TreeSet<String>(); + SortedSet<String> fullPosSetWithoutPosExamples = new TreeSet<String>(); + SortedSet<String> negExamples = new TreeSet<String>(); - - - - - + /** * @param args */ public static void main(String[] args) { - System.out.println("Start"); - + logger.info("Start"); + // String resultString=""; + // System.out.println(time()); + // System.out.println(System.currentTimeMillis()); + initLogger(); - //parameters - - - if(local){ + // parameters + + if (local) { url = "http://139.18.2.37:8890/sparql"; - sparqlTasks = new SPARQLTasks(Cache.getPersistentCache(),SparqlEndpoint.EndpointLOCALDBpedia()); - }else{ + sparqlTasks = new SPARQLTasks(Cache.getPersistentCache(), + SparqlEndpoint.EndpointLOCALDBpedia()); + } else { url = "http://dbpedia.openlinksw.com:8890/sparql"; - sparqlTasks = new SPARQLTasks(Cache.getPersistentCache(),SparqlEndpoint.EndpointDBpedia()); + sparqlTasks = new SPARQLTasks(Cache.getPersistentCache(), + SparqlEndpoint.EndpointDBpedia()); } + + //System.out.println(sparqlTasks.getDomain( + // "http://dbpedia.org/property/predecessor", 1000)); - System.out.println(sparqlTasks.getDomain("http://dbpedia.org/property/predecessor", 1000)); - - String prim="http://dbpedia.org/resource/Category:Prime_Ministers_of_the_United_Kingdom"; - -// String award=("http://dbpedia.org/resource/Category:Best_Actor_Academy_Award_winners"); - - SKOS7030 s= new SKOS7030(); - - s.makeExamples(prim, percentOfSKOSSet, negfactor, sparqlResultSize); - - List<Description> conceptresults = s.learn(); - logger.debug("found nr of concepts: "+conceptresults.size()); + String target = "http://dbpedia.org/resource/Category:Prime_Ministers_of_the_United_Kingdom"; + + // String + // award=("http://dbpedia.org/resource/Category:Best_Actor_Academy_Award_winners"); + + SKOS7030 s = new SKOS7030(); + + s.makeExamples(target, percentOfSKOSSet, negfactor, sparqlResultSize); + + // System.exit(0); + List<Description> conceptresults = new ArrayList<Description>(); + List<EvaluatedDescription> conceptresults2 = new ArrayList<EvaluatedDescription>(); + s.learn(); + + recordConceptClasses(); + + System.exit(0); + + // EvaluatedDescription + logger.debug("found nr of concepts: " + conceptresults.size()); System.out.println(conceptresults); - - int x=0; - + + int x = 0; + SortedSet<ResultMostCoveredInRest> res = new TreeSet<ResultMostCoveredInRest>(); for (Description concept : conceptresults) { - if(x++==100)break; + if (x++ == 100) + break; res.add(s.evaluate(concept, 1000)); - + } - - x=0; + + x = 0; for (ResultMostCoveredInRest resultMostCoveredInRest : res) { - if(x++==10)break; + if (x++ == 10) + break; System.out.println(resultMostCoveredInRest.concept); System.out.println(resultMostCoveredInRest.accuracy); System.out.println(resultMostCoveredInRest.retrievedInstancesSize); - - + } - + s.print(res.first().concept, 1000); - + System.out.println("Finished"); JamonMonitorLogger.printAllSortedByLabel(); - - } - - void print(Description concept, int sparqlResultLimit){ - logger.debug("evaluating concept: "+concept); -// SortedSet<String> instances = sparqlTasks.retrieveInstancesForConcept(oneConcept.toKBSyntaxString(), sparqlResultLimit); - SortedSet<String> instances = - sparqlTasks.retrieveInstancesForConceptIncludingSubclasses( - concept.toKBSyntaxString(),sparqlResultLimit); - - SortedSet<String> coveredInRest = new TreeSet<String>(fullPosSetWithoutPosExamples); + + } + + void print(final Description concept, final int sparqlResultLimit) { + logger.debug("evaluating concept: " + concept); + // SortedSet<String> instances = + // sparqlTasks.retrieveInstancesForConcept(oneConcept.toKBSyntaxString(), + // sparqlResultLimit); + SortedSet<String> instances = sparqlTasks + .retrieveInstancesForConceptIncludingSubclasses(concept + .toKBSyntaxString(), sparqlResultLimit); + + SortedSet<String> coveredInRest = new TreeSet<String>( + fullPosSetWithoutPosExamples); coveredInRest.retainAll(instances); - - + SortedSet<String> coveredTotal = new TreeSet<String>(fullPositiveSet); coveredTotal.retainAll(instances); - - - SortedSet<String> notCoveredInRest = new TreeSet<String>(fullPosSetWithoutPosExamples); + + SortedSet<String> notCoveredInRest = new TreeSet<String>( + fullPosSetWithoutPosExamples); notCoveredInRest.retainAll(coveredInRest); System.out.println(notCoveredInRest); - + SortedSet<String> notCoveredTotal = new TreeSet<String>(fullPositiveSet); notCoveredTotal.retainAll(coveredTotal); System.out.println(notCoveredTotal); - + } - - ResultMostCoveredInRest evaluate(Description concept, int sparqlResultLimit){ - logger.debug("evaluating concept: "+concept); -// SortedSet<String> instances = sparqlTasks.retrieveInstancesForConcept(oneConcept.toKBSyntaxString(), sparqlResultLimit); - SortedSet<String> instances = - sparqlTasks.retrieveInstancesForConceptIncludingSubclasses( - concept.toKBSyntaxString(),sparqlResultLimit); - - SortedSet<String> coveredInRest = new TreeSet<String>(fullPosSetWithoutPosExamples); + + ResultMostCoveredInRest evaluate(Description concept, int sparqlResultLimit) { + logger.debug("evaluating concept: " + concept); + // SortedSet<String> instances = + // sparqlTasks.retrieveInstancesForConcept(oneConcept.toKBSyntaxString(), + // sparqlResultLimit); + SortedSet<String> instances = sparqlTasks + .retrieveInstancesForConceptIncludingSubclasses(concept + .toKBSyntaxString(), sparqlResultLimit); + + SortedSet<String> coveredInRest = new TreeSet<String>( + fullPosSetWithoutPosExamples); coveredInRest.retainAll(instances); - + SortedSet<String> coveredTotal = new TreeSet<String>(fullPositiveSet); coveredTotal.retainAll(instances); - - - SortedSet<String> notCoveredInRest = new TreeSet<String>(fullPosSetWithoutPosExamples); + + SortedSet<String> notCoveredInRest = new TreeSet<String>( + fullPosSetWithoutPosExamples); notCoveredInRest.retainAll(coveredInRest); - + SortedSet<String> notCoveredTotal = new TreeSet<String>(fullPositiveSet); notCoveredTotal.retainAll(coveredTotal); - double acc = (double) (coveredInRest.size() / fullPosSetWithoutPosExamples.size()); - System.out.println("Accuracy: "+acc); - return new ResultMostCoveredInRest(concept,acc,instances.size()); - - - - - + double acc = (double) (coveredInRest.size() / fullPosSetWithoutPosExamples + .size()); + System.out.println("Accuracy: " + acc); + return new ResultMostCoveredInRest(concept, acc, instances.size()); + } - - - - public static void initLogger() { - + + private static void initLogger() { + SimpleLayout layout = new SimpleLayout(); // create logger (a simple logger which outputs // its messages to the console) - FileAppender fileAppender =null; ; - try{ - fileAppender = new FileAppender(layout,"the_log.txt",false); - }catch (Exception e) {e.printStackTrace();} + FileAppender fileAppender = null; + ; + try { + fileAppender = new FileAppender(layout, "log/progress/skos" + + time() + ".txt", false); + } catch (Exception e) { + e.printStackTrace(); + } ConsoleAppender consoleAppender = new ConsoleAppender(layout); logger.removeAllAppenders(); @@ -191,253 +250,298 @@ logger.addAppender(fileAppender); logger.setLevel(Level.DEBUG); Logger.getLogger(KnowledgeSource.class).setLevel(Level.WARN); - + } - - /*public static SortedSet<String> selectDBpediaConcepts(int number){ - String query = "SELECT DISTINCT ?concept WHERE { \n" + - "[] a ?concept .FILTER (regex(str(?concept),'yago'))" + - " \n} \n"; //LIMIT "+number+" - - String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); - ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); - JenaResultSetConvenience rsc = new JenaResultSetConvenience(rs); - return SetManipulation.fuzzyShrink(rsc.getStringListForVariable("concept"),number); - }*/ - - public void makeExamples(String SKOSConcept, double percentOfSKOSSet , double negfactor, int sparqlResultSize){ - - //POSITIVES - AutomaticPositiveExampleFinderSPARQL apos = new AutomaticPositiveExampleFinderSPARQL(sparqlTasks); + /* + * public static SortedSet<String> selectDBpediaConcepts(int number){ + * String query = "SELECT DISTINCT ?concept WHERE { \n" + "[] a ?concept + * .FILTER (regex(str(?concept),'yago'))" + " \n} \n"; //LIMIT "+number+" + * + * String JSON = (c.executeSparqlQuery(new SparqlQuery(query, se))); + * ResultSet rs =SparqlQuery.JSONtoResultSet(JSON); JenaResultSetConvenience + * rsc = new JenaResultSetConvenience(rs); return + * SetManipulation.fuzzyShrink(rsc.getStringListForVariable("concept"),number); } + */ + + public void makeExamples(String SKOSConcept, double percentOfSKOSSet, + double negfactor, int sparqlResultSize) { + + // POSITIVES + AutomaticPositiveExampleFinderSPARQL apos = new AutomaticPositiveExampleFinderSPARQL( + sparqlTasks); apos.makePositiveExamplesFromSKOSConcept(SKOSConcept); - fullPositiveSet = apos.getPosExamples(); - - //System.exit(0); - - int poslimit=(int)Math.round(percentOfSKOSSet*fullPositiveSet.size()); - int neglimit=(int)Math.round(poslimit*negfactor); - - this.posExamples = SetManipulation.fuzzyShrink(fullPositiveSet,poslimit); - - - - //NEGATIVES - - AutomaticNegativeExampleFinderSPARQL aneg = new AutomaticNegativeExampleFinderSPARQL(fullPositiveSet,sparqlTasks); - - aneg.makeNegativeExamplesFromParallelClasses(posExamples, sparqlResultSize); - this.negExamples = aneg.getNegativeExamples(neglimit); - + fullPositiveSet = apos.getPosExamples(); + + // System.exit(0); + + int poslimit = (int) Math.round(percentOfSKOSSet + * fullPositiveSet.size()); + int neglimit = (int) Math.round(poslimit * negfactor); + + posExamples = SetManipulation.fuzzyShrink(fullPositiveSet, poslimit); + + // NEGATIVES + + AutomaticNegativeExampleFinderSPARQL aneg = new AutomaticNegativeExampleFinderSPARQL( + fullPositiveSet, sparqlTasks); + + aneg.makeNegativeExamplesFromParallelClasses(posExamples, + sparqlResultSize); + negExamples = aneg.getNegativeExamples(neglimit, stable); + logger.debug("POSITIVE EXAMPLES"); for (String pos : posExamples) { - logger.debug("+"+pos); + logger.debug("+" + pos); } - + logger.debug("NEGATIVE EXAMPLES"); for (String negs : this.negExamples) { - logger.debug("-"+negs); + logger.debug("-" + negs); } - - - + fullPosSetWithoutPosExamples = fullPositiveSet; fullPosSetWithoutPosExamples.removeAll(posExamples); - - + logger.debug(fullPositiveSet); logger.debug(fullPosSetWithoutPosExamples); } - - public List<Description> learn(){ - + + public void learn() { + SortedSet<String> instances = new TreeSet<String>(); instances.addAll(this.posExamples); instances.addAll(this.negExamples); - - + logger.info("Start Learning with"); - logger.info("positive examples: \t"+posExamples.size()); - logger.info("negative examples: \t"+negExamples.size()); - logger.info("instances \t"+instances.size()); - - - - - + logger.info("positive examples: \t" + posExamples.size()); + logger.info("negative examples: \t" + negExamples.size()); + logger.info("instances \t" + instances.size()); + ComponentManager cm = ComponentManager.getInstance(); - LearningAlgorithm la = null; + // LearningAlgorithm la = null; ReasoningService rs = null; - LearningProblem lp = null; - SparqlKnowledgeSource ks =null; + LearningProblem lp = null; + SparqlKnowledgeSource ks = null; try { - Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); - ks = cm.knowledgeSource(SparqlKnowledgeSource.class); - ReasonerComponent r = new FastInstanceChecker(sources); - rs = new ReasoningService(r); - //System.out.println("satisfy: "+rs.isSatisfiable()); - lp = new PosNegDefinitionLP(rs); - ((PosNegLP) lp).setPositiveExamples(SetManipulation.stringToInd(this.posExamples)); - ((PosNegLP) lp).setNegativeExamples(SetManipulation.stringToInd(this.negExamples)); - - la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); + Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); + ks = cm.knowledgeSource(SparqlKnowledgeSource.class); + ReasonerComponent r = new FastInstanceChecker(sources); + rs = new ReasoningService(r); + // System.out.println("satisfy: "+rs.isSatisfiable()); + lp = new PosNegDefinitionLP(rs); + ((PosNegLP) lp).setPositiveExamples(SetManipulation + .stringToInd(this.posExamples)); + ((PosNegLP) lp).setNegativeExamples(SetManipulation + .stringToInd(this.negExamples)); - logger.debug("start learning"); - - - //KNOWLEDGESOURCE - cm.applyConfigEntry(ks, "instances",instances); - cm.applyConfigEntry(ks, "url",url); - cm.applyConfigEntry(ks, "recursionDepth",recursiondepth); - cm.applyConfigEntry(ks, "closeAfterRecursion",closeAfterRecursion); - cm.applyConfigEntry(ks, "predefinedFilter","YAGO"); - if(local) - cm.applyConfigEntry(ks, "predefinedEndpoint","LOCALDBPEDIA"); - else { - cm.applyConfigEntry(ks, "predefinedEndpoint","DBPEDIA"); + la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); + + logger.debug("start learning"); + + // KNOWLEDGESOURCE + cm.applyConfigEntry(ks, "instances", instances); + cm.applyConfigEntry(ks, "url", url); + cm.applyConfigEntry(ks, "recursionDepth", recursiondepth); + cm.applyConfigEntry(ks, "closeAfterRecursion", closeAfterRecursion); + cm.applyConfigEntry(ks, "predefinedFilter", "YAGO"); + if (local) + cm.applyConfigEntry(ks, "predefinedEndpoint", "LOCALDBPEDIA"); + else { + cm.applyConfigEntry(ks, "predefinedEndpoint", "DBPEDIA"); + } + if (randomizeCache) + cm.applyConfigEntry(ks, "cacheDir", "cache/" + + System.currentTimeMillis() + ""); + else { + cm.applyConfigEntry(ks, "cacheDir", Cache.getDefaultCacheDir()); + } + + // LEARNINGALGORITHM + cm.applyConfigEntry(la, "useAllConstructor", false); + cm.applyConfigEntry(la, "useExistsConstructor", true); + cm.applyConfigEntry(la, "useCardinalityRestrictions", false); + cm.applyConfigEntry(la, "useNegation", false); + cm.applyConfigEntry(la, "minExecutionTimeInSeconds", 0); + cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", + maxExecutionTimeInSeconds); + cm.applyConfigEntry(la, "guaranteeXgoodDescriptions", + guaranteeXgoodDescriptions); + cm.applyConfigEntry(la, "writeSearchTree", false); + cm.applyConfigEntry(la, "searchTreeFile", "log/SKOS.txt"); + cm.applyConfigEntry(la, "replaceSearchTree", true); + cm.applyConfigEntry(la, "noisePercentage", noise); + // cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); + cm.applyConfigEntry(la, "logLevel", "TRACE"); + /* + * if(ignoredConcepts.size()>0) + * cm.applyConfigEntry(la,"ignoredConcepts",ignoredConcepts); + */ + + ks.init(); + sources.add(ks); + r.init(); + lp.init(); + la.init(); + + la.start(); + // Statistics.addTimeCollecting(sc.getTime()); + // Statistics.addTimeLearning(sc.getTime()); + + // return la.getCurrentlyBestDescriptions(); + + } catch (Exception e) { + e.printStackTrace(); } - if(randomizeCache) - cm.applyConfigEntry(ks, "cacheDir","cache/"+System.currentTimeMillis()+""); - else {cm.applyConfigEntry(ks, "cacheDir",Cache.getDefaultCacheDir());} - - //LEARNINGALGORITHM - cm.applyConfigEntry(la,"useAllConstructor",false); - cm.applyConfigEntry(la,"useExistsConstructor",true); - cm.applyConfigEntry(la,"useCardinalityRestrictions",false); - cm.applyConfigEntry(la,"useNegation",false); - cm.applyConfigEntry(la,"minExecutionTimeInSeconds",0); - cm.applyConfigEntry(la,"maxExecutionTimeInSeconds",maxExecutionTimeInSeconds); - cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",guaranteeXgoodDescriptions); - cm.applyConfigEntry(la,"writeSearchTree",false); - cm.applyConfigEntry(la,"searchTreeFile","log/SKOS.txt"); - cm.applyConfigEntry(la,"replaceSearchTree",true); - cm.applyConfigEntry(la,"noisePercentage",noise); - //cm.applyConfigEntry(la,"guaranteeXgoodDescriptions",999999); - cm.applyConfigEntry(la,"logLevel","TRACE"); - /*if(ignoredConcepts.size()>0) - cm.applyConfigEntry(la,"ignoredConcepts",ignoredConcepts); - */ - - ks.init(); - sources.add(ks); - r.init(); - lp.init(); - la.init(); - - - la.start(); - //Statistics.addTimeCollecting(sc.getTime()); - //Statistics.addTimeLearning(sc.getTime()); - - - return la.getCurrentlyBestDescriptions(); - - }catch (Exception e) {e.printStackTrace();} - return null; - + // return null; + } - -// String t="\"http://dbpedia.org/class/yago/Fiction106367107\""; -// t="(\"http://dbpedia.org/class/yago/HeadOfState110164747\" AND (\"http://dbpedia.org/class/yago/Negotiator110351874\" AND \"http://dbpedia.org/class/yago/Representative110522035\"))"; -// //System.out.println(t); -// //t="\"http://www.w3.org/2004/02/skos/core#subject\""; -// //conceptRewrite(t); -// //getSubClasses(t); -// -// AutomaticExampleFinderSKOSSPARQL ae= new AutomaticExampleFinderSKOSSPARQL( se); -// try{ -// System.out.println("oneconcept: "+t); -// SortedSet<String> instances = ae.queryConceptAsStringSet(conceptRewrite(t), 200); -// if(instances.size()>=0)System.out.println("size of instances "+instances.size()); -// if(instances.size()>=0 && instances.size()<100) System.out.println("instances"+instances); -// }catch (Exception e) { -// e.printStackTrace(); -// } - //SortedSet<String> concepts = new TreeSet<String>(); - - - - //System.out.println(DBpediaSKOS(prim)); -// double acc1=0.0; -// for (int i = 0; i < 5; i++) { -// acc1+=DBpediaSKOS(prim); -// } -// System.out.println("accprim"+(acc1/5)); -// -// double acc2=0.0; -// for (int i = 0; i < 5; i++) { -// acc2+=DBpediaSKOS(award); -// } -// System.out.println("accprim"+(acc2/5)); - -// DBpediaSKOS(concepts.first()); -// DBpediaSKOS(concepts.first()); -// concepts.remove(concepts.first()); -// DBpediaSKOS(concepts.first()); -// DBpediaSKOS(concepts.first()); -// concepts.remove(concepts.first()); -// DBpediaSKOS(concepts.first()); -// DBpediaSKOS(concepts.first()); - //algorithm="refinement"; - //roles(); - - /*System.out.println(Level.DEBUG.getClass()); - System.out.println(Level.toLevel("INFO")); - System.out.println(Level.INFO);*/ - //System.exit(0); - - private class ResultCompare implements Comparable<ResultCompare>{ - Description concept ; + // String t="\"http://dbpedia.org/class/yago/Fiction106367107\""; + // t="(\"http://dbpedia.org/class/yago/HeadOfState110164747\" AND + // (\"http://dbpedia.org/class/yago/Negotiator110351874\" AND + // \"http://dbpedia.org/class/yago/Representative110522035\"))"; + // //System.out.println(t); + // //t="\"http://www.w3.org/2004/02/skos/core#subject\""; + // //conceptRewrite(t); + // //getSubClasses(t); + // + // AutomaticExampleFinderSKOSSPARQL ae= new + // AutomaticExampleFinderSKOSSPARQL( se); + // try{ + // System.out.println("oneconcept: "+t); + // SortedSet<String> instances = + // ae.queryConceptAsStringSet(conceptRewrite(t), 200); + // if(instances.size()>=0)System.out.println("size of instances + // "+instances.size()); + // if(instances.size()>=0 && instances.size()<100) + // System.out.println("instances"+instances); + // }catch (Exception e) { + // e.printStackTrace(); + // } + // SortedSet<String> concepts = new TreeSet<String>(); + + // System.out.println(DBpediaSKOS(prim)); + // double acc1=0.0; + // for (int i = 0; i < 5; i++) { + // acc1+=DBpediaSKOS(prim); + // } + // System.out.println("accprim"+(acc1/5)); + // + // double acc2=0.0; + // for (int i = 0; i < 5; i++) { + // acc2+=DBpediaSKOS(award); + // } + // System.out.println("accprim"+(acc2/5)); + + // DBpediaSKOS(concepts.first()); + // DBpediaSKOS(concepts.first()); + // concepts.remove(concepts.first()); + // DBpediaSKOS(concepts.first()); + // DBpediaSKOS(concepts.first()); + // concepts.remove(concepts.first()); + // DBpediaSKOS(concepts.first()); + // DBpediaSKOS(concepts.first()); + // algorithm="refinement"; + // roles(); + + /* + * System.out.println(Level.DEBUG.getClass()); + * System.out.println(Level.toLevel("INFO")); + * System.out.println(Level.INFO); + */ + // System.exit(0); + private class ResultCompare implements Comparable<ResultCompare> { + Description concept; + double accuracy = 0.0; - int retrievedInstancesSize=0; - + + int retrievedInstancesSize = 0; + public int compareTo(ResultCompare o2) { return 0; } - public boolean equals(ResultCompare o2){ + + public boolean equals(ResultCompare o2) { return this.concept.equals(o2.concept); } - - - public ResultCompare(Description conceptKBSyntax, double accuracy, int retrievedInstancesSize) { + + public ResultCompare(Description conceptKBSyntax, double accuracy, + int retrievedInstancesSize) { super(); this.concept = conceptKBSyntax; this.accuracy = accuracy; this.retrievedInstancesSize = retrievedInstancesSize; } - - + } - - private class ResultMostCoveredInRest extends ResultCompare{ - + + private class ResultMostCoveredInRest extends ResultCompare { + public ResultMostCoveredInRest(Description concept, double accuracy, int retrievedInstancesSize) { super(concept, accuracy, retrievedInstancesSize); - + } public int compareTo(ResultMostCoveredInRest o2) { - if(this.equals(o2))return 0; - - if(this.accuracy > o2.accuracy){ + if (this.equals(o2)) + return 0; + + if (this.accuracy > o2.accuracy) { return 1; - } - else if(this.accuracy == o2.accuracy) { - if(this.retrievedInstancesSize < o2.retrievedInstancesSize ) + } else if (this.accuracy == o2.accuracy) { + if (this.retrievedInstancesSize < o2.retrievedInstancesSize) return 1; - else if(this.retrievedInstancesSize > o2.retrievedInstancesSize){ + else if (this.retrievedInstancesSize > o2.retrievedInstancesSize) { return -1; - } - else return this.concept.toKBSyntaxString().compareTo(o2.concept.toKBSyntaxString()); - }else { + } else + return this.concept.toKBSyntaxString().compareTo( + o2.concept.toKBSyntaxString()); + } else { return -1; } - + } - + } - - + + public static String time() { + return ("" + (System.currentTimeMillis() - wash)).substring(0, 7); + + } + + public static void recordConceptClasses() { + String result = ""; + String result1 = "\n\n ***********Entity*****\n"; + String result2 = "\n\n ***********OR*****\n"; + int result1count = 1; + int result2count = 1; + List<EvaluatedDescription> conceptresults = la + .getCurrentlyBestEvaluatedDescriptions(5000, .70, true); + + int x = 0; + for (EvaluatedDescription description : conceptresults) { + if (x < 50) { + x++; + result += description + "\n"; + } + + if (!description.toString().contains("Entity")) { + result1 += description + "\n"; + result1count++; + } + if (!description.toString().contains("OR")) { + result2 += description + "\n"; + result2count++; + } + } + result += "full size: " + conceptresults.size() + ""; + result += result1 + " size: " + result1count + "\n"; + result += result2 + " size: " + result2count + "\n"; + + Files.createFile(new File("results/descriptions/concepts" + time() + + ".txt"), result); + } + } Modified: trunk/src/dl-learner/org/dllearner/utilities/datastructures/SetManipulation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/datastructures/SetManipulation.java 2008-07-28 17:50:10 UTC (rev 1020) +++ trunk/src/dl-learner/org/dllearner/utilities/datastructures/SetManipulation.java 2008-07-29 08:24:15 UTC (rev 1021) @@ -11,7 +11,7 @@ /** * shrinks a set to the limit - * size will be roughly the same as limit, but can be more or less a bit + * fuzzy here means the elements will be randomly picked * @param set * @param limit * @return @@ -37,6 +37,27 @@ return ret; } + /** + * shrinks a set to the limit + * takes the first elements up to limit + * @param set + * @param limit + * @return + */ + public static SortedSet<String> stableShrink(SortedSet<String> set, int limit) { + if (set.size()<=limit)return set; + SortedSet<String> ret = new TreeSet<String>(); + + + for (String oneInd : set) { + ret.add(oneInd); + if(ret.size()>= limit)break; + + } + + return ret; + } + public static SortedSet<Individual> stringToInd(SortedSet<String> set ){ SortedSet<Individual> ret = new TreeSet<Individual>(); for (String ind : set) { Modified: trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java 2008-07-28 17:50:10 UTC (rev 1020) +++ trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java 2008-07-29 08:24:15 UTC (rev 1021) @@ -1,3 +1,22 @@ +/** + * 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.utilities.examples; import java.util.SortedSet; @@ -15,6 +34,7 @@ private SPARQLTasks sparqltasks; + private SortedSet<String> fullPositiveSet; private SortedSet<String> fromRelated = new TreeSet<String>(); @@ -42,21 +62,29 @@ } - + public SortedSet<String> getNegativeExamples(int neglimit ) { + return getNegativeExamples(neglimit, false); + } /** * aggregates all collected neg examples - * @param neglimit + * @param neglimit size of negative Example set + * @param stable decides whether neg Examples are randomly picked, default false, faster for developing * @return */ - public SortedSet<String> getNegativeExamples(int neglimit ) { + public SortedSet<String> getNegativeExamples(int neglimit, boolean stable ) { SortedSet<String> negatives = new TreeSet<String>(); negatives.addAll(fromParallelClasses); negatives.addAll(fromRelated); negatives.addAll(fromSuperclasses); logger.debug("neg Example size before shrinking: " + negatives.size()); - negatives = SetManipulation.fuzzyShrink(negatives,neglimit); + if (stable) { + negatives = SetManipulation.stableShrink(negatives,neglimit); + } + else { + negatives = SetManipulation.fuzzyShrink(negatives,neglimit); + } logger.debug("neg Example size after shrinking: " + negatives.size()); return negatives; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-07-28 17:50:15
|
Revision: 1020 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1020&view=rev Author: jenslehmann Date: 2008-07-28 17:50:10 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Javadoc improvements and small fixes Modified Paths: -------------- trunk/build.xml trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/Component.java trunk/src/dl-learner/org/dllearner/core/ComponentManager.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2008-07-28 09:21:08 UTC (rev 1019) +++ trunk/build.xml 2008-07-28 17:50:10 UTC (rev 1020) @@ -262,7 +262,7 @@ use="true" version="true" linksource="true" - bottom="<img style='float:right' src='http://sflogo.sourceforge.net/sflogo.php?group_id=203619&type=1' width='88' height='31' border='0' alt='SourceForge.net Logo' /> DL-Learner is licenced under the terms of the GNU General Public License.<br />Copyright &#169; 2007 Jens Lehmann" + bottom="<img style='float:right' src='http://sflogo.sourceforge.net/sflogo.php?group_id=203619&type=1' width='88' height='31' border='0' alt='SourceForge.net Logo' /> DL-Learner is licenced under the terms of the GNU General Public License.<br />Copyright &#169; 2007-2008 Jens Lehmann" Encoding="ISO-8859-1" windowtitle="DL-Learner Javadoc"> <link href="http://java.sun.com/javase/6/docs/api/"/> Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-07-28 09:21:08 UTC (rev 1019) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-07-28 17:50:10 UTC (rev 1020) @@ -769,6 +769,16 @@ return rs; } + public static String getCLIMapping(String componentSuperClass){ + HashMap<String, String> m = new HashMap<String, String>(); + m.put("KnowledgeSource", "import"); + m.put("ReasonerComponent", "reasoner"); + m.put("PosNegLP", "problem"); + m.put("PosOnlyLP", "problem"); + m.put("LearningAlgorithm", "algorithm"); + return m.get(componentSuperClass); + } + /** * Set Reasoner class. Define here all possible reasoners. * Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2008-07-28 09:21:08 UTC (rev 1019) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2008-07-28 17:50:10 UTC (rev 1020) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -27,7 +27,7 @@ import org.dllearner.core.config.InvalidConfigOptionValueException; /** - * General component base class. + * Base class of all components. See also http://dl-learner.org/wiki/Architecture. * * @author Jens Lehmann * @@ -35,7 +35,9 @@ public abstract class Component { /** - * + * Returns the name of this component. By default, "unnamed + * component" is returned, but all implementations of components + * are strongly encouraged to overwrite this method. * @return The name of this component. */ public static String getName() { @@ -44,6 +46,8 @@ /** * Returns all configuration options supported by this component. + * @return A list of supported configuration options for this + * component. */ public static Collection<ConfigOption<?>> createConfigOptions() { return new LinkedList<ConfigOption<?>>(); @@ -51,11 +55,16 @@ /** * Method to be called after the component has been configured. + * Implementation of components can overwrite this method to + * perform setup and initialisation tasks for this component. */ public abstract void init() throws ComponentInitException; /** - * Applies a configuration option to this component. + * Applies a configuration option to this component. Implementations + * of components should use option and value of the config entry to + * perform an action (usually setting an internal variable to + * an appropriate value). * * @param entry A configuration entry. */ Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-07-28 09:21:08 UTC (rev 1019) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-07-28 17:50:10 UTC (rev 1020) @@ -135,7 +135,6 @@ } } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -169,7 +168,7 @@ } /** - * + * Gets the singleton instance of <code>ComponentManager</code>. * @return The singleton <code>ComponentManager</code> instance. */ public static ComponentManager getInstance() { @@ -301,6 +300,17 @@ return ks; } + /** + * Factory method for creating a reasoner component from a single + * knowledge source. Example + * call: reasoner(OWLAPIReasoner.class, ks) where ks is a + * knowledge source object. + * @see #reasoner(Class, Set) + * @param <T> The type of this method is a subclass of reasoner component. + * @param reasoner A class object, where the class is subclass of ReasonerComponent. + * @param source A knowledge source. + * @return A reasoner component. + */ public <T extends ReasonerComponent> T reasoner(Class<T> reasoner, KnowledgeSource source) { Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); @@ -308,6 +318,15 @@ return reasoner(reasoner, sources); } + /** + * Factory method for creating a reasoner component from a set of + * knowledge sources. + * @see #reasoner(Class, KnowledgeSource) + * @param <T> The type of this method is a subclass of reasoner component. + * @param reasoner A class object, where the class is subclass of ReasonerComponent. + * @param sources A set of knowledge sources. + * @return A reasoner component. + */ public <T extends ReasonerComponent> T reasoner(Class<T> reasoner, Set<KnowledgeSource> sources) { if (!reasonerComponents.contains(reasoner)) @@ -336,6 +355,13 @@ return new ReasoningService(reasoner); } + /** + * Factory method for creating a learning problem component. + * @param <T> The type of this method is a subclass of learning problem. + * @param lpClass A class object, where the class is a subclass of learning problem. + * @param reasoner A reasoning service object. + * @return A learning problem component. + */ public <T extends LearningProblem> T learningProblem(Class<T> lpClass, ReasoningService reasoner) { if (!learningProblems.contains(lpClass)) System.err.println("Warning: learning problem " + lpClass @@ -347,7 +373,17 @@ return lp; } - // automagically calls the right constructor for the given learning problem + /** + * Factory method for creating a learning algorithm, which + * automagically calls the right constructor for the given problem. + * @param <T> The type of this method is a subclass of learning algorithm. + * @param laClass A class object, where the class is subclass of learning algorithm. + * @param lp A learning problem, which the algorithm should try to solve. + * @param rs A reasoning service for querying the background knowledge of this learning problem. + * @return A learning algorithm component. + * @throws LearningProblemUnsupportedException Thrown when the learning problem and + * the learning algorithm are not compatible. + */ public <T extends LearningAlgorithm> T learningAlgorithm(Class<T> laClass, LearningProblem lp, ReasoningService rs) throws LearningProblemUnsupportedException { if (!learningAlgorithms.contains(laClass)) System.err.println("Warning: learning algorithm " + laClass @@ -360,7 +396,7 @@ if (problemClass.isAssignableFrom(lp.getClass())) constructorArgument = problemClass; } - + if (constructorArgument == null) { throw new LearningProblemUnsupportedException(lp.getClass(), laClass, algorithmProblemsMapping.get(laClass)); // System.err.println("Warning: No suitable constructor registered for algorithm " @@ -387,10 +423,28 @@ pool.unregisterComponent(component); } + /** + * Frees all references to components created by <code>ComponentManager</code>. + * @see #freeComponent(Component) + */ public void freeAllComponents() { pool.clearComponents(); } + /** + * Gets the value of a config option of the specified component. + * This is done by first checking, which value the given option + * was set to using {@link #applyConfigEntry(Component, ConfigEntry)}. + * If the value has not been changed, the default value for this + * option is returned. Note, that this method will not work properly + * if the component options are changed internally surpassing the + * component manager (which is discouraged). + * + * @param <T> The type of the config option, e.g. String, boolean, integer. + * @param component The component, which has the specified option. + * @param option The option for which we want to know its value. + * @return The value of the specified option in the specified component. + */ public <T> T getConfigOptionValue(Component component, ConfigOption<T> option) { T object = pool.getLastValidConfigValue(component, option); if(object==null) @@ -399,12 +453,30 @@ return object; } + /** + * Works as {@link #getConfigOptionValue(Component, ConfigOption)}, + * but using the name of the option instead of a <code>ConfigOption</code> + * object. + * @see #getConfigOptionValue(Component, ConfigOption) + * @param component A component. + * @param optionName A valid option name for this component. + * @return The value of the specified option in the specified component. + */ public Object getConfigOptionValue(Component component, String optionName) { ConfigOption<?> option = (ConfigOption<?>) componentOptionsByName.get( component.getClass()).get(optionName); return getConfigOptionValue(component, option); } + /** + * Writes documentation for all components available in this + * <code>ComponentManager</code> instance. It goes through + * all components (sorted by their type) and all the configuration + * options of the components. Explanations, default values, allowed + * values for the options are collected and the obtained string is + * written in a file. + * @param file The documentation file. + */ public void writeConfigDocumentation(File file) { String doc = ""; doc += "This file contains an automatically generated files of all components and their config options.\n\n"; @@ -440,7 +512,7 @@ private String getComponentConfigString(Class<? extends Component> component) { String componentDescription = "component: " + invokeStaticMethod(component,"getName") + " (" + component.getName() + ")"; String str = componentDescription + "\n"; - String CLI = getCLIMapping(component.getSuperclass().getSimpleName()+""); + String CLI = Start.getCLIMapping(component.getSuperclass().getSimpleName()+""); String usage =""; Map<Class<? extends Component>, String> m=Start.createComponentPrefixMapping(); @@ -466,17 +538,9 @@ return str+"\n"; } - public static String getCLIMapping(String componentSuperClass){ - HashMap<String, String> m = new HashMap<String, String>(); - m.put("KnowledgeSource", "import"); - m.put("ReasonerComponent", "reasoner"); - m.put("PosNegLP", "problem"); - m.put("PosOnlyLP", "problem"); - m.put("LearningAlgorithm", "algorithm"); - return m.get(componentSuperClass); - } - - + // convenience method for invoking a static method; + // used as a central point for exception handling for Java reflection + // static method calls private Object invokeStaticMethod(Class<?> clazz, String methodName, Object... args) { // unfortunately Java does not seem to offer a way to call // a static method given a class object directly, so we have @@ -485,53 +549,49 @@ Method method = clazz.getMethod(methodName); return method.invoke(null, args); } catch (SecurityException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { - // TODO Auto-generated catch block e.printStackTrace(); } return null; } + // convenience method for invoking a constructor; + // used as a central point for exception handling for Java reflection + // constructor calls private <T> T invokeConstructor(Class<T> clazz, Class<?>[] argumentClasses, Object[] argumentObjects) { try { Constructor<T> constructor = clazz.getConstructor(argumentClasses); return constructor.newInstance(argumentObjects); } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block e.printStackTrace(); } - return null; } + /** + * Returns the available options of the specified component. + * @param componentClass The class object of a component. + * @return A list of available configuration options of the specified component. + */ public static List<ConfigOption<?>> getConfigOptions(Class<? extends Component> componentClass) { if (!components.contains(componentClass)) System.err.println("Warning: component " + componentClass @@ -539,44 +599,71 @@ return componentOptions.get(componentClass); } + /** + * Returns a <code>ConfigOption</code> object given a component and + * the option name. + * @param component A component class object. + * @param name A valid configuration option name for the component. + * @return A <code>ConfigOption</code> object for the specified component class and option name. + */ public ConfigOption<?> getConfigOption(Class<? extends Component> component, String name) { return componentOptionsByName.get(component).get(name); } + /** + * Returns the name of a component. + * @param component A component class object. + * @return The name of the component. + */ public String getComponentName(Class<? extends Component> component) { return componentNames.get(component); } /** - * @return the components + * Returns a list of all available components in this instance + * of <code>ComponentManager</code>. + * @return the components A list of component classes available in this + * instance of <code>ComponentManager</code>. */ public List<Class<? extends Component>> getComponents() { return new LinkedList<Class<? extends Component>>(components); } /** - * @return the knowledgeSources + * Returns a list of all available knowledge sources in this instance + * of <code>ComponentManager</code>. + * @return the components A list of knowledge source component classes available in this + * instance of <code>ComponentManager</code>. */ public List<Class<? extends KnowledgeSource>> getKnowledgeSources() { return new LinkedList<Class<? extends KnowledgeSource>>(knowledgeSources); } /** - * @return the reasonerComponents - */ + * Returns a list of all available reasoners in this instance + * of <code>ComponentManager</code>. + * @return the components A list of reasoner component classes available in this + * instance of <code>ComponentManager</code>. + */ public List<Class<? extends ReasonerComponent>> getReasonerComponents() { return new LinkedList<Class<? extends ReasonerComponent>>(reasonerComponents); } /** - * @return the learningProblems - */ + * Returns a list of all available learning problems in this instance + * of <code>ComponentManager</code>. + * @return the components A list of learning problem classes available in this + * instance of <code>ComponentManager</code>. + */ public List<Class<? extends LearningProblem>> getLearningProblems() { return new LinkedList<Class<? extends LearningProblem>>(learningProblems); } /** - * @return the learningAlgorithms + * Returns a list of all available learning algorithms in this instance + * of <code>ComponentManager</code>. + * @return the components A list of learning algorithm classes available in this + * instance of <code>ComponentManager</code>. */ public List<Class<? extends LearningAlgorithm>> getLearningAlgorithms() { return new LinkedList<Class<? extends LearningAlgorithm>>(learningAlgorithms); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-07-28 09:21:14
|
Revision: 1019 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1019&view=rev Author: jenslehmann Date: 2008-07-28 09:21:08 +0000 (Mon, 28 Jul 2008) Log Message: ----------- - added isRunning() method to abstract learning algorithm class - removed getReasoningService() from learning problem base class and changed all affected classes - documentation improvements Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.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/Component.java trunk/src/dl-learner/org/dllearner/core/ComponentInitException.java trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/core/LearningProblem.java trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Description.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.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/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/BruteForceLearner.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -59,6 +59,7 @@ public class BruteForceLearner extends LearningAlgorithm { private LearningProblem learningProblem; + private ReasoningService rs; private Description bestDefinition; private Score bestScore; @@ -67,12 +68,14 @@ private String returnType; private boolean stop = false; + private boolean isRunning = false; // list of all generated concepts sorted by length private Map<Integer,List<Description>> generatedDefinitions = new HashMap<Integer,List<Description>>(); public BruteForceLearner(LearningProblem learningProblem, ReasoningService rs) { this.learningProblem = learningProblem; + this.rs = rs; } public static String getName() { @@ -121,6 +124,7 @@ @Override public void start() { + isRunning = true; // FlatABox abox = FlatABox.getInstance(); System.out.print("Generating definitions up to length " + maxLength + " ... "); @@ -148,7 +152,7 @@ //System.out.println("false negatives: " + Helper.intersection(bestDefNegSet,posExamples)); //System.out.print("Score: " + bestScore + " Max: " + maxScore + " Difference: " + (maxScore-bestScore)); //System.out.println(" Accuracy: " + df.format((double)bestScore/maxScore*100) + "%"); - + isRunning = false; } private void testGeneratedDefinitions(int maxLength) { @@ -203,7 +207,7 @@ if(length==1) { generatedDefinitions.get(1).add(new Thing()); generatedDefinitions.get(1).add(new Nothing()); - for(NamedClass atomicConcept : learningProblem.getReasoningService().getAtomicConcepts()) { + for(NamedClass atomicConcept : rs.getAtomicConcepts()) { generatedDefinitions.get(1).add(atomicConcept); } } @@ -261,7 +265,7 @@ // EXISTS and ALL for(Description childNode : generatedDefinitions.get(length-2)) { - for(ObjectProperty atomicRole : learningProblem.getReasoningService().getAtomicRoles()) { + for(ObjectProperty atomicRole : rs.getAtomicRoles()) { Description root1 = new ObjectSomeRestriction(atomicRole,childNode); generatedDefinitions.get(length).add(root1); @@ -310,4 +314,12 @@ } + /* (non-Javadoc) + * @see org.dllearner.core.LearningAlgorithm#isRunning() + */ + @Override + public boolean isRunning() { + return isRunning; + } + } Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -177,4 +177,13 @@ // TODO Auto-generated method stub } + + /* (non-Javadoc) + * @see org.dllearner.core.LearningAlgorithm#isRunning() + */ + @Override + public boolean isRunning() { + // TODO Auto-generated method stub + return false; + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/RandomGuesser.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -42,6 +42,7 @@ private Score bestScore; private double bestFitness = Double.NEGATIVE_INFINITY; private LearningProblem learningProblem; + private ReasoningService rs; private int numberOfTrees; private int maxDepth; @@ -49,6 +50,7 @@ public RandomGuesser(LearningProblem learningProblem, ReasoningService rs) { this.learningProblem = learningProblem; + this.rs = rs; } public static String getName() { @@ -99,7 +101,7 @@ for(int i=0; i<numberOfTrees; i++) { // p = GPUtilities.createGrowRandomProgram(learningProblem, maxDepth); - p = GPUtilities.createGrowRandomProgram(learningProblem, maxDepth, false); + p = GPUtilities.createGrowRandomProgram(learningProblem, rs, maxDepth, false); if(p.getFitness()>bestFitness) { bestFitness = p.getFitness(); bestScore = p.getScore(); @@ -133,4 +135,13 @@ } + /* (non-Javadoc) + * @see org.dllearner.core.LearningAlgorithm#isRunning() + */ + @Override + public boolean isRunning() { + // TODO Auto-generated method stub + return false; + } + } Modified: trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/SimpleSuggestionLearningAlgorithm.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -100,4 +100,13 @@ } return simpleSuggestions; } + + /* (non-Javadoc) + * @see org.dllearner.core.LearningAlgorithm#isRunning() + */ + @Override + public boolean isRunning() { + // TODO Auto-generated method stub + return false; + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GP.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -274,7 +274,7 @@ @Override public void start() { // falls refinement-Wahrscheinlichkeit größer 0, dann erzeuge psi - psi = new Psi(learningProblem); + psi = new Psi(learningProblem, rs); System.out.println(); System.out.println("Starting Genetic Programming Learner"); @@ -437,11 +437,11 @@ i++; // mutation } else if(rand >= crossoverBoundary && rand < mutationBoundary) { - newIndividuals[i] = GPUtilities.mutation(learningProblem, individuals[selectedIndividuals[i]]); + newIndividuals[i] = GPUtilities.mutation(learningProblem, rs, individuals[selectedIndividuals[i]]); // hill climbing } else if(rand >= mutationBoundary && rand < hillClimbingBoundary) { // System.out.println("hill climbing"); - newIndividuals[i] = GPUtilities.hillClimbing(learningProblem, individuals[selectedIndividuals[i]]); + newIndividuals[i] = GPUtilities.hillClimbing(learningProblem, rs, individuals[selectedIndividuals[i]]); // refinement operator } else if(rand >= hillClimbingBoundary && rand < refinementBoundary) { newIndividuals[i] = psi.applyOperator(individuals[selectedIndividuals[i]]); @@ -615,9 +615,9 @@ // int depth = rand.nextInt(initMaxDepth-initMinDepth)+initMinDepth; if(grow) - individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem,depth, adc); + individuals[i] = GPUtilities.createGrowRandomProgram(learningProblem, rs, depth, adc); else - individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, depth, adc); + individuals[i] = GPUtilities.createFullRandomProgram(learningProblem, rs, depth, adc); } /* @@ -965,6 +965,15 @@ } + /* (non-Javadoc) + * @see org.dllearner.core.LearningAlgorithm#isRunning() + */ + @Override + public boolean isRunning() { + // TODO Auto-generated method stub + return false; + } + /** * This allows to set the number of individuals in the whole population. A * higher value slows down the algorithm, but will in general improve Modified: trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/gp/GPUtilities.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -9,6 +9,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasoningMethodUnsupportedException; +import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.NamedClass; @@ -134,31 +135,31 @@ * Perform a point mutation on the given program. * @param p The program to be mutated. */ - public static Program mutation(LearningProblem learningProblem, Program p) { + public static Program mutation(LearningProblem learningProblem, ReasoningService rs, Program p) { mutation++; if(p.getAdc() != null) { // TODO: hier kann man noch mehr Feinabstimmung machen, d.h. // Mutation abh�ngig von Knotenanzahl if(Math.random()<0.5) { - Description mainTree = mutation(learningProblem, p.getTree(),true); + Description mainTree = mutation(learningProblem, rs, p.getTree(),true); Description adc = p.getAdc(); Score score = calculateFitness(learningProblem,mainTree,adc); return new Program(score, mainTree, adc); } else { Description mainTree = p.getTree(); - Description adc = mutation(learningProblem, p.getAdc(),false); + Description adc = mutation(learningProblem, rs, p.getAdc(),false); Score score = calculateFitness(learningProblem,mainTree,adc); return new Program(score, mainTree, adc); } } else { - Description tree = mutation(learningProblem, p.getTree(),false); + Description tree = mutation(learningProblem, rs,p.getTree(),false); Score score = calculateFitness(learningProblem, tree); return new Program(score, tree); } } - private static Description mutation(LearningProblem learningProblem, Description tree, boolean useADC) { + private static Description mutation(LearningProblem learningProblem, ReasoningService rs, Description tree, boolean useADC) { // auch bei Mutation muss darauf geachtet werden, dass // Baum nicht modifiziert wird (sonst w�rde man automatisch auch // andere "selected individuals" modifizieren) @@ -185,11 +186,11 @@ Description st = t.getSubtree(randNr); Description stParent = st.getParent(); stParent.getChildren().remove(st); - Description treeNew = createGrowRandomTree(learningProblem,3, useADC); + Description treeNew = createGrowRandomTree(learningProblem, rs, 3, useADC); stParent.addChild(treeNew); } else // return createLeafNode(useADC); - return pickTerminalSymbol(learningProblem,useADC); + return pickTerminalSymbol(learningProblem,rs,useADC); return t; } @@ -303,10 +304,10 @@ // m�sste auch mit ADC funktionieren, da nur am Hauptbaum etwas // ver�ndert wird - public static Program hillClimbing(LearningProblem learningProblem, Program p) { + public static Program hillClimbing(LearningProblem learningProblem, ReasoningService rs, Program p) { hillClimbing++; // checken, ob Bedingungen f�r hill-climbing erf�llt sind - if(!learningProblem.getReasoningService().getReasonerType().equals(ReasonerType.FAST_RETRIEVAL) + if(!rs.getReasonerType().equals(ReasonerType.FAST_RETRIEVAL) || !(p.getScore() instanceof ScoreThreeValued)) { throw new Error("Hill climbing can only be used with the fast-retrieval-algorithm on a three valued learning problem."); } @@ -316,9 +317,9 @@ // parent-Link ver�ndert) Description treecloned = (Description) p.getTree().clone(); if(p.getAdc() != null) - return createProgram(learningProblem,hillClimbing(learningProblem,treecloned,(ScoreThreeValued)p.getScore()),p.getAdc()); + return createProgram(learningProblem,hillClimbing(learningProblem,rs,treecloned,(ScoreThreeValued)p.getScore()),p.getAdc()); else - return createProgram(learningProblem,hillClimbing(learningProblem,treecloned,(ScoreThreeValued)p.getScore())); + return createProgram(learningProblem,hillClimbing(learningProblem,rs,treecloned,(ScoreThreeValued)p.getScore())); } // one-step hill-climbing @@ -326,7 +327,7 @@ // Alternativen zu speichern und dann ein Element zuf�llig auszuw�hlen, // aber w�rde man das nicht machen, dann w�re das ein starker Bias // zu z.B. Disjunktion (weil die als erstes getestet wird) - private static Description hillClimbing(LearningProblem learningProblem, Description node, ScoreThreeValued score) { + private static Description hillClimbing(LearningProblem learningProblem, ReasoningService rs, Description node, ScoreThreeValued score) { SortedSetTuple<Individual> tuple = new SortedSetTuple<Individual>(score.getPosClassified(),score.getNegClassified()); SortedSetTuple<String> stringTuple = Helper.getStringTuple(tuple); // FlatABox abox = FlatABox.getInstance(); @@ -345,7 +346,7 @@ // FlatABox abox = Main.getFlatAbox(); FlatABox abox = null; try { - abox = Helper.createFlatABox(learningProblem.getReasoningService()); + abox = Helper.createFlatABox(rs); } catch (ReasoningMethodUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -361,14 +362,14 @@ // TODO: double retrieval nutzen tmp2 = FastRetrieval.calculateDisjunctionSets(stringTuple, tmp); - tmpScore = getScore(node.getLength()+2, learningProblem,Helper.getIndividualSet(tmp2.getPosSet()),Helper.getIndividualSet(tmp2.getNegSet())); + tmpScore = getScore(node.getLength()+2, learningProblem, rs, Helper.getIndividualSet(tmp2.getPosSet()),Helper.getIndividualSet(tmp2.getNegSet())); if(tmpScore.getScore()==bestScore) bestNeighbours = updateMap(bestNeighbours,1,concept,false); else if(tmpScore.getScore()>bestScore) bestNeighbours = updateMap(bestNeighbours,1,concept,true); tmp2 = FastRetrieval.calculateConjunctionSets(stringTuple, tmp); - tmpScore = getScore(node.getLength()+2,learningProblem,Helper.getIndividualSet(tmp2.getPosSet()),Helper.getIndividualSet(tmp2.getNegSet())); + tmpScore = getScore(node.getLength()+2,learningProblem, rs, Helper.getIndividualSet(tmp2.getPosSet()),Helper.getIndividualSet(tmp2.getNegSet())); if(tmpScore.getScore()==bestScore) bestNeighbours = updateMap(bestNeighbours,2,concept,false); else if(tmpScore.getScore()>bestScore) @@ -378,14 +379,14 @@ // Tests f�r All und Exists for(String role : abox.roles) { tmp = FastRetrieval.calculateAllSet(abox,role,stringTuple); - tmpScore = getScore(node.getLength()+2,learningProblem,Helper.getIndividualSet(tmp.getPosSet()),Helper.getIndividualSet(tmp.getNegSet())); + tmpScore = getScore(node.getLength()+2,learningProblem, rs, Helper.getIndividualSet(tmp.getPosSet()),Helper.getIndividualSet(tmp.getNegSet())); if(tmpScore.getScore()==bestScore) bestNeighbours = updateMap(bestNeighbours,3,role,false); else if(tmpScore.getScore()>bestScore) bestNeighbours = updateMap(bestNeighbours,3,role,true); tmp = FastRetrieval.calculateExistsSet(abox,role,stringTuple); - tmpScore = getScore(node.getLength()+2,learningProblem,Helper.getIndividualSet(tmp.getPosSet()),Helper.getIndividualSet(tmp.getNegSet())); + tmpScore = getScore(node.getLength()+2,learningProblem, rs, Helper.getIndividualSet(tmp.getPosSet()),Helper.getIndividualSet(tmp.getNegSet())); if(tmpScore.getScore()==bestScore) bestNeighbours = updateMap(bestNeighbours,4,role,false); else if(tmpScore.getScore()>bestScore) @@ -451,10 +452,10 @@ } } - private static ScoreThreeValued getScore(int conceptLength, LearningProblem learningProblem, SortedSet<Individual> posClassified, SortedSet<Individual> negClassified) { + private static ScoreThreeValued getScore(int conceptLength, LearningProblem learningProblem, ReasoningService rs, SortedSet<Individual> posClassified, SortedSet<Individual> negClassified) { // es muss hier die Helper-Methode verwendet werden, sonst werden // Individuals gel�scht !! - SortedSet<Individual> neutClassified = Helper.intersection(learningProblem.getReasoningService().getIndividuals(),posClassified); + SortedSet<Individual> neutClassified = Helper.intersection(rs.getIndividuals(),posClassified); // learningProblem.getReasoner().getIndividuals(); // neutClassified.retainAll(posClassified); neutClassified.retainAll(negClassified); @@ -488,10 +489,10 @@ return returnMap; } - private static Description pickTerminalSymbol(LearningProblem learningProblem, boolean useADC) { + private static Description pickTerminalSymbol(LearningProblem learningProblem, ReasoningService rs, boolean useADC) { // FlatABox abox = FlatABox.getInstance(); int nr; - int nrOfConcepts = learningProblem.getReasoningService().getAtomicConcepts().size(); + int nrOfConcepts = rs.getAtomicConcepts().size(); // ein Blattknoten kann folgendes sein: // Top, Bottom, Konzept => alles am Besten gleichwahrscheinlich @@ -510,7 +511,7 @@ return new ADC(); } else - return (NamedClass) learningProblem.getReasoningService().getAtomicConceptsList().get(nr-2).clone(); + return (NamedClass) rs.getAtomicConceptsList().get(nr-2).clone(); } // Funktion nach Umstelllung der Konstruktoren nicht mehr ben�tigt @@ -618,28 +619,28 @@ * @param depth Depth of the tree. * @return The created program. */ - public static Program createFullRandomProgram(LearningProblem learningProblem, int depth, boolean adc) { + public static Program createFullRandomProgram(LearningProblem learningProblem, ReasoningService rs, int depth, boolean adc) { if(adc) { // erster Baum Hauptbaum, zweiter Baum ADC - return createProgram(learningProblem, createFullRandomTree(learningProblem, depth, true), - createFullRandomTree(learningProblem, depth, false)); + return createProgram(learningProblem, createFullRandomTree(learningProblem, rs, depth, true), + createFullRandomTree(learningProblem, rs, depth, false)); } else - return createProgram(learningProblem, createFullRandomTree(learningProblem, depth, false)); + return createProgram(learningProblem, createFullRandomTree(learningProblem, rs, depth, false)); } - private static Description createFullRandomTree(LearningProblem learningProblem, int depth, boolean useADC) { + private static Description createFullRandomTree(LearningProblem learningProblem, ReasoningService rs, int depth, boolean useADC) { // FlatABox abox = FlatABox.getInstance(); - int numberOfRoles = learningProblem.getReasoningService().getAtomicRoles().size(); // abox.roles.size(); + int numberOfRoles = rs.getAtomicRoles().size(); // abox.roles.size(); if (depth > 1) { int nr = rand.nextInt(3+2*numberOfRoles); // System.out.println(nr); // Node node = createNonLeafNodeEqualProp(); // Concept node = pickFunctionSymbol(); - Description child1 = createFullRandomTree(learningProblem, depth-1, useADC); + Description child1 = createFullRandomTree(learningProblem, rs, depth-1, useADC); if(nr == 0 || nr == 1) { - Description child2 = createFullRandomTree(learningProblem, depth-1, useADC); + Description child2 = createFullRandomTree(learningProblem, rs, depth-1, useADC); if(nr == 0) { // if(useMultiStructures) return new Union(child1,child2); @@ -654,9 +655,9 @@ } else if(nr==2) { return new Negation(child1); } else if(nr - 3 < numberOfRoles) - return new ObjectSomeRestriction(learningProblem.getReasoningService().getAtomicRolesList().get(nr-3),child1); + return new ObjectSomeRestriction(rs.getAtomicRolesList().get(nr-3),child1); else - return new ObjectAllRestriction(learningProblem.getReasoningService().getAtomicRolesList().get(nr-3-numberOfRoles),child1); + return new ObjectAllRestriction(rs.getAtomicRolesList().get(nr-3-numberOfRoles),child1); /* if(node instanceof Disjunction || node instanceof Conjunction) { @@ -670,7 +671,7 @@ // return node; } else { // return createLeafNode(useADC); - return pickTerminalSymbol(learningProblem, useADC); + return pickTerminalSymbol(learningProblem, rs, useADC); } } @@ -679,17 +680,17 @@ * @param depth The maximum depth of the program tree. * @return The created program. */ - public static Program createGrowRandomProgram(LearningProblem learningProblem, int depth, boolean adc) { + public static Program createGrowRandomProgram(LearningProblem learningProblem, ReasoningService rs, int depth, boolean adc) { if(adc) { // erster Baum Hauptbaum, zweiter Baum ADC - return createProgram(learningProblem, createGrowRandomTree(learningProblem,depth,true), - createGrowRandomTree(learningProblem,depth,false)); + return createProgram(learningProblem, createGrowRandomTree(learningProblem,rs,depth,true), + createGrowRandomTree(learningProblem,rs,depth,false)); } else - return createProgram(learningProblem, createGrowRandomTree(learningProblem, depth,false)); + return createProgram(learningProblem, createGrowRandomTree(learningProblem, rs, depth,false)); } - private static Description createGrowRandomTree(LearningProblem learningProblem, int depth, boolean useADC) { + private static Description createGrowRandomTree(LearningProblem learningProblem, ReasoningService rs, int depth, boolean useADC) { /* private static Concept pickAlphabetSymbol(boolean useADC) { FlatABox abox = FlatABox.getInstance(); @@ -724,8 +725,8 @@ */ // FlatABox abox = FlatABox.getInstance(); - int numberOfConcepts = learningProblem.getReasoningService().getAtomicConcepts().size(); - int numberOfRoles = learningProblem.getReasoningService().getAtomicRoles().size(); + int numberOfConcepts = rs.getAtomicConcepts().size(); + int numberOfRoles = rs.getAtomicRoles().size(); // TODO: ev. größere Wahrscheinlichkeit für Konjunktion/Disjunktion (?), // mit größerer Konzept-, und Rollenanzahl kommen die sonst kaum noch vor int numberOfAlphabetSymbols = numberOfConcepts + 2*numberOfRoles + 5; //7;// 5; @@ -768,23 +769,23 @@ else if(nr==numberOfConcepts + 2*numberOfRoles + 5) return new ADC(); else if(nr>=2 && nr < numberOfConcepts+2) - return (NamedClass)learningProblem.getReasoningService().getAtomicConceptsList().get(nr-2).clone(); + return (NamedClass)rs.getAtomicConceptsList().get(nr-2).clone(); else if(nr==numberOfConcepts+2) { // if(useMultiStructures) - return new Intersection(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); + return new Intersection(createGrowRandomTree(learningProblem, rs, depth-1, useADC),createGrowRandomTree(learningProblem, rs, depth-1, useADC)); // else // return new Conjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); } else if(nr==numberOfConcepts+3) { // if(useMultiStructures) - return new Union(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); + return new Union(createGrowRandomTree(learningProblem, rs, depth-1, useADC),createGrowRandomTree(learningProblem, rs, depth-1, useADC)); // else // return new Disjunction(createGrowRandomTree(learningProblem, depth-1, useADC),createGrowRandomTree(learningProblem, depth-1, useADC)); } else if(nr==numberOfConcepts+4) - return new Negation(createGrowRandomTree(learningProblem, depth-1, useADC)); + return new Negation(createGrowRandomTree(learningProblem, rs, depth-1, useADC)); else if(nr>=numberOfConcepts+5 && nr<numberOfConcepts+5+numberOfRoles) - return new ObjectSomeRestriction(learningProblem.getReasoningService().getAtomicRolesList().get(nr-numberOfConcepts-5),createGrowRandomTree(learningProblem,depth-1, useADC)); + return new ObjectSomeRestriction(rs.getAtomicRolesList().get(nr-numberOfConcepts-5),createGrowRandomTree(learningProblem, rs, depth-1, useADC)); else - return new ObjectAllRestriction(learningProblem.getReasoningService().getAtomicRolesList().get(nr-numberOfConcepts-5-numberOfRoles),createGrowRandomTree(learningProblem,depth-1, useADC)); + return new ObjectAllRestriction(rs.getAtomicRolesList().get(nr-numberOfConcepts-5-numberOfRoles),createGrowRandomTree(learningProblem, rs, depth-1, useADC)); /* if(node instanceof Disjunction || node instanceof Conjunction) { @@ -798,7 +799,7 @@ // return node; } else { // return createLeafNode(useADC); - return pickTerminalSymbol(learningProblem, useADC); + return pickTerminalSymbol(learningProblem, rs, useADC); } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/hybridgp/Psi.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -6,6 +6,7 @@ import java.util.TreeMap; import org.dllearner.algorithms.gp.Program; +import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.core.owl.Description; import org.dllearner.learningproblems.PosNegLP; @@ -48,12 +49,12 @@ private long someTimeStart = 0; public long someTime = 0; - public Psi(PosNegLP learningProblem) { //, PsiUp pu, PsiDown pd) { + public Psi(PosNegLP learningProblem, ReasoningService reasoningService) { //, PsiUp pu, PsiDown pd) { // this.pu = pu; // this.pd = pd; this.learningProblem = learningProblem; - pu = new PsiUp(learningProblem); - pd = new PsiDown(learningProblem); + pu = new PsiUp(learningProblem, reasoningService); + pd = new PsiDown(learningProblem, reasoningService); nrOfPositiveExamples = learningProblem.getPositiveExamples().size(); nrOfNegativeExamples = learningProblem.getNegativeExamples().size(); random = new Random(); Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -430,5 +430,13 @@ public void resume() { // TODO: not implemented } + + /* (non-Javadoc) + * @see org.dllearner.core.LearningAlgorithm#isRunning() + */ + @Override + public boolean isRunning() { + return algorithm.isRunning(); + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -143,6 +143,7 @@ // setting to true gracefully stops the algorithm private boolean stop = false; + private boolean isRunning = false; // node from which algorithm has started private ExampleBasedNode startNode; @@ -287,6 +288,7 @@ } public void start() { + isRunning = true; runtime=System.currentTimeMillis(); JamonMonitorLogger.getTimeMonitor(ExampleBasedROLComponent.class, "totalLearningTime").start(); // TODO: write a JUnit test for this problem (long-lasting or infinite loops because @@ -483,6 +485,7 @@ logger.info("Algorithm terminated succesfully."); JamonMonitorLogger.getTimeMonitor(ExampleBasedROLComponent.class, "totalLearningTime").stop(); + isRunning = false; } @@ -1222,5 +1225,9 @@ else return false; } + + public boolean isRunning() { + return isRunning; + } } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -93,6 +93,7 @@ private boolean quiet = false; private boolean stop = false; + private boolean isRunning = false; private ReasoningService rs; @@ -388,6 +389,7 @@ @Override @SuppressWarnings("unchecked") public void start() { + isRunning = true; runtime=System.currentTimeMillis(); // Suche wird mit Top-Konzept gestartet Thing top = new Thing(); @@ -582,6 +584,8 @@ System.out.println("Algorithm stopped."); else System.out.println("Algorithm terminated succesfully."); + + isRunning = false; } // einfache Erweiterung des Knotens (ohne properness) @@ -1147,4 +1151,12 @@ } + /* (non-Javadoc) + * @see org.dllearner.core.LearningAlgorithm#isRunning() + */ + @Override + public boolean isRunning() { + return isRunning; + } + } Modified: trunk/src/dl-learner/org/dllearner/core/Component.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Component.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/core/Component.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -68,5 +68,6 @@ * @param option A configuration option of this component. * @return Current value of the configuration option. */ +// now implemented in ComponentManager // public abstract <T> T getConfigValue(ConfigOption<T> option) throws UnknownConfigOptionException; } Modified: trunk/src/dl-learner/org/dllearner/core/ComponentInitException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentInitException.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/core/ComponentInitException.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -21,9 +21,9 @@ /** * Exception which is thrown when a component cannot be intialised, - * e.g. due to bad configuration parameteres or unforeseen - * circumstances unreachable web files. It can encapsulate arbitrary - * exceptions occuring during initialisation. + * e.g. due to bad configuration parameters, or unforeseen + * circumstances, e.g. unreachable web files. It can encapsulate arbitrary + * exceptions occurring during initialisation. * * @author Jens Lehmann * @@ -32,15 +32,31 @@ private static final long serialVersionUID = -3550079897929658317L; + /** + * Creates a <code>ComponentInitException</code> with the specified message. + * @param message The specified detail message. + */ public ComponentInitException(String message) { super(message); } - public ComponentInitException(Exception exception) { - super(exception); + /** + * Creates a <code>ComponentInitException</code> with the + * specified cause. + * @param cause The cause of this exception. + */ + public ComponentInitException(Throwable cause) { + super(cause); + } + + /** + * Creates a <code>ComponentInitException</code> with the + * specified message and cause. + * @param message The specified detail message. + * @param cause The cause of this exception. + */ + public ComponentInitException(String message, Throwable cause) { + super(message, cause); } - - public ComponentInitException(String message, Exception exception) { - super(message, exception); - } + } Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -72,6 +72,14 @@ public abstract void stop(); /** + * Returns whether the learning algorithm is running. Implementation + * should use a boolean status variable in their implementations of + * the start and resume methods. + * @return True if the algorithm is running, false otherwise. + */ + public abstract boolean isRunning(); + + /** * Every algorithm must be able to return the score of the * best solution found. * Modified: trunk/src/dl-learner/org/dllearner/core/LearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/core/LearningProblem.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -23,18 +23,19 @@ /** * Base class for all learning problems. + * See also the wiki page for + * <a href="http://dl-learner.org/Projects/DLLearner/Architecture">DL-Learner-Architecture</a>. + * Currently, we assume that all learning problems have the goal + * of learning class descriptions. However, this may be extended + * to other scenarios if desired. * - * @todo The current learning problem implementations - * assume that we learn a concept, which does not exist - * in the knowledge base so far. However, often we want - * to learn a complex definition for a concept which - * is already integrated in a subsumption hierarchy. This - * means it would make sense to specifiy the list of these - * superclasses as an additional argument of the learning - * problem. The learning algorithms could then make use of - * this to optimise their search for a solution. (More - * generally, one could specify the name of the concept, which - * should be improved.) + * TODO: The current learning problem implementations assume that + * we learn a description for a class, which does not exist + * in the knowledge base so far (if it exists, it needs to be ignored + * explicitly). However, often we want to learn a complex definition + * for a concept which is already integrated in a subsumption hierarchy + * or may already have an associated description. It may make sense + * to use this knowledge for (re-)learning descriptions. * * @author Jens Lehmann * @@ -43,16 +44,25 @@ protected ReasoningService reasoningService; + /** + * Constructs a learning problem using a reasoning service for + * querying the background knowledge. It can be used for + * evaluating solution candidates. + * @param reasoningService The reasoning service used as + * background knowledge. + */ public LearningProblem(ReasoningService reasoningService) { this.reasoningService = reasoningService; } - public abstract Score computeScore(Description concept); + /** + * Computes the <code>Score</code> of a given class description + * with respect to this learning problem. + * This can (but does not need to) be used by learning algorithms + * to measure how good the description fits the learning problem. + * @param description A class description (as solution candidate for this learning problem). + * @return A <code>Score</code> object. + */ + public abstract Score computeScore(Description description); - // TODO: remove? reasoning service should probably not be accessed via - // learning problem - public ReasoningService getReasoningService() { - return reasoningService; - } - } Modified: trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/core/config/ConfigOption.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -71,7 +71,7 @@ * * @param object * The object to check. - * @return + * @return True of the type is correct, false otherwise. */ public abstract boolean checkType(Object object); Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypePropertyHierarchy.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -29,7 +29,7 @@ /** * Represents a hierarchy of datatype properties. * - * @todo. Currently, the role hierarchy pruning algorithm (analogous to the + * TODO: Currently, the role hierarchy pruning algorithm (analogous to the * subsumption hierarchy) is not implemented. * * @author Jens Lehmann Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -20,13 +20,19 @@ package org.dllearner.core.owl; /** + * Represents datatype quantor restrictions. For instance, + * \exists salary < 100.000 can be used to specify + * those objects (persons) which have a salary of below 100.000. + * * @author Jens Lehmann * */ public abstract class DatatypeQuantorRestriction extends QuantorRestriction { /** - * @param propertyExpression + * Creates a <code>DatatypeQuantorRestriction</code> along the + * given property. + * @param propertyExpression The datatype property along which this restriction acts. */ public DatatypeQuantorRestriction(DatatypeProperty datatypeProperty) { super(datatypeProperty); Modified: trunk/src/dl-learner/org/dllearner/core/owl/Description.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Description.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/core/owl/Description.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -127,14 +127,16 @@ /** * Adds a description as child of this one. The parent link - * of the concept will point to this one. + * of the description will point to this one. For instance, + * if the description is an intersection, then this method adds + * an element to the intersection, e.g. A AND B becomes A AND B + * AND C. * - * @param child - * @return + * @param child The child description. */ - public boolean addChild(Description child) { + public void addChild(Description child) { child.setParent(this); - return children.add(child); + children.add(child); } /** Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyHierarchy.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -29,7 +29,7 @@ /** * Represents a hierarchy of roles. * - * @todo Currently, the role hierarchy pruning algorithm (analogous to the + * TODO: Currently, the role hierarchy pruning algorithm (analogous to the * subsumption hierarchy) is not implemented. * * @author Jens Lehmann Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluationCache.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -37,7 +37,7 @@ * which tries to infer the covered examples of a given concept * from previous results. * - * @todo Under construction. + * TODO Under construction. * @author Jens Lehmann * */ Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -75,8 +75,8 @@ * If it is not weak, it returns the number of covered negative example. It * can use retrieval or instance checks for classification. * - * @see org.dllearner.learningproblems.DefinitionLP.MultiInstanceChecks - * @todo Performance could be slightly improved by counting the number of + * @see org.dllearner.learningproblems.PosNegLP.MultiInstanceChecks + * TODO: Performance could be slightly improved by counting the number of * covers instead of using sets and counting their size. * @param concept * The concept to test. @@ -154,7 +154,7 @@ * to implement TWO_CHECKS in this function, because we have to test all * examples to create a score object anyway). * - * @see org.dllearner.learningproblems.DefinitionLP.MultiInstanceChecks + * @see org.dllearner.learningproblems.PosNegLP.MultiInstanceChecks * @param concept * The concept to test. * @return Corresponding Score object. Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegInclusionLP.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -101,7 +101,7 @@ * concept. Thus, this methods uses a different notion of coverage than * the one for the standard definition learning problem. * - * @see org.dllearner.learningproblems.DefinitionLP.MultiInstanceChecks + * @see org.dllearner.learningproblems.PosNegLP.MultiInstanceChecks * @param concept * The concept to test. * @return -1 if concept is too weak and the number of covered negative @@ -173,7 +173,7 @@ * Calls the same method on the standard definition learning problem, but * negates the concept before and permutes positive and negative examples. * - * @see org.dllearner.core.LearningProblemNew#computeScore(org.dllearner.core.owl.Description) + * @see org.dllearner.core.LearningProblem#computeScore(org.dllearner.core.owl.Description) */ @Override public Score computeScore(Description concept) { Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ScoreThreeValued.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -32,7 +32,7 @@ * Computes the score (a negative value) by comparing the classification results * with ideal results. * - * @todo: The implementation is not very efficient, because some things are + * TODO: The implementation is not very efficient, because some things are * only computed to be able to present the score results. This means that * it would be better to compute only the necessary computations and do * the other ones only when they are needed to calculate statistical values. Modified: trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/reasoning/DIGReasoner.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -256,7 +256,7 @@ * Constructs a role hierarchy using DIG queries. After calling this method, * one can query parents or children of roles. * - * @todo Does not yet take ignored roles into account. + * TODO Does not yet take ignored roles into account. */ @Override public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/MathOperations.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -107,21 +107,24 @@ * number = 6: [[6], [4, 1], [3, 2], [2, 1, 1]] * number = 7: [[7], [5, 1], [4, 2], [3, 3], [3, 1, 1], [2, 2, 1], [1, 1, 1, 1]] * - * @param length - * @return + * @param number A natural number. + * @return A two dimensional list constructed as described above. */ - public static List<List<Integer>> getCombos(int length) { + public static List<List<Integer>> getCombos(int number) { // on Notebook: length 70 in 17 seconds, length 50 in 800ms, length 30 in 15ms LinkedList<List<Integer>> combosTmp = new LinkedList<List<Integer>>(); - decompose(length, length, new LinkedList<Integer>(), combosTmp); + decompose(number, number, new LinkedList<Integer>(), combosTmp); return combosTmp; } /** + * Methods for computing combinations with the additional restriction + * that <code>maxValue</code> is the highest natural number, which can + * occur. * @see #getCombos(int) * @param length Length of construct. * @param maxValue Maximum value which can occur in sum. - * @return + * @return A two dimensional list constructed in {@link #getCombos(int)}. */ public static List<List<Integer>> getCombos(int length, int maxValue) { LinkedList<List<Integer>> combosTmp = new LinkedList<List<Integer>>(); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/PsiDown.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -44,9 +44,9 @@ private TreeSet<Description> topSet; - public PsiDown(PosNegLP learningProblem) { + public PsiDown(PosNegLP learningProblem, ReasoningService reasoningService) { this.learningProblem = learningProblem; - reasoningService = learningProblem.getReasoningService(); + this.reasoningService = reasoningService; // Top-Menge erstellen createTopSet(); @@ -65,7 +65,7 @@ topSet.addAll(reasoningService.getMoreSpecialConcepts(new Thing())); // negierte speziellste Konzepte - Set<Description> tmp = learningProblem.getReasoningService().getMoreGeneralConcepts(new Nothing()); + Set<Description> tmp = reasoningService.getMoreGeneralConcepts(new Nothing()); for(Description c : tmp) topSet.add(new Negation(c)); Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/PsiUp.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -32,9 +32,9 @@ private TreeSet<Description> bottomSet; - public PsiUp(PosNegLP learningProblem) { + public PsiUp(PosNegLP learningProblem, ReasoningService reasoningService) { this.learningProblem = learningProblem; - reasoningService = learningProblem.getReasoningService(); + this.reasoningService = reasoningService; // Top-Menge erstellen createBottomSet(); Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -94,6 +94,7 @@ /** * @return the isAlgorithmRunning */ + @Deprecated public boolean isAlgorithmRunning() { return isAlgorithmRunning; } @@ -101,6 +102,7 @@ /** * @param isAlgorithmRunning the isAlgorithmRunning to set */ + @Deprecated public void setAlgorithmRunning(boolean isAlgorithmRunning) { this.isAlgorithmRunning = isAlgorithmRunning; } @@ -199,8 +201,8 @@ } /** - * @param key - * @return + * @param is A component ID. + * @return The component associated with this ID. * @see java.util.Map#get(java.lang.Object) */ public Component getComponent(int id) { @@ -208,8 +210,10 @@ } /** - * @param e - * @return + * Adds a knowledge source to the client session. Use the + * returned value to refer to this knowledge source. + * @param ks The knowledge source to add. + * @return The component ID for the newly added knowledge source. */ public int addKnowledgeSource(KnowledgeSource ks) { knowledgeSources.add(ks); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -348,9 +348,9 @@ Thread learningThread = new Thread() { @Override public void run() { - state.setAlgorithmRunning(true); +// state.setAlgorithmRunning(true); state.getLearningAlgorithm().start(); - state.setAlgorithmRunning(false); +// state.setAlgorithmRunning(false); } }; learningThread.start(); @@ -393,7 +393,7 @@ @WebMethod public boolean isAlgorithmRunning(int id) throws ClientNotKnownException { - return getState(id).isAlgorithmRunning(); + return getState(id).getLearningAlgorithm().isRunning(); } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-07-24 16:42:40 UTC (rev 1018) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-07-28 09:21:08 UTC (rev 1019) @@ -11,7 +11,6 @@ import org.dllearner.core.owl.Description; -import org.semanticweb.owl.model.OWLDescription; /** * * @author Heero Yuy This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-07-24 16:42:42
|
Revision: 1018 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1018&view=rev Author: jenslehmann Date: 2008-07-24 16:42:40 +0000 (Thu, 24 Jul 2008) Log Message: ----------- - removed ToDo-Taglet from Javadoc ant task - slightly improved Javadoc Modified Paths: -------------- trunk/build.xml trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/core/ComponentManager.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2008-07-24 11:06:45 UTC (rev 1017) +++ trunk/build.xml 2008-07-24 16:42:40 UTC (rev 1018) @@ -246,7 +246,7 @@ <pathconvert refid="classpath" property="jdocclasspath"/> <javadoc access="public" author="true" - classpath="${jdocclasspath};${java.home}/../lib/tools.jar" + classpath="${jdocclasspath}" destdir="doc/javadoc" doctitle="DL-Learner Javadoc" nodeprecated="false" @@ -265,7 +265,6 @@ bottom="<img style='float:right' src='http://sflogo.sourceforge.net/sflogo.php?group_id=203619&type=1' width='88' height='31' border='0' alt='SourceForge.net Logo' /> DL-Learner is licenced under the terms of the GNU General Public License.<br />Copyright &#169; 2007 Jens Lehmann" Encoding="ISO-8859-1" windowtitle="DL-Learner Javadoc"> - <taglet name="org.dllearner.utilities.ToDoTaglet" path="classes" /> <link href="http://java.sun.com/javase/6/docs/api/"/> </javadoc> </target> Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-07-24 11:06:45 UTC (rev 1017) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-07-24 16:42:40 UTC (rev 1018) @@ -434,7 +434,9 @@ System.out.println("best child of this node: " + bestChild); System.out.println(bestNode.getChildConcepts()); System.out.println("TODO: needs to be integrated with other stopping criteria"); - System.exit(0); + System.out.println("You tried to use this algorithm for positive only learning, which is not recommended (yet)."); +// System.out.println("Exiting."); +// System.exit(0); } else { // tag as non-candidate so we do not need to search again bestNode.setPosOnlyCandidate(false); Modified: trunk/src/dl-learner/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-07-24 11:06:45 UTC (rev 1017) +++ trunk/src/dl-learner/org/dllearner/core/ComponentManager.java 2008-07-24 16:42:40 UTC (rev 1018) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -178,6 +178,16 @@ return cm; } + /** + * Set the classes, which can be used as components. By default, + * this is read from components.ini, but this method can be used + * to set the components programmatically. This method must be + * used before the first call to {@link #getInstance()}, otherwise + * it has no effect. + * + * @param componentClasses A list of class names, e.g. + * org.dllearner.refinement.ROLearner. + */ public static void setComponentClasses(String[] componentClasses) { ComponentManager.componentClasses = componentClasses; } @@ -211,9 +221,9 @@ * value is correct, it is preferable to create a ConfigEntry object and * apply it to the component (no type checking necessary). * - * @param component - * @param optionName - * @param value + * @param component A component. + * @param optionName The name of the config option. + * @param value The value of the config option. */ @SuppressWarnings( { "unchecked" }) public <T> void applyConfigEntry(Component component, String optionName, T value) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-07-24 11:06:49
|
Revision: 1017 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1017&view=rev Author: jenslehmann Date: 2008-07-24 11:06:45 +0000 (Thu, 24 Jul 2008) Log Message: ----------- - bug fix in evaluated description comparator - sample script cleanup Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/Sample.java trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java Modified: trunk/src/dl-learner/org/dllearner/scripts/Sample.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/Sample.java 2008-07-24 09:36:02 UTC (rev 1016) +++ trunk/src/dl-learner/org/dllearner/scripts/Sample.java 2008-07-24 11:06:45 UTC (rev 1017) @@ -18,11 +18,9 @@ package org.dllearner.scripts; import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashSet; +import java.io.IOException; +import java.text.DecimalFormat; import java.util.List; -import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -32,49 +30,41 @@ import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; -import org.dllearner.core.owl.Description; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.PosNegDefinitionLP; -import org.dllearner.learningproblems.PosNegLP; import org.dllearner.reasoning.FastInstanceChecker; -import org.dllearner.utilities.JamonMonitorLogger; -import org.dllearner.utilities.datastructures.SetManipulation; +import org.dllearner.utilities.Files; -// TODO COMMENT !!! added a sample java call class for the dl-learner (as a -// possible entry point for tool developers) +import com.jamonapi.MonitorFactory; + +/** + * Sample script showing how to use DL-Learner. Provides an entry point for tool + * developers. + * + * @author Sebastian Hellmann + * @author Jens Lehmann + * + */ public class Sample { private static Logger logger = Logger.getRootLogger(); + private static DecimalFormat df = new DecimalFormat(); - String owlfile = ""; + public static void main(String[] args) throws IOException, ComponentInitException, + LearningProblemUnsupportedException { - // examples - SortedSet<String> posExamples = new TreeSet<String>(); - - SortedSet<String> negExamples = new TreeSet<String>(); - - /** - * @param args - */ - public static void main(String[] args) { - System.out.println("Start"); - - // create logger (a simple logger which outputs - // its messages to the console) + // create logger (configure this to your needs) SimpleLayout layout = new SimpleLayout(); - FileAppender fileAppender = null; - ; - try { - fileAppender = new FileAppender(layout, "the_log.txt", false); - } catch (Exception e) { - e.printStackTrace(); - } + FileAppender fileAppender = new FileAppender(layout, "log/sample_log.txt", false); ConsoleAppender consoleAppender = new ConsoleAppender(layout); logger.removeAllAppenders(); @@ -82,127 +72,86 @@ logger.addAppender(fileAppender); logger.setLevel(Level.DEBUG); - Sample s = new Sample(); + // OWL file containing background knowledge + String owlFile = "examples/trains/trains.owl"; - s.owlfile = "examples/trains/trains.owl"; + // examples + SortedSet<String> posExamples = new TreeSet<String>(); + posExamples.add("http://example.com/foo#east1"); + posExamples.add("http://example.com/foo#east2"); + posExamples.add("http://example.com/foo#east3"); + posExamples.add("http://example.com/foo#east4"); + posExamples.add("http://example.com/foo#east5"); - s.posExamples = new TreeSet<String>(); - s.negExamples = new TreeSet<String>(); + SortedSet<String> negExamples = new TreeSet<String>(); + negExamples.add("http://example.com/foo#west6"); + negExamples.add("http://example.com/foo#west7"); + negExamples.add("http://example.com/foo#west8"); + negExamples.add("http://example.com/foo#west9"); + negExamples.add("http://example.com/foo#west10"); - /* Examples */ - s.posExamples.add("http://example.com/foo#east1"); - s.posExamples.add("http://example.com/foo#east2"); - s.posExamples.add("http://example.com/foo#east3"); - s.posExamples.add("http://example.com/foo#east4"); - s.posExamples.add("http://example.com/foo#east5"); - - s.negExamples.add("http://example.com/foo#west6"); - s.negExamples.add("http://example.com/foo#west7"); - s.negExamples.add("http://example.com/foo#west8"); - s.negExamples.add("http://example.com/foo#west9"); - s.negExamples.add("http://example.com/foo#west10"); - - List<Description> conceptresults = s.learn(); + List<EvaluatedDescription> results = learn(owlFile, posExamples, negExamples, 5); int x = 0; - for (Description description : conceptresults) { - if (x >= 5) - break; - System.out - .println(description.toManchesterSyntaxString(null, null)); + for (EvaluatedDescription ed : results) { + System.out.println("solution: " + x); + System.out.println(" description: \t" + + ed.getDescription().toManchesterSyntaxString(null, null)); + System.out.println(" accuracy: \t" + df.format(ed.getAccuracy() * 100) + "%"); + System.out.println(); x++; } - System.out.println("Finished"); - JamonMonitorLogger.printAllSortedByLabel(); - + Files.createFile(new File("log/jamon_sample.html"), MonitorFactory.getReport()); } - public List<Description> learn() { + public static List<EvaluatedDescription> learn(String owlFile, SortedSet<String> posExamples, + SortedSet<String> negExamples, int maxNrOfResults) throws ComponentInitException, + LearningProblemUnsupportedException { logger.info("Start Learning with"); logger.info("positive examples: \t" + posExamples.size()); logger.info("negative examples: \t" + negExamples.size()); - // Components + // the component manager is the central object to create + // and configure components ComponentManager cm = ComponentManager.getInstance(); - LearningAlgorithm la = null; - ReasoningService rs = null; - LearningProblem lp = null; - KnowledgeSource ks = null; - try { - Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); - ks = cm.knowledgeSource(OWLFile.class); + // knowledge source + KnowledgeSource ks = cm.knowledgeSource(OWLFile.class); + String fileURL = new File(owlFile).toURI().toString(); + cm.applyConfigEntry(ks, "url", fileURL); - // there are probably better ways, but this works - File f = new File(this.owlfile); - URL url = null; - try { - url = new URL("file://" + f.getAbsolutePath()); + // reasoner + ReasonerComponent r = cm.reasoner(FastInstanceChecker.class, ks); + ReasoningService rs = cm.reasoningService(r); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - cm.applyConfigEntry(ks, "url", url.toString()); + // learning problem + LearningProblem lp = cm.learningProblem(PosNegDefinitionLP.class, rs); + cm.applyConfigEntry(lp, "positiveExamples", posExamples); + cm.applyConfigEntry(lp, "negativeExamples", negExamples); - ReasonerComponent r = new FastInstanceChecker(sources); - rs = new ReasoningService(r); - // System.out.println("satisfy: "+rs.isSatisfiable()); + // learning algorithm + LearningAlgorithm la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); + cm.applyConfigEntry(la, "useAllConstructor", false); + cm.applyConfigEntry(la, "useExistsConstructor", true); + cm.applyConfigEntry(la, "useCardinalityRestrictions", false); + cm.applyConfigEntry(la, "useNegation", false); + cm.applyConfigEntry(la, "writeSearchTree", false); + cm.applyConfigEntry(la, "searchTreeFile", "log/searchTree.txt"); + cm.applyConfigEntry(la, "replaceSearchTree", true); + cm.applyConfigEntry(la, "noisePercentage", 0.0); - lp = new PosNegDefinitionLP(rs); - lp = new PosNegDefinitionLP(rs); + // all components need to be initialised before they can be used + ks.init(); + r.init(); + lp.init(); + la.init(); - // This method is a workaround, it should be like the two commented - // lines below - ((PosNegLP) lp).setPositiveExamples(SetManipulation - .stringToInd(this.posExamples)); - ((PosNegLP) lp).setNegativeExamples(SetManipulation - .stringToInd(this.negExamples)); - // cm.applyConfigEntry(lp,"positiveExamples",this.posExamples); - // cm.applyConfigEntry(lp,"negativeExamples",this.negExamples); - - la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); - - logger.debug("start learning"); - - // KNOWLEDGESOURCE - // - - // LEARNINGALGORITHM - cm.applyConfigEntry(la, "useAllConstructor", false); - cm.applyConfigEntry(la, "useExistsConstructor", true); - cm.applyConfigEntry(la, "useCardinalityRestrictions", false); - cm.applyConfigEntry(la, "useNegation", false); - - cm.applyConfigEntry(la, "writeSearchTree", false); - cm.applyConfigEntry(la, "searchTreeFile", "log/searchtree.txt"); - cm.applyConfigEntry(la, "replaceSearchTree", true); - // cm.applyConfigEntry(la,"noisePercentage",noise); - - /* - * if(ignoredConcepts.size()>0) - * cm.applyConfigEntry(la,"ignoredConcepts",ignoredConcepts); - */ - - // initialization - ks.init(); - sources.add(ks); - r.init(); - lp.init(); - la.init(); - - la.start(); - // Statistics.addTimeCollecting(sc.getTime()); - // Statistics.addTimeLearning(sc.getTime()); - - return la.getCurrentlyBestDescriptions(); - // return la.getCurrentlyBestEvaluatedDescriptions(); - - } catch (Exception e) { - e.printStackTrace(); - } - return null; - + // start learning algorithm + logger.debug("start learning"); + la.start(); + + return la.getCurrentlyBestEvaluatedDescriptions(maxNrOfResults); } } Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java 2008-07-24 09:36:02 UTC (rev 1016) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/EvaluatedDescriptionComparator.java 2008-07-24 11:06:45 UTC (rev 1017) @@ -43,16 +43,16 @@ double acc1 = ed1.getAccuracy(); double acc2 = ed2.getAccuracy(); if(acc1 > acc2) + return -1; + else if(acc1 < acc2) return 1; - else if(acc1 < acc2) - return -1; else { int length1 = ed1.getDescriptionLength(); int length2 = ed2.getDescriptionLength(); if(length1 < length2) + return -1; + else if(length1 > length2) return 1; - else if(length1 > length2) - return -1; else return cc.compare(ed1.getDescription(), ed2.getDescription()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-07-24 09:36:06
|
Revision: 1016 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1016&view=rev Author: kurzum Date: 2008-07-24 09:36:02 +0000 (Thu, 24 Jul 2008) Log Message: ----------- corrected sample.java Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/Sample.java Modified: trunk/src/dl-learner/org/dllearner/scripts/Sample.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/Sample.java 2008-07-24 05:46:45 UTC (rev 1015) +++ trunk/src/dl-learner/org/dllearner/scripts/Sample.java 2008-07-24 09:36:02 UTC (rev 1016) @@ -1,3 +1,20 @@ +/** + * 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.scripts; import java.io.File; @@ -29,172 +46,163 @@ import org.dllearner.utilities.JamonMonitorLogger; import org.dllearner.utilities.datastructures.SetManipulation; -//TODO COMMENT !!! added a sample java call class for the dl-learner (as a possible entry point for tool developers) +// TODO COMMENT !!! added a sample java call class for the dl-learner (as a +// possible entry point for tool developers) public class Sample { - private static Logger logger = Logger.getRootLogger(); - - String owlfile=""; - - //examples + + String owlfile = ""; + + // examples SortedSet<String> posExamples = new TreeSet<String>(); + SortedSet<String> negExamples = new TreeSet<String>(); - - - - - + /** * @param args */ public static void main(String[] args) { System.out.println("Start"); - + // create logger (a simple logger which outputs // its messages to the console) SimpleLayout layout = new SimpleLayout(); - FileAppender fileAppender =null; ; - try{ - fileAppender = new FileAppender(layout,"the_log.txt",false); - }catch (Exception e) {e.printStackTrace();} + FileAppender fileAppender = null; + ; + try { + fileAppender = new FileAppender(layout, "the_log.txt", false); + } catch (Exception e) { + e.printStackTrace(); + } ConsoleAppender consoleAppender = new ConsoleAppender(layout); logger.removeAllAppenders(); logger.addAppender(consoleAppender); logger.addAppender(fileAppender); logger.setLevel(Level.DEBUG); - - - Sample s= new Sample(); - - s.owlfile = "examples/trains/trains.owl"; - + + Sample s = new Sample(); + + s.owlfile = "examples/trains/trains.owl"; + s.posExamples = new TreeSet<String>(); s.negExamples = new TreeSet<String>(); - /*Examples*/ + /* Examples */ s.posExamples.add("http://example.com/foo#east1"); s.posExamples.add("http://example.com/foo#east2"); s.posExamples.add("http://example.com/foo#east3"); s.posExamples.add("http://example.com/foo#east4"); s.posExamples.add("http://example.com/foo#east5"); - - + s.negExamples.add("http://example.com/foo#west6"); s.negExamples.add("http://example.com/foo#west7"); s.negExamples.add("http://example.com/foo#west8"); s.negExamples.add("http://example.com/foo#west9"); s.negExamples.add("http://example.com/foo#west10"); - - - - - - List<Description> conceptresults = s.learn(); - int x=0; + int x = 0; for (Description description : conceptresults) { - if(x>=5)break; - System.out.println(description.toManchesterSyntaxString(null,null)); + if (x >= 5) + break; + System.out + .println(description.toManchesterSyntaxString(null, null)); x++; } - + System.out.println("Finished"); JamonMonitorLogger.printAllSortedByLabel(); - - } - - public List<Description> learn(){ - - - - + + } + + public List<Description> learn() { + logger.info("Start Learning with"); - logger.info("positive examples: \t"+posExamples.size()); - logger.info("negative examples: \t"+negExamples.size()); - + logger.info("positive examples: \t" + posExamples.size()); + logger.info("negative examples: \t" + negExamples.size()); + // Components ComponentManager cm = ComponentManager.getInstance(); LearningAlgorithm la = null; ReasoningService rs = null; - LearningProblem lp = null; - KnowledgeSource ks =null; - + LearningProblem lp = null; + KnowledgeSource ks = null; + try { - Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); - ks = cm.knowledgeSource(OWLFile.class); - - // there are probably better ways, but this works - File f= new File(this.owlfile); - URL url=null; - try { - url = new URL("file://"+f.getAbsolutePath()); - - } catch (MalformedURLException e) { + Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); + ks = cm.knowledgeSource(OWLFile.class); + + // there are probably better ways, but this works + File f = new File(this.owlfile); + URL url = null; + try { + url = new URL("file://" + f.getAbsolutePath()); + + } catch (MalformedURLException e) { + e.printStackTrace(); + } + cm.applyConfigEntry(ks, "url", url.toString()); + + ReasonerComponent r = new FastInstanceChecker(sources); + rs = new ReasoningService(r); + // System.out.println("satisfy: "+rs.isSatisfiable()); + + lp = new PosNegDefinitionLP(rs); + lp = new PosNegDefinitionLP(rs); + + // This method is a workaround, it should be like the two commented + // lines below + ((PosNegLP) lp).setPositiveExamples(SetManipulation + .stringToInd(this.posExamples)); + ((PosNegLP) lp).setNegativeExamples(SetManipulation + .stringToInd(this.negExamples)); + // cm.applyConfigEntry(lp,"positiveExamples",this.posExamples); + // cm.applyConfigEntry(lp,"negativeExamples",this.negExamples); + + la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); + + logger.debug("start learning"); + + // KNOWLEDGESOURCE + // + + // LEARNINGALGORITHM + cm.applyConfigEntry(la, "useAllConstructor", false); + cm.applyConfigEntry(la, "useExistsConstructor", true); + cm.applyConfigEntry(la, "useCardinalityRestrictions", false); + cm.applyConfigEntry(la, "useNegation", false); + + cm.applyConfigEntry(la, "writeSearchTree", false); + cm.applyConfigEntry(la, "searchTreeFile", "log/searchtree.txt"); + cm.applyConfigEntry(la, "replaceSearchTree", true); + // cm.applyConfigEntry(la,"noisePercentage",noise); + + /* + * if(ignoredConcepts.size()>0) + * cm.applyConfigEntry(la,"ignoredConcepts",ignoredConcepts); + */ + + // initialization + ks.init(); + sources.add(ks); + r.init(); + lp.init(); + la.init(); + + la.start(); + // Statistics.addTimeCollecting(sc.getTime()); + // Statistics.addTimeLearning(sc.getTime()); + + return la.getCurrentlyBestDescriptions(); + // return la.getCurrentlyBestEvaluatedDescriptions(); + + } catch (Exception e) { e.printStackTrace(); - } - cm.applyConfigEntry(ks, "url",url.toString()); - - ReasonerComponent r = new FastInstanceChecker(sources); - rs = new ReasoningService(r); - //System.out.println("satisfy: "+rs.isSatisfiable()); - - lp = new PosNegDefinitionLP(rs); - lp = new PosNegDefinitionLP(rs); - - // This method is a workaround, it should be like the two commented lines below - ((PosNegLP) lp).setPositiveExamples(SetManipulation.stringToInd(this.posExamples)); - ((PosNegLP) lp).setNegativeExamples(SetManipulation.stringToInd(this.negExamples)); - //cm.applyConfigEntry(lp,"positiveExamples",this.posExamples); - //cm.applyConfigEntry(lp,"negativeExamples",this.negExamples); - - - la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); + } + return null; - logger.debug("start learning"); - - - //KNOWLEDGESOURCE - // - - //LEARNINGALGORITHM - cm.applyConfigEntry(la,"useAllConstructor",false); - cm.applyConfigEntry(la,"useExistsConstructor",true); - cm.applyConfigEntry(la,"useCardinalityRestrictions",false); - cm.applyConfigEntry(la,"useNegation",false); - - cm.applyConfigEntry(la,"writeSearchTree",false); - cm.applyConfigEntry(la,"searchTreeFile","log/searchtree.txt"); - cm.applyConfigEntry(la,"replaceSearchTree",true); - //cm.applyConfigEntry(la,"noisePercentage",noise); - - - /*if(ignoredConcepts.size()>0) - cm.applyConfigEntry(la,"ignoredConcepts",ignoredConcepts); - */ - - // initialization - ks.init(); - sources.add(ks); - r.init(); - lp.init(); - la.init(); - - - la.start(); - //Statistics.addTimeCollecting(sc.getTime()); - //Statistics.addTimeLearning(sc.getTime()); - - - return la.getCurrentlyBestDescriptions(); - - }catch (Exception e) {e.printStackTrace();} - return null; - } - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2008-07-24 05:46:48
|
Revision: 1015 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1015&view=rev Author: kurzum Date: 2008-07-24 05:46:45 +0000 (Thu, 24 Jul 2008) Log Message: ----------- added a sample java call class for the dl-learner (as a possible entry point for tool developers) Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/Sample.java Added: trunk/src/dl-learner/org/dllearner/scripts/Sample.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/Sample.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/Sample.java 2008-07-24 05:46:45 UTC (rev 1015) @@ -0,0 +1,200 @@ +package org.dllearner.scripts; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.FileAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; +import org.dllearner.core.owl.Description; +import org.dllearner.kb.OWLFile; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegLP; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.utilities.JamonMonitorLogger; +import org.dllearner.utilities.datastructures.SetManipulation; + +//TODO COMMENT !!! added a sample java call class for the dl-learner (as a possible entry point for tool developers) +public class Sample { + + + private static Logger logger = Logger.getRootLogger(); + + String owlfile=""; + + //examples + SortedSet<String> posExamples = new TreeSet<String>(); + SortedSet<String> negExamples = new TreeSet<String>(); + + + + + + /** + * @param args + */ + public static void main(String[] args) { + System.out.println("Start"); + + // create logger (a simple logger which outputs + // its messages to the console) + SimpleLayout layout = new SimpleLayout(); + FileAppender fileAppender =null; ; + try{ + fileAppender = new FileAppender(layout,"the_log.txt",false); + }catch (Exception e) {e.printStackTrace();} + + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + logger.removeAllAppenders(); + logger.addAppender(consoleAppender); + logger.addAppender(fileAppender); + logger.setLevel(Level.DEBUG); + + + Sample s= new Sample(); + + s.owlfile = "examples/trains/trains.owl"; + + s.posExamples = new TreeSet<String>(); + s.negExamples = new TreeSet<String>(); + + /*Examples*/ + s.posExamples.add("http://example.com/foo#east1"); + s.posExamples.add("http://example.com/foo#east2"); + s.posExamples.add("http://example.com/foo#east3"); + s.posExamples.add("http://example.com/foo#east4"); + s.posExamples.add("http://example.com/foo#east5"); + + + s.negExamples.add("http://example.com/foo#west6"); + s.negExamples.add("http://example.com/foo#west7"); + s.negExamples.add("http://example.com/foo#west8"); + s.negExamples.add("http://example.com/foo#west9"); + s.negExamples.add("http://example.com/foo#west10"); + + + + + + + + List<Description> conceptresults = s.learn(); + int x=0; + for (Description description : conceptresults) { + if(x>=5)break; + System.out.println(description.toManchesterSyntaxString(null,null)); + x++; + } + + System.out.println("Finished"); + JamonMonitorLogger.printAllSortedByLabel(); + + } + + public List<Description> learn(){ + + + + + logger.info("Start Learning with"); + logger.info("positive examples: \t"+posExamples.size()); + logger.info("negative examples: \t"+negExamples.size()); + + // Components + ComponentManager cm = ComponentManager.getInstance(); + LearningAlgorithm la = null; + ReasoningService rs = null; + LearningProblem lp = null; + KnowledgeSource ks =null; + + try { + Set<KnowledgeSource> sources = new HashSet<KnowledgeSource>(); + ks = cm.knowledgeSource(OWLFile.class); + + // there are probably better ways, but this works + File f= new File(this.owlfile); + URL url=null; + try { + url = new URL("file://"+f.getAbsolutePath()); + + } catch (MalformedURLException e) { + e.printStackTrace(); + } + cm.applyConfigEntry(ks, "url",url.toString()); + + ReasonerComponent r = new FastInstanceChecker(sources); + rs = new ReasoningService(r); + //System.out.println("satisfy: "+rs.isSatisfiable()); + + lp = new PosNegDefinitionLP(rs); + lp = new PosNegDefinitionLP(rs); + + // This method is a workaround, it should be like the two commented lines below + ((PosNegLP) lp).setPositiveExamples(SetManipulation.stringToInd(this.posExamples)); + ((PosNegLP) lp).setNegativeExamples(SetManipulation.stringToInd(this.negExamples)); + //cm.applyConfigEntry(lp,"positiveExamples",this.posExamples); + //cm.applyConfigEntry(lp,"negativeExamples",this.negExamples); + + + la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); + + logger.debug("start learning"); + + + //KNOWLEDGESOURCE + // + + //LEARNINGALGORITHM + cm.applyConfigEntry(la,"useAllConstructor",false); + cm.applyConfigEntry(la,"useExistsConstructor",true); + cm.applyConfigEntry(la,"useCardinalityRestrictions",false); + cm.applyConfigEntry(la,"useNegation",false); + + cm.applyConfigEntry(la,"writeSearchTree",false); + cm.applyConfigEntry(la,"searchTreeFile","log/searchtree.txt"); + cm.applyConfigEntry(la,"replaceSearchTree",true); + //cm.applyConfigEntry(la,"noisePercentage",noise); + + + /*if(ignoredConcepts.size()>0) + cm.applyConfigEntry(la,"ignoredConcepts",ignoredConcepts); + */ + + // initialization + ks.init(); + sources.add(ks); + r.init(); + lp.init(); + la.init(); + + + la.start(); + //Statistics.addTimeCollecting(sc.getTime()); + //Statistics.addTimeLearning(sc.getTime()); + + + return la.getCurrentlyBestDescriptions(); + + }catch (Exception e) {e.printStackTrace();} + return null; + + } + + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-07-21 18:07:44
|
Revision: 1014 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1014&view=rev Author: sknappe Date: 2008-07-21 18:07:39 +0000 (Mon, 21 Jul 2008) Log Message: ----------- Started to work with new ajax mechanism, at the moment only started with article search, more to come soon Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php Added Paths: ----------- trunk/src/dbpedia-navigator/ajax_get_article.php trunk/src/dbpedia-navigator/helper_functions.php trunk/src/dbpedia-navigator/index-new.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-07-19 13:37:47 UTC (rev 1013) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-07-21 18:07:39 UTC (rev 1014) @@ -88,7 +88,8 @@ sleep($sleeptime); // see what we have learned so far - $concepts=$this->client->getCurrentlyBestConcepts($this->id,3,"kb"); + //$concepts=$this->client->getCurrentlyBestConcepts($this->id,3,"kb"); + $concepts=$this->client->getCurrentlyBestEvaluatedDescriptions($this->id,3); $running=$this->client->isAlgorithmRunning($this->id); $seconds = $i * $sleeptime; @@ -107,7 +108,8 @@ $this->client->stop($this->id); } - return $concepts->item; + //return $concepts->item; + return $concepts; } function getConceptDepth() Added: trunk/src/dbpedia-navigator/ajax_get_article.php =================================================================== --- trunk/src/dbpedia-navigator/ajax_get_article.php (rev 0) +++ trunk/src/dbpedia-navigator/ajax_get_article.php 2008-07-21 18:07:39 UTC (rev 1014) @@ -0,0 +1,190 @@ +<?php + include('helper_functions.php'); + + session_start(); + + $subject=$_POST['label']; + $fromCache=$_POST['cache']; + + if (isset($_SESSION['articles'])) $articles=$_SESSION['articles']; + $id=$_SESSION['id']; + $ksID=$_SESSION['ksID']; + session_write_close(); + setRunning($id,"true"); + + //get first Letter of label big + $uri=subjectToURI($subject); + + //if article is in session, get it out of the session + if (isset($articles)){ + foreach ($articles as $key => $value) + { + if ($value['subject']==$subject){ + $fromCache=$key; + break; + } + } + } + + //initialize the content variables + $content=""; + $lastArticles=""; + $artTitle=""; + + //get the article + //if $fromCache is -2, no new SearchResults should be processed + //if $fromCache is -1, everything is normal + //if $fromCache is >=0, the article is taken out of the cache + if ($fromCache<0) { + //if there are errors see catch block + try{ + require_once("DLLearnerConnection.php"); + $sc=new DLLearnerConnection($id,$ksID); + $triples=$sc->getTriples($uri); + + //BUILD ARTICLE + // goal: display the data in a nice (DBpedia specific way), maybe similar to + // dbpedia.org/search + + // display a picture if there is one + if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) + $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0]['value'].'" alt="Picture of '.$subject.'" style="float:right; max-width:200px;" \>'; + + //display where it was redirected from, if it was redirected + $redirect=""; + if (isset($triples['http://dbpedia.org/property/redirect'])){ + $content.="<span id=\"redirectedFrom\">redirected from '$subject'</span>"; + $redirect=$triples['http://dbpedia.org/property/redirect'][0]['value']; + } + + // add short description in english + $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0]['value'])."</p>"; + + // give the link to the corresponding Wikipedia article + if(isset($triples['http://xmlns.com/foaf/0.1/page'])) + $content .= '<p><img src="'.$_GET['path'].'images/wikipedia_favicon.png" alt="Wikipedia" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0]['value'].'">view Wikipedia article</a>, '; + $content .= '<a href="'.$uri.'">view DBpedia resource description</a></p>'; + + // display a list of classes + if(isset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type'])) + $content .= '<p>classes: '.formatClassArray($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).'</p>'; + + if(isset($triples['http://dbpedia.org/property/reference'])) { + $content .= '<p>references: <ul>'; + foreach($triples['http://dbpedia.org/property/reference'] as $reference) + $content .= '<li><a href="'.$reference['value'].'">'.$reference['value'].'</a></li>'; + $content .= '</ul></p>'; + } + + //display a Google Map if Geo-koordinates are available + if (isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'])&&isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'])){ + $content.="<br/><img src=\"".$_GET['path']."images/mobmaps_googlemapsicon.jpg\" alt=\"Google Maps\" style=\"max-width:25px;\" /> <a href=\"\" onClick=\"loadGoogleMap(".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0]['value'].",".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0]['value'].",'".$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']."');return false;\">Toggle a map of the location</a><br/><br/><div id=\"map\" style=\"width: 500px; height: 300px;display:none;\"></div>"; + } + + //display photo collection, if there is one + if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])){ + $content.="<br/><img src=\"".$_GET['path']."images/flickr.jpg\" alt=\"Flickr\" style=\"max-width:25px;\" /> <a href=\"".$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value']."\">view a photo collection</a><br/>"; + } + + //skos-subjects + if (isset($triples['http://www.w3.org/2004/02/skos/core#subject'])){ + $content .= '<br/><p>skos subjects: <ul>'; + foreach($triples['http://www.w3.org/2004/02/skos/core#subject'] as $skos) + $content .= '<li><a href="'.$skos['value'].'">'.$skos['value'].'</a></li>'; + $content .= '</ul></p>'; + } + + //BUILD ARTICLE TITLE + $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']; + + // filter out uninteresting properties and properties which + // have already been displayed + unset($triples['http://xmlns.com/foaf/0.1/page']); + unset($triples['http://xmlns.com/foaf/0.1/depiction']); + unset($triples['http://dbpedia.org/property/abstract']); + unset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']); + unset($triples['http://dbpedia.org/property/redirect']); + unset($triples['http://dbpedia.org/property/reference']); + unset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long']); + unset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat']); + unset($triples['http://dbpedia.org/property/hasPhotoCollection']); + unset($triples['http://www.w3.org/2004/02/skos/core#subject']); + unset($triples['http://www.w3.org/2000/01/rdf-schema#label']); + + // display the remaining properties as list which can be used for further navigation + $content .= '<br/><br/><br/>'.get_triple_table($triples); + + //Restart the Session + session_start(); + + //store article in session, to navigate between last 5 articles quickly + $contentArray=array('content' => $content,'subject' => $artTitle); + if (!isset($_SESSION['nextArticle'])){ + $_SESSION['nextArticle']=0; + $_SESSION['articles']=array(); + } + if ($_SESSION['nextArticle']==5) $_SESSION['nextArticle']=0; + $_SESSION['articles'][$_SESSION['nextArticle']]=$contentArray; + $_SESSION['currentArticle']=$_SESSION['nextArticle']; + $_SESSION['nextArticle']++; + + //Add Positives to Session + if (!isset($_SESSION['positive'])){ + if ($redirect!=""){ + $array=array($redirect => $redirect); + } + else $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); + $_SESSION['positive']=$array; + } + else{ + $array=$_SESSION['positive']; + if ($redirect!="") $array[$redirect] = $redirect; + else $array["http://dbpedia.org/resource/".str_replace(" ","_",$subject)]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); + $_SESSION['positive']=$array; + } + + } catch (Exception $e) + { + $content=$e->getMessage(); + $artTitle="No Result"; + //$objResponse->call('xajax_getsubjects',$subject); + } + } + else { + session_start(); + //Article is in session + $content=$_SESSION['articles'][$fromCache]['content']; + $artTitle=$_SESSION['articles'][$fromCache]['subject']; + } + + //Build lastArticles + if (isset($_SESSION['articles'])){ + foreach ($_SESSION['articles'] as $key => $value) + { + $lastArticles.="<a href=\"\" onclick=\"xajax_getarticle('',".$key.");return false;\">".$value['subject']."</a><br/>"; + } + } + + //add Positives and Negatives to Interests + $posInterests=""; + if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ + $posInterests.=urldecode(substr (strrchr ($pos, "/"), 1))." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"".$_GET['path']."images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; + } + $negInterests=""; + if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ + $negInterests.=urldecode(substr (strrchr ($neg, "/"), 1))." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"".$_GET['path']."images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"".$_GET['path']."images/remove.png\" alt=\"Delete\"/></a><br/>"; + } + + + print $content; + print '$$'; + print $artTitle; + print '$$'; + print $lastArticles; + print '$$'; + print $posInterests; + print '$$'; + print $negInterests; + + //$objResponse->call('xajax_learnConcept'); +?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/helper_functions.php =================================================================== --- trunk/src/dbpedia-navigator/helper_functions.php (rev 0) +++ trunk/src/dbpedia-navigator/helper_functions.php 2008-07-21 18:07:39 UTC (rev 1014) @@ -0,0 +1,160 @@ +<?php +function subjectToURI($subject) +{ + //if the subject is already a URI return it + if (strpos($subject,"http://dbpedia.org/resource/")===0) + return $subject; + //delete whitespaces at beginning and end + $subject=trim($subject); + //get first letters big + $subject=ucfirst($subject); + //replace spaces with _ + $subject=str_replace(' ','_',$subject); + //add the uri + $subject="http://dbpedia.org/resource/".$subject; + + return $subject; +} + +function getTagCloud($tags,$label) +{ + $max=max($tags); + $min=min($tags); + $diff=$max-$min; + $distribution=$diff/3; + + $ret="<p>"; + foreach ($tags as $tag=>$count){ + if ($count==$min) $style="font-size:xx-small;"; + else if ($count==$max) $style="font-size:xx-large;"; + else if ($count>($min+2*$distribution)) $style="font-size:large;"; + else if ($count>($min+$distribution)) $style="font-size:medium;"; + else $style="font-size:small;"; + + $tag_with_entities=htmlentities("\"".$tag."\""); + $ret.='<a style="'.$style.'" href="#" onclick="xajax_getSubjectsFromConcept(\''.$tag_with_entities.'\');">'.$label[$tag].'</a>'; + } + $ret.="</p>"; + return $ret; +} + +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('".$result."',-1);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"); + $file=fopen("./temp/".$id.".temp","w"); + fwrite($file, $running); + fclose($file); +} + +function get_triple_table($triples) { + + $table = '<table border="0"><tr><td>predicate</td><td>object</td></tr>'; + $i=1; + foreach($triples as $predicate=>$object) { + if ($i>0) $backgroundcolor="eee"; + else $backgroundcolor="ffffff"; + $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'">'.nicePredicate($predicate).'</a></td>'; + $table .= '<td><ul>'; + foreach($object as $element) { + if ($element['type']=="uri") $table .= '<li><a href="'.$element['value'].'">'.$element['value'].'</a></li>'; + else $table .= '<li>'.$element['value'].'</li>'; + } + $table .= '</ul></td>'; + $i*=-1; + } + $table .= '</table>'; + return $table; +} + +function nicePredicate($predicate) +{ + if (strripos ($predicate, "#")>strripos ($predicate, "/")){ + $namespace=substr ($predicate,0,strripos ($predicate, "#")); + $name=substr ($predicate,strripos ($predicate, "#")+1); + } + else{ + $namespace=substr ($predicate,0,strripos ($predicate, "/")); + $name=substr ($predicate,strripos ($predicate, "/")+1); + } + + switch ($namespace){ + case "http://www.w3.org/2000/01/rdf-schema": $namespace="rdfs"; + break; + case "http://www.w3.org/2002/07/owl": $namespace="owl"; + break; + case "http://xmlns.com/foaf/0.1": $namespace="foaf"; + break; + case "http://dbpedia.org/property": $namespace="p"; + break; + case "http://www.w3.org/2003/01/geo/wgs84_pos": $namespace="geo"; + break; + case "http://www.w3.org/2004/02/skos/core": $namespace="skos"; + break; + } + + return $namespace.':'.$name; +} + +function formatClassArray($ar) { + $string = formatClass($ar[0]['value']); + for($i=1; $i<count($ar); $i++) { + $string .= ', ' . formatClass($ar[$i]['value']); + } + return $string; +} + +// format a class nicely, i.e. link to it and possibly display +// it in a better way +function formatClass($className) { + $yagoPrefix = 'http://dbpedia.org/class/yago/'; + if(substr($className,0,30)==$yagoPrefix) { + return '<a href="'.$className.'">'.substr($className,30).'</a>'; + // DBpedia is Linked Data, so it makes always sense to link it + // ToDo: instead of linking to other pages, the resource should better + // be openened within DBpedia Navigator + } else if(substr($className,0,14)=='http://dbpedia') { + return '<a href="'.$className.'">'.$className.'</a>'; + } else { + return $className; + } +} + +function arrayToCommaSseparatedList($ar) { + $string = $ar[0]; + for($i=1; $i<count($ar); $i++) { + $string .= ', ' . $ar[$i]; + } + return $string; +} +?> \ No newline at end of file Added: trunk/src/dbpedia-navigator/index-new.php =================================================================== --- trunk/src/dbpedia-navigator/index-new.php (rev 0) +++ trunk/src/dbpedia-navigator/index-new.php 2008-07-21 18:07:39 UTC (rev 1014) @@ -0,0 +1,274 @@ +<?php + +ini_set('error_reporting',E_ALL); +ini_set('max_execution_time',200); +ini_set("soap.wsdl_cache_enabled","1"); + +session_start(); +require_once('DLLearnerConnection.php'); +$sc=new DLLearnerConnection(); +$ids=$sc->getIDs(); +$_SESSION['id']=$ids[0]; +$_SESSION['ksID']=$ids[1]; + +if (isset($_GET['path'])) $path=$_GET['path']; +else $path=""; + +require_once('Settings.php'); +$settings=new Settings(); + +/* +//what happens onLoad +$onLoad="onLoad=\""; +if (isset($_GET['resource'])){ + $onLoad.="xajax_getarticle('".$_GET['resource']."',-1);"; + unset($_GET['resource']); +} +else if (isset($_SESSION['currentArticle'])){ + $onLoad.="xajax_getarticle('',".$_SESSION['currentArticle'].");"; +} +$onLoad.="\""; +*/ + +echo '<?xml version="1.0" encoding="UTF-8"?>'; +?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <head> + <title>DBpedia Navigator</title> + <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> + <link rel="stylesheet" href="<?php print $path;?>default.css"/> + <link rel="stylesheet" type="text/css" href="<?php print $path;?>treemenu/dhtmlxtree.css"> + <script src="http://maps.google.com/maps?file=api&v=2&key=<?php print $settings->googleMapsKey;?>" + type="text/javascript"></script> + <script src="<?php print $path;?>treemenu/dhtmlxcommon.js"></script> + <script src="<?php print $path;?>treemenu/dhtmlxtree.js"></script> + <script type="text/javascript"> + function showdiv(id){ + document.getElementById(id).style.display='block'; + } + + function hidediv(id) { + document.getElementById(id).style.display='none'; + } + + function loadGoogleMap(Lat,Lng,Label) { + if (document.getElementById("map").style.display=="none"){ + document.getElementById("map").style.display='block'; + if (GBrowserIsCompatible()) { + // Create and Center a Map + var map = new GMap2(document.getElementById("map")); + map.setCenter(new GLatLng(Lat, Lng), 12); + map.addControl(new GLargeMapControl()); + map.addControl(new GMapTypeControl()); + var marker=new GMarker(new GLatLng(Lat, Lng)); + GEvent.addListener(marker, "click", function() { + marker.openInfoWindowHtml(Label); + }); + map.addOverlay(marker); + } + } + else { + document.getElementById("map").style.display='none'; + } + } + + function get_article(param) + { + if (document.all){ + //IE + var XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); + } + else{ + //Mozilla + var XhrObj = new XMLHttpRequest(); + } + + XhrObj.open("POST",'ajax_get_article.php'); + + XhrObj.onreadystatechange = function() + { + if (XhrObj.readyState == 4 && XhrObj.status == 200){ + var response = XhrObj.responseText.split('$$'); + document.getElementById('articlecontent').innerHTML=response[0]; + document.getElementById('ArticleTitle').innerHTML=response[1]; + document.getElementById('lastarticles').innerHTML=response[2]; + document.getElementById('Positives').innerHTML=response[3]; + document.getElementById('Negatives').innerHTML=response[4]; + } + } + + XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); + XhrObj.send(param); + } + </script> + </head> + <body> + +<!-- <h1>DBpedia Navigator</h1> --> +<div><table border="0" width="100%"><tr><td width="35%"><img src="<?php print $path;?>images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /></td><td width="50%"><span id="conceptlink"></span></td><td width="15%"><span id="Loading" style="display:none">Server Call... <img src="<?php print $path;?>images/remove.png" onclick="xajax_stopServerCall();return false;" /></span></td></tr></table></div> +<div id="layer" style="display:none"> + <div id="layerContent" style="display:none"></div> +</div> + +<div id="wrapper"> + <div id="leftSidebar"> + + <div class="box"> + <div class="boxtitle">Search DBpedia</div> + <div class="boxcontent" id="search"> + <!-- Search:<br/> --> + <form onSubmit="get_article('label='+document.getElementById('label').value+'&cache=-1');return false;"> + <input type="text" name="label" id="label" /><br/> + <input type="button" value="Article" class="button" onclick="get_article('label='+document.getElementById('label').value+'&cache=-1');return false;" /> <input type="button" value="Search" class="button" onclick="var list=tree.getAllChecked();return false;" /> + <!-- <input type="button" value="Fulltext" class="button" onclick=""/> --> + </form> + </div> <!-- boxcontent --> + </div> <!-- box --> + + <div class="box" id="SearchResultBox" style="display:none"> + <div class="boxtitle">Search Results</div> + <div class="boxcontent"> + <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="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.setOnClickHandler(doOnClick); + function doOnClick(nodeId){ + var myUrl = tree.getUserData(nodeId,"myurl"); + xajax_getSubjectsFromConcept(myUrl); + } + tree.setXMLAutoLoading("processTreeMenu.php"); + tree.loadXML("processTreeMenu.php?id=0"); + </script> + + + <div class="box" id="credits"> + <p>DBpedia Navigator is powered by ... <br /> + <a href="http://dl-learner.org">DL-Learner</a><br /> + <a href="http//dbpedia.org">DBpedia</a><br/> + <a href="http://virtuoso.openlinksw.com/wiki/main/">OpenLink Virtuoso</a><br /> + ... and implemented by <a href="http://jens-lehmann.org">Jens Lehmann</a> and + Sebastian Knappe at the <a href="http:/aksw.org">AKSW</a> research group (University of Leipzig).</p> + + <a href="http://www.w3.org/2004/OWL/"><img src="<?php print $path;?>images/sw-owl-green.png" alt="OWL logo" /></a> + <a href="http://www.w3.org/2001/sw/DataAccess/"><img src="<?php print $path;?>images/sw-sparql-green.png" alt="SPARQL logo"/></a> + </div> + + </div><!-- END leftSidebar --> + + <div id="content"> + <div class="box"> + <div class="boxtitle" id="ArticleTitle">Welcome</div> + <div class="boxcontent" id="article"> + <div id="articlecontent" style="display:block"> + <br /><br /> + Welcome to the DBpedia Navigator interface! DBpedia Navigator allows you to search DBpedia + and uses the background knowledge in DBpedia to suggest possible interesting navigation + links. + </div> + </div> <!-- boxcontent --> + </div> <!-- box --> + </div><!-- content --> + + <div id="rightSidebar"> + + <div class="box"> + <div class="boxtitlewithbutton" id="positivesboxtitle">search relevant <img src="<?php print $path;?>images/remove.png" onclick="xajax_clearPositives()" /> </div> + <div class="boxcontent" id="Positives"> + </div> <!-- boxcontent --> + </div> <!-- box --> + + <div class="box"> + <div class="boxtitlewithbutton" id="negativesboxtitle">not relevant <img src="<?php print $path;?>images/remove.png" onclick="xajax_clearNegatives()" /> </div> + <div class="boxcontent" id="Negatives"> + </div> <!-- boxcontent --> + </div> <!-- box --> + + <div class="box" id="LastArticlesBox" style="display:none"> + <div class="boxtitle">Articles Last Viewed</div> + <div class="boxcontent" id="lastarticles"> + </div> <!-- boxcontent --> + </div> <!-- box --> + + </div><!-- rightSidebar --> + + <!-- <div id="clear"></div> --> + +</div><!-- wrapper --> +<div id="footer"> + <p>Licensed under the GNU General Public License (GPL) 3 as part of the DL-Learner open source + project.<br />Copyright © Jens Lehmann 2007-2008 </p> + <div id="validation"> + <?php + $uri = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; + + echo '<div><a href="http://validator.w3.org/check?uri='.$uri.'"'; + echo '><img src="'.$path.'images/valid-xhtml10.png" alt="valid XHTML 1.0" /></a>'."\n"; + echo '<a href="http://jigsaw.w3.org/css-validator/validator?uri='.$uri.'"'; + echo '><img src="'.$path.'images/valid-css.png" alt="valid CSS" /></a></div>'."\n"; + ?> + </div> + <p><a href='<?php print $path;?>rebuild.php'>rebuild [restart session and redownload WSDL file (for debugging)]</a></p> +</div> + +<div id="todo"> +<b>ToDo:</b> +<ul style="float:left"> + <li>Get learning component fast.</li> + <li>Get local DBpedia SPARQL endpoint working (next DBpedia release expected at the endof January and then every + two months, so it would be nice to have a script based partly automated or at least documented solution for + creating a DBpedia mirror).</li> + <li>Improve stability: Fix sometimes occurring PHP errors and warnings (check PHP error log).</li> + <li>For each result, display a "+" which shows more information about the concept in an overlay box, e.g. its + Description Logic or OWL syntax, its classification accuracy on the examples, and which + examples it classifies (in-)correctly.</li> + <li>Create a small number of test cases (e.g. 3), which can be used to verify that DBpedia Navigator is + working in typical scenarios (in particular cases where concepts with length greater one are learned).</li> + <li>Allow to disable caching functionality (in Settings.php).</li> + <li>Make DBpedia Navigator RESTful, e.g. URLs $base/showArticle/$URL for displaying an article; + $base/search/$phrase for searching; $base/listInstances/$complexClass for listing the instances of + a learned. Maybe session variables (in particuar the selected positive and negative examples) can + also be given, e.g. $base/search/$phrase?positives=[$URL1,$URL2,$URL3]&negatives=[$URL4]. The supported + URI design should be briefly documented (e.g. on a dbpedia.org wiki page). A good URI design allows + easier external access (just give someone a link instead of saying exactly which actions have to be done to + get to a state), simplifies debugging the application, and may be of use for creating further + features.</li> + <li>Improve search functionality [we will probably get feedback from Georgi in February].</li> + <li>[maybe] Display a tag cloud similar to <a href="http://dbpedia.org/search/">DBpedia search</a>.</li> + <li>[maybe] Instead of only allowing a search as entry point to the application, also display + a navigatable class tree.</li> + <li>[if possible] When expensive SPARQL queries or learning problems have been posed, there should be + some way to abandon these if the user has already switched to doing something else. Example: The user + has added 3 positive and 1 negative examples. This is executed as a learning problem, but has no solution (so + DL-Learner would run forever unless we pose some internal time limit). The user adds another negative example a + second later, so instead of letting the previous learning problem run for a long time (and needing much resources), + it should be stopped by DBpedia Navigator.</li> + <li>[if possible] Find an easy way to validate HTML/JS in AJAX applications.</li> + <li>[maybe] Would be interesting to somehow view the Wikipedia article (without the left navigation part, + tabs etc.) as an overlay, because the Wikipedia article will almost always be a human-friendlier + description of an object compared to the extracted one.</li> +</ul> +</div> + + <div class="box" id="ConceptBox" style="position:absolute;top:15px;right:15px;width:18%;opacity:0.90;display:none;z-index:5;"> + <div class="boxtitle">Detailed Concept Information</div> + <div class="boxcontent" id="ConceptInformation"></div> + </div> + + </body> +</html> + \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-07-19 13:37:54
|
Revision: 1013 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1013&view=rev Author: jenslehmann Date: 2008-07-19 13:37:47 +0000 (Sat, 19 Jul 2008) Log Message: ----------- WSDL update Modified Paths: -------------- trunk/src/music-recommender/main.wsdl Modified: trunk/src/music-recommender/main.wsdl =================================================================== --- trunk/src/music-recommender/main.wsdl 2008-07-19 08:55:55 UTC (rev 1012) +++ trunk/src/music-recommender/main.wsdl 2008-07-19 13:37:47 UTC (rev 1013) @@ -112,6 +112,20 @@ <message name="learnResponse"> <part name="return" type="xsd:string"></part> </message> + <message name="learnDescriptionsEvaluated"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + </message> + <message name="learnDescriptionsEvaluatedResponse"> + <part name="return" type="xsd:string"></part> + </message> + <message name="getCurrentlyBestEvaluatedDescriptions"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + </message> + <message name="getCurrentlyBestEvaluatedDescriptionsResponse"> + <part name="return" type="xsd:string"></part> + </message> <message name="learnThreaded"> <part name="arg0" type="xsd:int"></part> </message> @@ -329,6 +343,16 @@ <message name="SparqlRetrievalResponse"> <part name="return" type="xsd:string"></part> </message> + <message name="getNegativeExamples"> + <part name="arg0" type="xsd:int"></part> + <part name="arg1" type="xsd:int"></part> + <part xmlns:ns19="http://jaxb.dev.java.net/array" name="arg2" type="ns19:stringArray"></part> + <part name="arg3" type="xsd:int"></part> + <part name="arg4" type="xsd:string"></part> + </message> + <message name="getNegativeExamplesResponse"> + <part xmlns:ns20="http://jaxb.dev.java.net/array" name="return" type="ns20:stringArray"></part> + </message> <portType name="DLLearnerWebService"> <operation name="init" parameterOrder="arg0 arg1"> <input message="tns:init"></input> @@ -420,6 +444,16 @@ <output message="tns:learnResponse"></output> <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> </operation> + <operation name="learnDescriptionsEvaluated" parameterOrder="arg0 arg1"> + <input message="tns:learnDescriptionsEvaluated"></input> + <output message="tns:learnDescriptionsEvaluatedResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> + <operation name="getCurrentlyBestEvaluatedDescriptions" parameterOrder="arg0 arg1"> + <input message="tns:getCurrentlyBestEvaluatedDescriptions"></input> + <output message="tns:getCurrentlyBestEvaluatedDescriptionsResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> <operation name="learnThreaded" parameterOrder="arg0"> <input message="tns:learnThreaded"></input> <output message="tns:learnThreadedResponse"></output> @@ -592,6 +626,11 @@ <output message="tns:SparqlRetrievalResponse"></output> <fault message="tns:ParseException" name="ParseException"></fault> </operation> + <operation name="getNegativeExamples" parameterOrder="arg0 arg1 arg2 arg3 arg4"> + <input message="tns:getNegativeExamples"></input> + <output message="tns:getNegativeExamplesResponse"></output> + <fault message="tns:ClientNotKnownException" name="ClientNotKnownException"></fault> + </operation> </portType> <binding name="DLLearnerWebServicePortBinding" type="tns:DLLearnerWebService"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding> @@ -811,6 +850,30 @@ <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> </fault> </operation> + <operation name="learnDescriptionsEvaluated"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> + <operation name="getCurrentlyBestEvaluatedDescriptions"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> <operation name="learnThreaded"> <soap:operation soapAction=""></soap:operation> <input> @@ -1234,6 +1297,18 @@ <soap:fault name="ParseException" use="literal"></soap:fault> </fault> </operation> + <operation name="getNegativeExamples"> + <soap:operation soapAction=""></soap:operation> + <input> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </input> + <output> + <soap:body use="literal" namespace="http://server.dllearner.org/"></soap:body> + </output> + <fault name="ClientNotKnownException"> + <soap:fault name="ClientNotKnownException" use="literal"></soap:fault> + </fault> + </operation> </binding> <service name="DLLearnerWSService"> <port name="DLLearnerWebServicePort" binding="tns:DLLearnerWebServicePortBinding"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-07-19 08:56:02
|
Revision: 1012 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1012&view=rev Author: sknappe Date: 2008-07-19 08:55:55 +0000 (Sat, 19 Jul 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-19 08:53:52 UTC (rev 1011) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-19 08:55:55 UTC (rev 1012) @@ -388,7 +388,6 @@ json += "\"solution" + count + "\" : " + description.asJSON(); count++; } - System.out.println(json); return json; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-07-19 08:54:01
|
Revision: 1011 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1011&view=rev Author: sknappe Date: 2008-07-19 08:53:52 +0000 (Sat, 19 Jul 2008) Log Message: ----------- Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-17 14:49:00 UTC (rev 1010) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-19 08:53:52 UTC (rev 1011) @@ -379,6 +379,20 @@ } @WebMethod + public String getCurrentlyBestEvaluatedDescriptions(int id, int limit) throws ClientNotKnownException{ + ClientState state = getState(id); + List<EvaluatedDescription> descriptions = state.getLearningAlgorithm().getCurrentlyBestEvaluatedDescriptions(limit); + String json = "{"; + int count = 1; + for(EvaluatedDescription description : descriptions) { + json += "\"solution" + count + "\" : " + description.asJSON(); + count++; + } + System.out.println(json); + return json; + } + + @WebMethod public boolean isAlgorithmRunning(int id) throws ClientNotKnownException { return getState(id).isAlgorithmRunning(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-07-17 14:49:59
|
Revision: 1010 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1010&view=rev Author: sknappe Date: 2008-07-17 14:49:00 +0000 (Thu, 17 Jul 2008) Log Message: ----------- commented something Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-07-15 16:44:26 UTC (rev 1009) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-07-17 14:49:00 UTC (rev 1010) @@ -54,8 +54,6 @@ if(empty($negExamples)){ $negExamples=$this->client->getNegativeExamples($this->id,$this->ksID,$posExamples,count($posExamples),"http://dbpedia.org/resource/"); $negExamples=$negExamples->item; - - var_dump($negExamples); } $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); $this->client->setReasoner($this->id, "fastInstanceChecker"); @@ -338,11 +336,11 @@ } } - +/* ini_set('default_socket_timeout',200); $sc=new DLLearnerConnection(); $ids=$sc->getIDs(); $sc=new DLLearnerConnection($ids[0],$ids[1]); $triples=$sc->getConceptFromExamples(array('http://dbpedia.org/resource/Leipzig'),array()); -var_dump($triples); +var_dump($triples);*/ ?> Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-07-15 16:44:26 UTC (rev 1009) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-07-17 14:49:00 UTC (rev 1010) @@ -392,9 +392,9 @@ $concept.="<table border=0>\n"; $i=1; foreach ($concepts as $con){ - $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".htmlentities($con)."');return false;\" onMouseOver=\"showdiv('div".$i."');showdiv('ConceptBox');\" onMouseOut=\"hidediv('div".$i."');hidediv('ConceptBox');\" />".$con."</a></td></tr>"; + $concept.="<tr><td><a href=\"\" onclick=\"xajax_getSubjectsFromConcept('".urlencode($con)."');return false;\" onMouseOver=\"showdiv('div".$i."');showdiv('ConceptBox');\" onMouseOut=\"hidediv('div".$i."');hidediv('ConceptBox');\" />".$con."</a></td></tr>"; //put information about concepts in divs - //$conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."<br/>Concept Length: ".$sc->getConceptLength($con)."</div>"; + $conceptinformation.="<div id=\"div".$i."\" style=\"display:none\">Concept Depth: ".$conceptDepth[$i-1]."<br/>Concept Arity: ".$conceptArity[$i-1]."<br/>Concept Length: ".$sc->getConceptLength($con)."</div>"; $i++; } $concept.="</table>"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-07-15 16:44:30
|
Revision: 1009 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1009&view=rev Author: lorenz_b Date: 2008-07-15 09:44:26 -0700 (Tue, 15 Jul 2008) Log Message: ----------- added method toManchesterSyntaxString() to class individual fixed some bugs in wizard view Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/Individual.java trunk/src/dl-learner/org/dllearner/tools/ore/ColorListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/ore/ColumnListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/LeftPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/Main.java trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifierOWLAPI.java trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/UndoLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/Wizard.java trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java trunk/src/dl-learner/org/dllearner/tools/ore/WizardPanelDescriptor.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWL.java trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWLDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparql.java trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparqlDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java trunk/src/dl-learner/org/dllearner/tools/ore/StatsLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/all_test.owl trunk/src/dl-learner/org/dllearner/tools/ore/father3.owl trunk/src/dl-learner/org/dllearner/tools/ore/father_disjoint.owl trunk/src/dl-learner/org/dllearner/tools/ore/father_inverse_property.owl trunk/src/dl-learner/org/dllearner/tools/ore/father_neg.owl trunk/src/dl-learner/org/dllearner/tools/ore/father_new.owl trunk/src/dl-learner/org/dllearner/tools/ore/father_property.owl trunk/src/dl-learner/org/dllearner/tools/ore/father_wrong.owl trunk/src/dl-learner/org/dllearner/tools/ore/incohaerent.owl trunk/src/dl-learner/org/dllearner/tools/ore/neg_has_all.owl trunk/src/dl-learner/org/dllearner/tools/ore/neg_has_some.owl trunk/src/dl-learner/org/dllearner/tools/ore/pos_b.owl trunk/src/dl-learner/org/dllearner/tools/ore/pos_has_all.owl Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionButton.java trunk/src/dl-learner/org/dllearner/tools/ore/MoveMenuItem.java trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java trunk/src/dl-learner/org/dllearner/tools/ore/Neu_006.gif trunk/src/dl-learner/org/dllearner/tools/ore/inkohaerent.owl Modified: trunk/src/dl-learner/org/dllearner/core/owl/Individual.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Individual.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/core/owl/Individual.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -67,6 +67,10 @@ return "\"" + Helper.getAbbreviatedString(name, baseURI, prefixes) + "\""; } + public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { + return Helper.getAbbreviatedString(name, baseURI, prefixes); + } + public void accept(KBElementVisitor visitor) { visitor.visit(this); } Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWL.java (from rev 1006, trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanel.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWL.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWL.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -0,0 +1,112 @@ +package org.dllearner.tools.ore; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.geom.Ellipse2D; +import java.awt.geom.RoundRectangle2D; + +import javax.swing.DefaultListModel; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.event.ListSelectionListener; + +import org.jdesktop.swingx.JXBusyLabel; +import org.jdesktop.swingx.icon.EmptyIcon; +import org.jdesktop.swingx.painter.BusyPainter; + + +public class ClassPanelOWL extends JPanel{ + + private static final long serialVersionUID = 3026319637264844550L; + + private javax.swing.JList conceptList; + + private JPanel contentPanel; + + private DefaultListModel model; + private JXBusyLabel loadingLabel; + private JLabel statusLabel; + + @SuppressWarnings("unchecked") + public ClassPanelOWL() { + + super(); + + model = new DefaultListModel(); + loadingLabel = new JXBusyLabel(new Dimension(15,15)); + statusLabel = new JLabel(); + + + BusyPainter painter = new BusyPainter( + new RoundRectangle2D.Float(0, 0,6.0f,2.6f,10.0f,10.0f), + new Ellipse2D.Float(2.0f,2.0f,11.0f,11.0f)); + painter.setTrailLength(2); + painter.setPoints(7); + painter.setFrame(-1); + loadingLabel.setPreferredSize(new Dimension(15,15)); + loadingLabel.setIcon(new EmptyIcon(15,15)); + loadingLabel.setBusyPainter(painter); + + + + JPanel labelPanel = new JPanel(); + labelPanel.add(loadingLabel); + labelPanel.add(statusLabel); + + + contentPanel = getContentPanel(); + setLayout(new java.awt.BorderLayout()); + add(contentPanel,BorderLayout.CENTER); + add(labelPanel, BorderLayout.SOUTH); + } + + private JPanel getContentPanel() { + + JPanel contentPanel1 = new JPanel(); + JScrollPane scroll = new JScrollPane(); + + + conceptList = new JList(model); + scroll.setPreferredSize(new Dimension(400,400)); + scroll.setViewportView(conceptList); + contentPanel1.add(scroll); + + + + return contentPanel1; + } + + public DefaultListModel getModel(){ + return model; + } + + public void setModel(DefaultListModel dm){ + conceptList.setModel(dm); + } + + public void addSelectionListener(ListSelectionListener l){ + conceptList.addListSelectionListener(l); + } + + public JList getList(){ + return conceptList; + } + + + public JLabel getStatusLabel() { + return statusLabel; + } + + public JXBusyLabel getLoadingLabel() { + return loadingLabel; + } + + + + + + + +} \ No newline at end of file Property changes on: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWL.java ___________________________________________________________________ Name: svn:mergeinfo + Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWLDescriptor.java (from rev 1006, trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanelDescriptor.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWLDescriptor.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWLDescriptor.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -0,0 +1,70 @@ +package org.dllearner.tools.ore; + +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import org.dllearner.core.owl.NamedClass; + + + + +public class ClassPanelOWLDescriptor extends WizardPanelDescriptor implements ListSelectionListener{ + + public static final String IDENTIFIER = "CLASS_CHOOSE_OWL_PANEL"; + public static final String INFORMATION = "In this panel all atomic classes in the ontology are shown in the list above. " + + "Select one of them which should be (re)learned from then press \"Next-Button\""; + + ClassPanelOWL panel3; + + public ClassPanelOWLDescriptor() { + panel3 = new ClassPanelOWL(); + panel3.addSelectionListener(this); + + setPanelDescriptorIdentifier(IDENTIFIER); + setPanelComponent(panel3); + + } + + @Override + public Object getNextPanelDescriptor() { + return LearningPanelDescriptor.IDENTIFIER; + } + + @Override + public Object getBackPanelDescriptor() { + return KnowledgeSourcePanelDescriptor.IDENTIFIER; + } + + @Override + public void aboutToDisplayPanel() { + getWizard().getInformationField().setText(INFORMATION); + setNextButtonAccordingToConceptSelected(); + } + + + public void valueChanged(ListSelectionEvent e) { + setNextButtonAccordingToConceptSelected(); + if (!e.getValueIsAdjusting()) + getWizardModel().getOre().setConcept((NamedClass)panel3.getList().getSelectedValue()); + + } + + private void setNextButtonAccordingToConceptSelected() { + + if (panel3.getList().getSelectedValue()!= null){ + getWizard().setNextFinishButtonEnabled(true); + }else{ + getWizard().setNextFinishButtonEnabled(false); + } + + } + + + + + + + + + +} Property changes on: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWLDescriptor.java ___________________________________________________________________ Name: svn:mergeinfo + Added: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparql.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparql.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -0,0 +1,88 @@ +package org.dllearner.tools.ore; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.geom.Ellipse2D; +import java.awt.geom.RoundRectangle2D; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.jdesktop.swingx.JXBusyLabel; +import org.jdesktop.swingx.icon.EmptyIcon; +import org.jdesktop.swingx.painter.BusyPainter; + + +public class ClassPanelSparql extends JPanel{ + + private static final long serialVersionUID = 3026319637264844550L; + + private JTextField classField; + + private JPanel contentPanel; + + private JXBusyLabel loadingLabel; + private JLabel statusLabel; + + @SuppressWarnings("unchecked") + public ClassPanelSparql() { + + super(); + + statusLabel = new JLabel(); + + loadingLabel = new JXBusyLabel(new Dimension(15,15)); + BusyPainter painter = new BusyPainter( + new RoundRectangle2D.Float(0, 0,6.0f,2.6f,10.0f,10.0f), + new Ellipse2D.Float(2.0f,2.0f,11.0f,11.0f)); + painter.setTrailLength(2); + painter.setPoints(7); + painter.setFrame(-1); + loadingLabel.setPreferredSize(new Dimension(15,15)); + loadingLabel.setIcon(new EmptyIcon(15,15)); + loadingLabel.setBusyPainter(painter); + + + JPanel labelPanel = new JPanel(); + labelPanel.add(loadingLabel); + labelPanel.add(statusLabel); + + contentPanel = getContentPanel(); + setLayout(new java.awt.BorderLayout()); + add(contentPanel,BorderLayout.CENTER); + add(labelPanel, BorderLayout.SOUTH); + } + + private JPanel getContentPanel() { + + JPanel contentPanel = new JPanel(); + + classField = new JTextField(); + + contentPanel.add(classField); + + return contentPanel; + } + + + public JTextField getClassField(){ + return classField; + } + + + public JLabel getStatusLabel() { + return statusLabel; + } + + public JXBusyLabel getLoadingLabel() { + return loadingLabel; + } + + + + + + + +} \ No newline at end of file Added: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparqlDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparqlDescriptor.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparqlDescriptor.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -0,0 +1,51 @@ +package org.dllearner.tools.ore; + + + + + +public class ClassPanelSparqlDescriptor extends WizardPanelDescriptor{ + + public static final String IDENTIFIER = "CLASS_CHOOSE_SPARQL_PANEL"; + public static final String INFORMATION = "In this panel all atomic classes in the ontology are shown in the list above. " + + "Select one of them which should be (re)learned from then press \"Next-Button\""; + + ClassPanelSparql panel3; + + public ClassPanelSparqlDescriptor() { + panel3 = new ClassPanelSparql(); + + + setPanelDescriptorIdentifier(IDENTIFIER); + setPanelComponent(panel3); + + } + + @Override + public Object getNextPanelDescriptor() { + return LearningPanelDescriptor.IDENTIFIER; + } + + @Override + public Object getBackPanelDescriptor() { + return KnowledgeSourcePanelDescriptor.IDENTIFIER; + } + + @Override + public void aboutToDisplayPanel() { + getWizard().getInformationField().setText(INFORMATION); + + } + + + + + + + + + + + + +} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ColorListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ColorListCellRenderer.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ColorListCellRenderer.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -7,18 +7,27 @@ import javax.swing.JList; import javax.swing.ListCellRenderer; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; + public class ColorListCellRenderer extends JLabel implements ListCellRenderer { private static final long serialVersionUID = -7592805113197759247L; - - public ColorListCellRenderer() { + private ORE ore; + + public ColorListCellRenderer(ORE ore) { setOpaque(true); + this.ore = ore; } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - - setText(value.toString()); + + if(value instanceof NamedClass) + setText(((NamedClass)value).toManchesterSyntaxString(ore.getBaseURI(), ore.getPrefixes())); + else if(value instanceof Individual) + setText(((Individual)value).toManchesterSyntaxString(ore.getBaseURI(), ore.getPrefixes())); + Color background; Color foreground; @@ -28,8 +37,8 @@ } else if(isSelected){ - background = Color.BLUE; - foreground = Color.WHITE; + background = Color.LIGHT_GRAY; + foreground = Color.BLACK; }else{ background = Color.WHITE; foreground = Color.BLACK; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ColumnListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ColumnListCellRenderer.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ColumnListCellRenderer.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -1,8 +1,10 @@ package org.dllearner.tools.ore; -import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import javax.swing.JLabel; import javax.swing.JList; @@ -24,18 +26,18 @@ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + removeAll(); + JLabel cor = new JLabel(); JLabel desc = new JLabel(); - setLayout(new BorderLayout()); - - - desc.setText(value.toString()); - cor.setText( (ore.getCorrectness((Description)value)).toString()); - - add(cor, BorderLayout.WEST); - add(desc, BorderLayout.EAST); - + setLayout(new GridBagLayout()); + desc.setText(((Description) value).toManchesterSyntaxString( + ore.getBaseURI(), ore.getPrefixes())); + cor.setText((ore.getCorrectness((Description) value)).toString()); + add(cor,new GridBagConstraints(0, 0, 1, 1, 0.1, 0.0, GridBagConstraints.LINE_END, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));//, BorderLayout.WEST); + add(desc,new GridBagConstraints(1, 0, 1, 1, 0.8, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));//, BorderLayout.EAST); + Color background; Color foreground; @@ -45,7 +47,7 @@ } else if(isSelected){ - background = Color.BLUE; + background = Color.LIGHT_GRAY; foreground = Color.WHITE; }else{ background = Color.WHITE; Deleted: trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanel.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanel.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -1,113 +0,0 @@ -package org.dllearner.tools.ore; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.geom.Ellipse2D; -import java.awt.geom.RoundRectangle2D; - -import javax.swing.DefaultListModel; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.event.ListSelectionListener; - -import org.jdesktop.swingx.JXBusyLabel; -import org.jdesktop.swingx.icon.EmptyIcon; -import org.jdesktop.swingx.painter.BusyPainter; - - -public class ConceptPanel extends JPanel{ - - private static final long serialVersionUID = 3026319637264844550L; - - private javax.swing.JList conceptList; - - private JPanel contentPanel; - - private DefaultListModel model; - private JXBusyLabel loadingLabel; - private JLabel statusLabel; - - @SuppressWarnings("unchecked") - public ConceptPanel() { - - super(); - - model = new DefaultListModel(); - loadingLabel = new JXBusyLabel(new Dimension(15,15)); - statusLabel = new JLabel(); - - - BusyPainter painter = new BusyPainter( - new RoundRectangle2D.Float(0, 0,6.0f,2.6f,10.0f,10.0f), - new Ellipse2D.Float(2.0f,2.0f,11.0f,11.0f)); - painter.setTrailLength(2); - painter.setPoints(7); - painter.setFrame(-1); - loadingLabel.setPreferredSize(new Dimension(15,15)); - loadingLabel.setIcon(new EmptyIcon(15,15)); - loadingLabel.setBusyPainter(painter); - - - - JPanel labelPanel = new JPanel(); - labelPanel.add(loadingLabel); - labelPanel.add(statusLabel); - - - contentPanel = getContentPanel(); - setLayout(new java.awt.BorderLayout()); - add(contentPanel,BorderLayout.CENTER); - add(labelPanel, BorderLayout.SOUTH); - } - - private JPanel getContentPanel() { - - JPanel contentPanel1 = new JPanel(); - JScrollPane scroll = new JScrollPane(); - - - conceptList = new JList(model); - conceptList.setCellRenderer(new ColorListCellRenderer()); - scroll.setPreferredSize(new Dimension(400,400)); - scroll.setViewportView(conceptList); - contentPanel1.add(scroll); - - - - return contentPanel1; - } - - public DefaultListModel getModel(){ - return model; - } - - public void setModel(DefaultListModel dm){ - conceptList.setModel(dm); - } - - public void addSelectionListener(ListSelectionListener l){ - conceptList.addListSelectionListener(l); - } - - public JList getList(){ - return conceptList; - } - - - public JLabel getStatusLabel() { - return statusLabel; - } - - public JXBusyLabel getLoadingLabel() { - return loadingLabel; - } - - - - - - - -} \ No newline at end of file Deleted: trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanelDescriptor.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ConceptPanelDescriptor.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -1,69 +0,0 @@ -package org.dllearner.tools.ore; - -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import org.dllearner.core.owl.NamedClass; - - - - -public class ConceptPanelDescriptor extends WizardPanelDescriptor implements ListSelectionListener{ - - public static final String IDENTIFIER = "CONCEPT_CHOOSE_PANEL"; - - ConceptPanel panel3; - - public ConceptPanelDescriptor() { - - panel3 = new ConceptPanel(); - panel3.addSelectionListener(this); - - setPanelDescriptorIdentifier(IDENTIFIER); - setPanelComponent(panel3); - - } - - @Override - public Object getNextPanelDescriptor() { - return LearningPanelDescriptor.IDENTIFIER; - } - - @Override - public Object getBackPanelDescriptor() { - return KnowledgeSourcePanelDescriptor.IDENTIFIER; - } - - @Override - public void aboutToDisplayPanel() { - setNextButtonAccordingToConceptSelected(); - } - - - - public void valueChanged(ListSelectionEvent e) { - setNextButtonAccordingToConceptSelected(); - if (!e.getValueIsAdjusting()) - getWizardModel().getOre().setConcept((NamedClass)panel3.getList().getSelectedValue()); - - } - - private void setNextButtonAccordingToConceptSelected() { - - if (panel3.getList().getSelectedValue()!= null){ - getWizard().setNextFinishButtonEnabled(true); - }else{ - getWizard().setNextFinishButtonEnabled(false); - } - - } - - - - - - - - - -} Deleted: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionButton.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionButton.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionButton.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -1,25 +0,0 @@ -package org.dllearner.tools.ore; - -import javax.swing.JButton; - -import org.dllearner.core.owl.Description; - -public class DescriptionButton extends JButton { - /** - * - */ - private static final long serialVersionUID = 1L; - private Description desc; - - public DescriptionButton(String name, Description desc){ - super(name); - this.desc = desc; - - } - - public Description getDescription(){ - return desc; - } - - -} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -2,14 +2,17 @@ import java.awt.Color; import java.awt.Component; +import java.awt.Cursor; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.util.Map; import java.util.Set; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JPopupMenu; +import javax.swing.ToolTipManager; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; @@ -24,14 +27,33 @@ * */ private static final long serialVersionUID = 1L; + + + private static final int MOVE_TO_CLASS = 0; + private static final int MOVE_FROM_CLASS = 1; + private static final int ADD_CLASS = 2; + private static final int REMOVE_CLASS = 3; + private static final int ADD_PROPERTY = 4; + private static final int REMOVE_RANGE_PROPERTY = 5; + private static final int DELETE_PROPERTY = 6; + private static final int REMOVE_NOT_RANGE_PROPERTY = 7; + + + + private final Description desc; private Individual ind; private ORE ore; private JPopupMenu menu; + private String mode; - public DescriptionLabel(Description d){ - super(d.toString()); + private String baseURI; + private Map<String, String> prefixes; + + public DescriptionLabel(Description d, String mode){ + super(); this.desc = d; + this.mode = mode; setForeground(Color.red); addMouseListener(this); @@ -39,19 +61,75 @@ } public void init(){ + baseURI = ore.getBaseURI(); + prefixes = ore.getPrefixes(); + + setText(((Description)desc).toManchesterSyntaxString(ore.getBaseURI(),ore.getPrefixes())); menu = new JPopupMenu(); - if(!(desc instanceof Negation)){ - if(desc instanceof NamedClass){ - menu.add(new DescriptionMenuItem("remove class assertion " + desc.toString(), desc) ); - JMenu dme = new JMenu("move class assertion " + desc.toString() + " to ..."); - - for(NamedClass nc : ore.getpossibleMoveClasses(ind)){ - MoveMenuItem move = new MoveMenuItem((NamedClass)desc, nc); - dme.add(move); - Set<NamedClass> complements = ore.getComplements(nc, ind); - System.out.println("Gr\xF6\xDFe" + complements.size()); - if(!(complements.size() <=1)){ - move.setEnabled(false); + ToolTipManager.sharedInstance().setDismissDelay(7000); + if(mode.equals("neg")){ + if(!(desc instanceof Negation)){ + if(desc instanceof NamedClass){ + menu.add(new DescriptionMenuItem(REMOVE_CLASS, desc.toManchesterSyntaxString(baseURI, prefixes), desc) ); + + JMenu dme = new JMenu("move class assertion " + desc.toManchesterSyntaxString(baseURI, prefixes) + " to ..."); + for(NamedClass nc : ore.getpossibleClassesMoveTo(ind)){ + DescriptionMenuItem move = new DescriptionMenuItem(MOVE_TO_CLASS, nc.toManchesterSyntaxString(baseURI, prefixes), (NamedClass)desc); + dme.add(move); + Set<NamedClass> complements = ore.getComplements(nc, ind); + if(!(complements.size() <=1)){ + move.setEnabled(false); + StringBuffer strBuf = new StringBuffer(); + strBuf.append("<html>class assertion not possible because individual<br> " + + "is still asserted to its complements:<br><BLOCKQUOTE>"); + + for(NamedClass n: complements) + strBuf.append("<br><b>" + n + "</b>"); + strBuf.append("</BLOCKQUOTE></html>"); + + + move.setToolTipText(strBuf.toString()); + } + } + menu.add(dme); + } + else if(desc instanceof ObjectSomeRestriction){ + String propertyName = ((ObjectSomeRestriction)desc).getRole().toString(baseURI, prefixes); + String propertyRange = ((ObjectSomeRestriction)desc).getChild(0).toManchesterSyntaxString(baseURI, prefixes); + menu.add(new DescriptionMenuItem(DELETE_PROPERTY, propertyName , desc)); + if (!(desc.getChild(0) instanceof Thing)) + menu.add(new DescriptionMenuItem(REMOVE_RANGE_PROPERTY,propertyRange , desc)); + + } + else if(desc instanceof ObjectAllRestriction){ + if (!(desc.getChild(0) instanceof Thing)) { + JMenu dme = new JMenu("add property assertion " + ((ObjectAllRestriction) desc).getRole() + + " with object ..."); + for (Individual i : ore.getIndividualsNotInPropertyRange((ObjectAllRestriction) desc, ind)) + dme.add(new DescriptionMenuItem(ADD_PROPERTY,i.toManchesterSyntaxString(baseURI, prefixes), desc)); + menu.add(dme); + } + } + + } + else if(desc instanceof Negation){ + if(desc.getChild(0) instanceof NamedClass){ + DescriptionMenuItem item = new DescriptionMenuItem(ADD_CLASS, desc.getChild(0).toManchesterSyntaxString(baseURI, prefixes), desc.getChild(0)); + menu.add(item); + if(!ore.getComplements(desc, ind).isEmpty()){ + item.setEnabled(false); + item.setToolTipText("<html>class assertion not possible because individual<br> is still asserted to its complement</html>"); + } + } + } + } + else if(mode.equals("pos")){ + if(!(desc instanceof Negation)){ + if(desc instanceof NamedClass){ + DescriptionMenuItem add = new DescriptionMenuItem(ADD_CLASS, desc.toManchesterSyntaxString(baseURI, prefixes), desc); + Set<NamedClass> complements = ore.getComplements(desc, ind); + if((complements.size() >0)){ + add.setEnabled(false); StringBuffer strBuf = new StringBuffer(); strBuf.append("<html>class assertion not possible because individual<br> " + "is still asserted to its complements:<br><BLOCKQUOTE>"); @@ -61,45 +139,120 @@ strBuf.append("</BLOCKQUOTE></html>"); - move.setToolTipText(strBuf.toString()); + add.setToolTipText(strBuf.toString()); } + menu.add(add); + + Set<NamedClass> moveClasses = ore.getpossibleClassesMoveFrom(ind); + if(moveClasses.size() > 0){ + JMenu move = new JMenu("move to " + desc + " from ..."); + for (NamedClass m : moveClasses) + move.add(new DescriptionMenuItem(MOVE_FROM_CLASS,m.toManchesterSyntaxString(baseURI, prefixes), desc)); + menu.add(move); + + } + + } - menu.add(dme); - } - else if(desc instanceof ObjectSomeRestriction){ - menu.add(new DescriptionMenuItem("remove complete property " + ((ObjectSomeRestriction)desc).getRole(), desc)); - if (!(desc.getChild(0) instanceof Thing)) - menu.add(new DescriptionMenuItem("remove all property assertions to " + ((ObjectSomeRestriction)desc).getChild(0), desc)); - - } - else if(desc instanceof ObjectAllRestriction){ - if (!(desc.getChild(0) instanceof Thing)) { - JMenu dme = new JMenu("add property assertion " + ((ObjectAllRestriction) desc).getRole() + else if(desc instanceof ObjectSomeRestriction){ + JMenu dme = new JMenu("add property assertion " + ((ObjectSomeRestriction) desc).getRole() + " with object ..."); - for (Individual i : ore.getIndividualsNotOfPropertyRange((ObjectAllRestriction) desc, ind)) - dme.add(new DescriptionMenuItem(i.getName(), desc.getChild(0))); + for (Individual i : ore.getIndividualsOfPropertyRange((ObjectSomeRestriction) desc, ind)) + dme.add(new DescriptionMenuItem(ADD_PROPERTY,i.toManchesterSyntaxString(baseURI, prefixes), desc)); menu.add(dme); + } - } - - } - else if(desc instanceof Negation){ - if(desc.getChild(0) instanceof NamedClass){ - DescriptionMenuItem item = new DescriptionMenuItem("add class assertion to " + desc.getChild(0).toString(), desc.getChild(0)); - menu.add(item); - if(!ore.getComplements(desc, ind).isEmpty()){ - item.setEnabled(false); - item.setToolTipText("<html>class assertion not possible because individual<br> is still asserted to its complement</html>"); + else if(desc instanceof ObjectAllRestriction){ + if (!(desc.getChild(0) instanceof Thing)) { + menu.add(new DescriptionMenuItem(REMOVE_NOT_RANGE_PROPERTY,((ObjectAllRestriction) desc).getChild(0).toString(baseURI, prefixes), desc)); + menu.add(new DescriptionMenuItem(DELETE_PROPERTY,((ObjectAllRestriction) desc).getRole().toString(baseURI, prefixes), desc)); + } } + } - else if(desc.getChild(0) instanceof ObjectSomeRestriction){ - JMenu dme = new JMenu("add property " + desc.toString() + " with object ..."); - for(Individual i : ore.getIndividualsOfPropertyRange((ObjectSomeRestriction)desc.getChild(0), ind)) - dme.add(new DescriptionMenuItem(i.getName(), desc.getChild(0))); - menu.add(dme); - } + } + +// else if(desc instanceof Negation){ +// if(desc.getChild(0) instanceof NamedClass){ +// DescriptionMenuItem item = new DescriptionMenuItem("add class assertion to " + desc.getChild(0).toString(), desc.getChild(0)); +// menu.add(item); +// if(!ore.getComplements(desc, ind).isEmpty()){ +// item.setEnabled(false); +// item.setToolTipText("<html>class assertion not possible because individual<br> is still asserted to its complement</html>"); +// } +// } +// else if(desc.getChild(0) instanceof ObjectSomeRestriction){ +// JMenu dme = new JMenu("add property " + desc.toString() + " with object ..."); +// for(Individual i : ore.getIndividualsOfPropertyRange((ObjectSomeRestriction)desc.getChild(0), ind)) +// dme.add(new DescriptionMenuItem(i.getName(), desc.getChild(0))); +// menu.add(dme); +// } +// } + } +// menu = new JPopupMenu(); +// ToolTipManager.sharedInstance().setDismissDelay(7000); +// if(!(desc instanceof Negation)){ +// if(desc instanceof NamedClass){ +// menu.add(new DescriptionMenuItem("remove class assertion " + desc.toString(), desc) ); +// JMenu dme = new JMenu("move class assertion " + desc.toString() + " to ..."); +// +// for(NamedClass nc : ore.getpossibleMoveClasses(ind)){ +// MoveMenuItem move = new MoveMenuItem((NamedClass)desc, nc); +// dme.add(move); +// Set<NamedClass> complements = ore.getComplements(nc, ind); +// System.out.println("Gr\xF6\xDFe" + complements.size()); +// if(!(complements.size() <=1)){ +// move.setEnabled(false); +// StringBuffer strBuf = new StringBuffer(); +// strBuf.append("<html>class assertion not possible because individual<br> " + +// "is still asserted to its complements:<br><BLOCKQUOTE>"); +// +// for(NamedClass n: complements) +// strBuf.append("<br><b>" + n + "</b>"); +// strBuf.append("</BLOCKQUOTE></html>"); +// +// +// move.setToolTipText(strBuf.toString()); +// } +// } +// menu.add(dme); +// } +// else if(desc instanceof ObjectSomeRestriction){ +// menu.add(new DescriptionMenuItem("remove complete property " + ((ObjectSomeRestriction)desc).getRole(), desc)); +// if (!(desc.getChild(0) instanceof Thing)) +// menu.add(new DescriptionMenuItem("remove all property assertions to " + ((ObjectSomeRestriction)desc).getChild(0), desc)); +// +// } +// else if(desc instanceof ObjectAllRestriction){ +// if (!(desc.getChild(0) instanceof Thing)) { +// JMenu dme = new JMenu("add property assertion " + ((ObjectAllRestriction) desc).getRole() +// + " with object ..."); +// for (Individual i : ore.getIndividualsNotOfPropertyRange((ObjectAllRestriction) desc, ind)) +// dme.add(new DescriptionMenuItem(i.getName(), desc.getChild(0))); +// menu.add(dme); +// } +// } +// +// } +// else if(desc instanceof Negation){ +// if(desc.getChild(0) instanceof NamedClass){ +// DescriptionMenuItem item = new DescriptionMenuItem("add class assertion to " + desc.getChild(0).toString(), desc.getChild(0)); +// menu.add(item); +// if(!ore.getComplements(desc, ind).isEmpty()){ +// item.setEnabled(false); +// item.setToolTipText("<html>class assertion not possible because individual<br> is still asserted to its complement</html>"); +// } +// } +// else if(desc.getChild(0) instanceof ObjectSomeRestriction){ +// JMenu dme = new JMenu("add property " + desc.toString() + " with object ..."); +// for(Individual i : ore.getIndividualsOfPropertyRange((ObjectSomeRestriction)desc.getChild(0), ind)) +// dme.add(new DescriptionMenuItem(i.getName(), desc.getChild(0))); +// menu.add(dme); +// } +// } +// } public Description getDescription(){ return desc; @@ -132,14 +285,15 @@ public void mouseEntered(MouseEvent e) { - setText("<html><u>" + desc.toString() + "</u></html>"); + setText("<html><u>" + ((Description)desc).toManchesterSyntaxString(ore.getBaseURI(),ore.getPrefixes()) + "</u></html>"); + setCursor(new Cursor(Cursor.HAND_CURSOR)); } public void mouseExited(MouseEvent e) { - setText(desc.toString()); - + setText(((Description)desc).toManchesterSyntaxString(ore.getBaseURI(),ore.getPrefixes())); + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -11,12 +11,30 @@ */ private static final long serialVersionUID = 6784086889435854440L; - Description desc; + private Description desc; + private int action; - - public DescriptionMenuItem(String text, Description d){ - super(text); + public DescriptionMenuItem(int action, String text, Description d){ + super(); + if(action == 3) + setText("remove class assertion to " + text); + else if(action == 0) + setText(text); + else if(action == 2) + setText("add class assertion to " + text); + else if(action == 4) + setText(text); + else if(action == 6) + setText("delete complete property " + text); + else if(action == 5) + setText("remove all property assertions to " + text); + else if(action == 7) + setText("remove all property assertions with range not in " + text); + else if(action == 1) + setText(text); + this.desc = d; + this.action = action; } @@ -24,6 +42,10 @@ return desc; } + public int getActionID(){ + return action; + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionPanel.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionPanel.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -21,8 +21,10 @@ ORE ore; Individual ind; ActionListener aL; + String mode; + boolean correct = false; - public DescriptionPanel(ORE ore, Individual ind, ActionListener aL){ + public DescriptionPanel(ORE ore, Individual ind, ActionListener aL, String mode){ super(); setBackground(Color.WHITE); @@ -30,35 +32,72 @@ this.ore = ore; this.ind = ind; this.aL = aL; - for(JLabel jL : ore.DescriptionToJLabel(ind, ore.conceptToAdd)){ - add(jL); - if(jL instanceof DescriptionLabel){ + this.mode = mode; + if(mode.equals("neg")){ + for(JLabel jL : ore.DescriptionToJLabelNeg(ind, ore.conceptToAdd)){ + add(jL); + if(jL instanceof DescriptionLabel){ + + ((DescriptionLabel)jL).setIndOre(ore, ind); + ((DescriptionLabel)jL).init(); + ((DescriptionLabel)jL).addActionListeners(aL); + + } - ((DescriptionLabel)jL).setIndOre(ore, ind); - ((DescriptionLabel)jL).init(); - ((DescriptionLabel)jL).addActionListeners(aL); } } + else if(mode.equals("pos")){ + for(JLabel jL : ore.DescriptionToJLabelPos(ind, ore.conceptToAdd)){ + add(jL); + if(jL instanceof DescriptionLabel){ + + ((DescriptionLabel)jL).setIndOre(ore, ind); + ((DescriptionLabel)jL).init(); + ((DescriptionLabel)jL).addActionListeners(aL); + + } + + } + } } - public void updatePanel(){//DescriptionButton descBut, Description desc){ + public void updatePanel(){ for(Component c : getComponents()) if(c instanceof JLabel) remove(c); ore.updateReasoner(); - for(JLabel jL : ore.DescriptionToJLabel(ind, ore.conceptToAdd)){ - add(jL); - if(jL instanceof DescriptionLabel){ - ((DescriptionLabel)jL).setIndOre(ore, ind); - ((DescriptionLabel)jL).init(); - ((DescriptionLabel)jL).addActionListeners(aL); - - + correct = true; + if (mode.equals("neg")) { + for (JLabel jL : ore.DescriptionToJLabelNeg(ind, ore.conceptToAdd)) { + add(jL); + if (jL instanceof DescriptionLabel) { + ((DescriptionLabel) jL).setIndOre(ore, ind); + ((DescriptionLabel) jL).init(); + ((DescriptionLabel) jL).addActionListeners(aL); + correct = false; + + } } } + else if(mode.equals("pos")){ + for (JLabel jL : ore.DescriptionToJLabelPos(ind, ore.conceptToAdd)) { + add(jL); + if (jL instanceof DescriptionLabel) { + ((DescriptionLabel) jL).setIndOre(ore, ind); + ((DescriptionLabel) jL).init(); + ((DescriptionLabel) jL).addActionListeners(aL); + correct = false; + + } + } + } SwingUtilities.updateComponentTreeUI(this); } + + public boolean isCorrect(){ + return correct; + } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanel.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanel.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -16,6 +16,8 @@ public class IntroductionPanel extends JPanel { private static final long serialVersionUID = 7184544803724152044L; + + private JTextArea instructionsField; private JScrollPane jScrollPane1; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanelDescriptor.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanelDescriptor.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -5,7 +5,7 @@ public class IntroductionPanelDescriptor extends WizardPanelDescriptor { public static final String IDENTIFIER = "INTRODUCTION_PANEL"; - + public IntroductionPanelDescriptor() { super(IDENTIFIER, new IntroductionPanel()); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanel.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanel.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -1,24 +1,44 @@ package org.dllearner.tools.ore; import java.awt.BorderLayout; +import java.awt.GridLayout; import java.awt.event.ActionListener; import java.io.File; +import java.net.URL; +import java.util.Vector; +import javax.swing.Box; +import javax.swing.ButtonGroup; +import javax.swing.GroupLayout; +import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.SwingConstants; +import javax.swing.border.TitledBorder; import javax.swing.event.DocumentListener; import javax.swing.filechooser.FileFilter; +import org.dllearner.kb.sparql.SparqlEndpoint; + public class KnowledgeSourcePanel extends JPanel{ private static final long serialVersionUID = -3997200565180270088L; private javax.swing.JTextField fileURL; + private JTextField sparqlURL; private javax.swing.JButton browseButton; + private JComboBox sparqlBox; + private JPanel contentPanel; private JLabel message; + private JRadioButton owl; + private JRadioButton sparql; + + public KnowledgeSourcePanel() { new LeftPanel(1); @@ -26,7 +46,6 @@ setLayout(new java.awt.BorderLayout()); - //add(leftPanel,BorderLayout.WEST); add(contentPanel,BorderLayout.CENTER); } @@ -35,20 +54,61 @@ JPanel contentPanel1 = new JPanel(); + JPanel buttonPanel = new JPanel(); + ButtonGroup bg = new ButtonGroup(); + Box box = Box.createVerticalBox(); + owl = new JRadioButton("OWL", true); + sparql = new JRadioButton("SPARQL"); + bg.add(owl); + bg.add(sparql); + box.add(owl); + box.add(sparql); + buttonPanel.add(box); + + JPanel owlPanel = new JPanel(); + GroupLayout layout = new GroupLayout(owlPanel); + owlPanel.setLayout(layout); + layout.setAutoCreateGaps(true); + layout.setAutoCreateContainerGaps(true); + owlPanel.setBorder(new TitledBorder("OWL")); message = new JLabel(); message.setText("enter or browse OWL file"); - fileURL = new javax.swing.JTextField(40); - + fileURL = new javax.swing.JTextField(60); browseButton = new javax.swing.JButton("browse"); - - contentPanel1.setLayout(new BorderLayout()); + layout.setHorizontalGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(fileURL) + .addComponent(message)) + .addComponent(browseButton)); + layout.linkSize(SwingConstants.HORIZONTAL, fileURL, message); + + layout.setVerticalGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(fileURL) + .addComponent(browseButton)) + + .addComponent(message)); - JPanel panel = new JPanel(); - panel.add(fileURL); - panel.add(browseButton); - contentPanel1.add(panel,BorderLayout.CENTER); - contentPanel1.add(message,BorderLayout.SOUTH); + JPanel sparqlPanel = new JPanel(); + sparqlPanel.setBorder(new TitledBorder("SPARQL")); + sparqlURL = new JTextField(60); + sparqlURL.setEnabled(false); + + Vector<URL> model = new Vector<URL>(); + for(SparqlEndpoint e : SparqlEndpoint.listEndpoints()) + model.add(e.getURL()); + sparqlBox = new JComboBox(model); + sparqlBox.setEditable(false); + sparqlBox.setSelectedIndex(-1); + sparqlBox.setEnabled(false); + sparqlPanel.add(sparqlBox); + + + contentPanel1.setLayout(new GridLayout(0,1)); + contentPanel1.add(buttonPanel); + contentPanel1.add(owlPanel); + contentPanel1.add(sparqlPanel); @@ -58,6 +118,9 @@ public void addListeners(ActionListener l, DocumentListener d) { browseButton.addActionListener(l); fileURL.addActionListener(l); + sparqlURL.addActionListener(l); + owl.addActionListener(l); + sparql.addActionListener(l); fileURL.getDocument().addDocumentListener(d); } @@ -126,5 +189,25 @@ this.fileURL.setText(fileURL); } - + public void setOWLMode(){ + fileURL.setEnabled(true); + browseButton.setEnabled(true); + message.setVisible(true); + + sparqlBox.setEditable(false); + sparqlBox.setEnabled(false); + + } + + public void setSPARQLMode(){ + fileURL.setEnabled(false); + browseButton.setEnabled(false); + message.setVisible(false); + + sparqlBox.setEnabled(true); + sparqlBox.setEditable(true); + + } + + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanelDescriptor.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanelDescriptor.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -14,23 +14,28 @@ public class KnowledgeSourcePanelDescriptor extends WizardPanelDescriptor implements ActionListener, DocumentListener{ public static final String IDENTIFIER = "KNOWLEDGESOURCE_CHOOSE_PANEL"; + public static final String INFORMATION = "Select the KnowledgeSource(OWL-FILE) on which you want to work and " + + "then press \"Next\"-button"; - private KnowledgeSourcePanel panel2; + private KnowledgeSourcePanel knowledgePanel; public KnowledgeSourcePanelDescriptor() { - panel2 = new KnowledgeSourcePanel(); + knowledgePanel = new KnowledgeSourcePanel(); - panel2.addListeners(this, this); + knowledgePanel.addListeners(this, this); setPanelDescriptorIdentifier(IDENTIFIER); - setPanelComponent(panel2); + setPanelComponent(knowledgePanel); } @Override public Object getNextPanelDescriptor() { - return ConceptPanelDescriptor.IDENTIFIER; + if(getWizard().getKnowledgeSourceType() == 0) + return ClassPanelOWLDescriptor.IDENTIFIER; + else + return ClassPanelSparqlDescriptor.IDENTIFIER; } @Override @@ -41,13 +46,20 @@ @Override public void aboutToDisplayPanel() { - setNextButtonAccordingToExistingOWLFile(); + getWizard().getInformationField().setText(INFORMATION); + setNextButtonAccordingToExistingOWLFile(); } public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if(cmd.equals("browse")){ - panel2.openFileChooser(); + knowledgePanel.openFileChooser(); + }else if(cmd.equals("OWL")){ + knowledgePanel.setOWLMode(); + getWizard().setKnowledgeSourceType(0); + }else if(cmd.equals("SPARQL")){ + knowledgePanel.setSPARQLMode(); + getWizard().setKnowledgeSourceType(1); } setNextButtonAccordingToExistingOWLFile(); @@ -58,8 +70,8 @@ private void setNextButtonAccordingToExistingOWLFile() { - if (panel2.isExistingOWLFile()){ - getWizardModel().getOre().setKnowledgeSource(panel2.getOWLFile()); + if (knowledgePanel.isExistingOWLFile()){ + getWizardModel().getOre().setKnowledgeSource(knowledgePanel.getOWLFile()); getWizard().setNextFinishButtonEnabled(true); // new ConceptRetriever().execute(); // System.err.println("test"); @@ -89,6 +101,10 @@ setNextButtonAccordingToExistingOWLFile(); } + public KnowledgeSourcePanel getPanel() { + return knowledgePanel; + } + class ConceptRetriever extends SwingWorker<Set<NamedClass>, NamedClass> { @Override @@ -96,7 +112,7 @@ { getWizardModel().getOre().detectReasoner(); Set<NamedClass> ind = getWizardModel().getOre().getReasoningService().getAtomicConcepts(); - ConceptPanelDescriptor nextPanel = (ConceptPanelDescriptor)getWizardModel().getPanelHashMap().get(getNextPanelDescriptor()); + ClassPanelOWLDescriptor nextPanel = (ClassPanelOWLDescriptor)getWizardModel().getPanelHashMap().get(getNextPanelDescriptor()); nextPanel.panel3.getModel().clear(); for (NamedClass cl : ind){ @@ -111,9 +127,6 @@ } -public KnowledgeSourcePanel getPanel() { - return panel2; -} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -2,12 +2,16 @@ import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.ActionListener; import java.awt.geom.Ellipse2D; import java.awt.geom.RoundRectangle2D; import java.util.Dictionary; import java.util.Hashtable; +import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.DefaultListModel; import javax.swing.JButton; @@ -28,54 +32,34 @@ private JPanel contentPanel; - private javax.swing.JList resultList; + private DefaultListModel model; private JLabel statusLabel; private JXBusyLabel loadingLabel; - private JButton startButton; - private JButton stopButton; + + private JList resultList; + private JScrollPane listScrollPane; + private JPanel listPanel; + private JPanel noisePanel; private JSlider noiseSlider; - + private JLabel noiseLabel; + private JButton stopButton; + private JButton startButton; + private JPanel buttonPanel; + private JPanel buttonSliderPanel; + private JLabel conceptLabel; + private JLabel accuracyLabel; public LearningPanel() { super(); model = new DefaultListModel(); - - JPanel eastPanel = new JPanel(); - eastPanel.setLayout(new BoxLayout(eastPanel, BoxLayout.Y_AXIS)); - - JPanel buttonPanel = new JPanel(); - startButton = new JButton("Start"); - stopButton = new JButton("Stop"); - stopButton.setEnabled(false); - buttonPanel.add(startButton); - buttonPanel.add(stopButton); - - JPanel noisePanel = new JPanel(); - noisePanel.setLayout(new BoxLayout(noisePanel, BoxLayout.Y_AXIS)); - noiseSlider = new JSlider(0, 100, 0); - noiseSlider.setPaintTicks(true); - noiseSlider.setMajorTickSpacing(10); - noiseSlider.setMinorTickSpacing(5); - Dictionary<Integer, JLabel> map = new Hashtable<Integer, JLabel>(); - map.put( new Integer(0), new JLabel("0%") ); - map.put( new Integer(50), new JLabel("50%") ); - map.put( new Integer(100),new JLabel("100%") ); - noiseSlider.setLabelTable( map ); - noiseSlider.setPaintLabels(true); - noisePanel.add(new JLabel("noise")); - noisePanel.add(noiseSlider); - - eastPanel.add(buttonPanel); - eastPanel.add(noisePanel); - + JPanel statusPanel = new JPanel(); statusLabel = new JLabel(); - loadingLabel = new JXBusyLabel(new Dimension(15,15)); BusyPainter<Object> painter = new BusyPainter<Object>( new RoundRectangle2D.Float(0, 0,6.0f,2.6f,10.0f,10.0f), @@ -92,26 +76,115 @@ contentPanel = getContentPanel(); setLayout(new java.awt.BorderLayout()); - add(eastPanel, BorderLayout.EAST); + add(contentPanel,BorderLayout.CENTER); add(statusPanel, BorderLayout.SOUTH); } private JPanel getContentPanel() { + JPanel contentPanel = new JPanel(); + GridBagLayout contentLayout = new GridBagLayout(); + setPreferredSize(new Dimension(700, 500)); + contentLayout.rowWeights = new double[] {0.5}; + contentLayout.rowHeights = new int[] {500}; + contentLayout.columnWeights = new double[] {0.5, 0.0}; + contentLayout.columnWidths = new int[] {313, 7}; + this.setLayout(contentLayout); - JPanel contentPanel1 = new JPanel(); - JScrollPane scroll = new JScrollPane(); - - resultList = new JList(model); -// resultList.setCellRenderer(new ColumnListCellRenderer()); - scroll.setPreferredSize(new Dimension(900, 400)); - scroll.setViewportView(resultList); - - contentPanel1.add(scroll); + { + listPanel = new JPanel(); + GridBagLayout jPanel1Layout = new GridBagLayout(); + contentPanel.add(listPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + jPanel1Layout.rowWeights = new double[] {0.0, 0.5}; + jPanel1Layout.rowHeights = new int[] {16,400}; + jPanel1Layout.columnWeights = new double[] {0.0, 0.5}; + jPanel1Layout.columnWidths = new int[] {50, 700}; + listPanel.setLayout(jPanel1Layout); + listPanel.setBorder(BorderFactory.createTitledBorder("Learned Concepts")); + { + listScrollPane = new JScrollPane(); + listPanel.add(listScrollPane, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + { + + resultList = new JList(model); + listScrollPane.setViewportView(resultList); + } + } + { + accuracyLabel = new JLabel(); + listPanel.add(accuracyLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); + accuracyLabel.setText("Accuracy"); + } + { + conceptLabel = new JLabel(); + listPanel.add(conceptLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); + conceptLabel.setText("Concept"); + } + } + { + buttonSliderPanel = new JPanel(); + GridBagLayout buttonSliderPanelLayout = new GridBagLayout(); + contentPanel.add(buttonSliderPanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + buttonSliderPanelLayout.rowWeights = new double[] {0.8, 0.0}; + buttonSliderPanelLayout.rowHeights = new int[] {200, 7}; + buttonSliderPanelLayout.columnWeights = new double[] {0.1}; + buttonSliderPanelLayout.columnWidths = new int[] {7}; + buttonSliderPanel.setLayout(buttonSliderPanelLayout); + { + buttonPanel = new JPanel(); + BoxLayout buttonPanelLayout = new BoxLayout(buttonPanel, javax.swing.BoxLayout.X_AXIS); + buttonPanel.setLayout(buttonPanelLayout); + buttonSliderPanel.add(buttonPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + { + startButton = new JButton(); + buttonPanel.add(startButton); + startButton.setText("Start"); + } + { + stopButton = new JButton(); + buttonPanel.add(stopButton); + stopButton.setText("Stop"); + } + } + { + noisePanel = new JPanel(); + BoxLayout noisePanelLayout = new BoxLayout(noisePanel, javax.swing.BoxLayout.Y_AXIS); + noisePanel.setLayout(noisePanelLayout); + buttonSliderPanel.add(noisePanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); + { + noiseLabel = new JLabel(); + noisePanel.add(noiseLabel); + noiseLabel.setText("noise"); + } + { + noiseSlider = new JSlider(0, 100, 0); + noiseSlider.setPaintTicks(true); + noiseSlider.setMajorTickSpacing(10); + noiseSlider.setMinorTickSpacing(5); + Dictionary<Integer, JLabel> map = new Hashtable<Integer, JLabel>(); + map.put( new Integer(0), new JLabel("0%") ); + map.put( new Integer(50), new JLabel("50%") ); + map.put( new Integer(100),new JLabel("100%") ); + noiseSlider.setLabelTable( map ); + noiseSlider.setPaintLabels(true); + noisePanel.add(noiseSlider); + } + } + } +// JPanel contentPanel1 = new JPanel(); +// JScrollPane scroll = new JScrollPane(); +// +// +// resultList = new JList(model); +//// resultList.setCellRenderer(new ColumnListCellRenderer()); +// scroll.setPreferredSize(new Dimension(900, 400)); +// scroll.setViewportView(resultList); +// +// contentPanel1.add(scroll); - return contentPanel1; + return contentPanel; } public void addStartButtonListener(ActionListener a){ Modified: trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java 2008-07-15 10:25:32 UTC (rev 1008) +++ trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java 2008-07-15 16:44:26 UTC (rev 1009) @@ -7,6 +7,7 @@ import java.util.TimerTask; import java.util.concurrent.ExecutionException; +import javax.swing.DefaultListModel; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.event.ListSelectionEvent; @@ -48,13 +49,72 @@ @Override public Object getBackPanelDescriptor() { - return ConceptPanelDescriptor.IDENTIFIER; + return ClassPanelOWLDescriptor.IDENTIFIER; } - class ResultSwingWorker extends SwingWorker<List<Description>, List<Description>> { + @Override + public void aboutToDisplayPanel() { + setNextButtonAccordingToConceptSelected(); + } + + + + public void valueChanged(ListSelectionEvent e) { + setNextButtonAccordingToConceptSelected(); +// ObjectAllRestriction role = new ObjectAllRestriction(new ObjectProperty("http://example.com/father#hasChild"), +// new NamedClass("http://example.com/father#female")); +// Description de = new Intersection(new NamedClass("http://example.com/father#male"), role); + + if (!e.getValueIsAdjusting()){ + getWizardModel().getOre().setConceptToAdd((Description)(panel4.getResultList().getSelectedValue())); + + + } + + } + + public void actionPerformed(ActionEvent event) { + if(event.getActionCommand().equals("Start")){ + panel4.getModel().clear(); + panel4.getStartButton().setEnabled(false); + panel4.getStopButton().setEnabled(true); + worker = new ResultSwingWorker(); + worker.execute(); + } + else{ + canceled = true; + panel4.getStopButton().setEnabled(false); + la.stop(); + timer.cancel(); + panel4.getStartButton().setEnabled(true); + panel4.getStatusLabel().setText("Algorithm aborted"); + panel4.getLoadingLabel().setBusy(false); + + } + + + + } + + + + private void setNextButtonAccordingToConceptSelected() { + ... [truncated message content] |
From: <Jen...@us...> - 2008-07-15 10:25:36
|
Revision: 1008 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1008&view=rev Author: JensLehmann Date: 2008-07-15 03:25:32 -0700 (Tue, 15 Jul 2008) Log Message: ----------- added log4j to Helper class Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/utilities/Helper.java Modified: trunk/src/dl-learner/org/dllearner/utilities/Helper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2008-07-10 16:37:43 UTC (rev 1007) +++ trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2008-07-15 10:25:32 UTC (rev 1008) @@ -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.Iterator; @@ -10,6 +29,7 @@ import java.util.TreeSet; import java.util.Map.Entry; +import org.apache.log4j.Logger; import org.dllearner.core.ReasoningMethodUnsupportedException; import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.AssertionalAxiom; @@ -27,14 +47,15 @@ import org.dllearner.utilities.datastructures.SortedSetTuple; /** - * Die Hilfsmethoden benutzen alle SortedSet, da die Operationen damit schneller - * sind. + * TODO: JavaDoc * - * @author jl + * @author Jens Lehmann * */ public class Helper { + private static Logger logger = Logger.getLogger(Helper.class); + // findet alle atomaren Konzepte in einem Konzept public static List<NamedClass> getAtomicConcepts(Description concept) { List<NamedClass> ret = new LinkedList<NamedClass>(); @@ -461,11 +482,8 @@ Helper.removeUninterestingConcepts(concepts); for (NamedClass ac : ignoredConcepts) { boolean success = concepts.remove(ac); - if (!success) { - System.out.println("Warning: Ignored concept " + ac - + " does not exist in knowledge base."); - System.exit(0); - } + if (!success) + logger.warn("Warning: Ignored concept " + ac + " does not exist in knowledge base."); } return concepts; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-07-10 16:37:45
|
Revision: 1007 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1007&view=rev Author: heeroyuy Date: 2008-07-10 09:37:43 -0700 (Thu, 10 Jul 2008) Log Message: ----------- added new panel for more details of the learned concept Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-07-10 09:43:45 UTC (rev 1006) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-07-10 16:37:43 UTC (rev 1007) @@ -10,6 +10,8 @@ import javax.swing.event.ListSelectionEvent; import org.dllearner.core.owl.Description; + +import org.semanticweb.owl.model.OWLDescription; /** * * @author Heero Yuy @@ -37,7 +39,7 @@ * This is the view of the DL-Learner tab. */ private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; -// private JDialog detailDialog; + /** * This is the constructor for the action handler * @param a ActionHandler @@ -135,7 +137,7 @@ } if(z.getActionCommand().equals("Why")) { - view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel(model.getEvaluatedDescription()); + view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel((Description)view.getSuggestClassPanel().getSuggestList().getSelectedValue()); } } @@ -231,18 +233,10 @@ { if(!view.getAddButton().isEnabled()) { - view.getWhyButton().setEnabled(true); view.getAddButton().setEnabled(true); } } - /** - * - * @param t - */ - /*public void textValueChanged(TextEvent t) - { - }*/ /** * */ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-07-10 09:43:45 UTC (rev 1006) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-07-10 16:37:43 UTC (rev 1007) @@ -2,7 +2,7 @@ import java.util.Set; import java.util.TreeSet; -//import java.util.List; +import java.util.List; import java.util.Vector; import java.util.HashSet; import java.util.Iterator; @@ -176,7 +176,8 @@ * */ private OWLAxiom axiomOWLAPI; - private EvaluatedDescription evalDescription; + + private List<EvaluatedDescription> evalDescription; /** * This is the constructor for DL-Learner model * @param editorKit @@ -225,7 +226,8 @@ */ private void addToListModel() { - evalDescription = la.getCurrentlyBestEvaluatedDescription(); + evalDescription = la.getCurrentlyBestEvaluatedDescriptions(anzahl); + System.out.println("Size: "+la.getCurrentlyBestDescriptions().size()); for(int j = 0;j<la.getCurrentlyBestEvaluatedDescriptions(anzahl).size();j++) { suggestModel.add(j,la.getCurrentlyBestEvaluatedDescriptions(anzahl).get(j).getDescription()); @@ -234,7 +236,7 @@ /** * This method checks which positive and negative examples are checked - * and puts the checked examples into a treeset. + * and puts the checked examples into a tree set. */ public void setPositiveAndNegativeExamples() { @@ -271,7 +273,10 @@ { return description; } - + public List<EvaluatedDescription> getEvaluatedDescriptionList() + { + return evalDescription; + } /** * This method sets the knowledge source for the learning process. * Only OWLAPIOntology will be available. @@ -300,7 +305,7 @@ /** * This method sets the Learning problem for the learning process. * PosNegDefinitonLp for equivalent classes and - * PosNegInclusionLP for superclasses. + * PosNegInclusionLP for super classes. */ public void setLearningProblem() { @@ -356,6 +361,7 @@ la.start(); description = new Description[la.getCurrentlyBestEvaluatedDescriptions(anzahl).size()]; addToListModel(); + System.out.println(la.getCurrentlyBestEvaluatedDescriptions()); view.renderErrorMessage(error); view.getRunButton().setEnabled(true); view.getCancelButton().setEnabled(false); @@ -427,10 +433,6 @@ } } - public EvaluatedDescription getEvaluatedDescription() - { - return evalDescription; - } /** * This method resets the Concepts that are learned. */ @@ -636,7 +638,7 @@ } /** - * Thsi method gets a description learned by the DL-Learner an converts it + * This method gets a description learned by the DL-Learner an converts it * to the OWLDescription format. * @param desc Description learned by the DL-Learner */ @@ -672,7 +674,7 @@ /** * This method stores the new concept learned by the DL-Learner in the Ontology. - * @param desc Description learne by the DL-Learner + * @param desc Description learn by the DL-Learner */ public void changeDLLearnerDescriptionsToOWLDescriptions(Description desc) { @@ -686,6 +688,7 @@ OWLOntology ontology = editor.getOWLModelManager().getActiveOntology(); AddAxiom axiom = new AddAxiom(ontology, axiomOWLAPI); + System.out.println("axiom: "+axiomOWLAPI); try { manager.applyChange(axiom); } catch (OWLOntologyChangeException e) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-07-10 09:43:45 UTC (rev 1006) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-07-10 16:37:43 UTC (rev 1007) @@ -1,16 +1,18 @@ package org.dllearner.tools.protege; import java.util.Iterator; -import java.util.Set; +import java.util.List; import javax.swing.JPanel; import javax.swing.JLabel; +import javax.swing.JTextArea; import javax.swing.JScrollPane; import javax.swing.JDialog; +import javax.swing.WindowConstants; import java.awt.GridLayout; import org.dllearner.core.EvaluatedDescription; - +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; public class MoreDetailForSuggestedConceptsPanel extends JPanel{ @@ -18,18 +20,24 @@ private DLLearnerModel model; - private JLabel accuracy; + private JTextArea accuracy; private JPanel accuracyPanel; - private JPanel coveredExamplesPanel; - private JLabel coveredExamples; - + private JLabel coveredPositiveExamples; + private JLabel coveredNegativeExamples; + private JLabel notCoveredPositiveExamples; + private JLabel notCoveredNegativeExamples; private JDialog detailPopup; - + private JPanel examplePanel; + private JTextArea posCoveredText; + private JTextArea posNotCoveredText; + private JTextArea negCoveredText; + private JTextArea negNotCoveredText; + private JTextArea accuracyText; private JScrollPane detailScroll; private JPanel detailPanel; - private EvaluatedDescription evalDescription; + public MoreDetailForSuggestedConceptsPanel(DLLearnerModel model) { this.model = model; @@ -44,29 +52,110 @@ { return detailScroll; } + private EvaluatedDescription getSelectedConcept(Description eval) + { + List<EvaluatedDescription> evalDesc = model.getEvaluatedDescriptionList(); + EvaluatedDescription eDesc = null; + + for(Iterator<EvaluatedDescription> i = evalDesc.iterator(); i.hasNext();) + { + if(eDesc==null) + { + EvaluatedDescription e = i.next(); + System.out.println("Description: "+e.getDescription()); + System.out.println("Description2: "+eval); + if(e.getDescription().toString().equals(eval.toString())) + { + eDesc = e; + } + + } + } + return eDesc; + } - public void renderDetailPanel(EvaluatedDescription eval) + public void renderDetailPanel(Description desc) { - this.evalDescription = eval; - accuracy = new JLabel("Accuracy:"); - coveredExamples = new JLabel("Covered Examples:"); + EvaluatedDescription eval = getSelectedConcept(desc); + System.out.println("Eval: "+eval); + accuracyPanel = new JPanel(new GridLayout(0,2)); + accuracy = new JTextArea("Accuracy:"); + accuracy.setEditable(false); + accuracyPanel.add(accuracy); + posCoveredText = new JTextArea(); + posCoveredText.setEditable(false); + posNotCoveredText = new JTextArea(); + posNotCoveredText.setEditable(false); + negCoveredText = new JTextArea(); + negCoveredText.setEditable(false); + negNotCoveredText = new JTextArea(); + negNotCoveredText.setEditable(false); + accuracyText = new JTextArea(); + accuracyText.setEditable(false); + if(eval!=null) + { + accuracyText.append(String.valueOf(eval.getAccuracy())); + } + accuracyPanel.add(accuracyText); + accuracyPanel.setBounds(0,0,400,40); + examplePanel = new JPanel(new GridLayout(0,2)); + detailPanel = new JPanel(new GridLayout(0,1)); + //detailPanel.setLayout(null); + examplePanel.add(accuracy); + examplePanel.add(accuracyText); + coveredPositiveExamples = new JLabel("Covered Positive Examples:"); + notCoveredPositiveExamples = new JLabel("Not Covered Positive Examples"); + coveredNegativeExamples = new JLabel("Covered Negative Examples:"); + notCoveredNegativeExamples = new JLabel("Not Covered Negative Examples"); detailPopup = new JDialog(); - detailPopup.setSize(300, 300); - accuracyPanel = new JPanel(new GridLayout(0,1)); - coveredExamplesPanel = new JPanel(new GridLayout(0,1)); + detailPopup.setSize(400, 400); + detailPopup.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + detailPopup.setVisible(true); + detailPopup.setResizable(false); detailScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - detailPanel = new JPanel(new GridLayout(0,2)); - accuracyPanel.add(new JLabel(String.valueOf(evalDescription.getAccuracy()))); - Set<Individual> posCovered = evalDescription.getCoveredPositives(); - for(Iterator<Individual> i = posCovered.iterator(); i.hasNext();) + examplePanel.add(coveredPositiveExamples); + examplePanel.add(notCoveredPositiveExamples); + if(eval!=null) { - coveredExamplesPanel.add(new JLabel(i.next().toString())); + for(Iterator<Individual> i = eval.getCoveredPositives().iterator(); i.hasNext();) + { + posCoveredText.append(i.next()+"\n"); } - detailPanel.add(accuracy); - detailPanel.add(accuracyPanel); - detailPanel.add(coveredExamples); - detailPanel.add(coveredExamplesPanel); + examplePanel.add(posCoveredText); + } + if(eval!=null) + { + + for(Iterator<Individual> i = eval.getNotCoveredPositives().iterator(); i.hasNext();) + { + posNotCoveredText.append(i.next()+"\n"); + } + examplePanel.add(posNotCoveredText); + } + examplePanel.add(coveredNegativeExamples); + examplePanel.add(notCoveredNegativeExamples); + + if(eval!=null) + { + for(Iterator<Individual> i = eval.getCoveredNegatives().iterator(); i.hasNext();) + { + negCoveredText.append(i.next()+"\n"); + } + examplePanel.add(negCoveredText); + } + if(eval!=null) + { + + for(Iterator<Individual> i = eval.getNotCoveredNegatives().iterator(); i.hasNext();) + { + negNotCoveredText.append(i.next()+"\n"); + } + examplePanel.add(negNotCoveredText); + } + //detailPanel.add(accuracyPanel); + detailPanel.add(examplePanel); detailScroll.setViewportView(detailPanel); + detailPopup.add(detailScroll); } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-07-10 09:43:45 UTC (rev 1006) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-07-10 16:37:43 UTC (rev 1007) @@ -276,7 +276,7 @@ /** * */ - + private JButton why; /** * */ @@ -324,7 +324,7 @@ /** * */ - private JButton why; + // private JButton why; private MoreDetailForSuggestedConceptsPanel detail; /** * The constructor for the DL-Learner tab in the class description editor @@ -334,6 +334,7 @@ public DLLearnerView(OWLFrame<OWLClass> aktuell,String label) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); + why = new JButton("Why"); classSelectorPanel.firePropertyChange("test", false, true); URL iconUrl = this.getClass().getResource("pfeil.gif"); icon = new ImageIcon(iconUrl); @@ -348,7 +349,7 @@ run = new JButton("Suggest "+label); cancel = new JButton("Cancel"); accept = new JButton("ADD"); - why = new JButton("Why"); + //why = new JButton("Why"); sugPanel.addSuggestPanelMouseListener(action); errorMessage = new JLabel(); learner = new JPanel(); @@ -381,7 +382,6 @@ */ public void makeView() { - why.setEnabled(false); advanced.setIcon(icon); model.clearVector(); model.unsetListModel(); @@ -393,9 +393,9 @@ action.resetToggled(); sugPanel.setSuggestList(model.getSuggestList()); sugPanel = sugPanel.updateSuggestClassList(); - why.setBounds(10,160,200,30); advanced.setSelected(false); sugPanel.setBounds(10,40,490,110); + why.setBounds(10,160,200,30); adv.setBounds(40,200,200,20); run.setBounds(10,0,200,30); advanced.setBounds(10,200,20,20); @@ -407,8 +407,8 @@ errorMessage.setBounds(220,160,300,20); learner.add(run); learner.add(adv); - learner.add(why); learner.add(advanced); + learner.add(why); learner.add(cancel); learner.add(sugPanel); learner.add(accept); @@ -439,10 +439,6 @@ return learner; } - public JButton getWhyButton() - { - return why; - } /** * * @param visible @@ -534,7 +530,6 @@ public void dispose() { } - public void addWhyButtonListener(ActionListener a) { why.addActionListener(a); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-07-10 09:43:53
|
Revision: 1006 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1006&view=rev Author: lorenz_b Date: 2008-07-10 02:43:45 -0700 (Thu, 10 Jul 2008) Log Message: ----------- fixed some repair bugs Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifierOWLAPI.java trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/ore/new.gif Modified: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java 2008-07-10 09:41:14 UTC (rev 1005) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java 2008-07-10 09:43:45 UTC (rev 1006) @@ -5,6 +5,7 @@ import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.util.Set; import javax.swing.JLabel; import javax.swing.JMenu; @@ -14,6 +15,7 @@ import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; +import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.Thing; @@ -42,33 +44,52 @@ if(desc instanceof NamedClass){ menu.add(new DescriptionMenuItem("remove class assertion " + desc.toString(), desc) ); JMenu dme = new JMenu("move class assertion " + desc.toString() + " to ..."); - for(NamedClass nc : ore.getpossibleMoveClasses(ind)) - dme.add(new MoveMenuItem((NamedClass)desc, nc)); + + for(NamedClass nc : ore.getpossibleMoveClasses(ind)){ + MoveMenuItem move = new MoveMenuItem((NamedClass)desc, nc); + dme.add(move); + Set<NamedClass> complements = ore.getComplements(nc, ind); + System.out.println("Gr\xF6\xDFe" + complements.size()); + if(!(complements.size() <=1)){ + move.setEnabled(false); + StringBuffer strBuf = new StringBuffer(); + strBuf.append("<html>class assertion not possible because individual<br> " + + "is still asserted to its complements:<br><BLOCKQUOTE>"); + + for(NamedClass n: complements) + strBuf.append("<br><b>" + n + "</b>"); + strBuf.append("</BLOCKQUOTE></html>"); + + + move.setToolTipText(strBuf.toString()); + } + } menu.add(dme); -// menu.add(new DescriptionMenuItem("move class assertion " + desc.toString() + " to ...", desc)); } else if(desc instanceof ObjectSomeRestriction){ - menu.add(new DescriptionMenuItem("remove property " + ((ObjectSomeRestriction)desc).getRole(), desc)); - System.out.println(desc.getChild(0).getClass()); + menu.add(new DescriptionMenuItem("remove complete property " + ((ObjectSomeRestriction)desc).getRole(), desc)); + if (!(desc.getChild(0) instanceof Thing)) + menu.add(new DescriptionMenuItem("remove all property assertions to " + ((ObjectSomeRestriction)desc).getChild(0), desc)); + + } + else if(desc instanceof ObjectAllRestriction){ if (!(desc.getChild(0) instanceof Thing)) { - JMenu dme = new JMenu("add property assertion " - + ((ObjectSomeRestriction) desc).getRole() + JMenu dme = new JMenu("add property assertion " + ((ObjectAllRestriction) desc).getRole() + " with object ..."); - for (Individual i : ore.getIndividualsNotOfPropertyRange( - (ObjectSomeRestriction) desc, ind)) - dme.add(new DescriptionMenuItem(i.getName(), desc - .getChild(0))); + for (Individual i : ore.getIndividualsNotOfPropertyRange((ObjectAllRestriction) desc, ind)) + dme.add(new DescriptionMenuItem(i.getName(), desc.getChild(0))); menu.add(dme); } } + } else if(desc instanceof Negation){ if(desc.getChild(0) instanceof NamedClass){ DescriptionMenuItem item = new DescriptionMenuItem("add class assertion to " + desc.getChild(0).toString(), desc.getChild(0)); menu.add(item); - if(ore.hasComplement(desc, ind)){ + if(!ore.getComplements(desc, ind).isEmpty()){ item.setEnabled(false); - item.setToolTipText("class assertion not possible because individual is still asserted to its complement"); + item.setToolTipText("<html>class assertion not possible because individual<br> is still asserted to its complement</html>"); } } else if(desc.getChild(0) instanceof ObjectSomeRestriction){ Modified: trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java 2008-07-10 09:41:14 UTC (rev 1005) +++ trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java 2008-07-10 09:43:45 UTC (rev 1006) @@ -24,6 +24,7 @@ LearningPanel panel4; ResultSwingWorker worker; + LearningAlgorithm la; Timer timer; Boolean canceled = false; @@ -54,7 +55,7 @@ class ResultSwingWorker extends SwingWorker<List<Description>, List<Description>> { - LearningAlgorithm la; + Thread t; @@ -75,8 +76,7 @@ public void run() { if(la != null){ - System.out.println(scheduledExecutionTime()-System.currentTimeMillis()); - publish(la.getCurrentlyBestDescriptions(10, true)); + publish(la.getCurrentlyBestDescriptions(30, true)); } } @@ -88,14 +88,13 @@ @Override public void run() { - la.start(); + getWizardModel().getOre().start(); } }); t.setPriority(Thread.MIN_PRIORITY); t.start(); -// publish(la.getCurrentlyBestDescriptions(10, true)); try { t.join(); @@ -103,15 +102,15 @@ // TODO Auto-generated catch block e.printStackTrace(); } - List<Description> result = getWizardModel().getOre().getLearningResults(10); - + List<Description> result = getWizardModel().getOre().getLearningResults(30); + return result; } @Override public void done() { - + timer.cancel(); List<Description> result = null; try { result = get(); @@ -203,7 +202,7 @@ else{ canceled = true; panel4.getStopButton().setEnabled(false); - getWizardModel().getOre().getLa().stop(); + la.stop(); timer.cancel(); panel4.getStartButton().setEnabled(true); panel4.getStatusLabel().setText("Algorithm aborted"); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java 2008-07-10 09:41:14 UTC (rev 1005) +++ trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java 2008-07-10 09:43:45 UTC (rev 1006) @@ -51,10 +51,8 @@ private ORE ore; private Individual ind; -// private OWLAPIReasoner reasoner; private Description actualDesc; private Description newDesc; -// private Individual object; private Set<OWLOntologyChange> allChanges; @@ -62,7 +60,6 @@ super(dialog, "Repair negative example", true); this.ind = ind; this.ore = ore; -// this.reasoner = ore.reasoner2; allChanges = new HashSet<OWLOntologyChange>(); init(); } @@ -90,7 +87,7 @@ GridBagLayout gbl = new GridBagLayout(); gbl.rowWeights = new double[] {0.0, 0.1, 0.1}; - gbl.rowHeights = new int[] {34, 7, 7}; + gbl.rowHeights = new int[] {64, 7, 7}; gbl.columnWeights = new double[] {0.1}; gbl.columnWidths = new int[] {7}; action_stats_Panel.setLayout(gbl); @@ -156,22 +153,31 @@ else if(e.getActionCommand().startsWith("add property")){ //add property Individual ind = new Individual(e.getActionCommand()); List<OWLOntologyChange> changes = ore.modi.addObjectProperty(ind, (ObjectSomeRestriction)actualDesc, ind); - System.out.println("ghhfhg"); allChanges.addAll(changes); descPanel.updatePanel(); changesPanel.add(new ChangePanel("added property assertion " + ((ObjectSomeRestriction)actualDesc).getRole() + " to " + ind, changes, this)); } -// else if(e.getActionCommand().startsWith("remove property")){ //delete property -// ore.modi.deleteObjectProperty(ind, (ObjectSomeRestriction)actualDesc); -// } + else if(e.getActionCommand().startsWith("remove complete property")){ //delete property + List<OWLOntologyChange> changes = ore.modi.deleteObjectProperty(ind, (ObjectSomeRestriction)actualDesc); + allChanges.addAll(changes); + descPanel.updatePanel(); + changesPanel.add(new ChangePanel("removed property " + ((ObjectSomeRestriction)actualDesc).getRole(), changes, this)); + } + else if(e.getActionCommand().startsWith("remove all property")){ //remove property assertions + List<OWLOntologyChange> changes = ore.modi.deleteObjectPropertyAssertions(ind, (ObjectSomeRestriction)actualDesc); + allChanges.addAll(changes); + descPanel.updatePanel(); + changesPanel.add(new ChangePanel("added property assertion " + ((ObjectSomeRestriction)actualDesc).getRole() + " to " + ind, changes, this)); + } + }else if(e.getSource() instanceof MoveMenuItem){ actualDesc = ((MoveMenuItem)e.getSource()).getSource(); newDesc = new NamedClass(e.getActionCommand()); List<OWLOntologyChange> changes = ore.modi.moveIndividual(ind, actualDesc, newDesc); allChanges.addAll(changes); descPanel.updatePanel(); - statsPanel.updatePanel("remove", actualDesc); + statsPanel.updatePanel("move", actualDesc); changesPanel.add(new ChangePanel("moved class assertion from " + actualDesc + " to " + newDesc, changes, this)); } @@ -183,7 +189,8 @@ System.out.println(((RemoveAxiom)ol).getAxiom()); } else if(e.getActionCommand().equals("Ok")){ - + setVisible(false); + dispose(); } else if(e.getActionCommand().equals("Cancel")){ if (JOptionPane.showConfirmDialog(this, @@ -235,58 +242,6 @@ return allChanges; } -// if(e.getActionCommand().equals("delete instance")){ -// ore.modi.deleteIndividual(ind); -// -// } -// else{ -// actualDesc = ((DescriptionButton)e.getSource()).getDescription(); -// -// if(e.getActionCommand().startsWith("remove class")){ //remove class -// System.out.println(ore.reasoner2.instanceCheck(ore.getConceptToAdd() ,ind)); -// ore.modi.removeClassAssertion(ind, actualDesc); -// -// actionsPanel.updatePanel(); -// changes.add(new JLabel("removed class assertion to " + actualDesc)); -// changes.add(new JButton("Undo")); -// System.err.println(ore.modi.checkInstanceNewOntology(ore.conceptToAdd, ind)); -// -// } -// else if(e.getActionCommand().startsWith("add class")){ //add class -// System.err.println(actualDesc); -// ore.modi.addClassAssertion(ind, actualDesc); -// actionsPanel.updatePanel(); -// changes.add(new JLabel("added class assertion to " + actualDesc)); -// -// } -// else if(e.getActionCommand().startsWith("move class")){ //move class -// -// newDesc = (Description)new ChooseDialog(this, ore, ind).getSelectedElement(); -// System.err.println(newDesc); -// if(newDesc != null){ -// System.out.print(ind + " from " + actualDesc + " to " + newDesc); -// ore.modi.moveIndividual(ind, actualDesc, newDesc); -// } -// -// } -// else if(e.getActionCommand().equals("add property")){ //add property -// object = (Individual)new ChooseDialog(this, ore, actualDesc).getSelectedElement(); -// if(object != null) -// ore.modi.addObjectProperty(ind, (ObjectSomeRestriction)actualDesc, object); -// } -// else if(e.getActionCommand().equals("remove property")){ //delete property -// ore.modi.deleteObjectProperty(ind, (ObjectSomeRestriction)actualDesc); -// } -// } - - - - - - - - - } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java 2008-07-10 09:41:14 UTC (rev 1005) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java 2008-07-10 09:43:45 UTC (rev 1006) @@ -25,7 +25,6 @@ import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.Intersection; import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.Nothing; import org.dllearner.core.owl.ObjectQuantorRestriction; import org.dllearner.core.owl.Union; import org.dllearner.kb.OWLAPIOntology; @@ -50,7 +49,7 @@ NamedClass ignoredConcept; Description conceptToAdd; OntologyModifierOWLAPI modi; - Set<NamedClass> allAtomicConcepts; + public Set<NamedClass> allAtomicConcepts; private double noise = 0.0; Thread t; @@ -147,11 +146,11 @@ e1.printStackTrace(); } + Set<String> t = new TreeSet<String>(); - Set<String> t = new TreeSet<String>(); + t.add(ignoredConcept.getName()); cm.applyConfigEntry(la, "ignoredConcepts", t ); -// cm.applyConfigEntry(la, "noisePercentage", noise); cm.applyConfigEntry(la, "guaranteeXgoodDescriptions", 10); try { la.init(); @@ -173,6 +172,7 @@ this.setLearningProblem(); this.setLearningAlgorithm(); + } public LearningAlgorithm start(){ @@ -186,16 +186,15 @@ // TODO Auto-generated catch block e.printStackTrace(); } - System.out.println(noise); + la.start(); return la; } + + -// public List<Description> getSolutions(){ -// return la.getCurrentlyBestDescriptions(); -// } - + public List<Description> getLearningResults(int anzahl){ return la.getCurrentlyBestDescriptions(anzahl, true); } @@ -443,7 +442,7 @@ } public Set<Individual> getIndividualsNotOfPropertyRange(ObjectQuantorRestriction objRestr, Individual ind){ - + System.out.println(rs.getAtomicConcepts()); Set<Individual> individuals = reasoner2.retrieval(objRestr.getChild(0)); Set<Individual> allIndividuals = reasoner2.getIndividuals(); System.out.println("alle:" + allIndividuals); @@ -455,19 +454,23 @@ } public Set<NamedClass> getpossibleMoveClasses(Individual ind){ - Set<NamedClass> moveClasses = rs.getAtomicConcepts(); - Set<NamedClass> indClasses = new HashSet<NamedClass>(); + Set<NamedClass> moveClasses = new HashSet<NamedClass>(); + for(NamedClass nc : rs.getAtomicConcepts()) + if(!rs.instanceCheck(nc, ind)) + moveClasses.add(nc); + - for(NamedClass moveNc : moveClasses) - if(rs.instanceCheck(moveNc, ind)){ - indClasses.add(moveNc); - } - moveClasses.removeAll(indClasses); - for(NamedClass moveNc : moveClasses) - for(NamedClass indNc : indClasses ) - if(new Intersection(moveNc, indNc).equals(new Nothing())) - moveClasses.remove(moveNc); +// for(NamedClass moveNc : moveClasses) +// if(rs.instanceCheck(moveNc, ind)){ +// indClasses.add(moveNc); +// } +// moveClasses.removeAll(indClasses); +// System.out.println("hier?" + allAtomicConcepts); +// for(NamedClass moveNc : moveClasses) +// for(NamedClass indNc : indClasses ) +// if(new Intersection(moveNc, indNc).equals(new Nothing())) +// moveClasses.remove(moveNc); return moveClasses; } @@ -481,22 +484,25 @@ e.printStackTrace(); } reasoner2 = cm.reasoner(OWLAPIReasoner.class,new OWLAPIOntology(modi.ontology)); + try { reasoner2.init(); } catch (ComponentInitException e) { // TODO Auto-generated catch block e.printStackTrace(); } + rs = cm.reasoningService(reasoner2); + setLearningAlgorithm(); } - public boolean hasComplement(Description desc, Individual ind){ + public Set<NamedClass> getComplements(Description desc, Individual ind){ + Set<NamedClass> complements = new HashSet<NamedClass>(); - for(NamedClass nc : reasoner2.getAtomicConcepts()) - if(reasoner2.instanceCheck(nc, ind)) - if(modi.isComplement(desc, nc)) - return true; - - return false; + for(NamedClass nc : reasoner2.getConcepts(ind)){ + if(modi.isComplement(desc, nc)) + complements.add(nc); + } + return complements; } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifierOWLAPI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifierOWLAPI.java 2008-07-10 09:41:14 UTC (rev 1005) +++ trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifierOWLAPI.java 2008-07-10 09:43:45 UTC (rev 1006) @@ -7,9 +7,12 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import java.util.SortedSet; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.Negation; +import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.reasoning.OWLAPIDescriptionConvertVisitor; import org.dllearner.reasoning.OWLAPIReasoner; @@ -55,7 +58,9 @@ * @param oldDesc old description * @return */ - public void addAxiomToOWL(Description newDesc, Description oldDesc){ + public OWLOntologyChange addAxiomToOWL(Description newDesc, Description oldDesc){ + + OWLDescription newConceptOWLAPI = OWLAPIDescriptionConvertVisitor.getOWLDescription(newDesc); OWLDescription oldConceptOWLAPI = OWLAPIDescriptionConvertVisitor.getOWLDescription(oldDesc); @@ -73,8 +78,8 @@ // TODO Auto-generated catch block e.printStackTrace(); } + return axiom; - } /** @@ -217,7 +222,7 @@ try { manager.applyChanges(changes); - saveOntology(); + return changes; } catch (OWLOntologyChangeException e) { // TODO Auto-generated catch block @@ -281,6 +286,48 @@ /** * + * @param ind the individual which property has to be removed + * @param objSome the property which has to be removed + * @return changes that have been done + */ + public List<OWLOntologyChange> deleteObjectPropertyAssertions(Individual ind, ObjectSomeRestriction objSome){ + + List<OWLOntologyChange> changes = new LinkedList<OWLOntologyChange>(); + + OWLIndividual individualOWLAPI = factory.getOWLIndividual( URI.create(ind.getName())); + OWLObjectProperty propertyOWLAPI = factory.getOWLObjectProperty(URI.create(objSome.getRole().getName())); + + Set<OWLObjectPropertyAssertionAxiom> properties = ontology.getObjectPropertyAssertionAxioms(individualOWLAPI); + + + List<RemoveAxiom> removeList = new LinkedList<RemoveAxiom>(); + SortedSet<Individual> allObjects = reasoner.getRoleMembers((ObjectProperty) objSome.getRole()).get(ind); + + for(OWLObjectPropertyAssertionAxiom o :properties){ + if( (o.getProperty().equals(propertyOWLAPI)) && (o.getSubject().equals(individualOWLAPI))) + for(Individual i : allObjects) + if(o.getObject().equals(factory.getOWLIndividual( URI.create(i.getName())))) + removeList.add(new RemoveAxiom(ontology, o)); + + + + } + changes.addAll(removeList); + + try { + manager.applyChanges(removeList); + return changes; + } catch (OWLOntologyChangeException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + + } + + /** + * * @param subInd the individual which is subject in the objectProperty * @param objSome the property which has to be added to subject * @param objInd the individual which is object in the objectProperty @@ -320,8 +367,7 @@ for(OWLOntologyChange change : changes){ if(change instanceof RemoveAxiom){ - OWLAxiom axiom = ((RemoveAxiom)change).getAxiom(); - AddAxiom add = new AddAxiom(ontology, axiom); + AddAxiom add = new AddAxiom(ontology, change.getAxiom()); try { manager.applyChange(add); } catch (OWLOntologyChangeException e) { @@ -330,8 +376,7 @@ } } else if(change instanceof AddAxiom){ - OWLClassAssertionAxiom cl = (OWLClassAssertionAxiom)((AddAxiom)change).getAxiom(); - RemoveAxiom rem = new RemoveAxiom(ontology, cl); + RemoveAxiom rem = new RemoveAxiom(ontology, change.getAxiom()); try { manager.applyChange(rem); } catch (OWLOntologyChangeException e) { @@ -341,23 +386,40 @@ } } + + } public boolean isComplement(Description desc1, Description desc2){ - OWLDescription d1 = OWLAPIDescriptionConvertVisitor.getOWLDescription(desc1); OWLDescription d2 = OWLAPIDescriptionConvertVisitor.getOWLDescription(desc2); - OWLDescription d3 = OWLAPIDescriptionConvertVisitor.getOWLDescription(desc1.getChild(0)); - + OWLDescription negChild = null; + OWLDescription negDesc = null; + if(desc1 instanceof Negation){ + negChild = OWLAPIDescriptionConvertVisitor.getOWLDescription(desc1.getChild(0)); + } + else{ + negDesc = OWLAPIDescriptionConvertVisitor.getOWLDescription(new Negation(desc1)); + } + for(OWLAxiom ax : ontology.getAxioms()){ - if(ax.equals(factory.getOWLEquivalentClassesAxiom(d1, d2))) - return true; - if(ax.equals(factory.getOWLDisjointClassesAxiom(d3, d2))) - return true; + + if(desc1 instanceof Negation){ + if(ax.equals(factory.getOWLEquivalentClassesAxiom(d1, d2))) + return true; + if(ax.equals(factory.getOWLDisjointClassesAxiom(negChild, d2))) + return true; + } + else{ + if(ax.equals(factory.getOWLDisjointClassesAxiom(d1, d2))) + return true; + if(ax.equals(factory.getOWLEquivalentClassesAxiom(negDesc, d2))) + return true; + } + } - - + return false; } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java 2008-07-10 09:41:14 UTC (rev 1005) +++ trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java 2008-07-10 09:43:45 UTC (rev 1006) @@ -60,7 +60,7 @@ } public void actionPerformed(ActionEvent event) { - System.out.println(ontologyChanges); + System.out.println(getOntologyChanges()); if(event.getActionCommand().equals("save")){ getWizardModel().getOre().getModi().saveOntology(); @@ -74,14 +74,13 @@ if(e.getClickCount() == 2 && e.getSource() == panel4.getNegFailureList() ){ Individual ind = (Individual)panel4.getNegFailureList().getSelectedValue(); ontologyChanges.addAll(new NegExampleRepairDialog(ind, getWizard().getDialog(), getWizardModel().getOre()).getAllChanges()); -// System.out.println(getWizardModel().getOre().getCriticalDescriptions(ind, getWizardModel().getOre().conceptToAdd )); + getWizardModel().getOre().getModi().saveOntology(); } } public void mouseEntered(MouseEvent e) { - // TODO Auto-generated method stub - + } public void mouseExited(MouseEvent e) { @@ -97,5 +96,13 @@ public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub - }} + } + + public Set<OWLOntologyChange> getOntologyChanges() { + return ontologyChanges; + } + +} + + Modified: trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java 2008-07-10 09:41:14 UTC (rev 1005) +++ trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java 2008-07-10 09:43:45 UTC (rev 1006) @@ -29,6 +29,7 @@ ORE ore; Individual ind; Set<NamedClass> classes; + Set<String> newClasses; JPanel classesPanel; @@ -69,6 +70,7 @@ classesPanel.add(classLb); classes = ore.reasoner2.getConcepts(ind); + newClasses = new HashSet<String>(); for(NamedClass nc : classes) classesPanel.add(new JLabel(nc.getName())); @@ -81,32 +83,42 @@ public void updatePanel(String action, Description d){ - Set<NamedClass> afterUpdate = new HashSet<NamedClass>(); - afterUpdate.addAll(ore.reasoner2.getConcepts(ind)); + if(action.equals("undo")){ +// Set<String> afterUpdate = new HashSet<String>(); +// for(NamedClass nc : ore.reasoner2.getConcepts(ind)) +// afterUpdate.add(nc.toString()); +// Set<String> oldClasses = new HashSet<String>(); +// for(NamedClass nc : newClasses) +// oldClasses.add(nc.toString()); + }else{ + Set<String> afterUpdate = new HashSet<String>(); + for(NamedClass nc : ore.reasoner2.getConcepts(ind)) + afterUpdate.add(nc.toString()); + Set<String> oldClasses = new HashSet<String>(); + for(NamedClass nc : classes) + oldClasses.add(nc.toString()); + for(String nc : afterUpdate) + if(!oldClasses.contains(nc)){ + + ImageIcon icon = new ImageIcon("src/dl-learner/org/dllearner/tools/ore/new.gif"); + JLabel lab = new JLabel(nc); + lab.setIcon(icon); + lab.setHorizontalTextPosition(JLabel.LEFT); + classesPanel.add(lab); + } + + + for(NamedClass nc : classes) + + if(!afterUpdate.contains(nc.toString())) + for(Component co: classesPanel.getComponents()) + if(co instanceof JLabel) + if(((JLabel)co).getText().equals(nc.toString())) + ((JLabel)co).setText("<html><strike>" + nc + "</strike></html>"); + newClasses.addAll(afterUpdate); + } - for(NamedClass nc : afterUpdate) - if(!(classes.contains(nc))){ - ImageIcon icon = new ImageIcon("src/dl-learner/org/dllearner/tools/ore/Neu_006.gif"); - JLabel lab = new JLabel(nc.getName()); - lab.setIcon(icon); - lab.setHorizontalTextPosition(JLabel.LEFT); - classesPanel.add(lab); - } - for(NamedClass nc : classes) - if(!(afterUpdate.contains(nc))) - for(Component co: classesPanel.getComponents()) - if(co instanceof JLabel) - if(((JLabel)co).getText().equals(nc.toString())) - ((JLabel)co).setText("<html><strike>" + nc + "</strike></html>"); - - -// for(Component co: classesPanel.getComponents()){ -// if(co instanceof JLabel) -// if(((JLabel)co).getText().equals(d.toString())) -// ((JLabel)co).setText("<html><strike>" + d + "</strike></html>"); -// -// } SwingUtilities.updateComponentTreeUI(this); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java 2008-07-10 09:41:14 UTC (rev 1005) +++ trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java 2008-07-10 09:43:45 UTC (rev 1006) @@ -8,6 +8,7 @@ import java.util.concurrent.ExecutionException; import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; import javax.swing.SwingWorker; import org.dllearner.core.owl.Individual; @@ -69,26 +70,25 @@ //TODO nochmal \xFCberdenken if(nextPanelDescriptor.equals("CONCEPT_CHOOSE_PANEL")){ - ((ConceptPanelDescriptor)wizard.getModel().getPanelHashMap().get(nextPanelDescriptor)).panel3.getModel().clear(); + ((ConceptPanelDescriptor)model.getPanelHashMap().get(nextPanelDescriptor)).panel3.getModel().clear(); new ConceptRetriever(nextPanelDescriptor).execute(); } if( nextPanelDescriptor.equals("REPAIR_PANEL")){ - ((RepairPanelDescriptor)wizard.getModel().getPanelHashMap().get(nextPanelDescriptor)).panel4.getNegFailureModel().clear(); - ((RepairPanelDescriptor)wizard.getModel().getPanelHashMap().get(nextPanelDescriptor)).panel4.getPosFailureModel().clear(); - wizard.getModel().getOre().getModi().addAxiomToOWL(wizard.getModel().getOre().getConceptToAdd(), wizard.getModel().getOre().getIgnoredConcept()); + RepairPanelDescriptor repair = ((RepairPanelDescriptor)model.getPanelHashMap().get(nextPanelDescriptor)); + repair.panel4.getNegFailureModel().clear(); + repair.panel4.getPosFailureModel().clear(); +// OWLOntologyChange change = model.getOre().getModi().addAxiomToOWL(model.getOre().getConceptToAdd(), model.getOre().getIgnoredConcept()); +// repair.getOntologyChanges().add(change); new FailInstancesRetriever(nextPanelDescriptor).execute(); -// for(Description desc : wizard.getModel().getOre().getConceptToAdd().getChildren()) -// System.out.println(desc); - } if(nextPanelDescriptor.equals("LEARNING_PANEL")){ wizard.getModel().getOre().init(); - ((LearningPanelDescriptor)wizard.getModel().getPanelHashMap().get(nextPanelDescriptor)).panel4.getStatusLabel().setText(""); - ((LearningPanelDescriptor)wizard.getModel().getPanelHashMap().get(nextPanelDescriptor)).panel4.getModel().clear(); + ((LearningPanelDescriptor)model.getPanelHashMap().get(nextPanelDescriptor)).panel4.getStatusLabel().setText(""); + ((LearningPanelDescriptor)model.getPanelHashMap().get(nextPanelDescriptor)).panel4.getModel().clear(); } @@ -119,9 +119,27 @@ // panel, and display it. Object backPanelDescriptor = descriptor.getBackPanelDescriptor(); - wizard.setCurrentPanel(backPanelDescriptor); - refreshLeftPanel(backPanelDescriptor); + + if(backPanelDescriptor.equals("LEARNING_PANEL")){ + if (JOptionPane.showConfirmDialog(wizard.getDialog(), + "All changes will be lost!", "Warning!", + JOptionPane.YES_NO_OPTION) + == JOptionPane.YES_OPTION){ + + wizard.getModel().getOre().getModi().undoChanges(((RepairPanelDescriptor)descriptor).getOntologyChanges()); + ((RepairPanelDescriptor)descriptor).getOntologyChanges().clear(); + wizard.setCurrentPanel(backPanelDescriptor); + refreshLeftPanel(backPanelDescriptor); + } + + + }else{ + wizard.setCurrentPanel(backPanelDescriptor); + refreshLeftPanel(backPanelDescriptor); + } + + } void refreshLeftPanel(Object PanelDescriptor){ @@ -230,7 +248,7 @@ ConceptPanelDescriptor nextPanel = (ConceptPanelDescriptor) wizard .getModel().getPanelHashMap().get(nextPanelID); DefaultListModel dm = new DefaultListModel(); - + for (NamedClass cl : ind) { dm.addElement(cl); Added: trunk/src/dl-learner/org/dllearner/tools/ore/new.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/tools/ore/new.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Jen...@us...> - 2008-07-10 09:41:34
|
Revision: 1005 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1005&view=rev Author: JensLehmann Date: 2008-07-10 02:41:14 -0700 (Thu, 10 Jul 2008) Log Message: ----------- - bug fix: number of descriptions returned was incorrect Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-07-07 08:50:10 UTC (rev 1004) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2008-07-10 09:41:14 UTC (rev 1005) @@ -107,16 +107,13 @@ public synchronized List<Description> getCurrentlyBestDescriptions(int nrOfDescriptions, boolean filterNonMinimalDescriptions) { List<Description> currentlyBest = getCurrentlyBestDescriptions(); List<Description> returnList = new LinkedList<Description>(); - int count = 0; for(Description ed : currentlyBest) { - // return if we have sufficiently many descriptions - if(count >= nrOfDescriptions) + if(returnList.size() >= nrOfDescriptions) return returnList; if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed)) returnList.add(ed); - count++; } return returnList; } @@ -160,7 +157,6 @@ public synchronized List<EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(int nrOfDescriptions, double accuracyThreshold, boolean filterNonMinimalDescriptions) { SortedSet<EvaluatedDescription> currentlyBest = getCurrentlyBestEvaluatedDescriptions(); List<EvaluatedDescription> returnList = new LinkedList<EvaluatedDescription>(); - int count = 0; for(EvaluatedDescription ed : currentlyBest) { // once we hit a description with a below threshold accuracy, we simply return // because learning algorithms are advised to order descriptions by accuracy, @@ -169,13 +165,12 @@ return returnList; // return if we have sufficiently many descriptions - if(count >= nrOfDescriptions) + if(returnList.size() >= nrOfDescriptions) return returnList; if(!filterNonMinimalDescriptions || ConceptTransformation.isDescriptionMinimal(ed.getDescription())) returnList.add(ed); - count++; } return returnList; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-07-07 08:50:19
|
Revision: 1004 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1004&view=rev Author: jenslehmann Date: 2008-07-07 01:50:10 -0700 (Mon, 07 Jul 2008) Log Message: ----------- - small test Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java trunk/src/dl-learner/org/dllearner/test/ComponentTest.java trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-07-06 19:54:28 UTC (rev 1003) +++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2008-07-07 08:50:10 UTC (rev 1004) @@ -168,6 +168,11 @@ } } + @Override + public String toString() { + return description.toString() + "(accuracy: " + getAccuracy() + ")"; + } + // we need to use this method instead of the standard JSON array constructor, // otherwise we'll get unexpected results (JSONArray does not take Individuals // as arguments and does not use toString) Modified: trunk/src/dl-learner/org/dllearner/test/ComponentTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/ComponentTest.java 2008-07-06 19:54:28 UTC (rev 1003) +++ trunk/src/dl-learner/org/dllearner/test/ComponentTest.java 2008-07-07 08:50:10 UTC (rev 1004) @@ -23,7 +23,7 @@ import java.util.Set; import java.util.TreeSet; -import org.dllearner.algorithms.DBpediaNavigationSuggestor; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; @@ -83,7 +83,7 @@ // create the learning algorithm LearningAlgorithm la = null; try { - la = cm.learningAlgorithm(DBpediaNavigationSuggestor.class, lp, rs); + la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, rs); } catch (LearningProblemUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -95,7 +95,7 @@ // start the algorithm and print the best concept found la.start(); - System.out.println(la.getCurrentlyBestEvaluatedDescription()); + System.out.println(la.getCurrentlyBestEvaluatedDescriptions()); } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-07-06 19:54:28 UTC (rev 1003) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-07-07 08:50:10 UTC (rev 1004) @@ -9,8 +9,6 @@ import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionEvent; -import javax.swing.JDialog; - import org.dllearner.core.owl.Description; /** * @@ -39,7 +37,7 @@ * This is the view of the DL-Learner tab. */ private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; - private JDialog detailDialog; +// private JDialog detailDialog; /** * This is the constructor for the action handler * @param a ActionHandler This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2008-07-06 19:54:35
|
Revision: 1003 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1003&view=rev Author: lorenz_b Date: 2008-07-06 12:54:28 -0700 (Sun, 06 Jul 2008) Log Message: ----------- added some modifications to go back in wizard and undo changes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/ore/ChangesPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifierOWLAPI.java trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/ore/MoveMenuItem.java trunk/src/dl-learner/org/dllearner/tools/ore/Neu_006.gif Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/ore/ChooseDialog.java Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ChangesPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ChangesPanel.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ChangesPanel.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -17,15 +17,14 @@ private static final long serialVersionUID = -7538532926820669891L; public ChangesPanel(){ - super(new GridLayout(0, 1)); + super(); + setLayout(new GridLayout(0, 1)); setBackground(Color.WHITE); setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); } - public void init(){ -// setBorder(new TitledBorder("changes")); - } + public void updatePanel(Container cont){ remove(cont); Deleted: trunk/src/dl-learner/org/dllearner/tools/ore/ChooseDialog.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ChooseDialog.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ChooseDialog.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -1,117 +0,0 @@ -package org.dllearner.tools.ore; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JSeparator; -import javax.swing.border.EmptyBorder; - -import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; -import org.dllearner.core.owl.NamedClass; -import org.dllearner.core.owl.ObjectQuantorRestriction; - -public class ChooseDialog extends JDialog implements ActionListener{ - - /** - * - */ - private static final long serialVersionUID = -3554461981184458137L; - - - ORE ore; - DefaultListModel model; - JList list; - private JButton okButton; - private JButton cancelButton; - private Object selectedElement; - private Object chooseValue; - - public ChooseDialog(JDialog parent, ORE ore, Object chooseValue){ - super(parent, true); - this.ore = ore; - this.chooseValue = chooseValue; - init(); - - - } - - public void init(){ - setSize(new Dimension(400, 400)); - setLayout(new BorderLayout()); - - model = new DefaultListModel(); - System.out.println(chooseValue.getClass()); - if(chooseValue instanceof Description){ - setTitle("select object for property"); - for(Individual ind : ore.getIndividualsOfPropertyRange((ObjectQuantorRestriction)chooseValue)) - model.addElement(ind); - } - else if(chooseValue instanceof Individual){ - setTitle("choose new class"); - for(NamedClass nc : ore.getpossibleMoveClasses((Individual)chooseValue)) - model.addElement(nc); - } - - - list = new JList(model); - - okButton = new JButton("Ok"); - cancelButton = new JButton("Cancel"); - okButton.addActionListener(this); - cancelButton.addActionListener(this); - - - - JPanel buttonPanel = new JPanel(); - JSeparator separator = new JSeparator(); - Box buttonBox = new Box(BoxLayout.X_AXIS); - buttonPanel.setLayout(new BorderLayout()); - buttonPanel.add(separator, BorderLayout.NORTH); - - buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10))); - buttonBox.add(okButton); - buttonBox.add(Box.createHorizontalStrut(10)); - buttonBox.add(cancelButton); - buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST); - - getContentPane().add(list, BorderLayout.CENTER); - getContentPane().add(buttonPanel, BorderLayout.SOUTH); - - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - setModal(true); - setVisible(true); - - - } - - public Object getSelectedElement(){ - return selectedElement; - } - - - public void actionPerformed(ActionEvent e) { - if(e.getSource().equals(okButton)){ - selectedElement = list.getSelectedValue(); - setVisible(false); - dispose(); - } - else if(e.getSource().equals(cancelButton)){ - selectedElement = null; - setVisible(false); - dispose(); - } - - } - -} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -15,6 +15,7 @@ import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.Negation; import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.Thing; public class DescriptionLabel extends JLabel implements MouseListener{ /** @@ -31,28 +32,8 @@ this.desc = d; setForeground(Color.red); addMouseListener(this); -// menu = new JPopupMenu(); -// if(!(desc instanceof Negation)){ -// if(desc instanceof NamedClass){ -// menu.add(new DescriptionMenuItem("remove class assertion " + desc.toString(), desc) ); -// DescriptionMenuItem dme = new DescriptionMenuItem("move class assertion " + desc.toString() + " to ...", desc); -// for(NamedClass nc : ore.getpossibleMoveClasses(ind)) -// dme.add(new JMenuItem(nc.getName())); -// menu.add(dme); -//// menu.add(new DescriptionMenuItem("move class assertion " + desc.toString() + " to ...", desc)); -// } -// else if(desc instanceof ObjectSomeRestriction) -// menu.add(new DescriptionMenuItem("remove property assertion " + desc.toString(), desc)); -// } -// else if(desc instanceof Negation){ -// if(desc.getChild(0) instanceof NamedClass) -// menu.add(new DescriptionMenuItem("add class assertion to " + desc.getChild(0).toString(), desc.getChild(0))); -// else if(desc.getChild(0) instanceof ObjectSomeRestriction) -// menu.add(new DescriptionMenuItem("add property " + d.toString(), desc.getChild(0))); -// } + - - } public void init(){ @@ -62,12 +43,24 @@ menu.add(new DescriptionMenuItem("remove class assertion " + desc.toString(), desc) ); JMenu dme = new JMenu("move class assertion " + desc.toString() + " to ..."); for(NamedClass nc : ore.getpossibleMoveClasses(ind)) - dme.add(new DescriptionMenuItem(nc.getName(), desc)); + dme.add(new MoveMenuItem((NamedClass)desc, nc)); menu.add(dme); // menu.add(new DescriptionMenuItem("move class assertion " + desc.toString() + " to ...", desc)); } - else if(desc instanceof ObjectSomeRestriction) - menu.add(new DescriptionMenuItem("remove property assertion " + desc.toString(), desc)); + else if(desc instanceof ObjectSomeRestriction){ + menu.add(new DescriptionMenuItem("remove property " + ((ObjectSomeRestriction)desc).getRole(), desc)); + System.out.println(desc.getChild(0).getClass()); + if (!(desc.getChild(0) instanceof Thing)) { + JMenu dme = new JMenu("add property assertion " + + ((ObjectSomeRestriction) desc).getRole() + + " with object ..."); + for (Individual i : ore.getIndividualsNotOfPropertyRange( + (ObjectSomeRestriction) desc, ind)) + dme.add(new DescriptionMenuItem(i.getName(), desc + .getChild(0))); + menu.add(dme); + } + } } else if(desc instanceof Negation){ if(desc.getChild(0) instanceof NamedClass){ @@ -78,8 +71,12 @@ item.setToolTipText("class assertion not possible because individual is still asserted to its complement"); } } - else if(desc.getChild(0) instanceof ObjectSomeRestriction) - menu.add(new DescriptionMenuItem("add property " + desc.toString(), desc.getChild(0))); + else if(desc.getChild(0) instanceof ObjectSomeRestriction){ + JMenu dme = new JMenu("add property " + desc.toString() + " with object ..."); + for(Individual i : ore.getIndividualsOfPropertyRange((ObjectSomeRestriction)desc.getChild(0), ind)) + dme.add(new DescriptionMenuItem(i.getName(), desc.getChild(0))); + menu.add(dme); + } } } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -13,13 +13,17 @@ Description desc; + public DescriptionMenuItem(String text, Description d){ super(text); this.desc = d; } + public Description getDescription(){ return desc; } + + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -3,18 +3,19 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; import java.awt.geom.Ellipse2D; import java.awt.geom.RoundRectangle2D; +import java.util.Dictionary; +import java.util.Hashtable; +import javax.swing.BoxLayout; import javax.swing.DefaultListModel; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTextField; +import javax.swing.JSlider; import javax.swing.event.ListSelectionListener; import org.jdesktop.swingx.JXBusyLabel; @@ -36,15 +37,17 @@ private JButton startButton; private JButton stopButton; - private JTextField noiseField; + private JSlider noiseSlider; - @SuppressWarnings("unchecked") + public LearningPanel() { super(); model = new DefaultListModel(); - + JPanel eastPanel = new JPanel(); + eastPanel.setLayout(new BoxLayout(eastPanel, BoxLayout.Y_AXIS)); + JPanel buttonPanel = new JPanel(); startButton = new JButton("Start"); stopButton = new JButton("Stop"); @@ -52,12 +55,29 @@ buttonPanel.add(startButton); buttonPanel.add(stopButton); + JPanel noisePanel = new JPanel(); + noisePanel.setLayout(new BoxLayout(noisePanel, BoxLayout.Y_AXIS)); + noiseSlider = new JSlider(0, 100, 0); + noiseSlider.setPaintTicks(true); + noiseSlider.setMajorTickSpacing(10); + noiseSlider.setMinorTickSpacing(5); + Dictionary<Integer, JLabel> map = new Hashtable<Integer, JLabel>(); + map.put( new Integer(0), new JLabel("0%") ); + map.put( new Integer(50), new JLabel("50%") ); + map.put( new Integer(100),new JLabel("100%") ); + noiseSlider.setLabelTable( map ); + noiseSlider.setPaintLabels(true); + noisePanel.add(new JLabel("noise")); + noisePanel.add(noiseSlider); - JPanel labelPanel = new JPanel(); + eastPanel.add(buttonPanel); + eastPanel.add(noisePanel); + + JPanel statusPanel = new JPanel(); statusLabel = new JLabel(); loadingLabel = new JXBusyLabel(new Dimension(15,15)); - BusyPainter painter = new BusyPainter( + BusyPainter<Object> painter = new BusyPainter<Object>( new RoundRectangle2D.Float(0, 0,6.0f,2.6f,10.0f,10.0f), new Ellipse2D.Float(2.0f,2.0f,11.0f,11.0f)); painter.setTrailLength(2); @@ -66,15 +86,15 @@ loadingLabel.setPreferredSize(new Dimension(15,15)); loadingLabel.setIcon(new EmptyIcon(15,15)); loadingLabel.setBusyPainter(painter); - labelPanel.add(loadingLabel); - labelPanel.add(statusLabel); + statusPanel.add(loadingLabel); + statusPanel.add(statusLabel); contentPanel = getContentPanel(); setLayout(new java.awt.BorderLayout()); - add(buttonPanel, BorderLayout.EAST); + add(eastPanel, BorderLayout.EAST); add(contentPanel,BorderLayout.CENTER); - add(labelPanel, BorderLayout.SOUTH); + add(statusPanel, BorderLayout.SOUTH); } private JPanel getContentPanel() { @@ -87,31 +107,10 @@ // resultList.setCellRenderer(new ColumnListCellRenderer()); scroll.setPreferredSize(new Dimension(900, 400)); scroll.setViewportView(resultList); - - noiseField = new JTextField("noise"); - noiseField.setText("0.0"); - - - noiseField.addKeyListener(new KeyAdapter() { - @Override - public void keyTyped(KeyEvent e) { - char c = e.getKeyChar(); - if (!((Character.isDigit(c) || - (c == KeyEvent.VK_BACK_SPACE) || - (c == KeyEvent.VK_DELETE)))) { - getToolkit().beep(); - e.consume(); - } - - } - }); - + contentPanel1.add(scroll); - contentPanel1.add(noiseField); - - - - + + return contentPanel1; } @@ -152,7 +151,7 @@ } public double getNoise(){ - return Double.parseDouble(noiseField.getText()); + return noiseSlider.getValue(); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -4,6 +4,7 @@ import java.awt.event.ActionListener; import java.util.List; import java.util.Timer; +import java.util.TimerTask; import java.util.concurrent.ExecutionException; import javax.swing.SwingUtilities; @@ -13,7 +14,6 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.ObjectSomeRestriction; @@ -52,11 +52,13 @@ - class ResultSwingWorker extends - SwingWorker<List<Description>, List<Description>> { - LearningAlgorithm la; - - + class ResultSwingWorker extends SwingWorker<List<Description>, List<Description>> { + + LearningAlgorithm la; + Thread t; + + + @SuppressWarnings("unchecked") @Override public List<Description> doInBackground() { @@ -65,14 +67,43 @@ panel4.getLoadingLabel().setBusy(true); panel4.getStatusLabel().setText("Learning"); getWizardModel().getOre().setNoise(panel4.getNoise()); + la = getWizardModel().getOre().getLa(); + timer = new Timer(); + timer.schedule(new TimerTask(){ + + @Override + public void run() { + if(la != null){ + + System.out.println(scheduledExecutionTime()-System.currentTimeMillis()); + publish(la.getCurrentlyBestDescriptions(10, true)); + } + } + + }, 1000, 1000); + t = new Thread(new Runnable(){ + + @Override + public void run() { + + la.start(); + } + + }); + t.setPriority(Thread.MIN_PRIORITY); + t.start(); - la = getWizardModel().getOre().start();//started endlosen Algorithmus - publish(la.getCurrentlyBestDescriptions(10)); +// publish(la.getCurrentlyBestDescriptions(10, true)); - - List<Description> result = getWizardModel().getOre().getLearningResults(100); + try { + t.join(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + List<Description> result = getWizardModel().getOre().getLearningResults(10); return result; } @@ -163,6 +194,7 @@ public void actionPerformed(ActionEvent event) { if(event.getActionCommand().equals("Start")){ + panel4.getModel().clear(); panel4.getStartButton().setEnabled(false); panel4.getStopButton().setEnabled(true); worker = new ResultSwingWorker(); @@ -172,9 +204,11 @@ canceled = true; panel4.getStopButton().setEnabled(false); getWizardModel().getOre().getLa().stop(); - panel4.getStartButton().setEnabled(true); + timer.cancel(); + panel4.getStartButton().setEnabled(true); panel4.getStatusLabel().setText("Algorithm aborted"); panel4.getLoadingLabel().setBusy(false); + } @@ -189,15 +223,8 @@ for(Description d: getWizardModel().getOre().getAllChildren((Description)(panel4.getResultList().getSelectedValue()))){ System.out.println(d + " : " + d.getClass()); - if(d instanceof ObjectSomeRestriction){ - - - getWizardModel().getOre().getIndividualsOfPropertyRange((ObjectSomeRestriction)d); - - - - } + } } Added: trunk/src/dl-learner/org/dllearner/tools/ore/MoveMenuItem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/MoveMenuItem.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/MoveMenuItem.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -0,0 +1,30 @@ +package org.dllearner.tools.ore; + +import javax.swing.JMenuItem; + +import org.dllearner.core.owl.NamedClass; + +public class MoveMenuItem extends JMenuItem{ + + /** + * + */ + private static final long serialVersionUID = 7912723521355039174L; + NamedClass source; + NamedClass target; + + public MoveMenuItem(NamedClass source, NamedClass target){ + super(target.getName()); + this.source = source; + this.target = target; + } + + public NamedClass getSource(){ + return source; + } + + public NamedClass getTarget(){ + return target; + } + +} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/NegExampleRepairDialog.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -8,12 +8,15 @@ import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JDialog; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSeparator; @@ -22,6 +25,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectSomeRestriction; import org.semanticweb.owl.model.OWLOntologyChange; import org.semanticweb.owl.model.RemoveAxiom; @@ -44,14 +48,14 @@ private JButton okButton; private JButton cancelButton; - - + private ORE ore; private Individual ind; // private OWLAPIReasoner reasoner; private Description actualDesc; private Description newDesc; // private Individual object; + private Set<OWLOntologyChange> allChanges; public NegExampleRepairDialog(Individual ind, JDialog dialog, ORE ore){ @@ -59,28 +63,29 @@ this.ind = ind; this.ore = ore; // this.reasoner = ore.reasoner2; + allChanges = new HashSet<OWLOntologyChange>(); init(); } public void init(){ + setSize(700, 700); setLayout(new BorderLayout()); descPanel = new DescriptionPanel(ore, ind, this); + JScrollPane descScroll = new JScrollPane(); + descScroll.setViewportView(descPanel); - statsPanel = new StatsPanel(ore, ind); statsPanel.init(); - JScrollPane scroll = new JScrollPane(); - scroll.setViewportView(statsPanel); + JScrollPane statsScroll = new JScrollPane(); + statsScroll.setViewportView(statsPanel); changesPanel = new ChangesPanel(); - changesPanel.init(); - JButton deleteButton = new JButton("delete"); - deleteButton.addActionListener(this); - changesPanel.add(deleteButton); - + JScrollPane changesScroll = new JScrollPane(); + changesScroll.setViewportView(changesPanel); + action_stats_Panel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); @@ -91,9 +96,9 @@ action_stats_Panel.setLayout(gbl); - action_stats_Panel.add(descPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); - action_stats_Panel.add(scroll, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0)); - action_stats_Panel.add(changesPanel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0)); + action_stats_Panel.add(descScroll, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); + action_stats_Panel.add(statsScroll, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0)); + action_stats_Panel.add(changesScroll, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0)); JSeparator separator = new JSeparator(); @@ -103,9 +108,10 @@ ok_cancelPanel.setLayout(new BorderLayout()); ok_cancelPanel.add(separator, BorderLayout.NORTH); okButton = new JButton("Ok"); + okButton.addActionListener(this); cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(this); - getContentPane().add(action_stats_Panel, java.awt.BorderLayout.CENTER); @@ -128,50 +134,73 @@ if(e.getSource() instanceof DescriptionMenuItem){ actualDesc = ((DescriptionMenuItem)e.getSource()).getDescription(); - + System.out.println(e.getActionCommand()); if(e.getActionCommand().startsWith("remove class")){ //remove class List<OWLOntologyChange> changes = ore.modi.removeClassAssertion(ind, actualDesc); + allChanges.addAll(changes); descPanel.updatePanel(); + statsPanel.updatePanel("remove", actualDesc); changesPanel.add(new ChangePanel("removed class assertion to " + actualDesc, changes, this)); } else if(e.getActionCommand().startsWith("add class")){ //add class List<OWLOntologyChange> changes = ore.modi.addClassAssertion(ind, actualDesc); + allChanges.addAll(changes); descPanel.updatePanel(); changesPanel.add(new ChangePanel("added class assertion to " + actualDesc, changes, this)); - - - } - else{ //move class - - newDesc = new NamedClass(e.getActionCommand()); - List<OWLOntologyChange> changes = ore.modi.moveIndividual(ind, actualDesc, newDesc); - descPanel.updatePanel(); - changesPanel.add(new ChangePanel("moved class assertion from " + actualDesc + " to " + newDesc, changes, this)); } + else if(e.getActionCommand().startsWith("add property")){ //add property + Individual ind = new Individual(e.getActionCommand()); + List<OWLOntologyChange> changes = ore.modi.addObjectProperty(ind, (ObjectSomeRestriction)actualDesc, ind); + System.out.println("ghhfhg"); + allChanges.addAll(changes); + descPanel.updatePanel(); + changesPanel.add(new ChangePanel("added property assertion " + ((ObjectSomeRestriction)actualDesc).getRole() + " to " + ind, changes, this)); + } +// else if(e.getActionCommand().startsWith("remove property")){ //delete property +// ore.modi.deleteObjectProperty(ind, (ObjectSomeRestriction)actualDesc); +// } + }else if(e.getSource() instanceof MoveMenuItem){ + actualDesc = ((MoveMenuItem)e.getSource()).getSource(); + newDesc = new NamedClass(e.getActionCommand()); + List<OWLOntologyChange> changes = ore.modi.moveIndividual(ind, actualDesc, newDesc); + allChanges.addAll(changes); + descPanel.updatePanel(); + statsPanel.updatePanel("remove", actualDesc); + changesPanel.add(new ChangePanel("moved class assertion from " + actualDesc + " to " + newDesc, changes, this)); } + + else if(e.getActionCommand().equals("delete")){ List<OWLOntologyChange> changes = ore.modi.deleteIndividual(ind); + allChanges.addAll(changes); for(OWLOntologyChange ol : changes) System.out.println(((RemoveAxiom)ol).getAxiom()); } + else if(e.getActionCommand().equals("Ok")){ + } + else if(e.getActionCommand().equals("Cancel")){ + if (JOptionPane.showConfirmDialog(this, + "All changes will be lost!", "Warning!", + JOptionPane.YES_NO_OPTION) + == JOptionPane.YES_OPTION){ + ore.modi.undoChanges(allChanges); + allChanges.clear(); + setVisible(false); + dispose(); + } + } + + } -// else if(e.getActionCommand().equals("add property")){ //add property -// object = (Individual)new ChooseDialog(this, ore, actualDesc).getSelectedElement(); -// if(object != null) -// ore.modi.addObjectProperty(ind, (ObjectSomeRestriction)actualDesc, object); -// } -// else if(e.getActionCommand().equals("remove property")){ //delete property -// ore.modi.deleteObjectProperty(ind, (ObjectSomeRestriction)actualDesc); -// } -// } + public void mouseClicked(MouseEvent e) { if(e.getSource() instanceof UndoLabel){ @@ -201,6 +230,10 @@ // TODO Auto-generated method stub } + + public Set<OWLOntologyChange> getAllChanges() { + return allChanges; + } // if(e.getActionCommand().equals("delete instance")){ // ore.modi.deleteIndividual(ind); Added: trunk/src/dl-learner/org/dllearner/tools/ore/Neu_006.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/tools/ore/Neu_006.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -35,7 +35,6 @@ import org.dllearner.reasoning.OWLAPIReasoner; - public class ORE { private LearningAlgorithm la; @@ -94,7 +93,7 @@ } -// rs = cm.reasoningService(reasoner); + reasoner2 = cm.reasoner(OWLAPIReasoner.class, ks); try { reasoner2.init(); @@ -102,8 +101,12 @@ // TODO Auto-generated catch block e.printStackTrace(); } + rs = cm.reasoningService(reasoner2); + modi = new OntologyModifierOWLAPI(reasoner2); - modi = new OntologyModifierOWLAPI(reasoner2); + + + } public ReasoningService getReasoningService(){ @@ -143,13 +146,13 @@ // TODO Auto-generated catch block e1.printStackTrace(); } - //la = new ROLearner(lp, rs); + Set<String> t = new TreeSet<String>(); t.add(ignoredConcept.getName()); cm.applyConfigEntry(la, "ignoredConcepts", t ); - cm.applyConfigEntry(la, "noisePercentage", noise); - cm.applyConfigEntry(la, "guaranteeXgoodDescriptions", 5); +// cm.applyConfigEntry(la, "noisePercentage", noise); + cm.applyConfigEntry(la, "guaranteeXgoodDescriptions", 10); try { la.init(); } catch (ComponentInitException e) { @@ -164,28 +167,37 @@ } - public LearningAlgorithm start(){ + public void init(){ this.setPosNegExamples(); this.setLearningProblem(); this.setLearningAlgorithm(); + } + + public LearningAlgorithm start(){ + Set<String> t = new TreeSet<String>(); + + cm.applyConfigEntry(la, "ignoredConcepts", t ); + cm.applyConfigEntry(la, "noisePercentage", noise); + try { + la.init(); + } catch (ComponentInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println(noise); la.start(); - return la; - } - public Description getLearningResult(){ - return la.getCurrentlyBestDescription(); - } - + // public List<Description> getSolutions(){ // return la.getCurrentlyBestDescriptions(); // } public List<Description> getLearningResults(int anzahl){ - return la.getCurrentlyBestDescriptions(anzahl); + return la.getCurrentlyBestDescriptions(anzahl, true); } /** @@ -372,6 +384,7 @@ try { if(reasoner.instanceCheck(desc, ind)){ + if(children.size() >= 2){ if(desc instanceof Intersection){ @@ -379,7 +392,7 @@ for(int i = 0; i<children.size()-1; i++){ criticals.addAll(DescriptionToJLabel(ind, desc.getChild(i))); criticals.add(new JLabel("AND")); - System.out.println(true); + } criticals.addAll(DescriptionToJLabel(ind, desc.getChild(children.size()-1))); criticals.add(new JLabel(")")); @@ -407,7 +420,7 @@ } } else{ - + criticals.add(new DescriptionLabel(desc)); } } @@ -421,20 +434,26 @@ return criticals; } - public Set<Individual> getIndividualsOfPropertyRange(ObjectQuantorRestriction objRestr){ + public Set<Individual> getIndividualsOfPropertyRange(ObjectQuantorRestriction objRestr, Individual ind){ - - System.out.println(objRestr.getChild(0)); - - Set<Individual> individuals = rs.retrieval(objRestr.getChild(0)); - System.out.println(objRestr.getRole()); + individuals.remove(ind); - System.out.println(individuals); - return individuals; } + public Set<Individual> getIndividualsNotOfPropertyRange(ObjectQuantorRestriction objRestr, Individual ind){ + + Set<Individual> individuals = reasoner2.retrieval(objRestr.getChild(0)); + Set<Individual> allIndividuals = reasoner2.getIndividuals(); + System.out.println("alle:" + allIndividuals); + allIndividuals.removeAll(individuals); + allIndividuals.remove(ind); + + System.out.println("range:" + individuals); + return allIndividuals; + } + public Set<NamedClass> getpossibleMoveClasses(Individual ind){ Set<NamedClass> moveClasses = rs.getAtomicConcepts(); Set<NamedClass> indClasses = new HashSet<NamedClass>(); @@ -461,6 +480,13 @@ // TODO Auto-generated catch block e.printStackTrace(); } + reasoner2 = cm.reasoner(OWLAPIReasoner.class,new OWLAPIOntology(modi.ontology)); + try { + reasoner2.init(); + } catch (ComponentInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } public boolean hasComplement(Description desc, Individual ind){ @@ -480,15 +506,18 @@ final ORE test = new ORE(); - File owlFile = new File("src/dl-learner/org/dllearner/tools/ore/inconsistent.owl"); + File owlFile = new File("src/dl-learner/org/dllearner/tools/ore/inkohaerent.owl"); test.setKnowledgeSource(owlFile); test.detectReasoner(); -// System.out.println(test.reasoner2.getInconsistentClasses()); -// System.err.println("Concepts :" + rs.getAtomicConcepts()); +// test.modi.reason(); +// Individual ind = new Individual("http://example.com/father#heinz"); +// Description d = new Intersection(new NamedClass("http://example.com/father#male"), new ObjectAllRestriction(new ObjectProperty("http://example.com/father#hasChild"), new NamedClass("http://example.com/father#male"))); +// System.out.println(test.reasoner2.instanceCheck(d, ind)); + // test.setConcept(new NamedClass("http://example.com/father#father")); // test.setPosNegExamples(); // System.out.println(test.posExamples); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifierOWLAPI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifierOWLAPI.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifierOWLAPI.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -1,6 +1,7 @@ package org.dllearner.tools.ore; import java.net.URI; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; @@ -13,6 +14,7 @@ import org.dllearner.reasoning.OWLAPIDescriptionConvertVisitor; import org.dllearner.reasoning.OWLAPIReasoner; import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.io.RDFXMLOntologyFormat; import org.semanticweb.owl.model.AddAxiom; import org.semanticweb.owl.model.OWLAxiom; import org.semanticweb.owl.model.OWLClassAssertionAxiom; @@ -80,8 +82,12 @@ */ public void saveOntology(){ + + + URI physicalURI2 = URI.create("file:/tmp/MyOnt2.owl"); + try { - manager.saveOntology(ontology); + manager.saveOntology(ontology, new RDFXMLOntologyFormat(), physicalURI2); } catch (UnknownOWLOntologyException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -89,18 +95,6 @@ // TODO Auto-generated catch block e.printStackTrace(); } - -// URI physicalURI2 = URI.create("file:/tmp/MyOnt2.owl"); -// -// try { -// manager.saveOntology(ontology, new RDFXMLOntologyFormat(), physicalURI2); -// } catch (UnknownOWLOntologyException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } catch (OWLOntologyStorageException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } } /** @@ -223,6 +217,7 @@ try { manager.applyChanges(changes); + saveOntology(); return changes; } catch (OWLOntologyChangeException e) { // TODO Auto-generated catch block @@ -320,7 +315,7 @@ * undo changes of type {@link OWLOntologyChange} * @param changes */ - public void undoChanges(List<OWLOntologyChange> changes){ + public void undoChanges(Collection<OWLOntologyChange> changes){ for(OWLOntologyChange change : changes){ @@ -362,46 +357,18 @@ return true; } -// OWLClass owlClass1 = factory.getOWLClass(URI.create(desc1.toString())); -// OWLClass owlClass2 = factory.getOWLClass(URI.create(desc2.toString())); -// for(OWLEquivalentClassesAxiom eq :ontology.getEquivalentClassesAxioms(owlClass1)) -// for(OWLDescription d : eq.getDescriptions()) -// System.out.println(d.isAnonymous()); -// for(OWLEquivalentClassesAxiom eq :ontology.getEquivalentClassesAxioms(owlClass2)){ -// for(OWLDescription d : eq.getDescriptions()) -// System.out.println(d.getClass()); -// for(OWLEntity e : eq.getReferencedEntities()) -// System.out.println(e); -// } return false; } - +// public void reason(){ +// reasoner.getInconsistencyReasons(ontology); +// +// } -// public OWLOntology copyOntology(){ -// try{ -// OWLOntology ontologyCopy = manager.createOntology(ontology.getURI()); -// -// -// Set<OWLAxiom> axioms = ontology.getAxioms(); -// List<AddAxiom> changes = new LinkedList<AddAxiom>(); -// for(OWLAxiom a : axioms) -// changes.add(new AddAxiom(ontologyCopy, a)); -// -// manager.applyChanges(changes); -// -// return ontologyCopy; -// -// }catch(OWLException e){ -// e.printStackTrace(); -// return null; -// } -// -// -// } + Modified: trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -4,11 +4,14 @@ import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.util.HashSet; +import java.util.Set; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.dllearner.core.owl.Individual; +import org.semanticweb.owl.model.OWLOntologyChange; @@ -18,6 +21,7 @@ public static final String IDENTIFIER = "REPAIR_PANEL"; RepairPanel panel4; + private Set<OWLOntologyChange> ontologyChanges; public RepairPanelDescriptor() { @@ -27,10 +31,10 @@ panel4.addSaveButtonListener(this); panel4.addSelectionListeners(this); panel4.addMouseListeners(this); - + setPanelDescriptorIdentifier(IDENTIFIER); setPanelComponent(panel4); - + ontologyChanges = new HashSet<OWLOntologyChange>(); } @@ -56,6 +60,7 @@ } public void actionPerformed(ActionEvent event) { + System.out.println(ontologyChanges); if(event.getActionCommand().equals("save")){ getWizardModel().getOre().getModi().saveOntology(); @@ -68,7 +73,7 @@ if(e.getClickCount() == 2 && e.getSource() == panel4.getNegFailureList() ){ Individual ind = (Individual)panel4.getNegFailureList().getSelectedValue(); - new NegExampleRepairDialog(ind, getWizard().getDialog(), getWizardModel().getOre()); + ontologyChanges.addAll(new NegExampleRepairDialog(ind, getWizard().getDialog(), getWizardModel().getOre()).getAllChanges()); // System.out.println(getWizardModel().getOre().getCriticalDescriptions(ind, getWizardModel().getOre().conceptToAdd )); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -1,18 +1,23 @@ package org.dllearner.tools.ore; import java.awt.Color; +import java.awt.Component; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Insets; +import java.util.HashSet; import java.util.Set; import javax.swing.BorderFactory; +import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import javax.swing.border.BevelBorder; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; @@ -23,7 +28,10 @@ private static final long serialVersionUID = -8418286820511803278L; ORE ore; Individual ind; + Set<NamedClass> classes; + JPanel classesPanel; + public StatsPanel(ORE ore, Individual ind){ super(); this.ore = ore; @@ -36,18 +44,14 @@ setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); GridBagLayout gbl = new GridBagLayout(); - gbl.rowWeights = new double[] {0.0, 0.1, 0.1}; + gbl.rowWeights = new double[] {0.0, 0.0, 0.1}; gbl.rowHeights = new int[] {34, 7, 7}; gbl.columnWeights = new double[] {0.1}; gbl.columnWidths = new int[] {7}; setLayout(gbl); - - - - JPanel indPanel = new JPanel(); indPanel.setBackground(new Color(224, 223, 227)); indPanel.setLayout(new GridLayout(0, 1)); @@ -57,24 +61,53 @@ indPanel.add(indLb); indPanel.add(indLb1); - JPanel classesPanel = new JPanel(); + classesPanel = new JPanel(); classesPanel.setBackground(new Color(224, 223, 227)); classesPanel.setLayout(new GridLayout(0, 1)); JLabel classLb = new JLabel("Classes:"); classLb.setFont(indLb.getFont().deriveFont(Font.BOLD)); classesPanel.add(classLb); - Set<NamedClass> t = null; - - t = ore.reasoner2.getConcepts(ind); + classes = ore.reasoner2.getConcepts(ind); - for(NamedClass nc : t) + for(NamedClass nc : classes) classesPanel.add(new JLabel(nc.getName())); - add(indPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); - - add(classesPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); + add(classesPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); } + + public void updatePanel(String action, Description d){ + + + Set<NamedClass> afterUpdate = new HashSet<NamedClass>(); + + afterUpdate.addAll(ore.reasoner2.getConcepts(ind)); + + for(NamedClass nc : afterUpdate) + if(!(classes.contains(nc))){ + ImageIcon icon = new ImageIcon("src/dl-learner/org/dllearner/tools/ore/Neu_006.gif"); + JLabel lab = new JLabel(nc.getName()); + lab.setIcon(icon); + lab.setHorizontalTextPosition(JLabel.LEFT); + classesPanel.add(lab); + } + for(NamedClass nc : classes) + if(!(afterUpdate.contains(nc))) + for(Component co: classesPanel.getComponents()) + if(co instanceof JLabel) + if(((JLabel)co).getText().equals(nc.toString())) + ((JLabel)co).setText("<html><strike>" + nc + "</strike></html>"); + + +// for(Component co: classesPanel.getComponents()){ +// if(co instanceof JLabel) +// if(((JLabel)co).getText().equals(d.toString())) +// ((JLabel)co).setText("<html><strike>" + d + "</strike></html>"); +// +// } + SwingUtilities.updateComponentTreeUI(this); + + } } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java 2008-07-06 17:07:09 UTC (rev 1002) +++ trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java 2008-07-06 19:54:28 UTC (rev 1003) @@ -72,6 +72,7 @@ ((ConceptPanelDescriptor)wizard.getModel().getPanelHashMap().get(nextPanelDescriptor)).panel3.getModel().clear(); new ConceptRetriever(nextPanelDescriptor).execute(); } + if( nextPanelDescriptor.equals("REPAIR_PANEL")){ ((RepairPanelDescriptor)wizard.getModel().getPanelHashMap().get(nextPanelDescriptor)).panel4.getNegFailureModel().clear(); @@ -85,6 +86,7 @@ } if(nextPanelDescriptor.equals("LEARNING_PANEL")){ + wizard.getModel().getOre().init(); ((LearningPanelDescriptor)wizard.getModel().getPanelHashMap().get(nextPanelDescriptor)).panel4.getStatusLabel().setText(""); ((LearningPanelDescriptor)wizard.getModel().getPanelHashMap().get(nextPanelDescriptor)).panel4.getModel().clear(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-07-06 17:07:38
|
Revision: 1002 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1002&view=rev Author: sknappe Date: 2008-07-06 10:07:09 -0700 (Sun, 06 Jul 2008) Log Message: ----------- Fixed little Bug Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java 2008-07-06 16:15:15 UTC (rev 1001) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQueryMaker.java 2008-07-06 17:07:09 UTC (rev 1002) @@ -102,12 +102,12 @@ int i=1; for (String p : sparqlQueryType.getPredicatefilterlist()) { if (this.sparqlQueryType.getMode()=="forbid") - if (!this.sparqlQueryType.isLiterals()||i!=1) + if (i!=1) Filter += lineend + filterPredicate(p); else Filter += lineend + filterPredicate(p).substring(2); else if (this.sparqlQueryType.getMode()=="allow") - if (!this.sparqlQueryType.isLiterals()||i!=1) + if (i!=1) Filter += lineend + allowPredicate(p); else Filter += lineend + allowPredicate(p).substring(2); @@ -123,12 +123,12 @@ i=1; for (String o : sparqlQueryType.getObjectfilterlist()) { if (this.sparqlQueryType.getMode()=="forbid") - if (!this.sparqlQueryType.isLiterals()||i!=1) + if (i!=1) Filter += lineend + filterObject(o); else Filter += lineend + filterObject(o).substring(2); else if (this.sparqlQueryType.getMode()=="allow") - if (!this.sparqlQueryType.isLiterals()||i!=1) + if (i!=1) Filter += lineend + allowObject(o); else Filter += lineend + allowObject(o).substring(2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-07-06 16:15:27
|
Revision: 1001 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1001&view=rev Author: sknappe Date: 2008-07-06 09:15:15 -0700 (Sun, 06 Jul 2008) Log Message: ----------- Added a way to find a class for a certain city Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/extraction/DBpediaNavigatorManipulator.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/kb/extraction/DBpediaNavigatorCityLocator.java Added: trunk/src/dl-learner/org/dllearner/kb/extraction/DBpediaNavigatorCityLocator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/DBpediaNavigatorCityLocator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/DBpediaNavigatorCityLocator.java 2008-07-06 16:15:15 UTC (rev 1001) @@ -0,0 +1,58 @@ +package org.dllearner.kb.extraction; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +import org.dllearner.utilities.datastructures.StringTuple; + +public class DBpediaNavigatorCityLocator { + + public static String getTypeToCoordinates(float lat, float lng){ + if (lat<71.08&&lat>33.39&&lng>-24.01&&lng<50.8){ + if (lat>50&&lat<52&&lng>12&&lng<13){ + return "http://dbpedia.org/class/custom/City_in_Saxony"; + } + else return "http://dbpedia.org/class/custom/City_in_Europe"; + } + else if (lng>-17.5&&lng<52.04&&lat>-36&&lat<36.6){ + if (lat>21.45&&lat<31.51&&lng>24.7&&lng<37.26){ + return "http://dbpedia.org/class/custom/City_in_Egypt"; + } + else return "http://dbpedia.org/class/custom/City_in_Africa"; + } + else if (((lng>27.4&&lng<180)||(lng<-168.75))&&lat>-11.2){ + return "http://dbpedia.org/class/custom/City_in_Asia"; + } + else if (lng>113.9&&lng<179.65&&lat<-10.8&&lat>-47.04){ + return "http://dbpedia.org/class/custom/City_in_Australia"; + } + else if (lng>-168.4&&lng<-19.7&&lat>6.6){ + return "http://dbpedia.org/class/custom/City_in_North_America"; + } + else if (lng>-81.56&&lng<-34.1&&lat<6.6){ + return "http://dbpedia.org/class/custom/City_in_South_America"; + } + else return "http://dbpedia.org/class/custom/City_in_World"; + } + + public static Set<StringTuple> getTuplesToAdd(String uri){ + String subClass="http://www.w3.org/2000/01/rdf-schema#subClassOf"; + + HashMap<String,String> map=new HashMap<String,String>(); + map.put("http://dbpedia.org/class/custom/City_in_Saxony", "http://dbpedia.org/class/custom/City_in_Europe"); + map.put("http://dbpedia.org/class/custom/City_in_Egypt", "http://dbpedia.org/class/custom/City_in_Africa"); + map.put("http://dbpedia.org/class/custom/City_in_Europe", "http://dbpedia.org/class/yago/City108524735"); + map.put("http://dbpedia.org/class/custom/City_in_Asia", "http://dbpedia.org/class/yago/City108524735"); + map.put("http://dbpedia.org/class/custom/City_in_Australia", "http://dbpedia.org/class/yago/City108524735"); + map.put("http://dbpedia.org/class/custom/City_in_North_America", "http://dbpedia.org/class/yago/City108524735"); + map.put("http://dbpedia.org/class/custom/City_in_South_America", "http://dbpedia.org/class/yago/City108524735"); + map.put("http://dbpedia.org/class/custom/City_in_Africa", "http://dbpedia.org/class/yago/City108524735"); + map.put("http://dbpedia.org/class/custom/City_in_World", "http://dbpedia.org/class/yago/City108524735"); + Set<StringTuple> toAdd = new HashSet<StringTuple>(); + if (map.containsKey(uri)){ + toAdd.add(new StringTuple(subClass,map.get(uri))); + } + return toAdd; + } +} Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/DBpediaNavigatorManipulator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/DBpediaNavigatorManipulator.java 2008-07-06 12:34:38 UTC (rev 1000) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/DBpediaNavigatorManipulator.java 2008-07-06 16:15:15 UTC (rev 1001) @@ -19,7 +19,6 @@ */ package org.dllearner.kb.extraction; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.Set; @@ -69,14 +68,13 @@ * @return */ public Set<StringTuple> check(Set<StringTuple> tuples, Node node) { - Set<StringTuple> toRemove = new HashSet<StringTuple>(); + //Set<StringTuple> toRemove = new HashSet<StringTuple>(); Iterator<StringTuple> it = tuples.iterator(); float lat=0; float lng=0; String clas=""; StringTuple typeTupel=null; - if (node.uri.toString().equals("http://dbpedia.org/class/custom/City_in_Saxony")) - tuples.add(new StringTuple("http://www.w3.org/2000/01/rdf-schema#subClassOf","http://dbpedia.org/class/yago/City108524735")); + tuples.addAll(DBpediaNavigatorCityLocator.getTuplesToAdd(node.uri.toString())); while (it.hasNext()) { StringTuple t = (StringTuple) it.next(); @@ -114,17 +112,16 @@ } if (clas.equals("http://dbpedia.org/class/yago/City108524735")){ - if (lat>50&&lat<52&&lng>12&&lng<13){ - tuples.add(new StringTuple("http://www.w3.org/1999/02/22-rdf-syntax-ns#type","http://dbpedia.org/class/custom/City_in_Saxony")); - tuples.remove(typeTupel); - } + String newType=DBpediaNavigatorCityLocator.getTypeToCoordinates(lat, lng); + tuples.add(new StringTuple("http://www.w3.org/1999/02/22-rdf-syntax-ns#type",newType)); + tuples.remove(typeTupel); } //tuples.removeAll(toRemove); return tuples; } - private void replacePredicate(StringTuple t) { + /*private void replacePredicate(StringTuple t) { for (StringTuple rep : replacePredicate) { if (rep.a.equals(t.a)) { t.a = rep.b; @@ -138,5 +135,5 @@ t.a = rep.b; } } - } + }*/ } Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-06 12:34:38 UTC (rev 1000) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-07-06 16:15:15 UTC (rev 1001) @@ -59,7 +59,6 @@ import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SPARQLTasks; -import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.kb.sparql.SparqlQuery; import org.dllearner.kb.sparql.SparqlQueryDescriptionConvertVisitor; @@ -676,7 +675,7 @@ SPARQLTasks task=ks.getSparqlTask(); AutomaticNegativeExampleFinderSPARQL finder=new AutomaticNegativeExampleFinderSPARQL(set,task); //finder.makeNegativeExamplesFromRelatedInstances(set, namespace); - finder.makeNegativeExamplesFromParallelClasses(set, 5); + finder.makeNegativeExamplesFromParallelClasses(set, 25); SortedSet<String> negExamples=finder.getNegativeExamples(results); return negExamples.toArray(new String[negExamples.size()]); Modified: trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java 2008-07-06 12:34:38 UTC (rev 1000) +++ trunk/src/dl-learner/org/dllearner/utilities/examples/AutomaticNegativeExampleFinderSPARQL.java 2008-07-06 16:15:15 UTC (rev 1001) @@ -1,14 +1,11 @@ package org.dllearner.utilities.examples; -import java.util.Iterator; import java.util.SortedSet; import java.util.TreeSet; import org.apache.log4j.Logger; import org.dllearner.core.ComponentManager; -import org.dllearner.kb.sparql.Cache; import org.dllearner.kb.sparql.SPARQLTasks; -import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.utilities.datastructures.SetManipulation; public class AutomaticNegativeExampleFinderSPARQL { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |