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: <seb...@us...> - 2012-04-24 07:47:46
|
Revision: 3657 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3657&view=rev Author: sebastianwtr Date: 2012-04-24 07:47:35 +0000 (Tue, 24 Apr 2012) Log Message: ----------- [tbsl-exploration] updated Levensthein-Module Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-24 00:48:26 UTC (rev 3656) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-24 07:47:35 UTC (rev 3657) @@ -9,7 +9,7 @@ import org.dllearner.algorithm.tbsl.exploration.Utils.Levenshtein; public class LevenstheinModule { - private final static double LevenstheinMin=0.85; + private final static double LevenstheinMin=0.65; public static ArrayList<Hypothesis> doLevensthein(String variable, String property_to_compare_with, HashMap<String, String> properties) throws SQLException { @@ -24,33 +24,44 @@ key=key.toLowerCase(); String value = entry.getValue(); - //compare property gotten from the resource with the property from the original query - double nld=Levenshtein.nld(property_to_compare_with.toLowerCase(), key); - - //if(nld>=LevenstheinMin||key.contains(lemmatiser.stem(property_to_compare_with))||property_to_compare_with.contains(lemmatiser.stem(key))){ - - if(key.contains(property_to_compare_with)||property_to_compare_with.contains(key)){ - if(nld<0.8){ - Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", 0.85); - listOfNewHypothesen.add(h); + ArrayList<String> property_array=new ArrayList<String>(); + property_array.add(property_to_compare_with); + if(property_to_compare_with.contains(" ")){ + + String[] array_temp = property_to_compare_with.split(" "); + for(String s : array_temp) property_array.add(s); + } + for(String compare_property :property_array ){ + + double nld=Levenshtein.nld(compare_property.toLowerCase(), key); + + //if(nld>=LevenstheinMin||key.contains(lemmatiser.stem(property_to_compare_with))||property_to_compare_with.contains(lemmatiser.stem(key))){ + + if(key.contains(compare_property)||compare_property.contains(key)){ + if(nld<0.8){ + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", 0.85); + listOfNewHypothesen.add(h); + } + else{ + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); + listOfNewHypothesen.add(h); + } + } - else{ + else if(key.substring(key.length()-1).contains("s")){ + String neuer_string = key.substring(0, key.length() -1); + if(neuer_string.contains(compare_property)||compare_property.contains(neuer_string)){ + Hypothesis h = new Hypothesis(variable, neuer_string, value, "PROPERTY", 1.5); + listOfNewHypothesen.add(h); + } + } + else if(nld>=LevenstheinMin){ Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); listOfNewHypothesen.add(h); } - } - else if(key.substring(key.length()-1).contains("s")){ - String neuer_string = key.substring(0, key.length() -1); - if(neuer_string.contains(property_to_compare_with)||property_to_compare_with.contains(neuer_string)){ - Hypothesis h = new Hypothesis(variable, neuer_string, value, "PROPERTY", 1.5); - listOfNewHypothesen.add(h); - } - } - else if(nld>=LevenstheinMin){ - Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); - listOfNewHypothesen.add(h); - } + //compare property gotten from the resource with the property from the original query + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2012-04-24 00:48:32
|
Revision: 3656 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3656&view=rev Author: kurzum Date: 2012-04-24 00:48:26 +0000 (Tue, 24 Apr 2012) Log Message: ----------- some fixes Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/ABoxQueryGenerator.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/QueryExecutor.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/TBoxQueryGenerator.java trunk/examples/thanh/AristotlePosNeg.conf Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/ABoxQueryGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/ABoxQueryGenerator.java 2012-04-23 22:19:40 UTC (rev 3655) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/ABoxQueryGenerator.java 2012-04-24 00:48:26 UTC (rev 3656) @@ -15,103 +15,99 @@ * @author didierc */ public class ABoxQueryGenerator { - public String createQuery(List<String> individuals, OntModel model, List<String> filters) { + + public String createQuery(Set<String> individuals, String aboxfilter) { Monitor monABoxQueryGeneration = MonitorFactory.getTimeMonitor("ABox query generator").start(); StringBuilder builder = new StringBuilder(); - builder.append("CONSTRUCT {?s ?p ?o} "); - builder.append("{ ?s ?p ?o ."); - Set<String> curIndividuals; - if (model.isEmpty()) { - curIndividuals = new HashSet<String>(individuals); - } else { - curIndividuals = this.difference2(individuals, model); + builder.append("CONSTRUCT {?s ?p ?o } "); + builder.append("{ ?s ?p ?o . "); + builder.append(makeInFilter("?s", individuals)); + if (aboxfilter != null) { + builder.append(aboxfilter); } - builder.append(" FILTER (?s IN( "); - for (String individual : curIndividuals) { - builder.append("<"); - builder.append(individual); - builder.append(">"); - builder.append(", "); - } - builder.deleteCharAt(builder.length() - 2); - builder.append("))"); - if (filters != null) { - for (String filter : filters) { - builder.append("filter"); - } - } builder.append("}"); monABoxQueryGeneration.stop(); return builder.toString(); } - public String createLastQuery(List<String> individuals, OntModel model, List<String> filters) { - Monitor monABoxQueryGeneration = MonitorFactory.getTimeMonitor("ABox query generator") - .start(); + public static StringBuilder makeInFilter(String var, Set<String> uris) { StringBuilder builder = new StringBuilder(); - if (false) { - builder.append("CONSTRUCT {?s ?p ?o . ?o a ?class} "); - builder.append("{ ?s ?p ?o ."); - builder.append("?o a ?class"); - } else { - builder.append("CONSTRUCT {?s ?p ?o } "); - builder.append("{ ?s ?p ?o . "); - } - - Set<String> curIndividuals; - if (model.isEmpty()) { - curIndividuals = new HashSet<String>(individuals); - } else { - curIndividuals = this.difference2(individuals, model); - } - builder.append(" FILTER ( ?s IN( "); - for (String individual : curIndividuals) { + builder.append(" FILTER (" + var + " IN( "); + for (String uri : uris) { builder.append("<"); - builder.append(individual); + builder.append(uri); builder.append(">"); builder.append(", "); } builder.deleteCharAt(builder.length() - 2); - builder.append(")). "); - if (filters != null) { - for (String filter : filters) { - builder.append(filter); - builder.append(". "); - } - } - builder.append("}"); - monABoxQueryGeneration.stop(); - return builder.toString(); + builder.append(")) . "); + return builder; } - public Set<String> difference2 - (List<String> a, OntModel model) { - Set<String> inds = new HashSet<String>(a); - Set<String> result = new HashSet<String>(); - for (ExtendedIterator<Individual> it = model.listIndividuals(); it.hasNext(); ) { - String individual = it.next().getURI(); - if (!inds.contains(individual)) { - result.add(individual); - } - } - return result; + /** + * + * + * @param oldIndividuals + * @param model + * @return + */ + + + /*public String createLastQuery(List<String> individuals, OntModel model, List<String> filters) { + Monitor monABoxQueryGeneration = MonitorFactory.getTimeMonitor("ABox query generator") + .start(); + StringBuilder builder = new StringBuilder(); + if (false) { + builder.append("CONSTRUCT {?s ?p ?o . ?o a ?class} "); + builder.append("{ ?s ?p ?o ."); + builder.append("?o a ?class"); + } else { + builder.append("CONSTRUCT {?s ?p ?o } "); + builder.append("{ ?s ?p ?o . "); } - /*private List<String> getIndividualsFromModel - (OntModel - model) { - ExtendedIterator<Individual> iterator = model.listIndividuals(); - LinkedList<String> result = new LinkedList<String>(); - while (iterator.hasNext()) { - result.add(iterator.next().getURI()); + Set<String> curIndividuals; + if (model.isEmpty()) { + curIndividuals = new HashSet<String>(individuals); + } else { + curIndividuals = this.difference2(individuals, model); + } + builder.append(" FILTER ( ?s IN( "); + for (String individual : curIndividuals) { + builder.append("<"); + builder.append(individual); + builder.append(">"); + builder.append(", "); + } + builder.deleteCharAt(builder.length() - 2); + builder.append(")). "); + if (filters != null) { + for (String filter : filters) { + builder.append(filter); + builder.append(". "); } - return result; } + builder.append("}"); + monABoxQueryGeneration.stop(); + return builder.toString(); +} */ - public List<String> difference - (List<String> a, List<String> b) { - ArrayList<String> result = new ArrayList<String>(b); - result.removeAll(a); - return result; - } */ + + /*private List<String> getIndividualsFromModel + (OntModel + model) { + ExtendedIterator<Individual> iterator = model.listIndividuals(); + LinkedList<String> result = new LinkedList<String>(); + while (iterator.hasNext()) { + result.add(iterator.next().getURI()); + } + return result; + } + + public List<String> difference + (List<String> a, List<String> b) { + ArrayList<String> result = new ArrayList<String>(b); + result.removeAll(a); + return result; + } */ } Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/QueryExecutor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/QueryExecutor.java 2012-04-23 22:19:40 UTC (rev 3655) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/QueryExecutor.java 2012-04-24 00:48:26 UTC (rev 3656) @@ -3,16 +3,13 @@ */ package org.dllearner.kb.sparql.simple; +import com.hp.hpl.jena.query.*; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.query.Query; -import com.hp.hpl.jena.query.QueryExecution; -import com.hp.hpl.jena.query.QueryExecutionFactory; -import com.hp.hpl.jena.query.QueryFactory; /** * @author didierc @@ -21,23 +18,26 @@ private static Logger log = LoggerFactory.getLogger(QueryExecutor.class); - public OntModel executeQuery(String queryString, String endpoint, OntModel model) { - Monitor monQueryingTotal = MonitorFactory.start("Query time total").start(); - Query query = QueryFactory.create(queryString); - log.debug("Jena Query: ", query); - QueryExecution qExec = QueryExecutionFactory.sparqlService(endpoint, query); - qExec.execConstruct(model); - monQueryingTotal.stop(); - return model; - } + public OntModel executeQuery(String queryString, String endpoint, OntModel model, String defaultGraphURI) { Monitor monQueryingTotal = MonitorFactory.start("Query time total").start(); + try{ Query query = QueryFactory.create(queryString); log.debug("Jena Query: ", query); - QueryExecution qExec = QueryExecutionFactory.sparqlService(endpoint, query, defaultGraphURI); + QueryExecution qExec; + if (defaultGraphURI == null) { + qExec = QueryExecutionFactory.sparqlService(endpoint, query); + + } else { + qExec = QueryExecutionFactory.sparqlService(endpoint, query, defaultGraphURI); + + } log.debug("Qexec: {}", qExec); qExec.execConstruct(model); + }catch (QueryParseException e ){ + log.warn("Query failed (skipping):\n" + queryString, e); + } monQueryingTotal.stop(); return model; } Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-23 22:19:40 UTC (rev 3655) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-24 00:48:26 UTC (rev 3656) @@ -1,27 +1,21 @@ package org.dllearner.kb.sparql.simple; -import java.io.File; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - +import com.hp.hpl.jena.ontology.OntClass; +import com.hp.hpl.jena.ontology.OntModel; +import com.hp.hpl.jena.query.QueryParseException; +import com.hp.hpl.jena.rdf.model.*; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; import org.dllearner.core.ComponentAnn; import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.config.ConfigOption; import org.dllearner.utilities.JamonMonitorLogger; -import org.dllearner.utilities.experiments.Jamon; import org.semanticweb.owlapi.model.OWLOntology; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.hp.hpl.jena.ontology.OntClass; -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelFactory; -import com.jamonapi.Monitor; -import com.jamonapi.MonitorFactory; +import java.util.*; @ComponentAnn(name = "efficient SPARQL fragment extractor", shortName = "sparqls", version = 0.1) public class SparqlSimpleExtractor implements KnowledgeSource { @@ -31,9 +25,8 @@ private OntModel model = null; @ConfigOption(name = "instances", description = "List of the instances to use", required = true) private List<String> instances = null; - @ConfigOption(name = "filters", description = "List of the filters to use", required = true) - private List<String> filters = null; - + @ConfigOption(name = "aboxfilter", description = "Filter for the tbox, can use variable ?s, ?p amd ?o", required = false) + private String aboxfilter = null; @ConfigOption(name = "tboxfilter", description = "Filter for the tbox, can use variable ?example and ?class", required = false) private String tboxfilter = null; @@ -83,8 +76,33 @@ // System.out.println(extractor.createQuery()); } + public Set<String> difference(Set<String> alreadyQueriedIndividuals, OntModel model) { + Set<String> candidates = new HashSet<String>(); + Set<String> result = new HashSet<String>(); + for (ResIterator it = model.listSubjects(); it.hasNext(); ) { + candidates.add(it.next().getURI()); + } + for (NodeIterator it = model.listObjects(); it.hasNext(); ) { + RDFNode cur = it.next(); + if (cur.isURIResource() && !cur.isAnon()) { + candidates.add(((Resource) cur).getURI()); + } + } + + for (String candidate : candidates) { + if (!alreadyQueriedIndividuals.contains(candidate)) { + System.out.println(candidate); + result.add(candidate); + } + } + + return result; + } + + @Override public void init() throws ComponentInitException { + if (endpointURL == null) { throw new ComponentInitException( "Parameter endpoint URL is required"); @@ -111,32 +129,43 @@ Monitor monQueryingABox; QueryExecutor executor = new QueryExecutor(); String queryString; + Set<String> instancesSet = new HashSet<String>(instances); + Set<String> alreadyQueried = new HashSet<String>(); if (sparqlQuery == null) { ABoxQueryGenerator aGenerator = new ABoxQueryGenerator(); - for (int i = 0; i < recursionDepth - 1; i++) { + for (int i = 0; i < recursionDepth; i++) { + if (instancesSet.isEmpty()) { + log.warn("no new instances found more recursions (recursion " + i + ") " + instancesSet.size() + " new instances"); - queryString = aGenerator.createQuery(instances, model, filters); + } + + log.info("processing (recursion " + i + ") " + instancesSet.size() + " new instances"); + queryString = aGenerator.createQuery(instancesSet, aboxfilter); log.debug("SPARQL: {}", queryString); monQueryingABox = MonitorFactory.start("ABox query time"); - executor.executeQuery(queryString, endpointURL, model, - defaultGraphURI); + executor.executeQuery(queryString, endpointURL, model, defaultGraphURI); monQueryingABox.stop(); + + alreadyQueried.addAll(instancesSet); + instancesSet = difference(alreadyQueried, model); + + } - queryString = aGenerator.createLastQuery(instances, model, filters); - log.debug("SPARQL: {}", queryString); + //queryString = aGenerator.createLastQuery(instances, model, filters); + //log.debug("SPARQL: {}", queryString); - monQueryingABox = MonitorFactory.start("ABox query time"); - Monitor monQueryingABox2 = MonitorFactory.start("ABox query time last query"); - executor.executeQuery(queryString, endpointURL, model, defaultGraphURI); - monQueryingABox.stop(); - monQueryingABox2.stop(); + //monQueryingABox = MonitorFactory.start("ABox query time"); + //Monitor monQueryingABox2 = MonitorFactory.start("ABox query time last query"); + //executor.executeQuery(queryString, endpointURL, model, defaultGraphURI); + //monQueryingABox.stop(); + //monQueryingABox2.stop(); } else { monQueryingABox = MonitorFactory.getTimeMonitor("ABox query time").start(); - executor.executeQuery(sparqlQuery, endpointURL, model); + executor.executeQuery(sparqlQuery, endpointURL, model, null); monQueryingABox.stop(); } @@ -144,7 +173,7 @@ TBoxQueryGenerator tGenerator = new TBoxQueryGenerator(); //TODO check if all instances are queried. model.listIndividuals().toSet() - queryString = tGenerator.createQuery(model, tboxfilter, instances); + queryString = tGenerator.createQuery(alreadyQueried, tboxfilter); Monitor monQueryingTBox = MonitorFactory.start("TBox query time"); @@ -196,18 +225,12 @@ this.model = model; } - /** - * @return the filters - */ - public List<String> getFilters() { - return filters; + public String getAboxfilter() { + return aboxfilter; } - /** - * @param filters the filters to set - */ - public void setFilters(List<String> filters) { - this.filters = filters; + public void setAboxfilter(String aboxfilter) { + this.aboxfilter = aboxfilter; } /** Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/TBoxQueryGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/TBoxQueryGenerator.java 2012-04-23 22:19:40 UTC (rev 3655) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/TBoxQueryGenerator.java 2012-04-24 00:48:26 UTC (rev 3656) @@ -4,7 +4,9 @@ package org.dllearner.kb.sparql.simple; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.rdf.model.ModelFactory; @@ -15,8 +17,7 @@ * @author didierc */ public class TBoxQueryGenerator { - public String createQuery(OntModel model, String filter, - List<String> individuals) { + public String createQuery(Set<String> individuals, String filter) { Monitor monTquery = MonitorFactory.getTimeMonitor("TBox query generator") .start(); StringBuilder builder = new StringBuilder( @@ -42,7 +43,7 @@ public static void main(String... args) { TBoxQueryGenerator generator = new TBoxQueryGenerator(); OntModel model = ModelFactory.createOntologyModel(); - List<String> individuals = new ArrayList<String>(); + Set<String> individuals = new HashSet<String>(); individuals.add("http://dbpedia.org/resource/JB_Carlson"); @@ -1046,10 +1047,10 @@ individuals.add("http://dbpedia.org/resource/Percy_Jackson"); individuals.add("http://dbpedia.org/resource/Glynis_Barber"); - String queryString = generator.createQuery(model, null, individuals); + String queryString = generator.createQuery(individuals, null); System.out.println(queryString); QueryExecutor executor = new QueryExecutor(); - executor.executeQuery(queryString, "http://live.dbpedia.org/sparql", model); + executor.executeQuery(queryString, "http://live.dbpedia.org/sparql", model, null); model.write(System.out); } } Modified: trunk/examples/thanh/AristotlePosNeg.conf =================================================================== --- trunk/examples/thanh/AristotlePosNeg.conf 2012-04-23 22:19:40 UTC (rev 3655) +++ trunk/examples/thanh/AristotlePosNeg.conf 2012-04-24 00:48:26 UTC (rev 3656) @@ -13,10 +13,13 @@ sparql.type = "sparqls" sparql.endpointURL = "http://live.dbpedia.org/sparql" sparql.defaultGraphURI = "http://dbpedia.org" -sparql.recursionDepth = 1 +sparql.recursionDepth = 2 sparql.ontologySchemaUrls = {"http://downloads.dbpedia.org/3.6/dbpedia_3.6.owl" } +sparql.aboxfilter = "FILTER ( !isLiteral(?o) ) " +// && regex(str(?o), '^http://dbpedia.org/resource/') && ! regex(str(?o), '^http://dbpedia.org/resource/Category') && ! regex(str(?o), '^http://dbpedia.org/resource/Template') ) . " +//|| regex(str(?p), '^http://dbpedia.org/property/') )) " sparql.tboxfilter = "FILTER ( regex(str(?class), '^http://dbpedia.org/ontology/') ) . " -//sparql.tboxfilter = "FILTER ( regex(str(?class), LIKE <http://dbpedia.org/ontology/%> ) . " +//sparql.tboxfilter = "FILTER ( ?class LIKE <http://dbpedia.org/ontology/%> ) . " sparql.instances = { "http://dbpedia.org/resource/Democritus", @@ -39,6 +42,7 @@ "http://dbpedia.org/resource/Pythagoras", "http://dbpedia.org/resource/Philolaus" } + lp.negativeExamples = { "http://dbpedia.org/resource/Democritus", "http://dbpedia.org/resource/Zeno_of_Elea", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2012-04-23 22:27:08
|
Revision: 3653 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3653&view=rev Author: kurzum Date: 2012-04-23 20:33:48 +0000 (Mon, 23 Apr 2012) Log Message: ----------- made small changes for webservice Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java 2012-04-23 16:04:23 UTC (rev 3652) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java 2012-04-23 20:33:48 UTC (rev 3653) @@ -3,6 +3,10 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; @@ -15,26 +19,52 @@ public class SchemaIndexer { private static Logger log = LoggerFactory.getLogger(SchemaIndexer.class); - private ClassIndexer classIndexer = null; private OntModel model; - private File ontologySchema; + //static instantiation + private static ClassIndexer classIndexer = new ClassIndexer(); + //remember ontologies + private static Set<String> alreadyIndexed = new HashSet<String>(); + //set or list of urls for the ontologies + private List<String> ontologySchemaUrls; + public SchemaIndexer() { } - public void init() { - classIndexer = new ClassIndexer(); - model = ModelFactory.createOntologyModel(); - try { - Monitor m0 = MonitorFactory.start("Indexer parsing ontology"); - model.read(new FileInputStream(ontologySchema), null); - m0.stop(); - } catch (FileNotFoundException e) { - log.error(e.getMessage(), e); + public synchronized void init() { + + for (String url : ontologySchemaUrls) { + if (!alreadyIndexed.add(url)) { + try { + Monitor m0 = MonitorFactory.start("Indexer parsing ontology"); + model = ModelFactory.createOntologyModel(); + model.read(url, null); + classIndexer.index(model); + m0.stop(); + log.debug("indexed " + url + " " + url); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } } - classIndexer.index(model); + + } + + /*public void init() { + classIndexer = new ClassIndexer(); + model = ModelFactory.createOntologyModel(); + try { + Monitor m0 = MonitorFactory.start("Indexer parsing ontology"); + model.read(new FileInputStream(ontologySchema), null); + m0.stop(); + } catch (FileNotFoundException e) { + log.error(e.getMessage(), e); + } + classIndexer.index(model); + } */ + public OntModel getHierarchyForURI(String classUri) { if (classIndexer == null) { this.init(); @@ -47,13 +77,7 @@ System.out.println(i.getHierarchyForURI("http://dbpedia.org/ontology/Software")); } - public File getOntologySchema() { - return ontologySchema; + public void setOntologySchemaUrls(List<String> ontologySchemaUrls) { + this.ontologySchemaUrls = ontologySchemaUrls; } - - public void setOntologySchema(File ontologySchema) { - this.ontologySchema = ontologySchema; - } - - } \ No newline at end of file Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-23 16:04:23 UTC (rev 3652) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-23 20:33:48 UTC (rev 3653) @@ -40,8 +40,9 @@ private String defaultGraphURI = null; @ConfigOption(name = "sparqlQuery", description = "Sparql Query", required = false) private String sparqlQuery = null; - @ConfigOption(name = "ontologyFile", description = "Ontology Schema File", required = true) - private File ontologyFile = null; + @ConfigOption(name = "ontologySchemaUrls", description = "List of Ontology Schema URLs", required = true) + private List<String> ontologySchemaUrls = null; + private OWLOntology owlOntology; private SchemaIndexer indexer; @@ -91,7 +92,7 @@ throw new ComponentInitException( "A value bigger than 0 is required for parameter recursionDepth"); } - if (ontologyFile == null) { + if (ontologySchemaUrls == null) { throw new ComponentInitException( "An ontology schema description file (ontologyFile) in RDF ist required"); } @@ -99,7 +100,7 @@ .start(); Monitor monIndexer = MonitorFactory.start("Schema Indexer").start(); indexer = new SchemaIndexer(); - indexer.setOntologySchema(ontologyFile); + indexer.setOntologySchemaUrls(ontologySchemaUrls); indexer.init(); monIndexer.stop(); @@ -240,12 +241,11 @@ return owlOntology; } - public File getOntologyFile() { - return ontologyFile; + public List<String> getOntologySchemaUrls() { + return ontologySchemaUrls; } - public void setOntologyFile(File ontologyFile) { - this.ontologyFile = ontologyFile; + public void setOntologySchemaUrls(List<String> ontologySchemaUrls) { + this.ontologySchemaUrls = ontologySchemaUrls; } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2012-04-23 21:22:10
|
Revision: 3654 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3654&view=rev Author: kurzum Date: 2012-04-23 21:17:47 +0000 (Mon, 23 Apr 2012) Log Message: ----------- finished caching of ontologies for sparql component, changed log level for file to debug Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java trunk/interfaces/src/main/resources/log4j.properties Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java 2012-04-23 20:33:48 UTC (rev 3653) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java 2012-04-23 21:17:47 UTC (rev 3654) @@ -34,37 +34,28 @@ public synchronized void init() { for (String url : ontologySchemaUrls) { - if (!alreadyIndexed.add(url)) { + log.info("Testing, if indexed: " + url); + if (alreadyIndexed.add(url)) { + log.info("Ontology not found, start indexing"); try { Monitor m0 = MonitorFactory.start("Indexer parsing ontology"); model = ModelFactory.createOntologyModel(); model.read(url, null); classIndexer.index(model); m0.stop(); - log.debug("indexed " + url + " " + url); + log.info("indexed ontology in ms:" + m0.getTotal()); } catch (Exception e) { log.error(e.getMessage(), e); } + } else { + //not so important output + log.debug("Already indexed: " + url + " " + alreadyIndexed); } } } - - /*public void init() { - classIndexer = new ClassIndexer(); - model = ModelFactory.createOntologyModel(); - try { - Monitor m0 = MonitorFactory.start("Indexer parsing ontology"); - model.read(new FileInputStream(ontologySchema), null); - m0.stop(); - } catch (FileNotFoundException e) { - log.error(e.getMessage(), e); - } - classIndexer.index(model); - } */ - public OntModel getHierarchyForURI(String classUri) { if (classIndexer == null) { this.init(); Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-23 20:33:48 UTC (rev 3653) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-23 21:17:47 UTC (rev 3654) @@ -160,11 +160,10 @@ monIndexing.stop(); monComp.stop(); log.info("*******Simple SPARQL Extractor********"); - for (Monitor monitor : MonitorFactory.getRootMonitor().getMonitors()) { + /*for (Monitor monitor : MonitorFactory.getRootMonitor().getMonitors()) { log.info("* {} *", monitor); - log.info(JamonMonitorLogger.getStringForAllSortedByLabel()); - - } + }*/ + log.info(JamonMonitorLogger.getStringForAllSortedByLabel()); log.info("**************************************"); } Modified: trunk/interfaces/src/main/resources/log4j.properties =================================================================== --- trunk/interfaces/src/main/resources/log4j.properties 2012-04-23 20:33:48 UTC (rev 3653) +++ trunk/interfaces/src/main/resources/log4j.properties 2012-04-23 21:17:47 UTC (rev 3654) @@ -3,14 +3,15 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout + log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File=log/interfaces.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n +log4j.appender.file.Threshold=DEBUG # DL-Learner Logs log4j.logger.org.dllearner=INFO - log4j.logger.org.dllearner.server.nke.LogicalRelationStrategy=DEBUG # Eliminate most of the Spring Context Loading noise This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <seb...@us...> - 2012-04-23 16:27:59
|
Revision: 3652 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3652&view=rev Author: sebastianwtr Date: 2012-04-23 16:04:23 +0000 (Mon, 23 Apr 2012) Log Message: ----------- [tbsl exploration] changed some functions Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-21 15:10:29 UTC (rev 3651) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-23 16:04:23 UTC (rev 3652) @@ -150,12 +150,12 @@ if(tmp1!=null){ result_List.add(tmp1); } - else{ + /*else{ /* * doesnt contains to much classes right now */ - ArrayList<String> tmp_List = new ArrayList<String>(); + /* ArrayList<String> tmp_List = new ArrayList<String>(); String[] array_tmp= string.split(" "); if(array_tmp.length>1){ @@ -163,7 +163,7 @@ } if(tmp_List!=null)for(String st : tmp_List){ if(st.contains("ontology")|| st.contains("yago"))result_List.add(st); - } + }*/ /*ArrayList<String> tmp_List = new ArrayList<String>(); @@ -175,7 +175,7 @@ } }*/ - } + //} if(tmp2!=null) { @@ -184,7 +184,7 @@ /* * if nothing is found, also try the like operator for each part of the string */ - else{ + /*else{ ArrayList<String> tmp_List = new ArrayList<String>(); String[] array_tmp= string.split(" "); for(String s : array_tmp){ @@ -194,7 +194,7 @@ } } - } + }*/ /* * also add String without the plural s at the end. Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java 2012-04-21 15:10:29 UTC (rev 3651) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java 2012-04-23 16:04:23 UTC (rev 3652) @@ -13,7 +13,9 @@ import java.sql.Statement; import java.util.ArrayList; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; import org.dllearner.algorithm.tbsl.exploration.Utils.Levenshtein; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; import org.dllearner.algorithm.tbsl.nlp.StanfordLemmatizer; public class SQLiteIndex { @@ -650,6 +652,8 @@ } public ArrayList<String> getListOfUriSpecialIndex(String string){ + + if(!Setting.isNewIndex())return null; string= string.toLowerCase(); String[] temp_list = string.split(" "); ArrayList<String> first_result=new ArrayList<String>(); @@ -696,8 +700,14 @@ return null; } + System.out.println(result.size() + " URI's over new Index were found!"); + try { + DebugMode.waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } - return result; } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java 2012-04-21 15:10:29 UTC (rev 3651) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java 2012-04-23 16:04:23 UTC (rev 3652) @@ -4,6 +4,7 @@ private static boolean waitModus; private static boolean debugModus; + private static boolean newIndex; public static boolean isWaitModus() { return waitModus; @@ -17,6 +18,12 @@ public static void setDebugModus(boolean debugModus) { Setting.debugModus = debugModus; } + public static boolean isNewIndex() { + return newIndex; + } + public static void setNewIndex(boolean newIndex) { + Setting.newIndex = newIndex; + } } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-21 15:10:29 UTC (rev 3651) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-23 16:04:23 UTC (rev 3652) @@ -69,6 +69,7 @@ Setting.setWaitModus(false); Setting.setDebugModus(false); + Setting.setNewIndex(false); @@ -114,6 +115,18 @@ if(Setting.isDebugModus()) System.out.println("DebugModus is now online"); else System.out.println("DebugModus is now offline"); } + if(line.contains(":newIndex on")){ + Setting.setNewIndex(true); + startQuestioning=false; + if(Setting.isDebugModus()) System.out.println("newIndex is now online"); + else System.out.println("DebugModus is now offline"); + } + if(line.contains(":newIndex off")){ + Setting.setNewIndex(false); + startQuestioning=false; + if(Setting.isDebugModus()) System.out.println("newIndex is now online"); + else System.out.println("DebugModus is now offline"); + } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-21 15:10:29 UTC (rev 3651) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-23 16:04:23 UTC (rev 3652) @@ -9,7 +9,7 @@ import org.dllearner.algorithm.tbsl.exploration.Utils.Levenshtein; public class LevenstheinModule { - private final static double LevenstheinMin=0.65; + private final static double LevenstheinMin=0.85; public static ArrayList<Hypothesis> doLevensthein(String variable, String property_to_compare_with, HashMap<String, String> properties) throws SQLException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <seb...@us...> - 2012-04-21 15:10:35
|
Revision: 3651 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3651&view=rev Author: sebastianwtr Date: 2012-04-21 15:10:29 +0000 (Sat, 21 Apr 2012) Log Message: ----------- [tbsl-exploration] added new Index Functions Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java Added Paths: ----------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/TestClassNewIndex.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/newSpecialSQliteIndex.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-20 14:40:53 UTC (rev 3650) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-21 15:10:29 UTC (rev 3651) @@ -70,14 +70,15 @@ result_List.add(result); } else{ + + ArrayList<String> tmp_List = new ArrayList<String>(); String[] array_tmp= string.split(" "); - for(String s : array_tmp){ - if(s.length()>4) tmp_List=myindex.getResourceURILike(s.toLowerCase(), string.toLowerCase()); - for(String st : tmp_List){ - result_List.add(st); - } + + if(array_tmp.length>1){ + tmp_List=myindex.getListOfUriSpecialIndex(string); } + if(tmp_List!=null)for(String st : tmp_List)result_List.add(st); } @@ -150,14 +151,29 @@ result_List.add(tmp1); } else{ + + /* + * doesnt contains to much classes right now + */ ArrayList<String> tmp_List = new ArrayList<String>(); String[] array_tmp= string.split(" "); + + if(array_tmp.length>1){ + tmp_List=myindex.getListOfUriSpecialIndex(string); + } + if(tmp_List!=null)for(String st : tmp_List){ + if(st.contains("ontology")|| st.contains("yago"))result_List.add(st); + } + + + /*ArrayList<String> tmp_List = new ArrayList<String>(); + String[] array_tmp= string.split(" "); for(String s : array_tmp){ if(s.length()>4) tmp_List=myindex.getontologyClassURILike(s.toLowerCase(),string.toLowerCase()); for(String st : tmp_List){ result_List.add(st); } - } + }*/ } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java 2012-04-20 14:40:53 UTC (rev 3650) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/SQLiteIndex.java 2012-04-21 15:10:29 UTC (rev 3651) @@ -31,6 +31,12 @@ createIndexOntology(); createIndexOntologyClass(); createIndexofYago(); + + System.out.println("start IndexNumber"); + createNewSpecialIndexNumber(); + System.out.println("start SpecialIndex"); + createNewSpecialIndex(); + lemma = new StanfordLemmatizer(); //optional!! @@ -643,6 +649,201 @@ } +public ArrayList<String> getListOfUriSpecialIndex(String string){ + string= string.toLowerCase(); + String[] temp_list = string.split(" "); + ArrayList<String> first_result=new ArrayList<String>(); + ArrayList<String> result=new ArrayList<String>(); + ArrayList<ArrayList<String>> tmp_result = new ArrayList<ArrayList<String>>(); + try { + for(String s : temp_list)first_result.add(getNumberForWordInIndex(s)); + + + for(String s : first_result){ + ArrayList<String> second_result=new ArrayList<String>(); + if(s!=null){ + String[] tmp = s.split(":"); + + for(String z : tmp) second_result.add(z); + + + + + tmp_result.add(second_result); + } + + } + + for(int i=1;i<tmp_result.size();i++){ + tmp_result.get(0).retainAll(tmp_result.get(i)); + } + + + if(tmp_result.get(0).size()!=0){ + for(String s : tmp_result.get(0)){ + result.add(getUriForIndex(s)); + } + } + + + + + + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + + + + return result; +} + +public String getUriForIndex(String string) throws SQLException{ + /* while(rs.next()) + {*/ + Statement stat = conn.createStatement(); + ResultSet rs; + try { + rs = stat.executeQuery("select uri from newSpecialIndexNumber where name='"+string.toLowerCase()+"';"); + return rs.getString("uri"); + } catch (Exception e) { + // TODO Auto-generated catch block + //e.printStackTrace(); + return null; + } + + } + + +public String getNumberForWordInIndex(String string) throws SQLException{ + /* while(rs.next()) + {*/ + Statement stat = conn.createStatement(); + ResultSet rs; + try { + rs = stat.executeQuery("select uri from newSpecialIndex where name='"+string.toLowerCase()+"';"); + return rs.getString("uri"); + } catch (Exception e) { + // TODO Auto-generated catch block + //e.printStackTrace(); + return null; + } + + } +private void createNewSpecialIndex() throws ClassNotFoundException, SQLException{ + System.out.println("start indexing Properties"); + Statement stat = conn.createStatement(); + stat.executeUpdate("drop table if exists newSpecialIndex;"); + stat.executeUpdate("create table newSpecialIndex (name, uri);"); + PreparedStatement prep = conn.prepareStatement("insert into newSpecialIndex values (?, ?);"); + BufferedReader in=null; + int zaehler=0; + try { + in = new BufferedReader( + new InputStreamReader( + new FileInputStream( "/home/swalter/workspace/SpecialIndex/Index" ) ) ); + String s; + while( null != (s = in.readLine()) ) { + String[] tmp_array =s.split(":::"); + tmp_array[1]=tmp_array[1].replace("\n", ""); + tmp_array[0]=tmp_array[0].replace("\n", ""); + if(tmp_array.length>=2){ + prep.setString(1, tmp_array[0]); + prep.setString(2, tmp_array[1]); + prep.addBatch(); + zaehler=zaehler+1; + if(zaehler%1000000==0){ + conn.setAutoCommit(false); + prep.executeBatch(); + conn.setAutoCommit(false); + // System.out.println(zaehler+" done"); + } + + } + } + } catch( FileNotFoundException ex ) { + } catch( Exception ex ) { + System.out.println( ex ); + } finally { + if( in != null ) + try { + in.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + conn.setAutoCommit(false); + prep.executeBatch(); + conn.setAutoCommit(true); + System.out.println("Number of newSpecialIndex: "+zaehler); + System.out.println("Done"); + + } + + +private void createNewSpecialIndexNumber() throws ClassNotFoundException, SQLException{ +System.out.println("start indexing newSpecialIndexNumber"); +Statement stat = conn.createStatement(); +stat.executeUpdate("drop table if exists newSpecialIndexNumber;"); +stat.executeUpdate("create table newSpecialIndexNumber (name, uri);"); +PreparedStatement prep = conn.prepareStatement("insert into newSpecialIndexNumber values (?, ?);"); +BufferedReader in=null; +int zaehler=0; +try { + in = new BufferedReader( + new InputStreamReader( + new FileInputStream( "/home/swalter/workspace/SpecialIndex/IndexNumberUri" ) ) ); + String s; + while( null != (s = in.readLine()) ) { + String[] tmp_array =s.split(":::"); + + tmp_array[1]=tmp_array[1].replace("\n", ""); + tmp_array[0]=tmp_array[0].replace("\n", ""); + /*System.out.println(tmp_array[0]); + System.out.println(tmp_array[1]);*/ + if(tmp_array.length>=2){ + prep.setString(1, tmp_array[1]); + prep.setString(2, tmp_array[0]); + prep.addBatch(); + zaehler=zaehler+1; + if(zaehler%1000000==0){ + conn.setAutoCommit(false); + prep.executeBatch(); + conn.setAutoCommit(false); + // System.out.println(zaehler+" done"); + } + + } + } + } catch( FileNotFoundException ex ) { + } catch( Exception ex ) { + System.out.println( ex ); + } finally { + if( in != null ) + try { + in.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +conn.setAutoCommit(false); +prep.executeBatch(); +conn.setAutoCommit(true); +System.out.println("Number of IndexNumberUri: "+zaehler); +System.out.println("Done"); + +} + + + + } \ No newline at end of file Added: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/TestClassNewIndex.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/TestClassNewIndex.java (rev 0) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/TestClassNewIndex.java 2012-04-21 15:10:29 UTC (rev 3651) @@ -0,0 +1,25 @@ +package org.dllearner.algorithm.tbsl.exploration.Index; + +import java.sql.SQLException; +import java.util.ArrayList; + +public class TestClassNewIndex { + + /** + * @param args + * @throws SQLException + * @throws ClassNotFoundException + */ + public static void main(String[] args) throws ClassNotFoundException, SQLException { + // TODO Auto-generated method stub + newSpecialSQliteIndex index = new newSpecialSQliteIndex(); + //System.out.println(index.getUriForIndex("381252")); + + ArrayList<String> test = new ArrayList<String>(); + + test=index.getListOfUriSpecialIndex("female Russian astronauts"); + + if(test!=null)for(String s:test) System.out.println(s); + } + +} Added: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/newSpecialSQliteIndex.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/newSpecialSQliteIndex.java (rev 0) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/newSpecialSQliteIndex.java 2012-04-21 15:10:29 UTC (rev 3651) @@ -0,0 +1,235 @@ +package org.dllearner.algorithm.tbsl.exploration.Index; + +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + + +public class newSpecialSQliteIndex { + private Connection conn; + + public ArrayList<String> getListOfUriSpecialIndex(String string){ + string = string.toLowerCase(); + String[] temp_list = string.split(" "); + ArrayList<String> first_result=new ArrayList<String>(); + ArrayList<String> result=new ArrayList<String>(); + ArrayList<ArrayList<String>> tmp_result = new ArrayList<ArrayList<String>>(); + try { + for(String s : temp_list)first_result.add(getNumberForWordInIndex(s)); + + + for(String s : first_result){ + ArrayList<String> second_result=new ArrayList<String>(); + if(s!=null){ + String[] tmp = s.split(":"); + + for(String z : tmp) second_result.add(z); + + + + + tmp_result.add(second_result); + } + + } + + for(int i=1;i<tmp_result.size();i++){ + tmp_result.get(0).retainAll(tmp_result.get(i)); + } + + + if(tmp_result.get(0).size()!=0){ + for(String s : tmp_result.get(0)){ + result.add(getUriForIndex(s)); + } + } + + + + + + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + + + + return result; + } + + + public newSpecialSQliteIndex() throws ClassNotFoundException, SQLException { + // TODO Auto-generated constructor stub + System.out.println("start"); + Class.forName( "org.sqlite.JDBC" ); + conn = DriverManager.getConnection("jdbc:sqlite::memory:"); + System.out.println("start IndexNumber"); + createNewSpecialIndexNumber(); + System.out.println("start SpecialIndex"); + createNewSpecialIndex(); + + System.out.println("done"); + + } + + + public String getUriForIndex(String string) throws SQLException{ + /* while(rs.next()) + {*/ + Statement stat = conn.createStatement(); + ResultSet rs; + try { + rs = stat.executeQuery("select uri from newSpecialIndexNumber where name='"+string.toLowerCase()+"';"); + return rs.getString("uri"); + } catch (Exception e) { + // TODO Auto-generated catch block + //e.printStackTrace(); + return null; + } + + } + + + public String getNumberForWordInIndex(String string) throws SQLException{ + /* while(rs.next()) + {*/ + Statement stat = conn.createStatement(); + ResultSet rs; + try { + rs = stat.executeQuery("select uri from newSpecialIndex where name='"+string.toLowerCase()+"';"); + return rs.getString("uri"); + } catch (Exception e) { + // TODO Auto-generated catch block + //e.printStackTrace(); + return null; + } + + } +private void createNewSpecialIndex() throws ClassNotFoundException, SQLException{ + System.out.println("start indexing Properties"); + Statement stat = conn.createStatement(); + stat.executeUpdate("drop table if exists newSpecialIndex;"); + stat.executeUpdate("create table newSpecialIndex (name, uri);"); + PreparedStatement prep = conn.prepareStatement("insert into newSpecialIndex values (?, ?);"); + BufferedReader in=null; + int zaehler=0; + try { + in = new BufferedReader( + new InputStreamReader( + new FileInputStream( "/home/swalter/workspace/SpecialIndex/Index" ) ) ); + String s; + while( null != (s = in.readLine()) ) { + String[] tmp_array =s.split(":::"); + tmp_array[1]=tmp_array[1].replace("\n", ""); + tmp_array[0]=tmp_array[0].replace("\n", ""); + if(tmp_array.length>=2){ + prep.setString(1, tmp_array[0]); + prep.setString(2, tmp_array[1]); + prep.addBatch(); + zaehler=zaehler+1; + if(zaehler%1000000==0){ + conn.setAutoCommit(false); + prep.executeBatch(); + conn.setAutoCommit(false); + // System.out.println(zaehler+" done"); + } + + } + } + } catch( FileNotFoundException ex ) { + } catch( Exception ex ) { + System.out.println( ex ); + } finally { + if( in != null ) + try { + in.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + conn.setAutoCommit(false); + prep.executeBatch(); + conn.setAutoCommit(true); + System.out.println("Number of newSpecialIndex: "+zaehler); + System.out.println("Done"); + + } + + +private void createNewSpecialIndexNumber() throws ClassNotFoundException, SQLException{ + System.out.println("start indexing newSpecialIndexNumber"); + Statement stat = conn.createStatement(); + stat.executeUpdate("drop table if exists newSpecialIndexNumber;"); + stat.executeUpdate("create table newSpecialIndexNumber (name, uri);"); + PreparedStatement prep = conn.prepareStatement("insert into newSpecialIndexNumber values (?, ?);"); + BufferedReader in=null; + int zaehler=0; + try { + in = new BufferedReader( + new InputStreamReader( + new FileInputStream( "/home/swalter/workspace/SpecialIndex/IndexNumberUri" ) ) ); + String s; + while( null != (s = in.readLine()) ) { + String[] tmp_array =s.split(":::"); + + tmp_array[1]=tmp_array[1].replace("\n", ""); + tmp_array[0]=tmp_array[0].replace("\n", ""); + /*System.out.println(tmp_array[0]); + System.out.println(tmp_array[1]);*/ + if(tmp_array.length>=2){ + prep.setString(1, tmp_array[1]); + prep.setString(2, tmp_array[0]); + prep.addBatch(); + zaehler=zaehler+1; + if(zaehler%1000000==0){ + conn.setAutoCommit(false); + prep.executeBatch(); + conn.setAutoCommit(false); + // System.out.println(zaehler+" done"); + } + + } + } + } catch( FileNotFoundException ex ) { + } catch( Exception ex ) { + System.out.println( ex ); + } finally { + if( in != null ) + try { + in.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + conn.setAutoCommit(false); + prep.executeBatch(); + conn.setAutoCommit(true); + System.out.println("Number of IndexNumberUri: "+zaehler); + System.out.println("Done"); + + } + + + +} \ 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: <seb...@us...> - 2012-04-20 14:41:02
|
Revision: 3650 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3650&view=rev Author: sebastianwtr Date: 2012-04-20 14:40:53 +0000 (Fri, 20 Apr 2012) Log Message: ----------- [tbsl exploration] improved settings Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -101,10 +101,17 @@ string=string.replace("-", " "); string=string.replace(".", " "); String result=null; + String result2 = null; ArrayList<String> result_List = new ArrayList<String>(); result=myindex.getPropertyURI(string.toLowerCase()); + result2=myindex.getontologyURI(string.toLowerCase()); if(Setting.isDebugModus())DebugMode.debugPrint("Result: "+result); - if(result!=null){ + if(result2!=null){ + result_List.add(result2); + hm.put(result, 1.0f); + if(Setting.isDebugModus())DebugMode.debugPrint("Found uri for: "+string.toLowerCase()); + } + else if(result!=null){ result_List.add(result); hm.put(result, 1.0f); if(Setting.isDebugModus())DebugMode.debugPrint("Found uri for: "+string.toLowerCase()); @@ -173,6 +180,38 @@ } + /* + * also add String without the plural s at the end. + */ + if(string.substring(string.length()-1).contains("s")){ + String neuer_string = string.substring(0, string.length() -1); + tmp1=myindex.getontologyClassURI(neuer_string.toLowerCase()); + tmp2=myindex.getYagoURI(neuer_string.toLowerCase()); + if(tmp1!=null){ + result_List.add(tmp1); + } + if(tmp2!=null){ + result_List.add(tmp1); + } + } + + if(string.length()>3){ + if(string.substring(string.length()-3).contains("ies")){ + String neuer_string = string.substring(0, string.length() -3); + neuer_string+="y"; + tmp1=myindex.getontologyClassURI(neuer_string.toLowerCase()); + tmp2=myindex.getYagoURI(neuer_string.toLowerCase()); + if(tmp1!=null){ + result_List.add(tmp1); + } + if(tmp2!=null){ + result_List.add(tmp1); + } + + } + } + + return result_List; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java 2012-04-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -48,12 +48,13 @@ ArrayList<Template> resultArrayList = new ArrayList<Template>(); Set<BasicQueryTemplate> querytemps =null; querytemps = btemplator.buildBasicQueries(question); + /* * check if templates were build, if not, safe the question and delete it for next time from the xml file. * Only in Debug Mode */ - if(Setting.isDebugModus()){ + //if(Setting.isDebugModus()){ if(querytemps.contains("could not be parsed") || querytemps.isEmpty()){ String dateiname="/home/swalter/Dokumente/Auswertung/NotParsed.txt"; String result_string =""; @@ -78,7 +79,7 @@ } - } + //} long stop_template = System.currentTimeMillis(); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -24,9 +24,10 @@ import org.dllearner.algorithm.tbsl.nlp.StanfordLemmatizer; import org.dllearner.algorithm.tbsl.nlp.WordNet; import org.dllearner.algorithm.tbsl.templator.BasicTemplator; +import org.dllearner.algorithms.gp.GP; public class MainInterface { - private static int anzahlAbgeschickterQueries = 100; + private static int anzahlAbgeschickterQueries = 10; public static ArrayList<String> startQuestioning(String question,BasicTemplator btemplator,SQLiteIndex myindex, WordNet wordnet,StanfordLemmatizer lemmatiser) throws ClassNotFoundException, SQLException, IOException{ @@ -93,6 +94,7 @@ else{ go_on=false; + if(qp.size()<3)go_on=true; System.out.println("Got Answer from Server with this Query: "+ q.getQuery()); //go_on=true; boolean contains_uri=false; @@ -249,6 +251,7 @@ printQueries(qp, type, Question); anzahl=1; go_on = true; + int id=0; for(QueryPair q : qp){ if(anzahl<anzahlAbgeschickterQueries&go_on){ ArrayList<String> answer_tmp = new ArrayList<String>(); @@ -261,6 +264,13 @@ //go_on=true; go_on=false; System.out.println("Got Answer from Server with this Query: "+ q.getQuery()); + if(qp.size()>(id+1)){ + if(q.getRank()==qp.get(id+1).getRank()){ + go_on=true; + } + } + + boolean contains_uri=false; for(String s : answer_tmp){ if(s.contains("http")){ @@ -288,6 +298,7 @@ } } anzahl+=1; + id+=1; } System.out.println("\n Answer from Server: \n"); for(String answer:answers){ Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -130,7 +130,8 @@ //line="/home/swalter/Dokumente/Auswertung/XMLDateien/vortragfragen.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/iteration-test.xml"; line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-tagged.xml"; - line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-tagged-withoutNotparsed.xml"; + //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-tagged-withoutNotparsed.xml"; + //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-test-questions.xml"; //create Structs ArrayList<queryInformation> list_of_structs = new ArrayList<queryInformation>(); @@ -161,6 +162,10 @@ for(queryInformation s : list_of_resultstructs){ System.out.println(s.getResult()); }*/ + + long stopTime = System.currentTimeMillis(); + System.out.println("For "+anzahl+" Questions the QA_System took "+ ((stopTime-startTime)/1000)+"sek"); + String systemid=""; systemid=createXML(list_of_structs); String filename_for_evaluation="/home/swalter/Dokumente/Auswertung/ResultXml/result"+systemid.replace(" ", "_")+".xml"; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-20 09:07:54 UTC (rev 3649) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-20 14:40:53 UTC (rev 3650) @@ -21,14 +21,33 @@ String key = entry.getKey(); key=key.replace("\"",""); key=key.replace("@en",""); + key=key.toLowerCase(); String value = entry.getValue(); //compare property gotten from the resource with the property from the original query double nld=Levenshtein.nld(property_to_compare_with.toLowerCase(), key); //if(nld>=LevenstheinMin||key.contains(lemmatiser.stem(property_to_compare_with))||property_to_compare_with.contains(lemmatiser.stem(key))){ - - if(nld>=LevenstheinMin){ + + if(key.contains(property_to_compare_with)||property_to_compare_with.contains(key)){ + if(nld<0.8){ + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", 0.85); + listOfNewHypothesen.add(h); + } + else{ + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); + listOfNewHypothesen.add(h); + } + + } + else if(key.substring(key.length()-1).contains("s")){ + String neuer_string = key.substring(0, key.length() -1); + if(neuer_string.contains(property_to_compare_with)||property_to_compare_with.contains(neuer_string)){ + Hypothesis h = new Hypothesis(variable, neuer_string, value, "PROPERTY", 1.5); + listOfNewHypothesen.add(h); + } + } + else if(nld>=LevenstheinMin){ Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); listOfNewHypothesen.add(h); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2012-04-20 09:08:03
|
Revision: 3649 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3649&view=rev Author: lorenz_b Date: 2012-04-20 09:07:54 +0000 (Fri, 20 Apr 2012) Log Message: ----------- Added preferences tab. Modified Paths: -------------- trunk/protege/src/main/java/org/dllearner/tools/protege/Manager.java trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java trunk/protege/src/main/java/org/dllearner/tools/protege/SuggestionsTable.java trunk/protege/src/main/java/org/dllearner/tools/protege/SuggestionsTableModel.java trunk/protege/src/main/resources/plugin.properties trunk/protege/src/main/resources/plugin.xml Added Paths: ----------- trunk/protege/src/main/java/org/dllearner/tools/protege/DLLearnerPreferences.java trunk/protege/src/main/java/org/dllearner/tools/protege/DLLearnerPreferencesPanel.java Added: trunk/protege/src/main/java/org/dllearner/tools/protege/DLLearnerPreferences.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/DLLearnerPreferences.java (rev 0) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/DLLearnerPreferences.java 2012-04-20 09:07:54 UTC (rev 3649) @@ -0,0 +1,35 @@ +package org.dllearner.tools.protege; + +import org.protege.editor.core.prefs.Preferences; +import org.protege.editor.core.prefs.PreferencesManager; + +public class DLLearnerPreferences { + private static DLLearnerPreferences instance; + + private static final String KEY = "org.dllearner"; + + private static final String TRACKING = "CheckConsistencyWhileLearning"; + + + public static synchronized DLLearnerPreferences getInstance() { + if(instance == null) { + instance = new DLLearnerPreferences(); + } + return instance; + } + + private Preferences getPrefs() { + return PreferencesManager.getInstance().getApplicationPreferences(KEY); + } + + + public boolean isCheckConsistencyWhileLearning() { + return getPrefs().getBoolean(TRACKING, true); + } + + + public void setCheckConsistencyWhileLearning(boolean checkConsistencyWhileLearning) { + getPrefs().putBoolean(TRACKING, checkConsistencyWhileLearning); + } + +} Added: trunk/protege/src/main/java/org/dllearner/tools/protege/DLLearnerPreferencesPanel.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/DLLearnerPreferencesPanel.java (rev 0) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/DLLearnerPreferencesPanel.java 2012-04-20 09:07:54 UTC (rev 3649) @@ -0,0 +1,120 @@ +package org.dllearner.tools.protege; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.ArrayList; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JTabbedPane; + +import org.protege.editor.owl.ui.preferences.OWLPreferencesPanel; + +public class DLLearnerPreferencesPanel extends OWLPreferencesPanel{ + + private static final long serialVersionUID = -943293597478204971L; + + private java.util.List<OWLPreferencesPanel> optionPages = new ArrayList<OWLPreferencesPanel>(); + + private JTabbedPane tabPane; + + public static final String DEFAULT_PAGE = "General Options"; + + + public void applyChanges() { + for (OWLPreferencesPanel optionPage : optionPages) { + optionPage.applyChanges(); + } + } + + + public void initialise() throws Exception { + setLayout(new BorderLayout()); + + tabPane = new JTabbedPane(); + + addOptions(new BasicOptionsPanel(), "General Options"); + + add(tabPane, BorderLayout.NORTH); + } + + + public void dispose() throws Exception { + for (OWLPreferencesPanel optionPage : optionPages) { + optionPage.dispose(); + } + } + + + private void addOptions(OWLPreferencesPanel page, String tabName) throws Exception { + // If the page does not exist, add it, and add the component + // to the page. + + Component c = getTab(tabName); + if(c == null) { + // Create a new Page + Box box = new Box(BoxLayout.Y_AXIS); + box.add(page); + box.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); + tabPane.add(tabName, box); + optionPages.add(page); + } + else { + Box box = (Box) c; + box.add(Box.createVerticalStrut(7)); + box.add(page); + optionPages.add(page); + } + + page.initialise(); + } + + protected Component getTab(String name) { + for(int i = 0; i < tabPane.getTabCount(); i++) { + if(tabPane.getTitleAt(i).equals(name)) { + return tabPane.getComponentAt(i); + } + } + return null; + } + + class BasicOptionsPanel extends OWLPreferencesPanel { + + /** + * + */ + private static final long serialVersionUID = -6685359718444062677L; + private JCheckBox checkConsistencyCheckBox; + + public void initialise() throws Exception { + setLayout(new BorderLayout(12, 12)); + setBorder(BorderFactory.createTitledBorder("Basic")); + add(createUI(), BorderLayout.NORTH); + } + + public void dispose() throws Exception { + // do nothing + } + + + protected JComponent createUI() { + Box panel = new Box(BoxLayout.LINE_AXIS); + + checkConsistencyCheckBox = new JCheckBox("Check consistency"); + panel.add(checkConsistencyCheckBox); + + return panel; + } + + public void applyChanges() { + DLLearnerPreferences.getInstance().setCheckConsistencyWhileLearning(checkConsistencyCheckBox.isSelected()); + } + } + + + + +} Modified: trunk/protege/src/main/java/org/dllearner/tools/protege/Manager.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/Manager.java 2012-04-20 07:53:21 UTC (rev 3648) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/Manager.java 2012-04-20 09:07:54 UTC (rev 3649) @@ -129,7 +129,7 @@ lp.setClassToDescribe(new NamedClass(editorKit.getOWLWorkspace() .getOWLSelectionModel().getLastSelectedClass().getIRI().toURI())); lp.setEquivalence(learningType == LearningType.EQUIVALENT); - lp.setCheckConsistency(false); + lp.setCheckConsistency(DLLearnerPreferences.getInstance().isCheckConsistencyWhileLearning()); lp.init(); System.out.println("Done in " + (System.currentTimeMillis()-startTime) + "ms."); Modified: trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java 2012-04-20 07:53:21 UTC (rev 3648) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java 2012-04-20 09:07:54 UTC (rev 3649) @@ -30,9 +30,9 @@ import org.protege.editor.owl.model.event.OWLModelManagerListener; import org.protege.editor.owl.model.inference.OWLReasonerManager; import org.protege.editor.owl.model.inference.ReasonerStatus; -import org.protege.editor.owl.model.inference.ReasonerUtilities; import org.protege.editor.owl.ui.editor.AbstractOWLClassExpressionEditor; import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.model.OWLClass; import org.semanticweb.owlapi.model.OWLClassExpression; /** @@ -136,9 +136,11 @@ @Override public void handleChange(OWLModelManagerChangeEvent event) { - System.out.println(event); - if(event.isType(EventType.REASONER_CHANGED) && !event.isType(EventType.ACTIVE_ONTOLOGY_CHANGED)){ - checkReasonerStatus(); - } + OWLClass lastSelectedClass = getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); + if (lastSelectedClass != null) { + if(event.isType(EventType.REASONER_CHANGED) && !event.isType(EventType.ACTIVE_ONTOLOGY_CHANGED)){ + checkReasonerStatus(); + } + } } } Modified: trunk/protege/src/main/java/org/dllearner/tools/protege/SuggestionsTable.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/SuggestionsTable.java 2012-04-20 07:53:21 UTC (rev 3648) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/SuggestionsTable.java 2012-04-20 09:07:54 UTC (rev 3649) @@ -1,8 +1,12 @@ package org.dllearner.tools.protege; +import java.awt.event.MouseEvent; import java.util.Comparator; import java.util.List; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableCellRenderer; + import org.dllearner.learningproblems.EvaluatedDescriptionClass; import org.jdesktop.swingx.JXTable; import org.protege.editor.owl.OWLEditorKit; @@ -72,4 +76,21 @@ public EvaluatedDescriptionClass getSelectedSuggestion(){ return ((SuggestionsTableModel)getModel()).getSelectedValue(getSelectedRow()); } + + @Override + public String getToolTipText(MouseEvent event) { + int column = columnAtPoint(event.getPoint()); + int row = rowAtPoint(event.getPoint()); + if(column == 1 && row != -1){ + EvaluatedDescriptionClass ec = ((SuggestionsTableModel)getModel()).getEntryAtRow(row); + String text = null; + if(ec.followsFromKB()){ + text = "This axiom follows implicitly from knowledge base!"; + } else if(DLLearnerPreferences.getInstance().isCheckConsistencyWhileLearning() && !ec.isConsistent()){ + text = "Adding this axiom may laed to an inconsistent knowlegde base!"; + } + return text; + } + return super.getToolTipText(event); + } } Modified: trunk/protege/src/main/java/org/dllearner/tools/protege/SuggestionsTableModel.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/SuggestionsTableModel.java 2012-04-20 07:53:21 UTC (rev 3648) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/SuggestionsTableModel.java 2012-04-20 09:07:54 UTC (rev 3649) @@ -47,9 +47,12 @@ case 0: return (int) (suggestionList.get(rowIndex).getAccuracy() * 100); case 1: - if (!suggestionList.get(rowIndex).isConsistent()) { - return inconsistentIcon; - } else if(suggestionList.get(rowIndex).followsFromKB()){ + if(DLLearnerPreferences.getInstance().isCheckConsistencyWhileLearning()){ + if (!suggestionList.get(rowIndex).isConsistent()) { + return inconsistentIcon; + } + } + if(suggestionList.get(rowIndex).followsFromKB()){ return followsIcon; }break; case 2: @@ -84,6 +87,14 @@ } } + public EvaluatedDescriptionClass getEntryAtRow(int row){ + if(suggestionList.size() >= row){ + return suggestionList.get(row); + } else { + return null; + } + } + public void clear(){ suggestionList.clear(); fireTableDataChanged(); Modified: trunk/protege/src/main/resources/plugin.properties =================================================================== --- trunk/protege/src/main/resources/plugin.properties 2012-04-20 07:53:21 UTC (rev 3648) +++ trunk/protege/src/main/resources/plugin.properties 2012-04-20 09:07:54 UTC (rev 3649) @@ -1,6 +1,6 @@ id=org.dllearner.tools.protege -version=0.6.0 -download=http://sourceforge.net/projects/dl-learner/files/Protege%20DL-Learner%20Plugin/0.6/Protege-DL-Learner-plugin-0.6.zip/download +version=0.7.0 +download=http://sourceforge.net/projects/dl-learner/files/Protege%20DL-Learner%20Plugin/0.7/Protege-DL-Learner-plugin-0.7.zip/download name=DL-Learner Plugin readme=http://dl-learner.svn.sourceforge.net/viewvc/dl-learner/trunk/src/dl-learner/org/dllearner/tools/protege/README license=http://dl-learner.svn.sourceforge.net/viewvc/dl-learner/trunk/LICENSE Modified: trunk/protege/src/main/resources/plugin.xml =================================================================== --- trunk/protege/src/main/resources/plugin.xml 2012-04-20 07:53:21 UTC (rev 3648) +++ trunk/protege/src/main/resources/plugin.xml 2012-04-20 09:07:54 UTC (rev 3649) @@ -6,5 +6,11 @@ <class value="org.dllearner.tools.protege.ProtegePlugin"/> <index value="E"/> </extension> + + <extension id="org.dllearner.tools.protege.prefs" + point="org.protege.editor.core.application.preferencespanel"> + <label value="DL-Learner"/> + <class value="org.dllearner.tools.protege.DLLearnerPreferencesPanel"/> + </extension> </plugin> \ 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: <lor...@us...> - 2012-04-20 07:53:30
|
Revision: 3648 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3648&view=rev Author: lorenz_b Date: 2012-04-20 07:53:21 +0000 (Fri, 20 Apr 2012) Log Message: ----------- Updated Protege lib versions. Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-04-20 07:52:12 UTC (rev 3647) +++ trunk/pom.xml 2012-04-20 07:53:21 UTC (rev 3648) @@ -264,13 +264,13 @@ <dependency> <groupId>org.protege.editor.core</groupId> <artifactId>org.protege.editor.core.application</artifactId> - <version>4.1</version> + <version>4.2</version> </dependency> <dependency> <groupId>org.protege.editor.owl</groupId> <artifactId>org.protege.editor.owl</artifactId> - <version>4.1</version> + <version>4.2</version> </dependency> <!--Dependencies that are generated as part of this parent pom --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2012-04-20 07:52:19
|
Revision: 3647 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3647&view=rev Author: lorenz_b Date: 2012-04-20 07:52:12 +0000 (Fri, 20 Apr 2012) Log Message: ----------- Removed libs which now are copied with the copy-dependencies plugin. Changed plugin configuration to Protege 4.2. Modified Paths: -------------- trunk/protege/pom.xml trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java trunk/protege/src/main/resources/META-INF/MANIFEST.MF Removed Paths: ------------- trunk/protege/src/main/resources/lib/ Modified: trunk/protege/pom.xml =================================================================== --- trunk/protege/pom.xml 2012-04-20 02:59:13 UTC (rev 3646) +++ trunk/protege/pom.xml 2012-04-20 07:52:12 UTC (rev 3647) @@ -46,9 +46,20 @@ <groupId>com.jgoodies</groupId> <artifactId>looks</artifactId> </dependency> + + <dependency> + <groupId>com.jamonapi</groupId> + <artifactId>jamon</artifactId> + </dependency> + + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + </dependency> </dependencies> <build> + <finalName>DL-Learner-Plugin</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -96,6 +107,62 @@ </excludes> </configuration> </plugin> + <!-- <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.4</version> + <executions> + <execution> + <id>copy</id> + <phase>prepare-package</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.protege.editor.owl</groupId> + <artifactId>org.protege.editor.owl</artifactId> + <version>4.2</version> + <type>jar</type> + <overWrite>true</overWrite> + <outputDirectory>${project.build.directory}/classes/lib</outputDirectory> + </artifactItem> + <artifactItem> + <groupId>org.protege.editor.owl</groupId> + <artifactId>org.protege.editor.owl</artifactId> + <version>4.2</version> + <type>jar</type> + <overWrite>true</overWrite> + <outputDirectory>${project.build.directory}/classes/lib</outputDirectory> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.4</version> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>prepare-package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}/classes/lib</outputDirectory> + <overWriteReleases>false</overWriteReleases> + <overWriteSnapshots>false</overWriteSnapshots> + <overWriteIfNewer>true</overWriteIfNewer> + <excludeTransitive>true</excludeTransitive> + <stripVersion>true</stripVersion> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> </project> Modified: trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java 2012-04-20 02:59:13 UTC (rev 3646) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java 2012-04-20 07:52:12 UTC (rev 3647) @@ -25,15 +25,15 @@ import javax.swing.JComponent; import org.protege.editor.core.ui.util.InputVerificationStatusChangedListener; -import org.protege.editor.owl.model.OWLModelManager; import org.protege.editor.owl.model.event.EventType; import org.protege.editor.owl.model.event.OWLModelManagerChangeEvent; import org.protege.editor.owl.model.event.OWLModelManagerListener; -import org.protege.editor.owl.model.inference.NoOpReasoner; +import org.protege.editor.owl.model.inference.OWLReasonerManager; +import org.protege.editor.owl.model.inference.ReasonerStatus; +import org.protege.editor.owl.model.inference.ReasonerUtilities; import org.protege.editor.owl.ui.editor.AbstractOWLClassExpressionEditor; import org.semanticweb.owlapi.model.AxiomType; import org.semanticweb.owlapi.model.OWLClassExpression; -import org.semanticweb.owlapi.reasoner.OWLReasoner; /** * This is the class that must be implemented to get the plugin integrated in @@ -43,7 +43,6 @@ * */ public class ProtegePlugin extends AbstractOWLClassExpressionEditor implements OWLModelManagerListener{ - private static final long serialVersionUID = 728362819273927L; private DLLearnerView view; @Override @@ -69,13 +68,23 @@ } private void checkReasonerStatus(){ - OWLReasoner r = getOWLEditorKit().getModelManager().getReasoner(); - if(r instanceof NoOpReasoner){ - view.setHintMessage("<html><font size=\"3\" color=\"red\">You have to select a reasoner (click on menu \"Reasoner\"). We recommend to use Pellet. </font></html>"); - view.setRunButtonEnabled(false); - } else { - view.setHintMessage(""); - view.setRunButtonEnabled(true); + OWLReasonerManager reasonerManager = getOWLEditorKit().getOWLModelManager().getOWLReasonerManager(); +// ReasonerUtilities.warnUserIfReasonerIsNotConfigured(getOWLEditorKit().getOWLWorkspace(), reasonerManager); + ReasonerStatus status = reasonerManager.getReasonerStatus(); + boolean enable = true; + String message = ""; + if(status == ReasonerStatus.INITIALIZED){ + if(status == ReasonerStatus.INCONSISTENT){ + message = "The loaded ontology is inconsistent. Learning is only supported for consistent ontologies."; + enable = false; + } + } else { + message = "You have to select a reasoner (click on menu \"Reasoner\"). We recommend to use Pellet."; + enable = false; + } + view.setHintMessage("<html><font size=\"3\" color=\"red\">" + message + "</font></html>"); + view.setRunButtonEnabled(enable); + if(enable){ if(!Manager.getInstance().isPreparing() && Manager.getInstance().isReinitNecessary()){ new ReadingOntologyThread(view).start(); } @@ -127,7 +136,8 @@ @Override public void handleChange(OWLModelManagerChangeEvent event) { - if(event.isType(EventType.REASONER_CHANGED) || event.isType(EventType.ACTIVE_ONTOLOGY_CHANGED)){ + System.out.println(event); + if(event.isType(EventType.REASONER_CHANGED) && !event.isType(EventType.ACTIVE_ONTOLOGY_CHANGED)){ checkReasonerStatus(); } } Modified: trunk/protege/src/main/resources/META-INF/MANIFEST.MF =================================================================== --- trunk/protege/src/main/resources/META-INF/MANIFEST.MF 2012-04-20 02:59:13 UTC (rev 3646) +++ trunk/protege/src/main/resources/META-INF/MANIFEST.MF 2012-04-20 07:52:12 UTC (rev 3647) @@ -9,16 +9,13 @@ Update-Url: http://dl-learner.svn.sourceforge.net/viewvc/dl-learner/trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/update.properties Bundle-ClassPath: ., lib/junit-4.4.jar, - lib/jamon-2.7.jar, - lib/swingx-1.6.jar, - lib/json-20090211.jar, - lib/log4j-1.2.16.jar, - lib/jamon-2.0.jar, - lib/jena/json.jar, - lib/jena/commons-logging-1.1.1.jar, - lib/components-core-1.0-SNAPSHOT.jar -Import-Package: org.osgi.framework,org.apache.log4j,org.apache.commons - .lang,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.s + lib/jamon.jar, + lib/swingx.jar, + lib/json.jar, + lib/log4j.jar, + lib/jamon.jar, + lib/components-core.jar +Import-Package: org.osgi.framework,org.apache.log4j,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.s wing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf. basic,javax.swing.plaf.metal,javax.swing.plaf.multi,javax.swing.plaf. synth,javax.swing.table,javax.swing.text,javax.swing.text.html,javax. @@ -51,11 +48,11 @@ .owlapi.turtle.parser,org.protege.owlapi.apibinding,org.protege.owlap i.concurrent,org.protege.owlapi.model Export-Package: lib -Bundle-Version: 0.6.0 +Bundle-Version: 0.7.0 Bundle-Activator: org.protege.editor.core.plugin.DefaultPluginActivator Require-Bundle: org.eclipse.equinox.registry, org.eclipse.equinox.common, - org.protege.editor.core.application;bundle-version="4.1.0", - org.protege.editor.owl;bundle-version="4.1.0", + org.protege.editor.core.application;bundle-version="4.2.0", + org.protege.editor.owl;bundle-version="4.2.0", org.semanticweb.owl.owlapi;bundle-version="3.0.0", com.clarkparsia.protege.plugin.pellet This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sha...@us...> - 2012-04-20 02:59:20
|
Revision: 3646 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3646&view=rev Author: shadowtm Date: 2012-04-20 02:59:13 +0000 (Fri, 20 Apr 2012) Log Message: ----------- Removed references to repositories - we should put external dependencies in our archiva (either through upload or proxied repository). This way, we aren't dependent on third party repositories when we build - just our own. Modified Paths: -------------- trunk/components-core/pom.xml trunk/pom.xml Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2012-04-19 22:10:21 UTC (rev 3645) +++ trunk/components-core/pom.xml 2012-04-20 02:59:13 UTC (rev 3646) @@ -137,20 +137,15 @@ </dependency> <!-- Latest JENA ARQ - we have to exclude XercesImpl and use an older version here because use version bei JENA leads to some errors --> - <dependency> - <groupId>org.apache.jena</groupId> - <artifactId>jena-arq</artifactId> - <exclusions> - <exclusion> - <artifactId>xercesImpl</artifactId> - <groupId>xerces</groupId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>xerces</groupId> - <artifactId>xercesImpl</artifactId> - <version>2.6.0</version> + <dependency> + <groupId>org.apache.jena</groupId> + <artifactId>jena-arq</artifactId> + <exclusions> + <exclusion> + <artifactId>xercesImpl</artifactId> + <groupId>xerces</groupId> + </exclusion> + </exclusions> </dependency> <!--JSON is in Central --> @@ -159,16 +154,7 @@ <artifactId>json</artifactId> </dependency> - <dependency> - <groupId>net.sf.jopt-simple</groupId> - <artifactId>jopt-simple</artifactId> - </dependency> - <dependency> - <groupId>org.ini4j</groupId> - <artifactId>ini4j</artifactId> - </dependency> - <dependency> <groupId>org.apache.xmlbeans</groupId> <artifactId>xmlbeans</artifactId> @@ -208,11 +194,6 @@ </dependency> <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - </dependency> - - <dependency> <groupId>fuzzydll</groupId> <artifactId>fuzzydl</artifactId> <version>1.0</version> @@ -241,19 +222,10 @@ <artifactId>spring-beans</artifactId> </dependency> <dependency> - <groupId>org.aksw.commons</groupId> - <artifactId>collections</artifactId> - </dependency> - <dependency> - <groupId>net.didion.jwnl</groupId> - <artifactId>jwnl</artifactId> - <version>1.4.1.RC2</version> + <groupId>org.apache.lucene</groupId> + <artifactId>lucene-core</artifactId> </dependency> - <dependency> - <groupId>org.apache.lucene</groupId> - <artifactId>lucene-core</artifactId> - </dependency> - - - </dependencies> + + + </dependencies> </project> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-04-19 22:10:21 UTC (rev 3645) +++ trunk/pom.xml 2012-04-20 02:59:13 UTC (rev 3646) @@ -86,6 +86,26 @@ <artifactId>maven-license-plugin</artifactId> <version>1.9.0</version> </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>tomcat-maven-plugin</artifactId> + <version>1.0</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>2.5</version> + </plugin> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>maven-jetty-plugin</artifactId> + <version>6.1.26</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.4</version> + </plugin> </plugins> </pluginManagement> </build> @@ -109,6 +129,13 @@ <groupId>com.owldl</groupId> <artifactId>pellet</artifactId> <version>2.3.0</version> + <exclusions> + <!--Excluding this because it has the same classpath as the new Apache Jena and can cause problems--> + <exclusion> + <groupId>com.hp.hpl.jena</groupId> + <artifactId>jena</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> @@ -442,109 +469,31 @@ </dependency> <!--END Logging Dependencies--> + <!--It seems that later versions of this causes a lot of problems for some of the libraries we depend on--> + <dependency> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + <version>2.6.0</version> + </dependency> + </dependencies> </dependencyManagement> <repositories> - - <repository> - <id>maven2-repository.dev.java.net</id> - <name>Java.net Repository for Maven</name> - <url>http://download.java.net/maven/2/</url> - <layout>default</layout> - </repository> - - <repository> <id>maven.aksw.internal</id> <name>University Leipzig, AKSW Maven2 Repository</name> <url>http://maven.aksw.org/archiva/repository/internal</url> + <releases/> </repository> - <repository> <id>maven.aksw.snapshots</id> <name>University Leipzig, AKSW Maven2 Repository</name> <url>http://maven.aksw.org/archiva/repository/snapshots</url> + <snapshots/> </repository> - - <!-- This repository contains the pellet jars --> - <repository> - <id>pellet_etc</id> - <url>http://on.cs.unibas.ch/maven/repository/</url> - </repository> - - <repository> - <id>GXT</id> - <url>http://maven.jahia.org/maven2/</url> - </repository> - - <!-- - This is so we can get the 1.3-SNAPSHOT of GWT Maven Plugin cause - 1.2 is broken on the hudson - - Here's a good place to browse the repository: - https://nexus.codehaus.org --> - <repository> - <id>maven.codehaus.snapshots</id> - <name>Codehaus repository Repository</name> - <url>https://nexus.codehaus.org/content/repositories/public</url> - </repository> - - <repository> - <id>google-maven-snapshot-repository</id> - <name>Google Maven Snapshot Repository</name> - <url>https://oss.sonatype.org/content/repositories/google-snapshots/</url> - <snapshots> - <enabled>true</enabled> - </snapshots> - </repository> - - <repository> - <id>apache-repo-releases</id> - <url>https://repository.apache.org/content/repositories/releases/</url> - <releases> - <enabled>true</enabled> - </releases> - </repository> - <repository> - <id>apache-repo-snapshots</id> - <url>https://repository.apache.org/content/repositories/snapshots/</url> - <releases> - <enabled>false</enabled> - </releases> - <snapshots> - <enabled>true</enabled> - </snapshots> - </repository> </repositories> - <pluginRepositories> - <pluginRepository> - <id>maven.codehaus.plugin.snapshots</id> - <name>Codehaus plugin Repository</name> - <url>https://nexus.codehaus.org/content/repositories/public</url> - <snapshots> - <enabled>true</enabled> - </snapshots> - <releases> - <enabled>true</enabled> - </releases> - </pluginRepository> - <pluginRepository> - <id>evolvis-release-repository</id> - <name>evolvis.org release repository</name> - <url>http://maven-repo.evolvis.org/releases</url> - <snapshots> - <enabled>false</enabled> - </snapshots> - </pluginRepository> - <pluginRepository> - <id>maven-latex-plugin-repo</id> - <url>http://akquinet.github.com/maven-latex-plugin/maven2/</url> - <releases> - <enabled>true</enabled> - </releases> - </pluginRepository> - </pluginRepositories> - - <distributionManagement> <repository> <id>archiva.internal</id> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dc...@us...> - 2012-04-19 22:10:27
|
Revision: 3645 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3645&view=rev Author: dcherix Date: 2012-04-19 22:10:21 +0000 (Thu, 19 Apr 2012) Log Message: ----------- files added for creating a debian package Added Paths: ----------- trunk/interfaces/CHANGES.txt trunk/interfaces/DebianPackageREADME.txt trunk/interfaces/log4j.properties trunk/interfaces/src/debian/ trunk/interfaces/src/debian/changelog trunk/interfaces/src/debian/control trunk/interfaces/src/debian/rules Added: trunk/interfaces/CHANGES.txt =================================================================== --- trunk/interfaces/CHANGES.txt (rev 0) +++ trunk/interfaces/CHANGES.txt 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,2 @@ +release date=20:13 13.10.2009,version=0.2,urgency=low,by=Jens Lehmann,distribution=staging + * Test application Added: trunk/interfaces/DebianPackageREADME.txt =================================================================== --- trunk/interfaces/DebianPackageREADME.txt (rev 0) +++ trunk/interfaces/DebianPackageREADME.txt 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,8 @@ +To create a debian package: + 1. use dch (apt-get install devscripts) to modify the changelog file in src/debian + 2. just copy the comments (only the comments) from the changelog file to CHANGES.txt + In CHANGES.txt the first line must be like release date=20:13 13.10.2009,version=0.2,urgency=low,by=Jens Lehmann,distribution=staging + paste the comments after this with one whitespace at begin of the line + 3. compile with mvn clean install -Pdebpackage + 4. the deb-package will be generate in target with a .changes file too + 5. sign the package and upload it to the stack \ No newline at end of file Added: trunk/interfaces/log4j.properties =================================================================== --- trunk/interfaces/log4j.properties (rev 0) +++ trunk/interfaces/log4j.properties 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,29 @@ +log4j.rootLogger=INFO, stdout, file + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout + +log4j.appender.file=org.apache.log4j.FileAppender +log4j.appender.file.File=/var/log/dllearner/interfaces.log +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n + +# DL-Learner Logs +log4j.logger.org.dllearner=INFO + +log4j.logger.org.dllearner.server.nke.LogicalRelationStrategy=DEBUG + +# Eliminate most of the Spring Context Loading noise +log4j.logger.org.springframework=WARN + +## log4j.logger.org.joseki.server.http.LocatorServletContext=ALL + +# Jena, including the Joseki client +#log4j.logger.com.hp.hpl.jena=WARN + +## log4j.logger.com.hp.hpl.jena.util.FileManager=ALL +## log4j.logger.com.hp.hpl.jena.util.LocatorURL=ALL +## log4j.logger.com.hp.hpl.jena.util.LocatorClassLoader=ALL +## log4j.logger.com.hp.hpl.jena.util.LocatorFile=ALL +## log4j.logger.com.hp.hpl.jena.util.LocationMapper=ALL + Property changes on: trunk/interfaces/log4j.properties ___________________________________________________________________ Added: svn:executable + * Added: trunk/interfaces/src/debian/changelog =================================================================== --- trunk/interfaces/src/debian/changelog (rev 0) +++ trunk/interfaces/src/debian/changelog 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1 @@ + Added: trunk/interfaces/src/debian/control =================================================================== --- trunk/interfaces/src/debian/control (rev 0) +++ trunk/interfaces/src/debian/control 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,9 @@ +Package: [[name]] +Version: [[version]] +Section: misc +Priority: optional +Architecture: all +Depends: openjdk-6-jre | sun-java6-jre +Maintainer: Jens Lehmann <le...@in...> +Description: This is a package that contains the cli component of the dl-learner. +Distribution: development \ No newline at end of file Added: trunk/interfaces/src/debian/rules =================================================================== --- trunk/interfaces/src/debian/rules (rev 0) +++ trunk/interfaces/src/debian/rules 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,21 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +install: + mkdir /usr/share/dllearner/ + mkdir /usr/share/dllearner/log + chmod -R 777 /usr/share/dllearner/log + cp -r tmp/${PACKAGE_NAME}-${VERSION}/lib /usr/share/dllearner + cp ../dllearner-cli /usr/bin/dllearner-cli + chmod +x /usr/bin/dllearner-cli + +%: + dh $@ \ No newline at end of file Property changes on: trunk/interfaces/src/debian/rules ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dc...@us...> - 2012-04-19 22:08:17
|
Revision: 3644 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3644&view=rev Author: dcherix Date: 2012-04-19 22:08:10 +0000 (Thu, 19 Apr 2012) Log Message: ----------- files added for creating a debian package Modified Paths: -------------- trunk/interfaces/pom.xml Removed Paths: ------------- trunk/interfaces/src/deb/ Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2012-04-19 20:39:59 UTC (rev 3643) +++ trunk/interfaces/pom.xml 2012-04-19 22:08:10 UTC (rev 3644) @@ -2,12 +2,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>org.dllearner</groupId> + <artifactId>interfaces</artifactId> <packaging>jar</packaging> <name>Interfaces: GUI, CLI, Web Service</name> <url>http://aksw.org/Projects/DLLearner</url> + <parent> <groupId>org.dllearner</groupId> <artifactId>dllearner-parent</artifactId> @@ -16,6 +17,8 @@ <properties> <release.name>1.0-beta-2</release.name> + <dist-dir>dl-learner-dist</dist-dir> + <install-dir>share/dl-learner</install-dir> </properties> <profiles> @@ -36,7 +39,7 @@ </execution> </executions> <configuration> - <repositoryLayout>flat</repositoryLayout> + <repositoryLayout>flat</repositoryLayout> <assembleDirectory>${project.build.directory}/dl-learner-dist</assembleDirectory> <repoPath>lib</repoPath> <repositoryName>lib</repositoryName> @@ -56,9 +59,9 @@ <mainClass>org.dllearner.cli.Enrichment</mainClass> <name>enrichment</name> </program> - <!-- <program> <mainClass>org.dllearner.gui.StartGUI</mainClass> - <name>gui</name> </program> <program> <mainClass>org.dllearner.cli.QuickStart</mainClass> - <name>quickstart</name> </program> <program> <mainClass>org.dllearner.server.DLLearnerWS</mainClass> + <!-- <program> <mainClass>org.dllearner.gui.StartGUI</mainClass> + <name>gui</name> </program> <program> <mainClass>org.dllearner.cli.QuickStart</mainClass> + <name>quickstart</name> </program> <program> <mainClass>org.dllearner.server.DLLearnerWS</mainClass> <name>ws</name> </program> --> </programs> </configuration> @@ -87,10 +90,10 @@ <version>1.1</version> <configuration> <settings> - <!-- all tex main documents in this folder (including subfolders) + <!-- all tex main documents in this folder (including subfolders) will be processed --> <texDirectory>${basedir}/doc/manual</texDirectory> - <!-- the generated artifacts will be copied to this folder relative + <!-- the generated artifacts will be copied to this folder relative to ${project.reporting.outputDirectory} --> <outputDirectory>.</outputDirectory> <!-- the working directory, for temporary files and LaTeX processing --> @@ -123,29 +126,201 @@ </plugins> </build> </profile> + <profile> + <id>debpackage</id> + <build> + <finalName>dl-learner</finalName> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>appassembler-maven-plugin</artifactId> + <version>1.1.1</version> + <executions> + <execution> + <goals> + <goal>assemble</goal> + </goals> + </execution> + </executions> + <configuration> + <repositoryLayout>flat</repositoryLayout> + <assembleDirectory>${project.build.directory}/${dist-dir}</assembleDirectory> + <repoPath>/usr/share/dl-learner/lib</repoPath> + <repositoryName>${install-dir}/lib</repositoryName> + <extraJvmArguments>-Xms256m -Xmx1024m</extraJvmArguments> + <installArtifacts>false</installArtifacts> + <configurationDirectory>/</configurationDirectory> + <platforms> + <platform>unix</platform> + </platforms> + <programs> + <program> + <mainClass>org.dllearner.cli.CLI</mainClass> + <name>dl-learner-cli</name> + </program> + <program> + <mainClass>org.dllearner.cli.Enrichment</mainClass> + <name>dl-learner-enrichment</name> + </program> + <!-- <program> <mainClass>org.dllearner.gui.StartGUI</mainClass> + <name>gui</name> </program> <program> <mainClass>org.dllearner.cli.QuickStart</mainClass> + <name>quickstart</name> </program> <program> <mainClass>org.dllearner.server.DLLearnerWS</mainClass> + <name>ws</name> </program> --> + </programs> + </configuration> + </plugin> + <plugin> + <groupId>de.akquinet.maven</groupId> + <artifactId>maven-latex-plugin</artifactId> + <version>1.1</version> + <configuration> + <settings> + <!-- all tex main documents in this folder (including subfolders) + will be processed --> + <texDirectory>${basedir}/doc/manual</texDirectory> + <!-- the generated artifacts will be copied to this folder relative + to ${project.reporting.outputDirectory} --> + <outputDirectory>.</outputDirectory> + <!-- the working directory, for temporary files and LaTeX processing --> + <tempDirectory>${project.build.directory}/m2latex</tempDirectory> + <!-- clean up the working directory in the end? May be used for debugging --> + <cleanUp>true</cleanUp> + <!-- path to the TeX scripts, if none, it must be on the system path --> + <texPath /> + <!-- the latex command --> + <texCommand>pdflatex</texCommand> + <!-- the bibtex command --> + <bibtexCommand>bibtex</bibtexCommand> + <!-- the arguments to use when calling latex --> + <texCommandArgs> + <texCommandArg>-interaction=nonstopmode</texCommandArg> + <texCommandArg>--src-specials</texCommandArg> + </texCommandArgs> + </settings> + </configuration> + <executions> + <!-- execute latex goal automatically during the site phase --> + <execution> + <phase>prepare-package</phase> + <goals> + <goal>latex</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>jdeb</artifactId> + <groupId>org.vafer</groupId> + <version>0.9</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>jdeb</goal> + </goals> + <configuration> + <deb>${basedir}/target/dl-learner-${release.name}.deb</deb> + <version>${release.name}</version> + <controlDir>${basedir}/src/debian</controlDir> + <dataSet> + <data> + <src>${project.build.directory}/${dist-dir}/${install-dir}/lib</src> + <type>directory</type> + <mapper> + <type>perm</type> + <prefix>/usr/share/dl-learner/lib</prefix> + </mapper> + </data> + <data> + <src>${project.build.directory}/${dist-dir}/bin/dl-learner-cli</src> + <type>file</type> + + <mapper> + <type>perm</type> + <filemode>777</filemode> + <prefix>/usr/bin</prefix> + </mapper> + </data> + <data> + <src>${project.build.directory}/${dist-dir}/bin/dl-learner-enrichment</src> + <type>file</type> + + <mapper> + <type>perm</type> + <filemode>777</filemode> + <prefix>/usr/bin</prefix> + </mapper> + </data> + <data> + <src>${basedir}/log4j.properties</src> + <type>file</type> + <mapper> + <type>perm</type> + <filemode>777</filemode> + <prefix>/usr/share/dl-learner/lib</prefix> + </mapper> + </data> + <data> + <src>${basedir}/log/interfaces.log</src> + <type>file</type> + <mapper> + <type>perm</type> + <filemode>777</filemode> + <prefix>/var/log/dl-learner</prefix> + </mapper> + </data> + </dataSet> + <changesIn>${basedir}/CHANGES.txt</changesIn> + <changesOut>${basedir}/target/dl-learner-${release.name}.changes</changesOut> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> </profiles> - <build> - <finalName>interfaces</finalName> + <finalName>dl-learner</finalName> <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>1.6</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer + implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>org.dllearner.cli.CLI</mainClass> + </transformer> + </transformers> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>xmlbeans-maven-plugin</artifactId> + <version>2.3.3</version> + <executions> + <execution> + <goals> + <goal>xmlbeans</goal> + </goals> + </execution> + </executions> + <inherited>true</inherited> + <configuration> + <schemaDirectory>src/main/xsd</schemaDirectory> + </configuration> + </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>xmlbeans-maven-plugin</artifactId> - <version>2.3.3</version> - <executions> - <execution> - <goals> - <goal>xmlbeans</goal> - </goals> - </execution> - </executions> - <inherited>true</inherited> - <configuration> - <schemaDirectory>src/main/xsd</schemaDirectory> - </configuration> - </plugin> - <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> @@ -171,10 +346,10 @@ </requestLog> </configuration> <!--execution is used for testing --> - <!--executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> - <goals> <goal>run</goal> </goals> <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> - <daemon>true</daemon> <stopKey>stopKey</stopKey> <stopPort>9999</stopPort> - </configuration> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> + <!--executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> + <goals> <goal>run</goal> </goals> <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> + <daemon>true</daemon> <stopKey>stopKey</stopKey> <stopPort>9999</stopPort> + </configuration> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions --> </plugin> @@ -185,10 +360,10 @@ <configuration> <excludes> <exclude>org/dllearner/test/junit/OWLlinkTest.java</exclude> - <exclude>org/dllearner/configuration/spring/TestBean.java</exclude> - <exclude>org/dllearner/test/SpringTest.java</exclude> - <exclude>org/dllearner/test/junit/GeizhalsTest.java</exclude> - <exclude>org/dllearner/cli/MoosiqueCLITest.java</exclude> + <exclude>org/dllearner/configuration/spring/TestBean.java</exclude> + <exclude>org/dllearner/test/SpringTest.java</exclude> + <exclude>org/dllearner/test/junit/GeizhalsTest.java</exclude> + <exclude>org/dllearner/cli/MoosiqueCLITest.java</exclude> </excludes> </configuration> </plugin> @@ -202,11 +377,9 @@ <groupId>org.dllearner</groupId> <artifactId>components-core</artifactId> </dependency> - <!--dependency> - <groupId>org.dllearner</groupId> - <artifactId>components-ext</artifactId> - </dependency--> - <!-- Added the dependency of the core tests so that they will be accessible + <!--dependency> <groupId>org.dllearner</groupId> <artifactId>components-ext</artifactId> + </dependency --> + <!-- Added the dependency of the core tests so that they will be accessible from the tests in this component --> <dependency> <groupId>org.dllearner</groupId> @@ -258,61 +431,64 @@ <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </dependency> - <dependency> - <groupId>org.apache.xmlbeans</groupId> - <artifactId>xmlbeans</artifactId> - </dependency> - <dependency> - <groupId>org.dllearner</groupId> - <artifactId>spring-xmlbeans-3.0</artifactId> - <version>1.0</version> - </dependency> + <dependency> + <groupId>org.apache.xmlbeans</groupId> + <artifactId>xmlbeans</artifactId> + </dependency> + <dependency> + <groupId>org.dllearner</groupId> + <artifactId>spring-xmlbeans-3.0</artifactId> + <version>1.0</version> + </dependency> - <dependency> - <groupId>net.sf.jopt-simple</groupId> - <artifactId>jopt-simple</artifactId> - </dependency> + <dependency> + <groupId>net.sf.jopt-simple</groupId> + <artifactId>jopt-simple</artifactId> + </dependency> - <dependency> - <groupId>org.json</groupId> - <artifactId>json</artifactId> - </dependency> - - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> -</dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + </dependency> - <!--BEGIN Logging Dependencies--> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> - <!--This is the api jar, it's needed at compile time--> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> + <!--BEGIN Logging Dependencies --> - <!--This is the bridge that ties calls to the slf4j api to the log4j framework. This is a runtime dependency for programs which wish to use log4j as their implementation.--> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <scope>runtime</scope> - </dependency> + <!--This is the api jar, it's needed at compile time --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> - <!--Log4J dependency needed for the runtime as well as some specific compile time calls--> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> + <!--This is the bridge that ties calls to the slf4j api to the log4j framework. + This is a runtime dependency for programs which wish to use log4j as their + implementation. --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <scope>runtime</scope> + </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - <scope>runtime</scope> - </dependency> - <!--END Logging Dependencies--> + <!--Log4J dependency needed for the runtime as well as some specific compile + time calls --> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </dependency> - + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <scope>runtime</scope> + </dependency> + <!--END Logging Dependencies --> + + </dependencies> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dc...@us...> - 2012-04-19 20:40:06
|
Revision: 3643 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3643&view=rev Author: dcherix Date: 2012-04-19 20:39:59 +0000 (Thu, 19 Apr 2012) Log Message: ----------- Try to reply the scala commons wit Jena Modified Paths: -------------- trunk/scripts/src/main/java/org/dllearner/scripts/improveWikipedia/DBpediaClassLearnerCELOE.java Modified: trunk/scripts/src/main/java/org/dllearner/scripts/improveWikipedia/DBpediaClassLearnerCELOE.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/improveWikipedia/DBpediaClassLearnerCELOE.java 2012-04-19 13:39:25 UTC (rev 3642) +++ trunk/scripts/src/main/java/org/dllearner/scripts/improveWikipedia/DBpediaClassLearnerCELOE.java 2012-04-19 20:39:59 UTC (rev 3643) @@ -20,7 +20,9 @@ package org.dllearner.scripts.improveWikipedia; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; import java.util.HashMap; @@ -30,6 +32,8 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.aksw.commons.sparql.core.SparqlTemplate; +import org.apache.velocity.VelocityContext; import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.AbstractReasonerComponent; import org.dllearner.core.ComponentManager; @@ -43,6 +47,7 @@ import org.dllearner.core.owl.Thing; import org.dllearner.gui.Config; import org.dllearner.gui.ConfigSave; +import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlKnowledgeSource; import org.dllearner.learningproblems.PosNegLPStandard; import org.dllearner.reasoning.FastInstanceChecker; @@ -52,247 +57,350 @@ import org.dllearner.utilities.datastructures.SetManipulation; import org.dllearner.utilities.datastructures.SortedSetTuple; +import com.hp.hpl.jena.ontology.OntClass; +import com.hp.hpl.jena.ontology.OntModel; +import com.hp.hpl.jena.query.Query; +import com.hp.hpl.jena.query.QueryExecution; +import com.hp.hpl.jena.query.QueryExecutionFactory; +import com.hp.hpl.jena.query.QueryFactory; +import com.hp.hpl.jena.query.QuerySolution; +import com.hp.hpl.jena.query.ResultSet; +import com.hp.hpl.jena.rdf.model.ModelFactory; + /** - * A script, which learns definitions / super classes of classes in the DBpedia ontology. - * + * A script, which learns definitions / super classes of classes in the DBpedia + * ontology. + * * TODO: This script made heavy use of aksw-commons-sparql-scala and needs to be * rewritten to use aksw-commons-sparql (the new SPARQL API). - * + * * @author Jens Lehmann * @author Sebastian Hellmann */ public class DBpediaClassLearnerCELOE { - public static String endpointurl = "http://139.18.2.96:8910/sparql"; - public static int examplesize = 30; + public static String endpointurl = "http://live.dbpedia.org/sparql"; + public static int examplesize = 30; - private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(DBpediaClassLearnerCELOE.class); + private static org.apache.log4j.Logger logger = org.apache.log4j.Logger + .getLogger(DBpediaClassLearnerCELOE.class); -// SparqlEndpoint sparqlEndpoint = new CachingSparqlEndpoint(new HttpSparqlEndpoint(endpointurl, "http://dbpedia.org"), "cache/"); + SparqlEndpoint sparqlEndpoint = null; - public DBpediaClassLearnerCELOE() { - // OPTIONAL: if you want to do some case distinctions in the learnClass method, you could add - // parameters to the constructure e.g. YAGO_ - } + public DBpediaClassLearnerCELOE() { + // OPTIONAL: if you want to do some case distinctions in the learnClass + // method, you could add + // parameters to the constructure e.g. YAGO_ + try { + sparqlEndpoint = new SparqlEndpoint(new URL(endpointurl)); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } - public static void main(String args[]) throws LearningProblemUnsupportedException, IOException, Exception { + public static void main(String args[]) + throws LearningProblemUnsupportedException, IOException, Exception { - DBpediaClassLearnerCELOE dcl = new DBpediaClassLearnerCELOE(); -// Set<String> classesToLearn = dcl.getClasses(); -// -// KB kb = dcl.learnAllClasses(classesToLearn); -// kb.export(new File("result.owl"), OntologyFormat.RDF_XML); - } + DBpediaClassLearnerCELOE dcl = new DBpediaClassLearnerCELOE(); + Set<String> classesToLearn = dcl.getClasses(); + KB kb = dcl.learnAllClasses(classesToLearn); + kb.export(new File("result.owl"), OntologyFormat.RDF_XML); + // Set<String> pos = dcl.getPosEx("http://dbpedia.org/ontology/Person"); + // dcl.getNegEx("http://dbpedia.org/ontology/Person", pos); + } + public KB learnAllClasses(Set<String> classesToLearn) { + KB kb = new KB(); + for (String classToLearn : classesToLearn) { + System.out.println(classToLearn); + try { + Description d = learnClass(classToLearn); + if (d == null + || d.toKBSyntaxString().equals( + new Thing().toKBSyntaxString())) { + logger.error("Description was " + d + ", continueing"); + continue; + } + kb.addAxiom(new EquivalentClassesAxiom(new NamedClass( + classToLearn), d)); + kb.export(new File("result_partial.owl"), + OntologyFormat.RDF_XML); + System.out.println("DESCRIPTION: " + d); + } catch (Exception e) { + logger.warn("", e); + } + } - public KB learnAllClasses(Set<String> classesToLearn) { - KB kb = new KB(); - for (String classToLearn : classesToLearn) { - try { - Description d = learnClass(classToLearn); - if (d == null || d.toKBSyntaxString().equals(new Thing().toKBSyntaxString()) ) { - logger.error("Description was "+d+", continueing"); - continue; - } - kb.addAxiom(new EquivalentClassesAxiom(new NamedClass(classToLearn), d)); - kb.export(new File("result_partial.owl"), OntologyFormat.RDF_XML); - System.out.println("DESCRIPTION: "+d); - } catch (Exception e) { - logger.warn("", e); - } - } + return kb; + } - return kb; - } + public Description learnClass(String classToLearn) throws Exception { + // TODO: use aksw-commons-sparql instead of sparql-scala + SortedSet<String> posEx = new TreeSet<String>(getPosEx(classToLearn)); + logger.info("Found " + posEx.size() + " positive examples"); + if (posEx.isEmpty()) { + return null; + } + SortedSet<String> negEx = new TreeSet<String>(getNegEx(classToLearn, + posEx)); - public Description learnClass(String classToLearn) throws Exception { - // TODO: use aksw-commons-sparql instead of sparql-scala - SortedSet<String> posEx = null; // = new TreeSet<String>(getPosEx(classToLearn)); - logger.info("Found " + posEx.size() + " positive examples"); - if (posEx.isEmpty()) { - return null; - } - SortedSet<String> negEx = new TreeSet<String>(getNegEx(classToLearn, posEx)); + posEx = SetManipulation.fuzzyShrink(posEx, examplesize); + negEx = SetManipulation.fuzzyShrink(negEx, examplesize); - posEx = SetManipulation.fuzzyShrink(posEx, examplesize); - negEx = SetManipulation.fuzzyShrink(negEx, examplesize); + SortedSet<Individual> posExamples = Helper.getIndividualSet(posEx); + SortedSet<Individual> negExamples = Helper.getIndividualSet(negEx); + SortedSetTuple<Individual> examples = new SortedSetTuple<Individual>( + posExamples, negExamples); - SortedSet<Individual> posExamples = Helper.getIndividualSet(posEx); - SortedSet<Individual> negExamples = Helper.getIndividualSet(negEx); - SortedSetTuple<Individual> examples = new SortedSetTuple<Individual>(posExamples, negExamples); + ComponentManager cm = ComponentManager.getInstance(); - ComponentManager cm = ComponentManager.getInstance(); + SparqlKnowledgeSource ks = cm + .knowledgeSource(SparqlKnowledgeSource.class); + ks.setInstances(Datastructures.individualSetToStringSet(examples + .getCompleteSet())); + // ks.getConfigurator().setPredefinedEndpoint("DBPEDIA"); // TODO: + // probably the official endpoint is too slow? + ks.setUrl(new URL(endpointurl)); + ks.setUseLits(false); + ks.setUseCacheDatabase(true); + ks.setRecursionDepth(1); + ks.setCloseAfterRecursion(true); + ks.setSaveExtractedFragment(true); + ks.setPredList(new HashSet<String>(Arrays.asList(new String[] { + "http://dbpedia.org/property/wikiPageUsesTemplate", + "http://dbpedia.org/ontology/wikiPageExternalLink", + "http://dbpedia.org/property/wordnet_type", + "http://www.w3.org/2002/07/owl#sameAs" }))); - SparqlKnowledgeSource ks = cm.knowledgeSource(SparqlKnowledgeSource.class); - ks.setInstances(Datastructures.individualSetToStringSet(examples.getCompleteSet())); - //ks.getConfigurator().setPredefinedEndpoint("DBPEDIA"); // TODO: probably the official endpoint is too slow? - ks.setUrl(new URL(endpointurl)); - ks.setUseLits(false); - ks.setUseCacheDatabase(true); - ks.setRecursionDepth(1); - ks.setCloseAfterRecursion(true); - ks.setSaveExtractedFragment(true); - ks.setPredList(new HashSet<String>(Arrays.asList(new String[]{ - "http://dbpedia.org/property/wikiPageUsesTemplate", - "http://dbpedia.org/ontology/wikiPageExternalLink", - "http://dbpedia.org/property/wordnet_type", - "http://www.w3.org/2002/07/owl#sameAs"}))); + ks.setObjList(new HashSet<String>(Arrays.asList(new String[] { + "http://dbpedia.org/class/yago/", + "" + "http://dbpedia.org/resource/Category:" }))); - ks.setObjList(new HashSet<String>(Arrays.asList(new String[]{ - "http://dbpedia.org/class/yago/", "" + - "http://dbpedia.org/resource/Category:"}))); + ks.init(); + AbstractReasonerComponent rc = cm.reasoner(FastInstanceChecker.class, + ks); + rc.init(); - ks.init(); + PosNegLPStandard lp = cm.learningProblem(PosNegLPStandard.class, rc); + lp.setPositiveExamples(posExamples); + lp.setNegativeExamples(negExamples); + lp.setAccuracyMethod("fmeasure"); + lp.setUseApproximations(false); + lp.init(); - AbstractReasonerComponent rc = cm.reasoner(FastInstanceChecker.class, ks); - rc.init(); + CELOE la = cm.learningAlgorithm(CELOE.class, lp, rc); + // CELOEConfigurator cc = la.getConfigurator(); + la.setMaxExecutionTimeInSeconds(100); - PosNegLPStandard lp = cm.learningProblem(PosNegLPStandard.class, rc); - lp.setPositiveExamples(posExamples); - lp.setNegativeExamples(negExamples); - lp.setAccuracyMethod("fmeasure"); - lp.setUseApproximations(false); - lp.init(); + RhoDRDown op = (RhoDRDown) la.getOperator(); + op.setUseNegation(false); + op.setUseAllConstructor(false); + op.setUseCardinalityRestrictions(false); + op.setUseHasValueConstructor(true); + la.setNoisePercentage(20); + la.setIgnoredConcepts(new HashSet<NamedClass>(Arrays + .asList(new NamedClass[] { new NamedClass(classToLearn) }))); + la.init(); - CELOE la = cm.learningAlgorithm(CELOE.class, lp, rc); -// CELOEConfigurator cc = la.getConfigurator(); - la.setMaxExecutionTimeInSeconds(100); + // to write the above configuration in a conf file (optional) + Config cf = new Config(cm, ks, rc, lp, la); + new ConfigSave(cf).saveFile(new File("/dev/null")); - RhoDRDown op = (RhoDRDown) la.getOperator(); - - op.setUseNegation(false); - op.setUseAllConstructor(false); - op.setUseCardinalityRestrictions(false); - op.setUseHasValueConstructor(true); - la.setNoisePercentage(20); - la.setIgnoredConcepts(new HashSet<NamedClass>(Arrays.asList(new NamedClass[]{new NamedClass(classToLearn)}))); - la.init(); + la.start(); - // to write the above configuration in a conf file (optional) - Config cf = new Config(cm, ks, rc, lp, la); - new ConfigSave(cf).saveFile(new File("/dev/null")); + cm.freeAllComponents(); + return la.getCurrentlyBestDescription(); + } - la.start(); + public Set<String> getClasses() throws Exception { + OntModel model = ModelFactory.createOntologyModel(); + model.read(new FileInputStream( + "/home/dcherix/Downloads/dbpedia_3.6.owl"), null); + Set<OntClass> classes = model.listClasses().toSet(); + Set<String> results = new HashSet<String>(); + for (OntClass ontClass : classes) { + results.add(ontClass.getURI()); + } + return results; + } - cm.freeAllComponents(); - return la.getCurrentlyBestDescription(); - } + // gets all DBpedia Classes + // public Set<String> getClasses() throws Exception { + // SparqlTemplate st = SparqlTemplate.getInstance("allClasses.vm"); + // st.setLimit(0); + // st.addFilter(sparqlEndpoint.like("classes", new + // HashSet<String>(Arrays.asList(new + // String[]{"http://dbpedia.org/ontology/"})))); + // VelocityContext vc = st.putSgetVelocityContext(); + // String query = st.getQuery(); + // return new + // HashSet<String>(ResultSetRenderer.asStringSet(sparqlEndpoint.executeSelect(query))); + // } + // + public Set<String> getPosEx(String clazz) throws Exception { + SparqlTemplate st = SparqlTemplate.getInstance("instancesOfClass.vm"); + st.setLimit(0); + VelocityContext vc = st.getVelocityContext(); + vc.put("class", clazz); + String queryString = st.getQuery(); + return this.executeResourceQuery(queryString); + } - //gets all DBpedia Classes -// public Set<String> getClasses() throws Exception { -// SparqlTemplate st = SparqlTemplate.getInstance("allClasses.vm"); -// st.setLimit(0); -// st.addFilter(sparqlEndpoint.like("classes", new HashSet<String>(Arrays.asList(new String[]{"http://dbpedia.org/ontology/"})))); -// VelocityContext vc = st.getVelocityContext(); -// String query = st.getQuery(); -// return new HashSet<String>(ResultSetRenderer.asStringSet(sparqlEndpoint.executeSelect(query))); -// } -// -// public Set<String> getPosEx(String clazz) throws Exception { -// SparqlTemplate st = SparqlTemplate.getInstance("instancesOfClass.vm"); -// st.setLimit(0); -// VelocityContext vc = st.getVelocityContext(); -// System.out.println(clazz); -// vc.put("class", clazz); -// String query = st.getQuery(); -// return new HashSet<String>(ResultSetRenderer.asStringSet(sparqlEndpoint.executeSelect(query))); -// } + /** + * gets all direct classes of all instances and has a look, what the most + * common is + * + * @param clazz + * @param posEx + * @return + * @throws Exception + */ + public String selectClass(String clazz, Set<String> posEx) throws Exception { + Map<String, Integer> m = new HashMap<String, Integer>(); + // TODO: use aksw-commons-sparql instead of sparql-scala + /* + * for (String pos : posEx) { SparqlTemplate st = + * SparqlTemplate.getInstance("directClassesOfInstance.vm"); + * st.setLimit(0); st.addFilter(sparqlEndpoint.like("direct", new + * HashSet<String>(Arrays.asList(new + * String[]{"http://dbpedia.org/ontology/"})))); VelocityContext vc = + * st.getVelocityContext(); vc.put("instance", pos); String query = + * st.getQuery(); Set<String> classes = new + * HashSet<String>(ResultSetRenderer + * .asStringSet(sparqlEndpoint.executeSelect(query))); + * classes.remove(clazz); for (String s : classes) { if (m.get(s) == + * null) { m.put(s, 0); } m.put(s, m.get(s).intValue() + 1); } } + */ - /** - * gets all direct classes of all instances and has a look, what the most common is - * - * @param clazz - * @param posEx - * @return - * @throws Exception - */ - public String selectClass(String clazz, Set<String> posEx) throws Exception { - Map<String, Integer> m = new HashMap<String, Integer>(); - // TODO: use aksw-commons-sparql instead of sparql-scala - /* - for (String pos : posEx) { - SparqlTemplate st = SparqlTemplate.getInstance("directClassesOfInstance.vm"); - st.setLimit(0); - st.addFilter(sparqlEndpoint.like("direct", new HashSet<String>(Arrays.asList(new String[]{"http://dbpedia.org/ontology/"})))); - VelocityContext vc = st.getVelocityContext(); - vc.put("instance", pos); - String query = st.getQuery(); - Set<String> classes = new HashSet<String>(ResultSetRenderer.asStringSet(sparqlEndpoint.executeSelect(query))); - classes.remove(clazz); - for (String s : classes) { - if (m.get(s) == null) { - m.put(s, 0); - } - m.put(s, m.get(s).intValue() + 1); - } - } - */ + int max = 0; + String maxClass = ""; + for (String key : m.keySet()) { + if (m.get(key).intValue() > max) { + maxClass = key; + } + } - int max = 0; - String maxClass = ""; - for (String key : m.keySet()) { - if (m.get(key).intValue() > max) { - maxClass = key; - } - } - - return maxClass; - } + return maxClass; + } - /** - * gets instances of a class or random instances - * - * @param clazz - * @param posEx - * @return - * @throws Exception - */ + /** + * gets instances of a class or random instances + * + * @param clazz + * @param posEx + * @return + * @throws Exception + */ - public Set<String> getNegEx(String clazz, Set<String> posEx) throws Exception { - Set<String> negEx = new HashSet<String>(); - // TODO: use aksw-commons-sparql instead of sparql-scala - /* - String targetClass = getParallelClass(clazz); - logger.info("using class for negatives: " + targetClass); - if (targetClass != null) { + public Set<String> getNegEx(String clazz, Set<String> posEx) + throws Exception { + Set<String> negEx = new HashSet<String>(); + // TODO: use aksw-commons-sparql instead of sparql-scala + /* + * String targetClass = getParallelClass(clazz); + * logger.info("using class for negatives: " + targetClass); if + * (targetClass != null) { + * + * SparqlTemplate st = + * SparqlTemplate.getInstance("instancesOfClass.vm"); st.setLimit(0); + * VelocityContext vc = st.getVelocityContext(); vc.put("class", + * targetClass); // st.addFilter(sparqlEndpoint.like("class", new + * HashSet<String>(Arrays.asList(new + * String[]{"http://dbpedia.org/ontology/"})))); String query = + * st.getQuery(); // negEx.addAll(new + * HashSet<String>(ResultSetRenderer.asStringSet + * (sparqlEndpoint.executeSelect(query)))); } else { + * + * SparqlTemplate st = SparqlTemplate.getInstance("someInstances.vm"); + * st.setLimit(posEx.size() + 100); VelocityContext vc = + * st.getVelocityContext(); String query = st.getQuery(); // + * negEx.addAll(new + * HashSet<String>(ResultSetRenderer.asStringSet(sparqlEndpoint + * .executeSelect(query)))); } negEx.removeAll(posEx); + */ - SparqlTemplate st = SparqlTemplate.getInstance("instancesOfClass.vm"); - st.setLimit(0); - VelocityContext vc = st.getVelocityContext(); - vc.put("class", targetClass); -// st.addFilter(sparqlEndpoint.like("class", new HashSet<String>(Arrays.asList(new String[]{"http://dbpedia.org/ontology/"})))); - String query = st.getQuery(); -// negEx.addAll(new HashSet<String>(ResultSetRenderer.asStringSet(sparqlEndpoint.executeSelect(query)))); - } else { + String targetClass = getParallelClass(clazz); + System.out.println(targetClass); + logger.info("using class for negatives: " + targetClass); + if (targetClass != null) { + SparqlTemplate st = SparqlTemplate + .getInstance("instancesOfClass.vm"); + st.setLimit(0); + VelocityContext vc = st.getVelocityContext(); + vc.put("class", targetClass); + st.addFilter("FILTER ( ?class LIKE (<http://dbpedia.org/ontology/%>"); - SparqlTemplate st = SparqlTemplate.getInstance("someInstances.vm"); - st.setLimit(posEx.size() + 100); - VelocityContext vc = st.getVelocityContext(); - String query = st.getQuery(); -// negEx.addAll(new HashSet<String>(ResultSetRenderer.asStringSet(sparqlEndpoint.executeSelect(query)))); - } - negEx.removeAll(posEx); - */ - return negEx; + String query = st.getQuery(); + negEx.addAll(this.executeResourceQuery(query)); + } else { + SparqlTemplate st = SparqlTemplate.getInstance("someInstances.vm"); + st.setLimit(posEx.size() + 100); + VelocityContext vc = st.getVelocityContext(); + String query = st.getQuery(); + negEx.addAll(this.executeResourceQuery(query)); + } + negEx.removeAll(posEx); + return negEx; + } - } + public String getParallelClass(String clazz) throws Exception { + // TODO: use aksw-commons-sparql instead of sparql-scala + // SparqlTemplate st = SparqlTemplate.getInstance("parallelClass.vm"); + // st.setLimit(0); + // VelocityContext vc = st.getVelocityContext(); + // vc.put("class", clazz); + // String query = st.getQuery(); + // Set<String> parClasses = new + // HashSet<String>(ResultSetRenderer.asStringSet(sparqlEndpoint.executeSelect(query))); + // for (String s : parClasses) { + // return s; + // } + SparqlTemplate st = SparqlTemplate.getInstance("parallelClass.vm"); + st.setLimit(0); + VelocityContext vc = st.getVelocityContext(); + vc.put("class", clazz); + String query = st.getQuery(); + Set<String> parClasses = this.executeClassQuery(query); + for (String s : parClasses) { + if (s.startsWith("http://dbpedia.org/ontology")) { + if (!s.endsWith("Unknown")) { + return s; + } + } + } + return null; + } + public Set<String> executeResourceQuery(String queryString) { + Query query = QueryFactory.create(queryString); + QueryExecution qexec = QueryExecutionFactory.sparqlService(endpointurl, + query); + ResultSet resultSet = qexec.execSelect(); + QuerySolution solution; + Set<String> results = new HashSet<String>(); + while (resultSet.hasNext()) { + solution = resultSet.next(); + results.add(solution.getResource("instances").getURI()); + } + return results; + } - public String getParallelClass(String clazz) throws Exception { - // TODO: use aksw-commons-sparql instead of sparql-scala -// SparqlTemplate st = SparqlTemplate.getInstance("parallelClass.vm"); -// st.setLimit(0); -// VelocityContext vc = st.getVelocityContext(); -// vc.put("class", clazz); -// String query = st.getQuery(); -// Set<String> parClasses = new HashSet<String>(ResultSetRenderer.asStringSet(sparqlEndpoint.executeSelect(query))); -// for (String s : parClasses) { -// return s; -// } - return null; - } + public Set<String> executeClassQuery(String queryString) { + Query query = QueryFactory.create(queryString); + QueryExecution qexec = QueryExecutionFactory.sparqlService(endpointurl, + query); + ResultSet resultSet = qexec.execSelect(); + QuerySolution solution; + Set<String> results = new HashSet<String>(); + while (resultSet.hasNext()) { + solution = resultSet.next(); + results.add(solution.getResource("sub").getURI()); + } + return results; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2012-04-19 13:39:37
|
Revision: 3642 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3642&view=rev Author: lorenz_b Date: 2012-04-19 13:39:25 +0000 (Thu, 19 Apr 2012) Log Message: ----------- Started Protege plugin refactoring to be able to work with latest DL-Learner architecture and Protege 4.1. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/reasoning/ProtegeReasoner.java trunk/protege/src/main/java/org/dllearner/tools/protege/ActionHandler.java trunk/protege/src/main/java/org/dllearner/tools/protege/META-INF/plugin.xml trunk/protege/src/main/java/org/dllearner/tools/protege/Manager.java trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java trunk/protege/src/main/resources/META-INF/MANIFEST.MF trunk/protege/src/main/resources/lib/components-core-1.0-SNAPSHOT.jar Added Paths: ----------- trunk/protege/src/main/resources/lib/jamon-2.0.jar trunk/protege/src/main/resources/lib/json-20090211.jar trunk/protege/src/main/resources/lib/log4j-1.2.16.jar Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/ProtegeReasoner.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/reasoning/ProtegeReasoner.java 2012-04-18 14:01:32 UTC (rev 3641) +++ trunk/components-core/src/main/java/org/dllearner/reasoning/ProtegeReasoner.java 2012-04-19 13:39:25 UTC (rev 3642) @@ -778,251 +778,254 @@ return inds; } -@SuppressWarnings("unchecked") -public SortedSet<Individual> getIndividualsImplFast(Description description) - throws ReasoningMethodUnsupportedException { - // policy: returned sets are clones, i.e. can be modified - // (of course we only have to clone the leafs of a class description tree) - if (description instanceof NamedClass) { - return (TreeSet<Individual>) classInstancesPos.get((NamedClass) description).clone(); - } else if (description instanceof Negation) { - if(description.getChild(0) instanceof NamedClass) { - return (TreeSet<Individual>) classInstancesNeg.get((NamedClass) description.getChild(0)).clone(); - } - // implement retrieval as default negation - return Helper.difference((TreeSet<Individual>) individuals.clone(), getIndividualsImpl(description.getChild(0))); - } else if (description instanceof Thing) { - return (TreeSet<Individual>) individuals.clone(); - } else if (description instanceof Nothing) { - return new TreeSet<Individual>(); - } else if (description instanceof Union) { - // copy instances of first element and then subtract all others - SortedSet<Individual> ret = getIndividualsImpl(description.getChild(0)); - int childNr = 0; - for(Description child : description.getChildren()) { - if(childNr != 0) { - ret.addAll(getIndividualsImpl(child)); + @SuppressWarnings("unchecked") + public SortedSet<Individual> getIndividualsImplFast(Description description) + throws ReasoningMethodUnsupportedException { + // policy: returned sets are clones, i.e. can be modified + // (of course we only have to clone the leafs of a class description tree) + if (description instanceof NamedClass) { + if(((NamedClass) description).getName().equals("http://www.w3.org/2002/07/owl#Nothing")){ + return new TreeSet<Individual>(); } - childNr++; - } - return ret; - } else if (description instanceof Intersection) { - // copy instances of first element and then subtract all others - SortedSet<Individual> ret = getIndividualsImpl(description.getChild(0)); - int childNr = 0; - for(Description child : description.getChildren()) { - if(childNr != 0) { - ret.retainAll(getIndividualsImpl(child)); + return (TreeSet<Individual>) classInstancesPos.get((NamedClass) description).clone(); + } else if (description instanceof Negation) { + if(description.getChild(0) instanceof NamedClass) { + return (TreeSet<Individual>) classInstancesNeg.get((NamedClass) description.getChild(0)).clone(); } - childNr++; - } - return ret; - } else if (description instanceof ObjectSomeRestriction) { - SortedSet<Individual> targetSet = getIndividualsImpl(description.getChild(0)); - SortedSet<Individual> returnSet = new TreeSet<Individual>(); - - ObjectPropertyExpression ope = ((ObjectSomeRestriction) description).getRole(); - if (!(ope instanceof ObjectProperty)) { - throw new ReasoningMethodUnsupportedException("Retrieval for description " - + description + " unsupported. Inverse object properties not supported."); - } - ObjectProperty op = (ObjectProperty) ope; - Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); - - // each individual is connected to a set of individuals via the property; - // we loop through the complete mapping - for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { - SortedSet<Individual> inds = entry.getValue(); - for(Individual ind : inds) { - if(targetSet.contains(ind)) { - returnSet.add(entry.getKey()); - // once we found an individual, we do not need to check the others - continue; + // implement retrieval as default negation + return Helper.difference((TreeSet<Individual>) individuals.clone(), getIndividualsImpl(description.getChild(0))); + } else if (description instanceof Thing) { + return (TreeSet<Individual>) individuals.clone(); + } else if (description instanceof Nothing) { + return new TreeSet<Individual>(); + } else if (description instanceof Union) { + // copy instances of first element and then subtract all others + SortedSet<Individual> ret = getIndividualsImpl(description.getChild(0)); + int childNr = 0; + for(Description child : description.getChildren()) { + if(childNr != 0) { + ret.addAll(getIndividualsImpl(child)); } + childNr++; } - } - return returnSet; - } else if (description instanceof ObjectAllRestriction) { - // \forall restrictions are difficult to handle; assume we want to check - // \forall hasChild.male with domain(hasChild)=Person; then for all non-persons - // this is satisfied trivially (all of their non-existing children are male) -// if(!configurator.getForallRetrievalSemantics().equals("standard")) { -// throw new Error("Only forallExists semantics currently implemented."); -// } - - // problem: we need to make sure that \neg \exists r.\top \equiv \forall r.\bot - // can still be reached in an algorithm (\forall r.\bot \equiv \bot under forallExists - // semantics) - - SortedSet<Individual> targetSet = getIndividualsImpl(description.getChild(0)); - - ObjectPropertyExpression ope = ((ObjectAllRestriction) description).getRole(); - if (!(ope instanceof ObjectProperty)) { - throw new ReasoningMethodUnsupportedException("Instance check for description " - + description + " unsupported. Inverse object properties not supported."); - } - ObjectProperty op = (ObjectProperty) ope; - Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); -// SortedSet<Individual> returnSet = new TreeSet<Individual>(mapping.keySet()); - SortedSet<Individual> returnSet = (SortedSet<Individual>) individuals.clone(); - - // each individual is connected to a set of individuals via the property; - // we loop through the complete mapping - for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { - SortedSet<Individual> inds = entry.getValue(); - for(Individual ind : inds) { - if(!targetSet.contains(ind)) { - returnSet.remove(entry.getKey()); - continue; + return ret; + } else if (description instanceof Intersection) { + // copy instances of first element and then subtract all others + SortedSet<Individual> ret = getIndividualsImpl(description.getChild(0)); + int childNr = 0; + for(Description child : description.getChildren()) { + if(childNr != 0) { + ret.retainAll(getIndividualsImpl(child)); } + childNr++; } - } - return returnSet; - } else if (description instanceof ObjectMinCardinalityRestriction) { - ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); - if (!(ope instanceof ObjectProperty)) { - throw new ReasoningMethodUnsupportedException("Instance check for description " - + description + " unsupported. Inverse object properties not supported."); - } - ObjectProperty op = (ObjectProperty) ope; - Description child = description.getChild(0); - Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); - SortedSet<Individual> targetSet = getIndividualsImpl(child); - SortedSet<Individual> returnSet = new TreeSet<Individual>(); - - int number = ((ObjectCardinalityRestriction) description).getNumber(); - - for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { - int nrOfFillers = 0; - int index = 0; - SortedSet<Individual> inds = entry.getValue(); + return ret; + } else if (description instanceof ObjectSomeRestriction) { + SortedSet<Individual> targetSet = getIndividualsImpl(description.getChild(0)); + SortedSet<Individual> returnSet = new TreeSet<Individual>(); - // we do not need to run tests if there are not sufficiently many fillers - if(inds.size() < number) { - continue; + ObjectPropertyExpression ope = ((ObjectSomeRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Retrieval for description " + + description + " unsupported. Inverse object properties not supported."); } + ObjectProperty op = (ObjectProperty) ope; + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); - for(Individual ind : inds) { - // stop inner loop when nr of fillers is reached - if(nrOfFillers >= number) { - returnSet.add(entry.getKey()); - break; - } - // early abort when too many instance checks failed - if (inds.size() - index < number) { - break; - } - if(targetSet.contains(ind)) { - nrOfFillers++; + // each individual is connected to a set of individuals via the property; + // we loop through the complete mapping + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + SortedSet<Individual> inds = entry.getValue(); + for(Individual ind : inds) { + if(targetSet.contains(ind)) { + returnSet.add(entry.getKey()); + // once we found an individual, we do not need to check the others + continue; + } } - index++; } - } - - return returnSet; - } else if (description instanceof ObjectMaxCardinalityRestriction) { - ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); - if (!(ope instanceof ObjectProperty)) { - throw new ReasoningMethodUnsupportedException("Instance check for description " - + description + " unsupported. Inverse object properties not supported."); - } - ObjectProperty op = (ObjectProperty) ope; - Description child = description.getChild(0); - Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); - SortedSet<Individual> targetSet = getIndividualsImpl(child); - // initially all individuals are in the return set and we then remove those - // with too many fillers - SortedSet<Individual> returnSet = (SortedSet<Individual>) individuals.clone(); - - int number = ((ObjectCardinalityRestriction) description).getNumber(); - - for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { - int nrOfFillers = 0; - int index = 0; - SortedSet<Individual> inds = entry.getValue(); + return returnSet; + } else if (description instanceof ObjectAllRestriction) { + // \forall restrictions are difficult to handle; assume we want to check + // \forall hasChild.male with domain(hasChild)=Person; then for all non-persons + // this is satisfied trivially (all of their non-existing children are male) +// if(!configurator.getForallRetrievalSemantics().equals("standard")) { +// throw new Error("Only forallExists semantics currently implemented."); +// } - // we do not need to run tests if there are not sufficiently many fillers - if(number < inds.size()) { - returnSet.add(entry.getKey()); - continue; + // problem: we need to make sure that \neg \exists r.\top \equiv \forall r.\bot + // can still be reached in an algorithm (\forall r.\bot \equiv \bot under forallExists + // semantics) + + SortedSet<Individual> targetSet = getIndividualsImpl(description.getChild(0)); + + ObjectPropertyExpression ope = ((ObjectAllRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); } + ObjectProperty op = (ObjectProperty) ope; + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); +// SortedSet<Individual> returnSet = new TreeSet<Individual>(mapping.keySet()); + SortedSet<Individual> returnSet = (SortedSet<Individual>) individuals.clone(); - for(Individual ind : inds) { - // stop inner loop when nr of fillers is reached - if(nrOfFillers >= number) { - break; - } - // early abort when too many instance are true already - if (inds.size() - index < number) { - returnSet.add(entry.getKey()); - break; - } - if(targetSet.contains(ind)) { - nrOfFillers++; + // each individual is connected to a set of individuals via the property; + // we loop through the complete mapping + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + SortedSet<Individual> inds = entry.getValue(); + for(Individual ind : inds) { + if(!targetSet.contains(ind)) { + returnSet.remove(entry.getKey()); + continue; + } } - index++; } - } - - return returnSet; - } else if (description instanceof ObjectValueRestriction) { - Individual i = ((ObjectValueRestriction)description).getIndividual(); - ObjectProperty op = (ObjectProperty) ((ObjectValueRestriction)description).getRestrictedPropertyExpression(); - - Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); - SortedSet<Individual> returnSet = new TreeSet<Individual>(); - - for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { - if(entry.getValue().contains(i)) { - returnSet.add(entry.getKey()); + return returnSet; + } else if (description instanceof ObjectMinCardinalityRestriction) { + ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); } - } - return returnSet; - } else if (description instanceof BooleanValueRestriction) { - DatatypeProperty dp = ((BooleanValueRestriction) description) - .getRestrictedPropertyExpression(); - boolean value = ((BooleanValueRestriction) description).getBooleanValue(); + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + SortedSet<Individual> targetSet = getIndividualsImpl(child); + SortedSet<Individual> returnSet = new TreeSet<Individual>(); - if (value) { - return (TreeSet<Individual>) bdPos.get(dp).clone(); - } else { - return (TreeSet<Individual>) bdNeg.get(dp).clone(); - } - } else if (description instanceof DatatypeSomeRestriction) { - DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) description; - DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); - DataRange dr = dsr.getDataRange(); + int number = ((ObjectCardinalityRestriction) description).getNumber(); - Map<Individual, SortedSet<Double>> mapping = dd.get(dp); - SortedSet<Individual> returnSet = new TreeSet<Individual>(); + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + int nrOfFillers = 0; + int index = 0; + SortedSet<Individual> inds = entry.getValue(); + + // we do not need to run tests if there are not sufficiently many fillers + if(inds.size() < number) { + continue; + } + + for(Individual ind : inds) { + // stop inner loop when nr of fillers is reached + if(nrOfFillers >= number) { + returnSet.add(entry.getKey()); + break; + } + // early abort when too many instance checks failed + if (inds.size() - index < number) { + break; + } + if(targetSet.contains(ind)) { + nrOfFillers++; + } + index++; + } + } + + return returnSet; + } else if (description instanceof ObjectMaxCardinalityRestriction) { + ObjectPropertyExpression ope = ((ObjectCardinalityRestriction) description).getRole(); + if (!(ope instanceof ObjectProperty)) { + throw new ReasoningMethodUnsupportedException("Instance check for description " + + description + " unsupported. Inverse object properties not supported."); + } + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + SortedSet<Individual> targetSet = getIndividualsImpl(child); + // initially all individuals are in the return set and we then remove those + // with too many fillers + SortedSet<Individual> returnSet = (SortedSet<Individual>) individuals.clone(); - if (dr instanceof DoubleMaxValue) { - for(Entry<Individual, SortedSet<Double>> entry : mapping.entrySet()) { - if(entry.getValue().first() <= ((DoubleMaxValue)dr).getValue()) { + int number = ((ObjectCardinalityRestriction) description).getNumber(); + + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + int nrOfFillers = 0; + int index = 0; + SortedSet<Individual> inds = entry.getValue(); + + // we do not need to run tests if there are not sufficiently many fillers + if(number < inds.size()) { returnSet.add(entry.getKey()); + continue; } - } - } else if (dr instanceof DoubleMinValue) { - for(Entry<Individual, SortedSet<Double>> entry : mapping.entrySet()) { - if(entry.getValue().last() >= ((DoubleMinValue)dr).getValue()) { + + for(Individual ind : inds) { + // stop inner loop when nr of fillers is reached + if(nrOfFillers >= number) { + break; + } + // early abort when too many instance are true already + if (inds.size() - index < number) { + returnSet.add(entry.getKey()); + break; + } + if(targetSet.contains(ind)) { + nrOfFillers++; + } + index++; + } + } + + return returnSet; + } else if (description instanceof ObjectValueRestriction) { + Individual i = ((ObjectValueRestriction)description).getIndividual(); + ObjectProperty op = (ObjectProperty) ((ObjectValueRestriction)description).getRestrictedPropertyExpression(); + + Map<Individual, SortedSet<Individual>> mapping = opPos.get(op); + SortedSet<Individual> returnSet = new TreeSet<Individual>(); + + for(Entry<Individual, SortedSet<Individual>> entry : mapping.entrySet()) { + if(entry.getValue().contains(i)) { returnSet.add(entry.getKey()); } } + return returnSet; + } else if (description instanceof BooleanValueRestriction) { + DatatypeProperty dp = ((BooleanValueRestriction) description) + .getRestrictedPropertyExpression(); + boolean value = ((BooleanValueRestriction) description).getBooleanValue(); + + if (value) { + return (TreeSet<Individual>) bdPos.get(dp).clone(); + } else { + return (TreeSet<Individual>) bdNeg.get(dp).clone(); + } + } else if (description instanceof DatatypeSomeRestriction) { + DatatypeSomeRestriction dsr = (DatatypeSomeRestriction) description; + DatatypeProperty dp = (DatatypeProperty) dsr.getRestrictedPropertyExpression(); + DataRange dr = dsr.getDataRange(); + + Map<Individual, SortedSet<Double>> mapping = dd.get(dp); + SortedSet<Individual> returnSet = new TreeSet<Individual>(); + + if (dr instanceof DoubleMaxValue) { + for(Entry<Individual, SortedSet<Double>> entry : mapping.entrySet()) { + if(entry.getValue().first() <= ((DoubleMaxValue)dr).getValue()) { + returnSet.add(entry.getKey()); + } + } + } else if (dr instanceof DoubleMinValue) { + for(Entry<Individual, SortedSet<Double>> entry : mapping.entrySet()) { + if(entry.getValue().last() >= ((DoubleMinValue)dr).getValue()) { + returnSet.add(entry.getKey()); + } + } + } } + + throw new ReasoningMethodUnsupportedException("Retrieval for description " + + description + " unsupported."); + + // return rs.retrieval(concept); +// SortedSet<Individual> inds = new TreeSet<Individual>(); +// for (Individual i : individuals) { +// if (hasType(concept, i)) { +// inds.add(i); +// } +// } +// return inds; } - - throw new ReasoningMethodUnsupportedException("Retrieval for description " - + description + " unsupported."); - - // return rs.retrieval(concept); -// SortedSet<Individual> inds = new TreeSet<Individual>(); -// for (Individual i : individuals) { -// if (hasType(concept, i)) { -// inds.add(i); -// } -// } -// return inds; -} @Override public Set<NamedClass> getTypesImpl(Individual individual) { Modified: trunk/protege/src/main/java/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/ActionHandler.java 2012-04-18 14:01:32 UTC (rev 3641) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/ActionHandler.java 2012-04-19 13:39:25 UTC (rev 3642) @@ -99,6 +99,14 @@ // view.setLearningStarted(); // view.showHorizontalExpansionMessage(Manager.getInstance().getMinimumHorizontalExpansion(), // Manager.getInstance().getMaximumHorizontalExpansion()); +// try { +// Manager manager = Manager.getInstance(); +// manager.initLearningProblem(); +// manager.initLearningAlgorithm(); +// Manager.getInstance().startLearning(); +// } catch (Exception e) { +// e.printStackTrace(); +// } retriever = new SuggestionRetriever(); retriever.addPropertyChangeListener(view.getStatusBar()); @@ -181,30 +189,30 @@ manager.initLearningAlgorithm(); view.setBusyTaskEnded(); -// SwingUtilities.invokeLater(new Runnable() { -// @Override -// public void run() { -// view.setLearningStarted(); -// view.showHorizontalExpansionMessage(Manager.getInstance().getMinimumHorizontalExpansion(), -// Manager.getInstance().getMaximumHorizontalExpansion()); -// } -// }); -// -// timer = new Timer(); -// timer.schedule(new TimerTask(){ -// int progress = 0; -// List<? extends EvaluatedDescription> result; -// @Override -// public void run() { -// progress++; -// setProgress(progress); -// if(!isCancelled() && Manager.getInstance().isLearning()){ -// result = Manager.getInstance().getCurrentlyLearnedDescriptions(); -// publish(result); -// } -// } -// -// }, 1000, 500); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + view.setLearningStarted(); + view.showHorizontalExpansionMessage(Manager.getInstance().getMinimumHorizontalExpansion(), + Manager.getInstance().getMaximumHorizontalExpansion()); + } + }); + + timer = new Timer(); + timer.schedule(new TimerTask(){ + int progress = 0; + List<? extends EvaluatedDescription> result; + @Override + public void run() { + progress++; + setProgress(progress); + if(!isCancelled() && Manager.getInstance().isLearning()){ + result = Manager.getInstance().getCurrentlyLearnedDescriptions(); + publish(result); + } + } + + }, 1000, 500); Manager.getInstance().startLearning(); } catch (Exception e) { ErrorLogPanel.showErrorDialog(e); @@ -218,13 +226,13 @@ @Override public void done() { -// if(!isCancelled()){ -// timer.cancel(); -// List<? extends EvaluatedDescription> result = Manager.getInstance().getCurrentlyLearnedDescriptions(); -// updateList(result); -// setProgress(0); -// view.setLearningFinished(); -// } + if(!isCancelled()){ + timer.cancel(); + List<? extends EvaluatedDescription> result = Manager.getInstance().getCurrentlyLearnedDescriptions(); + updateList(result); + setProgress(0); + view.setLearningFinished(); + } ProtegeApplication.getBackgroundTaskManager().endTask(learningTask); } Modified: trunk/protege/src/main/java/org/dllearner/tools/protege/META-INF/plugin.xml =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/META-INF/plugin.xml 2012-04-18 14:01:32 UTC (rev 3641) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/META-INF/plugin.xml 2012-04-19 13:39:25 UTC (rev 3642) @@ -1,7 +1,7 @@ <?xml version="1.0" ?> <plugin> <extension id="org.dllearner.tools.protege.ProtegePlugin" - point="org.protege.editor.owl.ui_editor_description"> + point="org.protege.editor.core.application.ViewComponent"> <label value="DL-Learner"/> <class value="org.dllearner.tools.protege.ProtegePlugin"/> <index value="E"/> Modified: trunk/protege/src/main/java/org/dllearner/tools/protege/Manager.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/Manager.java 2012-04-18 14:01:32 UTC (rev 3641) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/Manager.java 2012-04-19 13:39:25 UTC (rev 3642) @@ -6,11 +6,8 @@ import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.ComponentInitException; -import org.dllearner.core.ComponentManager; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.AbstractKnowledgeSource; -import org.dllearner.core.AbstractCELA; -import org.dllearner.core.AbstractLearningProblem; +import org.dllearner.core.KnowledgeSource; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; @@ -18,6 +15,7 @@ import org.dllearner.learningproblems.ClassLearningProblem; import org.dllearner.learningproblems.EvaluatedDescriptionClass; import org.dllearner.reasoning.ProtegeReasoner; +import org.dllearner.refinementoperators.RhoDRDown; import org.dllearner.utilities.owl.OWLAPIConverter; import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; import org.protege.editor.core.Disposable; @@ -37,14 +35,6 @@ public class Manager implements OWLModelManagerListener, OWLSelectionModelListener, Disposable{ - private final String[] components = { "org.dllearner.kb.OWLFile", - "org.dllearner.reasoning.OWLAPIReasoner", - "org.dllearner.reasoning.FastInstanceChecker", - "org.dllearner.reasoning.ProtegeReasoner", - "org.dllearner.reasoning.FastRetrievalReasoner", - "org.dllearner.algorithms.celoe.CELOE", - "org.dllearner.learningproblems.PosNegLPStandard", "org.dllearner.learningproblems.ClassLearningProblem"}; - private static Manager instance; private OWLEditorKit editorKit; @@ -52,11 +42,10 @@ private boolean reinitNecessary = true; - private ComponentManager cm; - private AbstractLearningProblem lp; - private AbstractCELA la; + private ClassLearningProblem lp; + private CELOE la; private ProtegeReasoner reasoner; - private AbstractKnowledgeSource ks; + private KnowledgeSource ks; private LearningType learningType; private int maxExecutionTimeInSeconds; @@ -85,8 +74,6 @@ private Manager(OWLEditorKit editorKit){ this.editorKit = editorKit; - ComponentManager.setComponentClasses(components); - cm = ComponentManager.getInstance(); } public void setOWLEditorKit(OWLEditorKit editorKit){ @@ -110,20 +97,25 @@ public void initLearningAlgorithm() throws Exception { System.out.print("Initializing learning algorithm..."); long startTime = System.currentTimeMillis(); - la = cm.learningAlgorithm(CELOE.class, lp, reasoner); - cm.applyConfigEntry(la, "useAllConstructor", useAllConstructor); - cm.applyConfigEntry(la, "useExistsConstructor", useExistsConstructor); - cm.applyConfigEntry(la, "useHasValueConstructor", - useHasValueConstructor); - cm.applyConfigEntry(la, "useNegation", useNegation); - cm.applyConfigEntry(la, "useCardinalityRestrictions", - useCardinalityRestrictions); - if (useCardinalityRestrictions) { - cm.applyConfigEntry(la, "cardinalityLimit", cardinalityLimit); + la = new CELOE(lp, reasoner); + + RhoDRDown op = new RhoDRDown(); + op.setReasoner(reasoner); + op.setUseNegation(useNegation); + op.setUseHasValueConstructor(useAllConstructor); + op.setUseCardinalityRestrictions(useCardinalityRestrictions); + if(useCardinalityRestrictions){ + op.setCardinalityLimit(cardinalityLimit); } - cm.applyConfigEntry(la, "noisePercentage", noisePercentage); - cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", - maxExecutionTimeInSeconds); + op.setUseExistsConstructor(useExistsConstructor); + op.setUseHasValueConstructor(useHasValueConstructor); + op.init(); + + la.setOperator(op); + + la.setMaxExecutionTimeInSeconds(maxExecutionTimeInSeconds); + la.setNoisePercentage(noisePercentage); + la.setMaxNrOfResults(maxNrOfResults); la.init(); System.out.println("done in " + (System.currentTimeMillis()-startTime) + "ms."); @@ -133,16 +125,11 @@ public void initLearningProblem() throws Exception { System.out.print("Initializing learning problem..."); long startTime = System.currentTimeMillis(); - lp = cm.learningProblem(ClassLearningProblem.class, reasoner); - cm.applyConfigEntry(lp, "classToDescribe", editorKit.getOWLWorkspace() - .getOWLSelectionModel().getLastSelectedClass().getIRI().toURI() - .toURL()); - if (learningType == LearningType.EQUIVALENT) { - cm.applyConfigEntry(lp, "type", "equivalence"); - } else if (learningType == LearningType.SUPER) { - cm.applyConfigEntry(lp, "type", "superClass"); - } - cm.applyConfigEntry(lp, "checkConsistency", false); + lp = new ClassLearningProblem(reasoner); + lp.setClassToDescribe(new NamedClass(editorKit.getOWLWorkspace() + .getOWLSelectionModel().getLastSelectedClass().getIRI().toURI())); + lp.setEquivalence(learningType == LearningType.EQUIVALENT); + lp.setCheckConsistency(false); lp.init(); System.out.println("Done in " + (System.currentTimeMillis()-startTime) + "ms."); @@ -154,17 +141,16 @@ } public void initReasoner() throws Exception{ - System.out.print("Initializing reasoner..."); + System.out.print("Initializing DL-Learner internal reasoner..."); long startTime = System.currentTimeMillis(); - reasoner = cm.reasoner(ProtegeReasoner.class, ks); - reasoner.setOWLReasoner(editorKit.getOWLModelManager().getReasoner()); + reasoner = new ProtegeReasoner(Collections.singleton(ks), editorKit.getOWLModelManager().getReasoner()); reasoner.setProgressMonitor(progressMonitor); reasoner.init(); System.out.println("Done in " + (System.currentTimeMillis()-startTime) + "ms."); } public void initReasonerAsynchronously(){ - reasoner = cm.reasoner(ProtegeReasoner.class, ks); + reasoner = new ProtegeReasoner(Collections.singleton(ks), editorKit.getOWLModelManager().getReasoner()); reasoner.setOWLReasoner(editorKit.getOWLModelManager().getReasoner()); reasoner.setProgressMonitor(progressMonitor); @@ -372,7 +358,6 @@ @Override public void dispose() throws Exception { reasoner.releaseKB(); - cm.freeAllComponents(); editorKit.getOWLModelManager().removeListener(this); editorKit.getOWLWorkspace().getOWLSelectionModel().removeListener(this); Modified: trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java 2012-04-18 14:01:32 UTC (rev 3641) +++ trunk/protege/src/main/java/org/dllearner/tools/protege/ProtegePlugin.java 2012-04-19 13:39:25 UTC (rev 3642) @@ -25,6 +25,10 @@ import javax.swing.JComponent; import org.protege.editor.core.ui.util.InputVerificationStatusChangedListener; +import org.protege.editor.owl.model.OWLModelManager; +import org.protege.editor.owl.model.event.EventType; +import org.protege.editor.owl.model.event.OWLModelManagerChangeEvent; +import org.protege.editor.owl.model.event.OWLModelManagerListener; import org.protege.editor.owl.model.inference.NoOpReasoner; import org.protege.editor.owl.ui.editor.AbstractOWLClassExpressionEditor; import org.semanticweb.owlapi.model.AxiomType; @@ -38,7 +42,7 @@ * @author Christian Koetteritzsch * */ -public class ProtegePlugin extends AbstractOWLClassExpressionEditor { +public class ProtegePlugin extends AbstractOWLClassExpressionEditor implements OWLModelManagerListener{ private static final long serialVersionUID = 728362819273927L; private DLLearnerView view; @@ -60,16 +64,22 @@ Manager.getInstance(getOWLEditorKit()).setLearningType(LearningType.SUPER); } view.reset(); + checkReasonerStatus(); + return true; + } + + private void checkReasonerStatus(){ OWLReasoner r = getOWLEditorKit().getModelManager().getReasoner(); if(r instanceof NoOpReasoner){ view.setHintMessage("<html><font size=\"3\" color=\"red\">You have to select a reasoner (click on menu \"Reasoner\"). We recommend to use Pellet. </font></html>"); view.setRunButtonEnabled(false); } else { + view.setHintMessage(""); + view.setRunButtonEnabled(true); if(!Manager.getInstance().isPreparing() && Manager.getInstance().isReinitNecessary()){ new ReadingOntologyThread(view).start(); } } - return true; } @Override @@ -105,6 +115,7 @@ } private void addListeners(){ + getOWLEditorKit().getOWLModelManager().addListener(this); getOWLEditorKit().getOWLModelManager().addListener(Manager.getInstance(getOWLEditorKit())); getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().addListener(Manager.getInstance(getOWLEditorKit())); } @@ -113,4 +124,11 @@ getOWLEditorKit().getOWLModelManager().removeListener(Manager.getInstance(getOWLEditorKit())); getOWLEditorKit().getOWLWorkspace().getOWLSelectionModel().removeListener(Manager.getInstance(getOWLEditorKit())); } + + @Override + public void handleChange(OWLModelManagerChangeEvent event) { + if(event.isType(EventType.REASONER_CHANGED) || event.isType(EventType.ACTIVE_ONTOLOGY_CHANGED)){ + checkReasonerStatus(); + } + } } Modified: trunk/protege/src/main/resources/META-INF/MANIFEST.MF =================================================================== --- trunk/protege/src/main/resources/META-INF/MANIFEST.MF 2012-04-18 14:01:32 UTC (rev 3641) +++ trunk/protege/src/main/resources/META-INF/MANIFEST.MF 2012-04-19 13:39:25 UTC (rev 3642) @@ -11,6 +11,9 @@ lib/junit-4.4.jar, lib/jamon-2.7.jar, lib/swingx-1.6.jar, + lib/json-20090211.jar, + lib/log4j-1.2.16.jar, + lib/jamon-2.0.jar, lib/jena/json.jar, lib/jena/commons-logging-1.1.1.jar, lib/components-core-1.0-SNAPSHOT.jar Modified: trunk/protege/src/main/resources/lib/components-core-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Added: trunk/protege/src/main/resources/lib/jamon-2.0.jar =================================================================== (Binary files differ) Property changes on: trunk/protege/src/main/resources/lib/jamon-2.0.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/protege/src/main/resources/lib/json-20090211.jar =================================================================== (Binary files differ) Property changes on: trunk/protege/src/main/resources/lib/json-20090211.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/protege/src/main/resources/lib/log4j-1.2.16.jar =================================================================== (Binary files differ) Property changes on: trunk/protege/src/main/resources/lib/log4j-1.2.16.jar ___________________________________________________________________ Added: 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: <seb...@us...> - 2012-04-18 14:01:39
|
Revision: 3641 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3641&view=rev Author: sebastianwtr Date: 2012-04-18 14:01:32 +0000 (Wed, 18 Apr 2012) Log Message: ----------- [tbsl exploration] added 1 R and 2 Conditions Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/ServerUtil.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java 2012-04-18 12:51:51 UTC (rev 3640) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java 2012-04-18 14:01:32 UTC (rev 3641) @@ -6,7 +6,10 @@ public class LinearSort { - public static void doSort(ArrayList<QueryPair> qp){ + /* + * TODO: test if the sorted queries are given back properly + */ + public static ArrayList<QueryPair> doSort(ArrayList<QueryPair> qp){ boolean change=true; while(change){ @@ -23,6 +26,8 @@ } if(Setting.isDebugModus())DebugMode.printQueryPair(qp); + + return qp; } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/ServerUtil.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/ServerUtil.java 2012-04-18 12:51:51 UTC (rev 3640) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/ServerUtil.java 2012-04-18 14:01:32 UTC (rev 3641) @@ -22,6 +22,12 @@ private static int timeToTimeoutOnServer=30000; + public static HashMap<String, String> generatesQueryForOutsideClasses(String query){ + String working_query= ServerUtil.getServer_Prefix()+"?default-graph-uri=&query="+ServerUtil.createServerRequest(query)+"%0D%0A&format=text%2Fhtml&debug=on&timeout="; + + return generateList(getListOfElements(working_query)); + + } public static String createServerRequest(String query){ String anfrage=null; @@ -135,7 +141,9 @@ /* * TODO: Still a not "valid" url */ - String query="SELECT DISTINCT ?s ?p WHERE {{?x ?p ?y. ?x rdfs:label ?s. FILTER (lang(?s) = 'en').} UNION {?y ?p ?x. ?x rdfs:label ?s. FILTER (lang(?s) = 'en').} { SELECT ?x { ?x rdf:type <"+classUri+">.}LIMIT 10}}"; + String query="SELECT DISTINCT ?s ?p WHERE {{?x ?p ?y. ?p rdfs:label ?s. FILTER (lang(?s) = 'en').} UNION {?y ?p ?x. ?p rdfs:label ?s. FILTER (lang(?s) = 'en').} { SELECT ?x { ?x rdf:type <"+classUri+">.}LIMIT 10}}"; + //System.out.println(query); + //DebugMode.waitForButton(); String query_final=ServerUtil.getServer_Prefix()+"?default-graph-uri=&query="+ServerUtil.createServerRequest(query)+"%0D%0A&format=text%2Fhtml&debug=on&timeout="; String result=""; result = getListOfElements(query_final); Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-18 12:51:51 UTC (rev 3640) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-18 14:01:32 UTC (rev 3641) @@ -1,6 +1,10 @@ package org.dllearner.algorithm.tbsl.exploration.exploration_main; import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; @@ -22,7 +26,7 @@ import org.dllearner.algorithm.tbsl.templator.BasicTemplator; public class MainInterface { - private static int anzahlAbgeschickterQueries = 10; + private static int anzahlAbgeschickterQueries = 100; public static ArrayList<String> startQuestioning(String question,BasicTemplator btemplator,SQLiteIndex myindex, WordNet wordnet,StanfordLemmatizer lemmatiser) throws ClassNotFoundException, SQLException, IOException{ @@ -55,7 +59,9 @@ ArrayList<QueryPair> qp = new ArrayList<QueryPair>(); //generate QueryPair + String Question=""; for(Template t : template_list){ + Question=t.getQuestion(); t.printAll(); ArrayList<QueryPair> qp_t = new ArrayList<QueryPair>(); qp_t = Query.returnSetOfQueries(t, "NORMAL"); @@ -72,7 +78,10 @@ } //sort QueryPairs - LinearSort.doSort(qp); + qp=LinearSort.doSort(qp); + printQueries(qp, "NORMAL", Question); + + int anzahl=1; boolean go_on = true; for(QueryPair q : qp){ @@ -128,7 +137,7 @@ if(answers.isEmpty()){ answers.clear(); - answers.addAll(doStart(myindex, wordnet, lemmatiser, template_list,"LEVENSTHEIN")); + answers.addAll(doStart(myindex, wordnet, lemmatiser, template_list,"LEVENSTHEIN","neu")); if(wait)DebugMode.waitForButton(); } @@ -139,7 +148,7 @@ if(answers.isEmpty()){ answers.clear(); - answers.addAll(doStart(myindex, wordnet, lemmatiser, template_list,"WORDNET")); + answers.addAll(doStart(myindex, wordnet, lemmatiser, template_list,"WORDNET","neu")); if(wait)DebugMode.waitForButton(); } @@ -171,7 +180,7 @@ private static ArrayList<String> doStart(SQLiteIndex myindex, WordNet wordnet, - StanfordLemmatizer lemmatiser, ArrayList<Template> template_list, String type) { + StanfordLemmatizer lemmatiser, ArrayList<Template> template_list, String type, String test) { ArrayList<String> answers = new ArrayList<String>(); ArrayList<QueryPair> qp = new ArrayList<QueryPair>(); int anzahl; @@ -179,9 +188,32 @@ System.out.println("No answer from direkt match, start "+type+"Modul"); for(Template t : template_list){ try{ - ArrayList<ArrayList<Hypothesis>> hypothesenSetList = IterationModule.doIteration(t.getElm(),t.getHypothesen(),t.getCondition(),type,myindex,wordnet,lemmatiser); - if(type.contains("WORDNET"))t.setHypothesenWordnet(hypothesenSetList); - if(type.contains("LEVENSTHEIN"))t.setHypothesenLevensthein(hypothesenSetList); + if(test.contains("alt")){ + ArrayList<ArrayList<Hypothesis>> hypothesenSetList = IterationModule.doIteration(t.getElm(),t.getHypothesen(),t.getCondition(),type,myindex,wordnet,lemmatiser); + if(type.contains("WORDNET"))t.setHypothesenWordnet(hypothesenSetList); + if(type.contains("LEVENSTHEIN"))t.setHypothesenLevensthein(hypothesenSetList); + } + + if(test.contains("neu")){ + System.err.println("IN NEU!!!!!"); + ArrayList<ArrayList<Hypothesis>> hypothesenSetList = new ArrayList<ArrayList<Hypothesis>>(); + for(ArrayList<Hypothesis> l_h : t.getHypothesen()){ + ArrayList<ArrayList<Hypothesis>> generated_hypothesis = new ArrayList<ArrayList<Hypothesis>>(); + generated_hypothesis= IterationModule.new_iteration(t.getElm(),l_h,t.getCondition(),type,myindex,wordnet,lemmatiser); + for(ArrayList<Hypothesis> h_t : generated_hypothesis){ + ArrayList<Hypothesis> new_hypothesen_set = new ArrayList<Hypothesis>(); + for(Hypothesis bla : h_t){ + new_hypothesen_set.add(bla); + } + hypothesenSetList.add(new_hypothesen_set); + } + + //hypothesenSetList.addAll(blub); + } + if(type.contains("WORDNET"))t.setHypothesenWordnet(hypothesenSetList); + if(type.contains("LEVENSTHEIN"))t.setHypothesenLevensthein(hypothesenSetList); + } + } catch (Exception e){ @@ -193,8 +225,10 @@ * Generate Queries and test queries */ //generate QueryPair + String Question=""; for(Template t : template_list){ //t.printAll(); + Question=t.getQuestion(); ArrayList<QueryPair> qp_t = new ArrayList<QueryPair>(); qp_t = Query.returnSetOfQueries(t, type); for(QueryPair p : qp_t){ @@ -210,7 +244,9 @@ } //sort QueryPairs - LinearSort.doSort(qp); + qp=LinearSort.doSort(qp); + + printQueries(qp, type, Question); anzahl=1; go_on = true; for(QueryPair q : qp){ @@ -275,4 +311,63 @@ else return true; } + + private static void printQueries(ArrayList<QueryPair> qp, String type, String Question){ + String dateiname="/home/swalter/Dokumente/Auswertung/CreatedQueryList.txt"; + String result_string =""; + //Open the file for reading + try { + BufferedReader br = new BufferedReader(new FileReader(dateiname)); + String thisLine; + while ((thisLine = br.readLine()) != null) { // while loop begins here + result_string+=thisLine+"\n"; + } // end while + } // end try + catch (IOException e) { + System.err.println("Error: " + e); + } + + File file = new File(dateiname); + BufferedWriter bw = null; + try { + bw = new BufferedWriter(new FileWriter(file)); + } catch (IOException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + String querylist=""; + querylist="\n Modul: "+type+"\nfor Question: "+ Question+"\n"; + int anzahl= 0; + /* + * write only the first 10 queries: + */ + for(QueryPair q : qp){ + if(anzahl<10){ + querylist+=q.getQuery()+" "+q.getRank()+"\n"; + anzahl+=1; + } + + } + + + + try { + bw.write(result_string+querylist); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + bw.flush(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { + bw.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java 2012-04-18 12:51:51 UTC (rev 3640) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java 2012-04-18 14:01:32 UTC (rev 3641) @@ -4,6 +4,7 @@ private static boolean waitModus; private static boolean debugModus; + public static boolean isWaitModus() { return waitModus; } @@ -16,6 +17,6 @@ public static void setDebugModus(boolean debugModus) { Setting.debugModus = debugModus; } + - } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-18 12:51:51 UTC (rev 3640) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-18 14:01:32 UTC (rev 3641) @@ -70,6 +70,8 @@ Setting.setWaitModus(false); Setting.setDebugModus(false); + + System.out.println("Time for Initialising "+(stopInitTime-startInitTime)+" ms"); boolean schleife=true; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java 2012-04-18 12:51:51 UTC (rev 3640) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java 2012-04-18 14:01:32 UTC (rev 3641) @@ -1,7 +1,15 @@ package org.dllearner.algorithm.tbsl.exploration.modules; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map.Entry; import net.didion.jwnl.JWNLException; @@ -10,6 +18,7 @@ import org.dllearner.algorithm.tbsl.exploration.Sparql.Elements; import org.dllearner.algorithm.tbsl.exploration.Sparql.Hypothesis; import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; +import org.dllearner.algorithm.tbsl.exploration.Utils.ServerUtil; import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; import org.dllearner.algorithm.tbsl.nlp.StanfordLemmatizer; import org.dllearner.algorithm.tbsl.nlp.WordNet; @@ -32,6 +41,9 @@ */ public static ArrayList<ArrayList<Hypothesis>> doIteration(Elements elm,ArrayList<ArrayList<Hypothesis>> givenHypothesenList,ArrayList<ArrayList<String>> givenConditionList, String type,SQLiteIndex myindex,WordNet wordnet,StanfordLemmatizer lemmatiser) throws SQLException{ + + + boolean gotResource=true; ArrayList<ElementList> resources = new ArrayList<ElementList>(); try{ @@ -316,6 +328,440 @@ return finalHypothesenList; } + + + /* + * Use Here only one Hypothesen Set at each time, so for each "AusgangshypothesenSet" start this function + */ + public static ArrayList<ArrayList<Hypothesis>> new_iteration(Elements elm,ArrayList<Hypothesis> givenHypothesenList,ArrayList<ArrayList<String>> givenConditionList, String type,SQLiteIndex myindex,WordNet wordnet,StanfordLemmatizer lemmatiser) throws SQLException, JWNLException, IOException{ + + //System.err.println("Startet new_iteration"); + ArrayList<ArrayList<Hypothesis>> finalHypothesenList = new ArrayList<ArrayList<Hypothesis>>(); + + boolean simple_structure = false; + + + /* String dateiname="/home/swalter/Dokumente/Auswertung/ConditionsList.txt"; + String result_string =""; + //Open the file for reading + try { + BufferedReader br = new BufferedReader(new FileReader(dateiname)); + String thisLine; + while ((thisLine = br.readLine()) != null) { // while loop begins here + result_string+=thisLine+"\n"; + } // end while + } // end try + catch (IOException e) { + System.err.println("Error: " + e); + } + + File file = new File(dateiname); + BufferedWriter bw = null; + try { + bw = new BufferedWriter(new FileWriter(file)); + } catch (IOException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + String condition_string=""; + for(ArrayList<String> cl : givenConditionList){ + condition_string+="["; + for(String s : cl){ + condition_string+=s+" "; + } + condition_string+="]"; + } + + + try { + bw.write(result_string+condition_string); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + bw.flush(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { + bw.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + + + + + + /*for(ArrayList<String> als : givenConditionList){ + for(String s : als) System.err.println(s); + }*/ + /*try { + DebugMode.waitForButton(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }*/ + if(givenConditionList.size()==1){ + System.err.println("Only one Condition => simple Struktur"); + simple_structure=true; + + boolean resource_case=false; + boolean isa_case=false; + + for(Hypothesis h : givenHypothesenList){ + /* + * if there is an ISA you cant to any thing, except returning HypothesenList to be send to the Server + */ + if(h.getType().contains("ISA")){ + isa_case=true; + finalHypothesenList.add(givenHypothesenList); + } + if(h.getType().contains("RESOURCE")){ + /* + * Check if Property is left or right of oneself + */ + String case_side = "RIGHT"; + + ArrayList<String> condition = new ArrayList<String>(); + condition = givenConditionList.get(0); + if(condition.get(2).contains(h.getVariable())) case_side="LEFT"; + + ArrayList<ElementList> resources = new ArrayList<ElementList>(); + boolean gotResource=true; + try{ + resources = elm.getElements(); + } + catch (Exception e){ + gotResource=false; + if(Setting.isDebugModus())DebugMode.debugErrorPrint("Didnt get any Resource"); + } + + if(gotResource){ + for(ElementList el : resources){ + if(el.getVariablename().contains(h.getName())&&el.getVariablename().contains(case_side)){ + + String property_name=""; + for(Hypothesis h_t : givenHypothesenList){ + if(h_t.getVariable().contains(condition.get(1))){ + property_name=h_t.getName(); + break; + } + } + ArrayList<Hypothesis> resultHypothesenList=new ArrayList<Hypothesis>(); + /* + * Here start levenstehin, wordnet etc etc + */ + if(type.contains("LEVENSTHEIN"))resultHypothesenList= LevenstheinModule.doLevensthein(condition.get(1),property_name,el.getHm()); + if(type.contains("WORDNET"))resultHypothesenList= WordnetModule.doWordnet(condition.get(1),property_name,el.getHm(),myindex,wordnet,lemmatiser); + for(Hypothesis h_temp : resultHypothesenList) { + ArrayList<Hypothesis> temp_al = new ArrayList<Hypothesis>(); + temp_al.add(h); + temp_al.add(h_temp); + finalHypothesenList.add(temp_al); + } + } + } + + } + + } + } + + + + return finalHypothesenList; + } + + + + + + /* + * two conditions! + */ + if(givenConditionList.size()==2){ + System.out.println("two Conditions => NOT simple Struktur"); + ArrayList<ElementList> resources = new ArrayList<ElementList>(); + boolean gotResource=true; + try{ + resources = elm.getElements(); + } + catch (Exception e){ + gotResource=false; + if(Setting.isDebugModus())DebugMode.debugErrorPrint("Didnt get any Resource"); + } + + + ArrayList<String> condition1 = givenConditionList.get(0); + ArrayList<String> condition2 = givenConditionList.get(1); + + /* + * ISA + */ + boolean condition1_exists_isa = false; + boolean condition2_exists_isa = false; + if(condition1.get(1).contains("ISA")) condition1_exists_isa=true; + if(condition2.get(1).contains("ISA")) condition2_exists_isa=true; + + + /* + * Resource: Find out the Resource, the Side of the depending Property and mark the Hypothesis for the Resource + */ + + boolean condition1_exists_resource = false; + boolean condition2_exists_resource = false; + String resource_variable=null; + Hypothesis resource_h=null; + + + String property_Side = "RIGHT"; + for(Hypothesis h : givenHypothesenList){ + if(h.getVariable().contains(condition1.get(0))&&h.getType().contains("RESOURCE")){ + condition1_exists_resource=true; + property_Side="RIGHT"; + resource_variable=h.getVariable(); + resource_h=h; + } + if(h.getVariable().contains(condition1.get(2))&&h.getType().contains("RESOURCE")){ + condition1_exists_resource=true; + property_Side="LEFT"; + resource_variable=h.getVariable(); + resource_h=h; + } + + if(h.getVariable().contains(condition2.get(0))&&h.getType().contains("RESOURCE")){ + condition2_exists_resource=true; + property_Side="RIGHT"; + resource_variable=h.getVariable(); + resource_h=h; + } + if(h.getVariable().contains(condition2.get(2))&&h.getType().contains("RESOURCE")){ + condition2_exists_resource=true; + property_Side="LEFT"; + resource_variable=h.getVariable(); + resource_h=h; + } + + } + + + /* + * ISA + */ + if((condition1_exists_isa||condition2_exists_isa)&&gotResource){ + + /* + * get Hypothese for the Class + */ + String class_variable=null; + if(condition1_exists_isa)class_variable= condition1.get(2); + if(condition2_exists_isa)class_variable= condition2.get(2); + + Hypothesis class_h=null; + + for(Hypothesis h_t : givenHypothesenList){ + if(h_t.getVariable().contains(class_variable)){ + class_h=h_t; + break; + } + } + + System.out.println("class_variable: " + class_variable); + System.out.println("Class Hypothese: "); + class_h.printAll(); + for(ElementList el : resources){ + //System.out.println("el.getVariablename(): "+el.getVariablename()); + if(el.getVariablename().contains(class_h.getName())){ + System.out.println("In If Abfrage bei der Iteration ueber el"); + String property_name=""; + String property_variable=""; + + if(condition1_exists_isa)property_variable= condition2.get(1); + if(condition2_exists_isa)property_variable= condition1.get(1); + + System.out.println("property_variable: " + property_variable); + + for(Hypothesis h_t : givenHypothesenList){ + if(h_t.getVariable().contains(property_variable)){ + property_name=h_t.getName(); + break; + } + } + System.out.println("property_name: " + property_name); + ArrayList<Hypothesis> resultHypothesenList=new ArrayList<Hypothesis>(); + for (Entry<String, String> entry : el.getHm().entrySet()) { + System.out.println(entry.getKey()+" "+entry.getValue()); + } + /* + * Here start levenstehin, wordnet etc etc + */ + if(type.contains("LEVENSTHEIN"))resultHypothesenList= LevenstheinModule.doLevensthein(property_variable,property_name,el.getHm()); + if(type.contains("WORDNET"))resultHypothesenList= WordnetModule.doWordnet(property_variable,property_name,el.getHm(),myindex,wordnet,lemmatiser); + System.out.println("After generating new Hypothesen.\n "+resultHypothesenList.size()+" new were generated"); + for(Hypothesis h_temp : resultHypothesenList) { + ArrayList<Hypothesis> temp_al = new ArrayList<Hypothesis>(); + temp_al.add(class_h); + temp_al.add(h_temp); + System.out.println("Hypothesen:"); + class_h.printAll(); + h_temp.printAll(); + finalHypothesenList.add(temp_al); + } + } + } + + +/* try { + DebugMode.waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + */ + return finalHypothesenList; + + } + + + + + /* + * Resource + */ + + if((condition1_exists_resource||condition2_exists_resource)&&gotResource){ + + System.out.println("IN RESOURCE NOT SIMPLE CASE!!!"); + System.out.println("resource_variable: " + resource_variable); + System.out.println("Resource Hypothese: "); + resource_h.printAll(); + + String property_name=""; + String second_property_name=""; + String property_variable=""; + String second_property_variable=""; + + if(condition1_exists_resource){ + //property_variable= condition1.get(1); + //second_property_variable=condition2.get(1); + property_variable= condition2.get(1); + second_property_variable=condition1.get(1); + } + if(condition2_exists_resource){ + //property_variable= condition2.get(1); + //second_property_variable=condition1.get(1); + property_variable= condition1.get(1); + second_property_variable=condition2.get(1); + } + + System.out.println("property_variable: " + property_variable); + System.out.println("scond_property_variable: " + second_property_variable); + for(ArrayList<String> al : givenConditionList){ + for(String s : al) System.out.println(s); + } + for(Hypothesis h : givenHypothesenList){ + h.printAll(); + } + + for(Hypothesis h_t : givenHypothesenList){ + if(h_t.getVariable().contains(property_variable)){ + property_name=h_t.getName(); + + } + if(h_t.getVariable().contains(second_property_variable)){ + second_property_name=h_t.getName(); + + } + } + System.out.println("property_name: " + property_name); + System.out.println("second_property_name: " + second_property_name); + + if(Setting.isWaitModus())DebugMode.waitForButton(); + + + for(ElementList el : resources){ + //System.out.println("el.getVariablename(): "+el.getVariablename()); + if(el.getVariablename().contains(resource_h.getName())&&el.getVariablename().contains(property_Side)){ + System.out.println("In If Abfrage bei der Iteration ueber el"); + + + System.out.println("property_name: " + property_name); + ArrayList<Hypothesis> resultHypothesenList=new ArrayList<Hypothesis>(); + /*for (Entry<String, String> entry : el.getHm().entrySet()) { + System.out.println(entry.getKey()+" "+entry.getValue()); + } + + if(Setting.isWaitModus()) + try { + DebugMode.waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ + /* + * Here start levenstehin, wordnet etc etc + */ + if(type.contains("LEVENSTHEIN"))resultHypothesenList= LevenstheinModule.doLevensthein(property_variable,property_name,el.getHm()); + if(type.contains("WORDNET"))resultHypothesenList= WordnetModule.doWordnet(property_variable,property_name,el.getHm(),myindex,wordnet,lemmatiser); + System.out.println("After generating new Hypothesen.\n "+resultHypothesenList.size()+" new were generated"); + for(Hypothesis h_temp : resultHypothesenList) { + String Query=""; + if(property_Side.contains("LEFT")){ + Query= "SELECT DISTINCT ?s ?x WHERE {<"+ resource_h.getUri()+"> <"+h_temp.getUri()+"> ?x. ?x rdfs:label ?s. FILTER (lang(?s) = 'en') }"; + + } + else{ + Query= "SELECT DISTINCT ?s ?x WHERE {?x <"+h_temp.getUri()+"> <"+ resource_h.getUri()+"> . ?x rdfs:label ?s. FILTER (lang(?s) = 'en') }"; + + } + /* + * Now use the variable from the second condition which does not has an Resource in the Hypothesis + */ + System.out.println("Query: "+Query); + HashMap<String, String> hm_newClasses=ServerUtil.generatesQueryForOutsideClasses(Query); + + + ArrayList<Hypothesis> second_resultHypothesenList=new ArrayList<Hypothesis>(); + + + + if(type.contains("LEVENSTHEIN"))second_resultHypothesenList= LevenstheinModule.doLevensthein(second_property_variable,second_property_name,hm_newClasses); + if(type.contains("WORDNET"))second_resultHypothesenList= WordnetModule.doWordnet(second_property_variable,second_property_name,hm_newClasses,myindex,wordnet,lemmatiser); + System.out.println("SIze of second_resultHypothesenList: "+second_resultHypothesenList.size()); + + for(Hypothesis second_h_temp : second_resultHypothesenList) { + ArrayList<Hypothesis> temp_al = new ArrayList<Hypothesis>(); + temp_al.add(resource_h); + temp_al.add(h_temp); + temp_al.add(second_h_temp); + resource_h.printAll(); + h_temp.printAll(); + second_h_temp.printAll(); + /* + * for each hypothesis now get the x from the Server an generate for second condition depending on the x new Hypothesen Set. + * afterwars add new_h_temp, h_temp, resource_h to the array Set temp_al and add temp_all to final Hypothesen Set + */ + + finalHypothesenList.add(temp_al); + } + + } + } + } + + return finalHypothesenList; + } + } + + return finalHypothesenList; + + + } + } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-18 12:51:51 UTC (rev 3640) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/LevenstheinModule.java 2012-04-18 14:01:32 UTC (rev 3641) @@ -9,7 +9,7 @@ import org.dllearner.algorithm.tbsl.exploration.Utils.Levenshtein; public class LevenstheinModule { - private final static double LevenstheinMin=0.85; + private final static double LevenstheinMin=0.65; public static ArrayList<Hypothesis> doLevensthein(String variable, String property_to_compare_with, HashMap<String, String> properties) throws SQLException { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java 2012-04-18 12:51:51 UTC (rev 3640) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java 2012-04-18 14:01:32 UTC (rev 3641) @@ -12,7 +12,9 @@ import org.dllearner.algorithm.tbsl.exploration.Index.SQLiteIndex; import org.dllearner.algorithm.tbsl.exploration.Sparql.Hypothesis; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; import org.dllearner.algorithm.tbsl.exploration.Utils.Levenshtein; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; import org.dllearner.algorithm.tbsl.nlp.StanfordLemmatizer; import org.dllearner.algorithm.tbsl.nlp.WordNet; @@ -90,19 +92,48 @@ String value = entry.getValue(); key=key.replace("\"",""); key=key.replace("@en",""); + key=key.toLowerCase(); for(String b : semantics){ - if(key.contains(b.toLowerCase())||key.contains(lemmatiser.stem(b.toLowerCase()))||b.toLowerCase().contains(lemmatiser.stem(key))){ + /* + * Error in StanfordLemmatizer, thats why first left out here + */ + //if(key.contains(b.toLowerCase())||key.contains(lemmatiser.stem(b.toLowerCase()))||b.toLowerCase().contains(lemmatiser.stem(key))){ + //System.out.println("B: "+b +" Key: "+key); + if(key.contains(b.toLowerCase())||b.toLowerCase().contains(key)){ + + /*System.out.println("Found: "+b); + if(Setting.isWaitModus()) + try { + DebugMode.waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ if(!result_SemanticsMatchProperties.contains(key)){ result_SemanticsMatchProperties.add(key); - if(key.toLowerCase().contains(property_to_compare_with.toLowerCase())){ + if(key.toLowerCase().contains(property_to_compare_with.toLowerCase())||property_to_compare_with.toLowerCase().contains(key)){ + System.out.println("Variable: "+ variable+" key: "+key+" value : "+value); Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", 1.5); listOfNewHypothesen.add(h); + try { + if(Setting.isWaitModus())DebugMode.waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } else{ double nld=Levenshtein.nld(property_to_compare_with.toLowerCase(), key); Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); listOfNewHypothesen.add(h); + System.out.println("Found for key: "+key); + try { + if(Setting.isWaitModus())DebugMode.waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } } @@ -111,6 +142,13 @@ } } + /*System.out.println("Anzahl listOfNewHypothesen: "+listOfNewHypothesen.size()); + try { + DebugMode.waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }*/ return listOfNewHypothesen; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sha...@us...> - 2012-04-18 12:52:02
|
Revision: 3640 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3640&view=rev Author: shadowtm Date: 2012-04-18 12:51:51 +0000 (Wed, 18 Apr 2012) Log Message: ----------- Cleaned up poms in preparation for removing third party repositories - these mods will make a significant impact on build time. Modified Paths: -------------- trunk/components-ext/pom.xml trunk/pom.xml Modified: trunk/components-ext/pom.xml =================================================================== --- trunk/components-ext/pom.xml 2012-04-18 03:45:36 UTC (rev 3639) +++ trunk/components-ext/pom.xml 2012-04-18 12:51:51 UTC (rev 3640) @@ -10,21 +10,6 @@ <version>1.0-SNAPSHOT</version> <url>http://aksw.org/Projects/DLLearner</url> - <repositories> - <repository> - <id>Simmetrics</id> - <url>http://maven.mse.jhu.edu/m2repository/</url> - </repository> - <!-- <repository> <id>Harvard Med</id> <url>http://repo.open.med.harvard.edu/nexus/content/repositories/public/</url> - </repository> --> - <repository> - <id>Annolab</id> - <url>http://annolab.org/m2/releases/</url> - </repository> - <!-- <repository> <id>Mirror for WSTX</id> <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url> - </repository> --> - </repositories> - <parent> <groupId>org.dllearner</groupId> <artifactId>dllearner-parent</artifactId> @@ -124,24 +109,13 @@ <groupId>uk.ac.shef.wit</groupId> <artifactId>simmetrics</artifactId> <version>1.6.2</version> - <type>jar</type> - <scope>compile</scope> </dependency> <dependency> <groupId>stax</groupId> <artifactId>stax-api</artifactId> <version>1.0.1</version> - <type>jar</type> - <scope>compile</scope> </dependency> <dependency> - <groupId>woodstox</groupId> - <artifactId>wstx-api</artifactId> - <version>3.2.0</version> - <type>jar</type> - <scope>compile</scope> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> @@ -179,10 +153,8 @@ <dependency> <groupId>org.nlp2rdf</groupId> <artifactId>nif</artifactId> - <version>1.1-SNAPSHOT</version> + <version>1.1</version> </dependency> - - <dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-04-18 03:45:36 UTC (rev 3639) +++ trunk/pom.xml 2012-04-18 12:51:51 UTC (rev 3640) @@ -16,7 +16,7 @@ <gwt.version>2.3.0</gwt.version> <!--Define the AKSW dependency version --> - <aksw.version>0.1</aksw.version> + <aksw.version>0.2-SNAPSHOT</aksw.version> <slf4j.version>1.6.4</slf4j.version> <log4j.version>1.2.16</log4j.version> @@ -81,11 +81,11 @@ <artifactId>maven-source-plugin</artifactId> <version>2.1.2</version> </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>gwt-maven-plugin</artifactId> - <version>${gwt.version}</version> - </plugin> + <plugin> + <groupId>com.mycila.maven-license-plugin</groupId> + <artifactId>maven-license-plugin</artifactId> + <version>1.9.0</version> + </plugin> </plugins> </pluginManagement> </build> @@ -117,12 +117,6 @@ <version>1.3.3</version> </dependency> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - <version>0.9.3</version> - </dependency> - <!-- SOLR Dependency --> <dependency> <groupId>org.apache.solr</groupId> @@ -152,13 +146,6 @@ </exclusions> </dependency> - - <dependency> - <groupId>com.extjs</groupId> - <artifactId>gxt</artifactId> - <version>2.2.3</version> - </dependency> - <!--Available via central, we use the latest with minor mods to DL Learner source (IE Dig related code) --> <dependency> @@ -293,34 +280,26 @@ </dependency> <dependency> - <groupId>org.dllearner</groupId> - <artifactId>sparql-query-generator</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> <groupId>org.aksw.commons</groupId> <artifactId>sparql</artifactId> - <version>0.2-SNAPSHOT</version> + <version>${aksw.version}</version> </dependency> <dependency> <groupId>org.aksw.commons</groupId> <artifactId>model</artifactId> - <version>0.2-SNAPSHOT</version> + <version>${aksw.version}</version> </dependency> <dependency> <groupId>org.aksw.commons</groupId> <artifactId>collections</artifactId> - <version>0.2-SNAPSHOT</version> + <version>${aksw.version}</version> </dependency> - <dependency> <groupId>org.aksw.commons</groupId> <artifactId>util</artifactId> - <version>0.2-SNAPSHOT</version> + <version>${aksw.version}</version> </dependency> - <dependency> <groupId>net.sourceforge.secondstring</groupId> <artifactId>secondstring</artifactId> @@ -357,25 +336,8 @@ <version>5.1.13</version> </dependency> - <dependency> - <groupId>commons-configuration</groupId> - <artifactId>commons-configuration</artifactId> - <version>1.6</version> - </dependency> - <!--GWT Dependencies --> <dependency> - <groupId>com.google.gwt</groupId> - <artifactId>gwt-servlet</artifactId> - <version>${gwt.version}</version> - </dependency> - <dependency> - <groupId>com.google.gwt</groupId> - <artifactId>gwt-user</artifactId> - <version>${gwt.version}</version> - </dependency> - - <dependency> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId> <version>8.4-701.jdbc4</version> @@ -478,13 +440,6 @@ <artifactId>jcl-over-slf4j</artifactId> <version>${slf4j.version}</version> </dependency> - - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-jdk14</artifactId> - <version>${slf4j.version}</version> - </dependency> <!--END Logging Dependencies--> </dependencies> @@ -518,13 +473,7 @@ <url>http://on.cs.unibas.ch/maven/repository/</url> </repository> - <!-- This repository contains the jars for the project lombok jars --> <repository> - <id>projectlombok.org</id> - <url>http://projectlombok.org/mavenrepo</url> - </repository> - - <repository> <id>GXT</id> <url>http://maven.jahia.org/maven2/</url> </repository> @@ -621,9 +570,11 @@ <artifactId>maven-source-plugin</artifactId> <executions> <execution> - <goals> - <goal>jar</goal> - </goals> + <id>attach-sources</id> + <phase>verify</phase> + <goals> + <goal>jar</goal> + </goals> </execution> </executions> </plugin> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sha...@us...> - 2012-04-18 03:45:42
|
Revision: 3639 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3639&view=rev Author: shadowtm Date: 2012-04-18 03:45:36 +0000 (Wed, 18 Apr 2012) Log Message: ----------- Added convenience method to AnnComponentManager Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/core/AnnComponentManager.java Added Paths: ----------- trunk/components-core/src/test/java/org/dllearner/core/ trunk/components-core/src/test/java/org/dllearner/core/AnnComponentManagerTest.java Modified: trunk/components-core/src/main/java/org/dllearner/core/AnnComponentManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/AnnComponentManager.java 2012-04-18 02:26:42 UTC (rev 3638) +++ trunk/components-core/src/main/java/org/dllearner/core/AnnComponentManager.java 2012-04-18 03:45:36 UTC (rev 3639) @@ -136,7 +136,25 @@ public Collection<Class<? extends Component>> getComponents() { return components; } - + + /** + * Get registered components which are of the specified type. + * + * @param type The super type. + * @return All sub classes of type. + */ + public Collection<Class<? extends Component>> getComponentsOfType(Class type) { + + Collection<Class<? extends Component>> result = new ArrayList<Class<? extends Component>>(); + for (Class<? extends Component> component : components) { + if (type.isAssignableFrom(component)) { + result.add(component); + } + } + + return result; + } + /** * Convenience method, which returns a list of components along with * their name. Added: trunk/components-core/src/test/java/org/dllearner/core/AnnComponentManagerTest.java =================================================================== --- trunk/components-core/src/test/java/org/dllearner/core/AnnComponentManagerTest.java (rev 0) +++ trunk/components-core/src/test/java/org/dllearner/core/AnnComponentManagerTest.java 2012-04-18 03:45:36 UTC (rev 3639) @@ -0,0 +1,25 @@ +package org.dllearner.core; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.Collection; + +/** + * Created with IntelliJ IDEA. + * User: Chris + * Date: 4/17/12 + * Time: 9:16 PM + * + * Tests for the AnnComponentManager + */ +public class AnnComponentManagerTest { + + + @Test + public void testGetComponentsOfType() { + + Collection<Class<? extends Component>> components = AnnComponentManager.getInstance().getComponentsOfType(ReasonerComponent.class); + Assert.assertEquals(3,components.size()); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sha...@us...> - 2012-04-18 02:26:52
|
Revision: 3638 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3638&view=rev Author: shadowtm Date: 2012-04-18 02:26:42 +0000 (Wed, 18 Apr 2012) Log Message: ----------- Moved configuration interfaces into the interfaces module as that's a more appropriate location for them since they're used solely by our interfaces to bootstrap a DL-Learner configuration. Added Paths: ----------- trunk/interfaces/src/main/java/org/dllearner/configuration/IConfiguration.java trunk/interfaces/src/main/java/org/dllearner/configuration/IConfigurationProperty.java Removed Paths: ------------- trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java trunk/components-core/src/main/java/org/dllearner/configuration/IConfigurationProperty.java Deleted: trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java 2012-04-13 14:02:37 UTC (rev 3637) +++ trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java 2012-04-18 02:26:42 UTC (rev 3638) @@ -1,64 +0,0 @@ -/** - * Copyright (C) 2007-2011, 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.configuration; - -import java.util.Collection; - -/** - * Created by IntelliJ IDEA. - * User: Chris - * Date: 8/18/11 - * Time: 9:45 PM - * - * This interface defines our interaction with a DL-Learner specific configuration. - * - */ -public interface IConfiguration { - - /** - * Get a collection of all the bean names defined in the configuration. - * - * @return a collection of all the bean names defined in the configuration. - */ - public Collection<String> getBeanNames(); - - /** - * Get the class for the given bean. - * - * @param beanName The name of the bean to get the class for. - * @return The class for the given bean. - */ - public Class getClass(String beanName); - - /** - * Get the Base Directory where this configuration should be running out of. - * - * @return The Base Directory where this configuration should be running out of. - */ - public String getBaseDir(); - - /** - * Get the configuration properties for the specified bean. - * - * @param beanName The bean to get properties for. - * @return A collection of properties - */ - public Collection<IConfigurationProperty> getConfigurationProperties(String beanName); -} Deleted: trunk/components-core/src/main/java/org/dllearner/configuration/IConfigurationProperty.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/configuration/IConfigurationProperty.java 2012-04-13 14:02:37 UTC (rev 3637) +++ trunk/components-core/src/main/java/org/dllearner/configuration/IConfigurationProperty.java 2012-04-18 02:26:42 UTC (rev 3638) @@ -1,42 +0,0 @@ -package org.dllearner.configuration; - -/** - * Created by IntelliJ IDEA. - * User: Chris - * Date: 8/27/11 - * Time: 8:57 AM - * - * Respresents a Configuraiton Option setting. - */ -public interface IConfigurationProperty { - - /** - * Get the Name of this Property - * - * @return The Name of this property. - */ - public String getName(); - - - /** - * Get the String representation of the value of this property. - * - * @return The String representation of the value of this property. - */ - public Object getValue(); - - - /** - * Does this property represent a bean reference? - * - * @return True if it does. - */ - public boolean isBeanReference(); - - /** - * Does this property represent a collection of bean references? - * - * @return True if it does. - */ - public boolean isBeanReferenceCollection(); -} Copied: trunk/interfaces/src/main/java/org/dllearner/configuration/IConfiguration.java (from rev 3637, trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java) =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/configuration/IConfiguration.java (rev 0) +++ trunk/interfaces/src/main/java/org/dllearner/configuration/IConfiguration.java 2012-04-18 02:26:42 UTC (rev 3638) @@ -0,0 +1,70 @@ +/** + * Copyright (C) 2007-2011, 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.configuration; + +import java.util.Collection; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 8/18/11 + * Time: 9:45 PM + * <p/> + * This interface represents on complete instance of a DL-Learner Configuration. + * <p/> + * Once an implementation of this interface is fully instantiated, it can be passed to an ApplicationContextBuilder in order + * to instantiate a Spring Application Context. + * <p/> + * Once the application context has been created, learning algorithms can be extracted and then executed. + * + * @see org.dllearner.configuration.spring.ApplicationContextBuilder + */ +public interface IConfiguration { + + /** + * Get a collection of all the bean names defined in the configuration. + * + * @return a collection of all the bean names defined in the configuration. + */ + public Collection<String> getBeanNames(); + + /** + * Get the class for the given bean. + * + * @param beanName The name of the bean to get the class for. + * @return The class for the given bean. + */ + public Class getClass(String beanName); + + /** + * Get the Base Directory where this configuration should be running out of. + * + * @return The Base Directory where this configuration should be running out of. + */ + public String getBaseDir(); + + /** + * Get the configuration properties for the specified bean. + * + * @param beanName The bean to get properties for. + * @return A collection of properties + */ + public Collection<IConfigurationProperty> getConfigurationProperties(String beanName); +} Copied: trunk/interfaces/src/main/java/org/dllearner/configuration/IConfigurationProperty.java (from rev 3637, trunk/components-core/src/main/java/org/dllearner/configuration/IConfigurationProperty.java) =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/configuration/IConfigurationProperty.java (rev 0) +++ trunk/interfaces/src/main/java/org/dllearner/configuration/IConfigurationProperty.java 2012-04-18 02:26:42 UTC (rev 3638) @@ -0,0 +1,44 @@ +package org.dllearner.configuration; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 8/27/11 + * Time: 8:57 AM + * + * This Represents a Configuration Option within a DL Learner Configuration. + * + * @see IConfiguration + */ +public interface IConfigurationProperty { + + /** + * Get the Name of this Property + * + * @return The Name of this property. + */ + public String getName(); + + + /** + * Get the String representation of the value of this property. + * + * @return The String representation of the value of this property. + */ + public Object getValue(); + + + /** + * Does this property represent a bean reference? + * + * @return True if it does. + */ + public boolean isBeanReference(); + + /** + * Does this property represent a collection of bean references? + * + * @return True if it does. + */ + public boolean isBeanReferenceCollection(); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2012-04-13 14:02:48
|
Revision: 3637 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3637&view=rev Author: lorenz_b Date: 2012-04-13 14:02:37 +0000 (Fri, 13 Apr 2012) Log Message: ----------- Changed metrics script. Modified Paths: -------------- trunk/scripts/src/main/java/org/dllearner/scripts/SPARQLEndpointMetrics.java Modified: trunk/scripts/src/main/java/org/dllearner/scripts/SPARQLEndpointMetrics.java =================================================================== --- trunk/scripts/src/main/java/org/dllearner/scripts/SPARQLEndpointMetrics.java 2012-04-13 11:12:31 UTC (rev 3636) +++ trunk/scripts/src/main/java/org/dllearner/scripts/SPARQLEndpointMetrics.java 2012-04-13 14:02:37 UTC (rev 3637) @@ -15,6 +15,7 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import org.dllearner.kb.sparql.ExtractionDBCache; import org.dllearner.kb.sparql.SparqlEndpoint; import org.dllearner.kb.sparql.SparqlQuery; @@ -34,6 +35,10 @@ private static long keepAliveTime = 10; private static int queryTimeout = 30; + + private static ExtractionDBCache cache = new ExtractionDBCache("cache"); + + private static boolean useCache = false; /** * @param args @@ -113,32 +118,40 @@ try { //count classes -// String query = "SELECT (COUNT(DISTINCT ?type) AS ?cnt) WHERE {?s a ?type.}"; -// int classCnt = executeQuery(query, se, 20).next().getLiteral("cnt").getInt(); + int classCnt = -1; + String query; + try { + query = "SELECT (COUNT(DISTINCT ?type) AS ?cnt) WHERE {?s a ?type. ?type a <http://www.w3.org/2002/07/owl#Class>}"; + classCnt = executeQuery(query, se).next().getLiteral("cnt").getInt(); + } catch (Exception e) { + query = "SELECT DISTINCT ?type WHERE {?s a ?type. ?type a <http://www.w3.org/2002/07/owl#Class>}"; + classCnt = countEntities(query, se); + } + //count object properties + int opCnt = -1; + try { + query = "SELECT (COUNT(DISTINCT ?p) AS ?cnt) WHERE {?s ?p ?o. ?p a <http://www.w3.org/2002/07/owl#ObjectProperty>}"; + opCnt = executeQuery(query, se).next().getLiteral("cnt").getInt(); + } catch (Exception e) { + query = "SELECT DISTINCT ?p WHERE {?s ?p ?o. ?p a <http://www.w3.org/2002/07/owl#ObjectProperty>}"; + opCnt = countEntities(query, se); + } + //count data properties + int dpCnt = -1; + try { + query = "SELECT (COUNT(DISTINCT ?p) AS ?cnt) WHERE {?s ?p ?o. ?p a <http://www.w3.org/2002/07/owl#DatatypeProperty>}"; + dpCnt = executeQuery(query, se).next().getLiteral("cnt").getInt(); + } catch (Exception e) { + query = "SELECT DISTINCT ?p WHERE {?s a ?type. ?type a <?s ?p ?o. ?p a <http://www.w3.org/2002/07/owl#DatatypeProperty>>}"; + dpCnt = countEntities(query, se); + } + // -// //count object properties -// query = "SELECT (COUNT(DISTINCT ?p) AS ?cnt) WHERE {?s ?p ?o.}"; -// int opCnt = executeQuery(query, se, 20).next().getLiteral("cnt").getInt(); -// -// //count data properties -// query = "SELECT (COUNT(DISTINCT ?p) AS ?cnt) WHERE {?s ?p ?o.}"; -// int dpCnt = executeQuery(query, se, 20).next().getLiteral("cnt").getInt(); -// // //count individuals // query = "SELECT (COUNT(DISTINCT ?s) AS ?cnt) WHERE {?s a ?type.}"; // int indCnt = executeQuery(query, se, 20).next().getLiteral("cnt").getInt(); - String query = "SELECT DISTINCT ?type WHERE {?s a ?type. ?type a <http://www.w3.org/2002/07/owl#Class>}"; - int classCnt = countEntities(query, se); - //count object properties - query = "SELECT DISTINCT ?p WHERE {?s ?p ?o. ?p a <http://www.w3.org/2002/07/owl#ObjectProperty>}"; - int opCnt = countEntities(query, se); - - //count data properties - query = "SELECT DISTINCT ?p WHERE {?s ?p ?o. ?p a <http://www.w3.org/2002/07/owl#DatatypeProperty>}"; - int dpCnt = countEntities(query, se); - //count individuals // query = "SELECT (COUNT(DISTINCT ?s) AS ?cnt) WHERE {?s a ?type.}"; // int indCnt = executeQuery(query, se, 20).next().getLiteral("cnt").getInt(); @@ -176,6 +189,7 @@ }); } threadPool.shutdown(); + System.out.println("##########"); System.out.println(sb); } @@ -202,11 +216,16 @@ } private static ResultSet executeQuery(String queryString, SparqlEndpoint endpoint) throws Exception{ - try { - QueryEngineHTTP qe = new QueryEngineHTTP(endpoint.getURL().toString(), queryString); - qe.setDefaultGraphURIs(endpoint.getDefaultGraphURIs()); - qe.setTimeout(queryTimeout * 1000); - return qe.execSelect(); + try {//System.out.println(queryString); + if(useCache){ + return SparqlQuery.convertJSONtoResultSet(cache.executeSelectQuery(endpoint, queryString, queryTimeout)); + } else { + QueryEngineHTTP qe = new QueryEngineHTTP(endpoint.getURL().toString(), queryString); + qe.setDefaultGraphURIs(endpoint.getDefaultGraphURIs()); + qe.setTimeout(queryTimeout * 1000); + return qe.execSelect(); + } + } catch (Exception e) { throw e; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2012-04-13 11:12:40
|
Revision: 3636 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3636&view=rev Author: lorenz_b Date: 2012-04-13 11:12:31 +0000 (Fri, 13 Apr 2012) Log Message: ----------- Added directory creation. Modified Paths: -------------- trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java Modified: trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java 2012-04-13 08:30:41 UTC (rev 3635) +++ trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java 2012-04-13 11:12:31 UTC (rev 3636) @@ -109,6 +109,7 @@ * @throws FileNotFoundException */ public static void main(String[] args) throws MalformedURLException, IllegalArgumentException, SecurityException, ComponentInitException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, LearningProblemUnsupportedException, FileNotFoundException { + new File(baseDir).mkdirs(); SimpleLayout layout = new SimpleLayout(); ConsoleAppender consoleAppender = new ConsoleAppender(layout); @@ -288,6 +289,7 @@ public static List<String> getErrorList(){ List<String> errorNames = new ArrayList<String>(); File dir = new File(baseDir + "/failed/"); + dir.mkdirs(); for(File file : dir.listFiles()){ errorNames.add(file.getName().replace(".log", "")); } @@ -297,6 +299,7 @@ public static List<String> getEmptyList(){ List<String> errorNames = new ArrayList<String>(); File dir = new File(baseDir + "/success/empty/"); + dir.mkdirs(); for(File file : dir.listFiles()){ errorNames.add(file.getName().replace(".ttl", "")); } @@ -306,6 +309,7 @@ public static List<String> getSuccessList(){ List<String> errorNames = new ArrayList<String>(); File dir = new File(baseDir + "/success/"); + dir.mkdirs(); for(File file : dir.listFiles()){ errorNames.add(file.getName().replace(".ttl", "")); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <seb...@us...> - 2012-04-13 08:30:53
|
Revision: 3635 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3635&view=rev Author: sebastianwtr Date: 2012-04-13 08:30:41 +0000 (Fri, 13 Apr 2012) Log Message: ----------- [tbsl exploration] startet with DebugOutputs Modified Paths: -------------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/Elements.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java Added Paths: ----------- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/DebugMode.java trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Index/Index_utils.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -5,7 +5,10 @@ import java.util.HashMap; import java.util.Map; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; + public class Index_utils { /** @@ -78,15 +81,13 @@ } - return result_List; } public static ArrayList<String> searchIndexForProperty(String string, SQLiteIndex myindex) throws SQLException{ HashMap<String,Float> hm = new HashMap<String,Float>(); - System.err.println("########"); - System.err.println("In search Index for Property"); + if(Setting.isDebugModus())DebugMode.debugPrint("######\n In search Index for Property"); // adding or set elements in Map by put method key and value pair /* @@ -102,19 +103,20 @@ String result=null; ArrayList<String> result_List = new ArrayList<String>(); result=myindex.getPropertyURI(string.toLowerCase()); - System.err.println("Result: "+result); + if(Setting.isDebugModus())DebugMode.debugPrint("Result: "+result); if(result!=null){ result_List.add(result); hm.put(result, 1.0f); - System.err.println("Found uri for: "+string.toLowerCase()); + if(Setting.isDebugModus())DebugMode.debugPrint("Found uri for: "+string.toLowerCase()); } else{ - System.err.println("Didnt find uri for: "+string.toLowerCase()); + if(Setting.isDebugModus())DebugMode.debugErrorPrint("Didnt find uri for: "+string.toLowerCase()); + result_List.add("http://dbpedia.org/ontology/"+string.toLowerCase().replace(" ", "_")); hm.put(result, 0.0f); } - System.err.println("########"); + if(Setting.isDebugModus())DebugMode.debugPrint("######\n"); return result_List; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/Elements.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/Elements.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/Elements.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -3,7 +3,9 @@ import java.io.IOException; import java.util.ArrayList; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; import org.dllearner.algorithm.tbsl.exploration.Utils.ServerUtil; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; /** * Creates Set of Classes and Resources with their properties @@ -48,7 +50,7 @@ e.printStackTrace(); } - System.out.println("Created Elements"); + if(Setting.isDebugModus())DebugMode.debugPrint("Created Elements"); } private void createElementsOfClasses(ArrayList<ArrayList<Hypothesis>> hypothesenList) throws IOException{ @@ -65,7 +67,7 @@ /* * TODO: improver performance, using geschicktes zwischenspeichern */ - System.out.println("Class Name: "+h.getName()+" Uri: "+h.getUri()); + if(Setting.isDebugModus())DebugMode.debugPrint("Create Elements for Class: "+h.getName()+" Uri: "+h.getUri()); ElementList el = new ElementList(h.getName(),h.getUri(),ServerUtil.getElementsForGivenClass(h.getUri())); //classes.add(el); this.addElements(el); @@ -84,7 +86,7 @@ for(ArrayList<Hypothesis> hl : hypothesenList){ for(Hypothesis h : hl){ if(h.getType().contains("RESOURCE")&&h.getUri().contains("http")){ - System.out.println("Resource Name: "+h.getName()+" Uri: "+h.getUri()); + if(Setting.isDebugModus())DebugMode.debugPrint("Create Elements for Resource: "+h.getName()+" Uri: "+h.getUri()); for(ArrayList<String> cl : conditionList){ if(h.getVariable().equals(cl.get(0))) { Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Sparql/TemplateBuilder.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -17,6 +17,8 @@ import org.dllearner.algorithm.tbsl.exploration.Index.SQLiteIndex; import org.dllearner.algorithm.tbsl.exploration.Index.Index_utils; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; import org.dllearner.algorithm.tbsl.sparql.BasicQueryTemplate; import org.dllearner.algorithm.tbsl.sparql.Path; import org.dllearner.algorithm.tbsl.sparql.SPARQL_Filter; @@ -49,33 +51,38 @@ /* * check if templates were build, if not, safe the question and delete it for next time from the xml file. + * Only in Debug Mode */ - if(querytemps.contains("could not be parsed") || querytemps.isEmpty()){ - String dateiname="/home/swalter/Dokumente/Auswertung/NotParsed.txt"; - String result_string =""; - //Open the file for reading - try { - BufferedReader br = new BufferedReader(new FileReader(dateiname)); - String thisLine; - while ((thisLine = br.readLine()) != null) { // while loop begins here - result_string+=thisLine+"\n"; - } // end while - } // end try - catch (IOException e) { - System.err.println("Error: " + e); - } - - File file = new File(dateiname); - BufferedWriter bw = new BufferedWriter(new FileWriter(file)); + if(Setting.isDebugModus()){ + if(querytemps.contains("could not be parsed") || querytemps.isEmpty()){ + String dateiname="/home/swalter/Dokumente/Auswertung/NotParsed.txt"; + String result_string =""; + //Open the file for reading + try { + BufferedReader br = new BufferedReader(new FileReader(dateiname)); + String thisLine; + while ((thisLine = br.readLine()) != null) { // while loop begins here + result_string+=thisLine+"\n"; + } // end while + } // end try + catch (IOException e) { + System.err.println("Error: " + e); + } + + File file = new File(dateiname); + BufferedWriter bw = new BufferedWriter(new FileWriter(file)); - bw.write(result_string+"\n"+question); - bw.flush(); - bw.close(); - - + bw.write(result_string+"\n"+question); + bw.flush(); + bw.close(); + + + } } + long stop_template = System.currentTimeMillis(); + if(Setting.isDebugModus())DebugMode.waitForButton(); for (BasicQueryTemplate bqt : querytemps) { long start_part1= System.currentTimeMillis(); @@ -172,7 +179,7 @@ for(String s : al){ con_temp+=" " + s; } - System.out.println("Condition: "+con_temp); + if(Setting.isDebugModus())DebugMode.debugPrint("Condition: "+con_temp); } template.setTime_part1(stop_part1-start_part1); @@ -225,15 +232,12 @@ } } ArrayList<ArrayList<Hypothesis>> final_list_set_hypothesis = new ArrayList<ArrayList<Hypothesis>>(); - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - /* System.out.println("Alle Hypothesen VOR der Verarbeitung"); + if(Setting.isDebugModus())DebugMode.printHypothesen(list_of_hypothesis,"Alle Hypothesen VOR der Verarbeitung"); + + for(Hypothesis x : list_of_hypothesis){ - x.printAll(); - } - System.out.println("Alle Hypothesen VOR der Verarbeitung - Done \n\n"); - */ - for(Hypothesis x : list_of_hypothesis){ /* * TODO: Change if ISA only ask classes, else resource */ @@ -279,14 +283,9 @@ } } - /* System.out.println("Alle Hypothesen nach der ERSTEN Verarbeitung"); - for(ArrayList<Hypothesis> lh : final_list_set_hypothesis){ - for(Hypothesis x : lh){ - x.printAll(); - } - } - System.out.println("Alle Hypothesen nach der ERSTEN Verarbeitung - Done \n\n"); - */ + + if(Setting.isDebugModus())DebugMode.printHypothesenSet(final_list_set_hypothesis,"Alle Hypothesen nach der ERSTEN Verarbeitung"); + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /* @@ -356,17 +355,8 @@ } } - /*System.out.println("Alle Hypothesen nach der ZWEITEN Verarbeitung"); - for(ArrayList<Hypothesis> lh : final_list_set_hypothesis){ - for(Hypothesis x : lh){ - x.printAll(); - } - } + if(Setting.isDebugModus())DebugMode.printHypothesenSet(final_list_set_hypothesis,"Alle Hypothesen nach der ZWEITEN Verarbeitung"); - System.out.println("Alle Hypothesen nach der ZWEITEN Verarbeitung - Done \n\n"); - */ - - template.setHypothesen(final_list_set_hypothesis); @@ -430,12 +420,10 @@ } } - /*System.out.println("Nach allen Verarbeitungsschritten:"); - for(Template temp : resultArrayList){ - temp.printAll(); - } - System.out.println("Nach allen Verarbeitungsschritten - DONE");*/ + if(Setting.isDebugModus())DebugMode.printTemplateList(resultArrayList, "Templates nach allen Verarbeitungsschritten"); + + return resultArrayList; } } Added: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/DebugMode.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/DebugMode.java (rev 0) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/DebugMode.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -0,0 +1,99 @@ +package org.dllearner.algorithm.tbsl.exploration.Utils; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; + +import org.dllearner.algorithm.tbsl.exploration.Sparql.Hypothesis; +import org.dllearner.algorithm.tbsl.exploration.Sparql.Template; + +public class DebugMode { + + public static void waitForButton() throws IOException { + BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); + String line; + System.out.println("\n\n"); + System.out.println("Press Any Key to continue"); + line = in.readLine(); + } + + + public static void printHypothesen(ArrayList<Hypothesis> list_of_hypothesis, String string){ + System.out.println(string); + for(Hypothesis x : list_of_hypothesis){ + x.printAll(); + } + System.out.println(string +" Done \n\n"); + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public static void printHypothesenSet(ArrayList<ArrayList<Hypothesis>> set_hypothesis, String string){ + System.out.println(string); + for(ArrayList<Hypothesis> lh : set_hypothesis){ + for(Hypothesis x : lh){ + x.printAll(); + } + } + System.out.println(string +" Done \n\n"); + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public static void printTemplateList(ArrayList<Template> templateList, String string){ + System.out.println(string); + for(Template t : templateList) t.printAll(); + System.out.println(string +" Done \n\n"); + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public static void debugPrint(String string){ + System.out.println(string); + } + + public static void debugErrorPrint(String string){ + System.err.println(string); + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void printQueryPair(ArrayList<QueryPair> qp){ + System.out.println("All constructed Queries with Rank"); + for(QueryPair p : qp){ + p.printAll(); + } + + try { + waitForButton(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + + +} Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/Utils/LinearSort.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -2,6 +2,8 @@ import java.util.ArrayList; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; + public class LinearSort { public static void doSort(ArrayList<QueryPair> qp){ @@ -20,9 +22,7 @@ } } - /*for(QueryPair p : qp){ - p.printAll(); - }*/ + if(Setting.isDebugModus())DebugMode.printQueryPair(qp); } Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/MainInterface.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -11,6 +11,7 @@ import org.dllearner.algorithm.tbsl.exploration.Sparql.Hypothesis; import org.dllearner.algorithm.tbsl.exploration.Sparql.Template; import org.dllearner.algorithm.tbsl.exploration.Sparql.TemplateBuilder; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; import org.dllearner.algorithm.tbsl.exploration.Utils.LinearSort; import org.dllearner.algorithm.tbsl.exploration.Utils.Query; import org.dllearner.algorithm.tbsl.exploration.Utils.QueryPair; @@ -26,6 +27,14 @@ public static ArrayList<String> startQuestioning(String question,BasicTemplator btemplator,SQLiteIndex myindex, WordNet wordnet,StanfordLemmatizer lemmatiser) throws ClassNotFoundException, SQLException, IOException{ + /* + * true, if you have to push a button to get to the next module + * false, goes through all + */ + boolean wait = false; + + if(Setting.isWaitModus())wait=true; + TemplateBuilder templateObject = new TemplateBuilder(btemplator, myindex); ArrayList<Template> template_list = new ArrayList<Template>(); @@ -69,20 +78,35 @@ for(QueryPair q : qp){ if(anzahl<anzahlAbgeschickterQueries&go_on){ ArrayList<String> answer_tmp = new ArrayList<String>(); - System.out.println(q.getQuery()); + System.out.println("Sending Query to Server: "+q.getQuery()); answer_tmp=ServerUtil.requestAnswerFromServer(q.getQuery()); if(answer_tmp.isEmpty()) go_on=true; else{ - //else go_on=false; - go_on=true; + go_on=false; + System.out.println("Got Answer from Server with this Query: "+ q.getQuery()); + //go_on=true; + boolean contains_uri=false; for(String s : answer_tmp){ + if(s.contains("http")){ + contains_uri=true; + break; + } + } + for(String s : answer_tmp){ if(checkAnswer(s)){ - boolean test = false; + boolean double_result = false; for(String s_t : answers){ - if(s_t.contains(s)) test=true; + if(s_t.contains(s)) double_result=true; } - if(!test)answers.add(s); + //TODO Test!!!!!! + //if in one answer is an http, only add uri's + if(!double_result){ + if(contains_uri){ + if(s.contains("http"))answers.add(s); + } + else answers.add(s); + } } } //if(checkAnswer(answer_tmp))answers.addAll(answer_tmp); @@ -91,14 +115,11 @@ anzahl+=1; } + System.out.println("\n Answer from Server: \n"); for(String answer:answers){ System.out.println(answer); } - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - String line; - System.out.println("\n\n"); - System.out.println("Press Any Key to continue"); - line = in.readLine(); + if(wait)DebugMode.waitForButton(); /* @@ -108,9 +129,7 @@ answers.clear(); answers.addAll(doStart(myindex, wordnet, lemmatiser, template_list,"LEVENSTHEIN")); - System.out.println("\n\n"); - System.out.println("Press Any Key to continue"); - line = in.readLine(); + if(wait)DebugMode.waitForButton(); } /* @@ -121,17 +140,15 @@ answers.clear(); answers.addAll(doStart(myindex, wordnet, lemmatiser, template_list,"WORDNET")); - System.out.println("\n\n"); - System.out.println("Press Any Key to continue"); - line = in.readLine(); + if(wait)DebugMode.waitForButton(); } - /*if(answers.isEmpty()){ - System.out.println("No answers were found with the three Modules"); + if(answers.isEmpty()){ + System.out.println(""); //answers.add("No answers were found with the three Modules"); - }*/ + } /* @@ -142,9 +159,16 @@ } + + + + + + + private static ArrayList<String> doStart(SQLiteIndex myindex, WordNet wordnet, StanfordLemmatizer lemmatiser, ArrayList<Template> template_list, String type) { @@ -193,20 +217,35 @@ if(anzahl<anzahlAbgeschickterQueries&go_on){ ArrayList<String> answer_tmp = new ArrayList<String>(); answer_tmp=ServerUtil.requestAnswerFromServer(q.getQuery()); - System.out.println(q.getQuery() + " Rank: "+q.getRank()); + System.out.println("Sending Query to Server: "+q.getQuery()); if(answer_tmp.isEmpty()) go_on=true; else{ //else go_on=false; - go_on=true; - //go_on=false; + //go_on=true; + go_on=false; + System.out.println("Got Answer from Server with this Query: "+ q.getQuery()); + boolean contains_uri=false; for(String s : answer_tmp){ + if(s.contains("http")){ + contains_uri=true; + break; + } + } + for(String s : answer_tmp){ if(checkAnswer(s)){ - boolean test = false; + boolean double_result = false; for(String s_t : answers){ - if(s_t.contains(s)) test=true; + if(s_t.contains(s)) double_result=true; } - if(!test)answers.add(s); + //TODO Test!!!!!! + //if in one answer is an http, only add uri's + if(!double_result){ + if(contains_uri){ + if(s.contains("http"))answers.add(s); + } + else answers.add(s); + } } } //if(checkAnswer(answer_tmp))answers.addAll(answer_tmp); @@ -214,6 +253,7 @@ } anzahl+=1; } + System.out.println("\n Answer from Server: \n"); for(String answer:answers){ System.out.println(answer); } @@ -231,7 +271,7 @@ } private static boolean checkQuery(String query){ - if(query.contains("wikiPageWiki")||query.contains("wikiPageExternal")||query.contains("wikiPageRedirects")|| query.contains("thumbnail")) return false; + if(query.contains("wikiPageWiki")||query.contains("wikiPageExternal")||query.contains("wikiPageRedirects")|| query.contains("thumbnail")||query.contains("wikiPage")) return false; else return true; } Added: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java (rev 0) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/Setting.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -0,0 +1,21 @@ +package org.dllearner.algorithm.tbsl.exploration.exploration_main; + +public class Setting { + + private static boolean waitModus; + private static boolean debugModus; + public static boolean isWaitModus() { + return waitModus; + } + public static void setWaitModus(boolean waitModus) { + Setting.waitModus = waitModus; + } + public static boolean isDebugModus() { + return debugModus; + } + public static void setDebugModus(boolean debugModus) { + Setting.debugModus = debugModus; + } + + +} Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/exploration_main/exploration_main.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -40,7 +40,6 @@ public class exploration_main { - /** * @param args @@ -59,21 +58,26 @@ * Initial Index and Templator */ BasicTemplator btemplator = new BasicTemplator(); - //btemplator.UNTAGGED_INPUT = false; + btemplator.UNTAGGED_INPUT = false; + SQLiteIndex myindex = new SQLiteIndex(); WordNet wordnet = new WordNet(); StanfordLemmatizer lemmatiser = new StanfordLemmatizer(); long stopInitTime = System.currentTimeMillis(); + + Setting.setWaitModus(false); + Setting.setDebugModus(false); + System.out.println("Time for Initialising "+(stopInitTime-startInitTime)+" ms"); boolean schleife=true; - boolean doing = true; + boolean startQuestioning = true; while(schleife==true){ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line; - doing = true; + startQuestioning = true; try { System.out.println("\n\n"); System.out.println("Please enter a Question:"); @@ -83,6 +87,33 @@ System.out.println("Bye!"); System.exit(0); } + + if(line.contains(":wait on")){ + Setting.setWaitModus(true); + startQuestioning=false; + if(Setting.isWaitModus()) System.out.println("WaitModus is now online"); + else System.out.println("Wait Modus is now offline"); + } + if(line.contains(":wait off")){ + Setting.setWaitModus(false); + startQuestioning=false; + if(Setting.isWaitModus()) System.out.println("WaitModus is now online"); + else System.out.println("Wait Modus is now offline"); + } + if(line.contains(":debug on")){ + Setting.setDebugModus(true); + startQuestioning=false; + if(Setting.isDebugModus()) System.out.println("DebugModus is now online"); + else System.out.println("DebugModus is now offline"); + } + if(line.contains(":debug off")){ + Setting.setDebugModus(false); + startQuestioning=false; + if(Setting.isDebugModus()) System.out.println("DebugModus is now online"); + else System.out.println("DebugModus is now offline"); + } + + if(line.contains(":xml")&& schleife==true){ TimeZone.setDefault(TimeZone.getTimeZone("GMT")); @@ -90,12 +121,14 @@ /*System.out.println("Please enter Path of xml File:"); line=in.readLine();*/ - line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train.xml"; - line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-withoutnonparsed.xml"; + //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train.xml"; + //line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-withoutnonparsed.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/very_small.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/berlin.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/vortragfragen.xml"; //line="/home/swalter/Dokumente/Auswertung/XMLDateien/iteration-test.xml"; + line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-tagged.xml"; + line="/home/swalter/Dokumente/Auswertung/XMLDateien/dbpedia-train-tagged-withoutNotparsed.xml"; //create Structs ArrayList<queryInformation> list_of_structs = new ArrayList<queryInformation>(); @@ -145,7 +178,7 @@ } - else if(schleife==true && doing ==true){ + else if(schleife==true && startQuestioning ==true){ long startTime = System.currentTimeMillis(); queryInformation result = new queryInformation(line,"0","",false,false,false,"non",false); MainInterface.startQuestioning(line,btemplator,myindex,wordnet,lemmatiser); @@ -241,7 +274,8 @@ int counter=0; System.out.println("Anzahl queryInformations: "+list.size()); for (queryInformation s : list){ - if(!s.getResult().isEmpty()){ + //why doing this? try that it doesnt matter if there is an answer or not.... + //if(!s.getResult().isEmpty()){ String tmp; if(counter==0){ counter=counter+1; @@ -266,7 +300,7 @@ } tmp+="</answers></question>\n"; xmlDocument+=tmp; - } + //} } xmlDocument+="</dataset>"; Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/IterationModule.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -9,6 +9,8 @@ import org.dllearner.algorithm.tbsl.exploration.Sparql.ElementList; import org.dllearner.algorithm.tbsl.exploration.Sparql.Elements; import org.dllearner.algorithm.tbsl.exploration.Sparql.Hypothesis; +import org.dllearner.algorithm.tbsl.exploration.Utils.DebugMode; +import org.dllearner.algorithm.tbsl.exploration.exploration_main.Setting; import org.dllearner.algorithm.tbsl.nlp.StanfordLemmatizer; import org.dllearner.algorithm.tbsl.nlp.WordNet; @@ -37,7 +39,7 @@ } catch (Exception e){ gotResource=false; - System.out.println("Didnt get any Resource"); + if(Setting.isDebugModus())DebugMode.debugErrorPrint("Didnt get any Resource"); } //System.out.println("Anzahl der Resource Listen: "+resources.size()); @@ -81,7 +83,7 @@ String variable = h.getVariable(); String name = h.getName(); RL.add(h); - System.out.println("Found Resource"); + if(Setting.isDebugModus())DebugMode.debugPrint("Found Resource "+h.getName() +" "+h.getUri()); /* @@ -121,11 +123,6 @@ for(String s : propertyNameList){ String[] array = s.split("::"); - System.out.println("String: "+s); - /*System.out.println("Array:"); - for(String t : array){ - System.out.println(t); - }*/ /* * array[0] contains name of Property @@ -173,7 +170,7 @@ * TODO:Add special case, if we have only one condition but with an isA in it. */ RL.add(h); - System.out.println("Found Class"); + if(Setting.isDebugModus())DebugMode.debugPrint("Found Class "+h.getName() +" "+h.getUri()); for(ElementList el:resources){ /* Modified: trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java =================================================================== --- trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java 2012-04-11 15:07:53 UTC (rev 3634) +++ trunk/components-ext/src/main/java/org/dllearner/algorithm/tbsl/exploration/modules/WordnetModule.java 2012-04-13 08:30:41 UTC (rev 3635) @@ -95,9 +95,16 @@ if(key.contains(b.toLowerCase())||key.contains(lemmatiser.stem(b.toLowerCase()))||b.toLowerCase().contains(lemmatiser.stem(key))){ if(!result_SemanticsMatchProperties.contains(key)){ result_SemanticsMatchProperties.add(key); - double nld=Levenshtein.nld(property_to_compare_with.toLowerCase(), key); - Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); - listOfNewHypothesen.add(h); + if(key.toLowerCase().contains(property_to_compare_with.toLowerCase())){ + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", 1.5); + listOfNewHypothesen.add(h); + } + else{ + double nld=Levenshtein.nld(property_to_compare_with.toLowerCase(), key); + Hypothesis h = new Hypothesis(variable, key, value, "PROPERTY", nld); + listOfNewHypothesen.add(h); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2012-04-11 15:08:03
|
Revision: 3634 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3634&view=rev Author: kurzum Date: 2012-04-11 15:07:53 +0000 (Wed, 11 Apr 2012) Log Message: ----------- added sorting for jamon log Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-11 13:48:27 UTC (rev 3633) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-11 15:07:53 UTC (rev 3634) @@ -10,6 +10,8 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.config.ConfigOption; +import org.dllearner.utilities.JamonMonitorLogger; +import org.dllearner.utilities.experiments.Jamon; import org.semanticweb.owlapi.model.OWLOntology; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -159,6 +161,8 @@ log.info("*******Simple SPARQL Extractor********"); for (Monitor monitor : MonitorFactory.getRootMonitor().getMonitors()) { log.info("* {} *", monitor); + log.info(JamonMonitorLogger.getStringForAllSortedByLabel()); + } log.info("**************************************"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2012-04-11 13:48:38
|
Revision: 3633 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3633&view=rev Author: kurzum Date: 2012-04-11 13:48:27 +0000 (Wed, 11 Apr 2012) Log Message: ----------- added more speed logging Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/ABoxQueryGenerator.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/QueryExecutor.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/TBoxQueryGenerator.java trunk/components-core/src/main/java/org/nlp2rdf/ontology/ClassIndexer.java trunk/examples/sparql/difference/DifferenceDBpediaYAGO_angela_vs_hillary.conf trunk/test/newcomponent/AristotlePosNeg.conf Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/ABoxQueryGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/ABoxQueryGenerator.java 2012-04-11 12:51:42 UTC (rev 3632) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/ABoxQueryGenerator.java 2012-04-11 13:48:27 UTC (rev 3633) @@ -1,5 +1,5 @@ /** - * + * */ package org.dllearner.kb.sparql.simple; @@ -10,13 +10,15 @@ import com.hp.hpl.jena.ontology.Individual; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.util.iterator.ExtendedIterator; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; /** * @author didierc - * */ public class ABoxQueryGenerator { public String createQuery(List<String> individuals, OntModel model, List<String> filters) { + Monitor monABoxQueryGeneration = MonitorFactory.getTimeMonitor("ABox query generator").start(); StringBuilder builder = new StringBuilder(); builder.append("CONSTRUCT {?s ?p ?o} "); builder.append("{ ?s ?p ?o ."); @@ -41,14 +43,23 @@ } } builder.append("}"); + monABoxQueryGeneration.stop(); return builder.toString(); } - + public String createLastQuery(List<String> individuals, OntModel model, List<String> filters) { + Monitor monABoxQueryGeneration = MonitorFactory.getTimeMonitor("ABox query generator") + .start(); StringBuilder builder = new StringBuilder(); - builder.append("CONSTRUCT {?s ?p ?o . ?o a ?class} "); - builder.append("{ ?s ?p ?o ."); - builder.append("?o a ?class"); + if (false) { + builder.append("CONSTRUCT {?s ?p ?o . ?o a ?class} "); + builder.append("{ ?s ?p ?o ."); + builder.append("?o a ?class"); + } else { + builder.append("CONSTRUCT {?s ?p ?o } "); + builder.append("{ ?s ?p ?o "); + } + List<String> curIndividuals; if (model.isEmpty()) { curIndividuals = individuals; @@ -71,10 +82,13 @@ } } builder.append("}"); + monABoxQueryGeneration.stop(); return builder.toString(); } - - private List<String> getIndividualsFromModel(OntModel model) { + + private List<String> getIndividualsFromModel + (OntModel + model) { ExtendedIterator<Individual> iterator = model.listIndividuals(); LinkedList<String> result = new LinkedList<String>(); while (iterator.hasNext()) { @@ -82,8 +96,9 @@ } return result; } - - public List<String> difference(List<String> a, List<String> b) { + + public List<String> difference + (List<String> a, List<String> b) { ArrayList<String> result = new ArrayList<String>(b); result.removeAll(a); return result; Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/QueryExecutor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/QueryExecutor.java 2012-04-11 12:51:42 UTC (rev 3632) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/QueryExecutor.java 2012-04-11 13:48:27 UTC (rev 3633) @@ -1,8 +1,10 @@ /** - * + * */ package org.dllearner.kb.sparql.simple; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,26 +16,29 @@ /** * @author didierc - * */ public class QueryExecutor { - - private static Logger log=LoggerFactory.getLogger(QueryExecutor.class); - + + private static Logger log = LoggerFactory.getLogger(QueryExecutor.class); + public OntModel executeQuery(String queryString, String endpoint, OntModel model) { + Monitor monQueryingTotal = MonitorFactory.start("Query time total").start(); Query query = QueryFactory.create(queryString); log.debug("Jena Query: ", query); QueryExecution qExec = QueryExecutionFactory.sparqlService(endpoint, query); qExec.execConstruct(model); + monQueryingTotal.stop(); return model; } - + public OntModel executeQuery(String queryString, String endpoint, OntModel model, String defaultGraphURI) { + Monitor monQueryingTotal = MonitorFactory.start("Query time total").start(); Query query = QueryFactory.create(queryString); log.debug("Jena Query: ", query); QueryExecution qExec = QueryExecutionFactory.sparqlService(endpoint, query, defaultGraphURI); - log.debug("Qexec: {}",qExec); + log.debug("Qexec: {}", qExec); qExec.execConstruct(model); + monQueryingTotal.stop(); return model; } } Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java 2012-04-11 12:51:42 UTC (rev 3632) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SchemaIndexer.java 2012-04-11 13:48:27 UTC (rev 3633) @@ -4,6 +4,8 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; import org.nlp2rdf.ontology.ClassIndexer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,42 +15,45 @@ public class SchemaIndexer { private static Logger log = LoggerFactory.getLogger(SchemaIndexer.class); - private ClassIndexer classIndexer=null; - private OntModel model; - private File ontologySchema; - - public SchemaIndexer(){} - - public void init(){ - classIndexer=new ClassIndexer(); + private ClassIndexer classIndexer = null; + private OntModel model; + private File ontologySchema; + + public SchemaIndexer() { + } + + public void init() { + classIndexer = new ClassIndexer(); model = ModelFactory.createOntologyModel(); try { - model.read(new FileInputStream(ontologySchema), null); - } catch (FileNotFoundException e) { - log.error(e.getMessage(),e); - } + Monitor m0 = MonitorFactory.start("Indexer parsing ontology"); + model.read(new FileInputStream(ontologySchema), null); + m0.stop(); + } catch (FileNotFoundException e) { + log.error(e.getMessage(), e); + } classIndexer.index(model); } - - public OntModel getHierarchyForURI(String classUri){ - if(classIndexer==null){ + + public OntModel getHierarchyForURI(String classUri) { + if (classIndexer == null) { this.init(); } return classIndexer.getHierarchyForClassURI(classUri); } - - public static void main(String...args){ - SchemaIndexer i= new SchemaIndexer(); - System.out.println(i.getHierarchyForURI("http://dbpedia.org/ontology/Software")); + + public static void main(String... args) { + SchemaIndexer i = new SchemaIndexer(); + System.out.println(i.getHierarchyForURI("http://dbpedia.org/ontology/Software")); } - public File getOntologySchema() { - return ontologySchema; - } + public File getOntologySchema() { + return ontologySchema; + } - public void setOntologySchema(File ontologySchema) { - this.ontologySchema = ontologySchema; - } - - + public void setOntologySchema(File ontologySchema) { + this.ontologySchema = ontologySchema; + } + + } \ No newline at end of file Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-11 12:51:42 UTC (rev 3632) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/SparqlSimpleExtractor.java 2012-04-11 13:48:27 UTC (rev 3633) @@ -24,224 +24,224 @@ @ComponentAnn(name = "efficient SPARQL fragment extractor", shortName = "sparqls", version = 0.1) public class SparqlSimpleExtractor implements KnowledgeSource { - @ConfigOption(name = "endpointURL", description = "URL of the SPARQL endpoint", required = true) - private String endpointURL = null; - private OntModel model = null; - @ConfigOption(name = "instances", description = "List of the instances to use", required = true) - private List<String> instances = null; - @ConfigOption(name = "filters", description = "List of the filters to use", required = true) - private List<String> filters = null; - @ConfigOption(name = "recursionDepth", description = "recursion depth", required = true) - private int recursionDepth = 0; + @ConfigOption(name = "endpointURL", description = "URL of the SPARQL endpoint", required = true) + private String endpointURL = null; + private OntModel model = null; + @ConfigOption(name = "instances", description = "List of the instances to use", required = true) + private List<String> instances = null; + @ConfigOption(name = "filters", description = "List of the filters to use", required = true) + private List<String> filters = null; + @ConfigOption(name = "recursionDepth", description = "recursion depth", required = true) + private int recursionDepth = 0; - @ConfigOption(name = "defaultGraphURI", description = "default graph URI", required = true) - private String defaultGraphURI = null; - @ConfigOption(name = "sparqlQuery", description = "Sparql Query", required = false) - private String sparqlQuery = null; - @ConfigOption(name = "ontologyFile", description = "Ontology Schema File", required = true) - private File ontologyFile = null; - private OWLOntology owlOntology; - private SchemaIndexer indexer; + @ConfigOption(name = "defaultGraphURI", description = "default graph URI", required = true) + private String defaultGraphURI = null; + @ConfigOption(name = "sparqlQuery", description = "Sparql Query", required = false) + private String sparqlQuery = null; + @ConfigOption(name = "ontologyFile", description = "Ontology Schema File", required = true) + private File ontologyFile = null; + private OWLOntology owlOntology; + private SchemaIndexer indexer; - private static Logger log = LoggerFactory - .getLogger(SparqlSimpleExtractor.class); + private static Logger log = LoggerFactory.getLogger(SparqlSimpleExtractor.class); - public SparqlSimpleExtractor() { - model = ModelFactory.createOntologyModel(); - } + public SparqlSimpleExtractor() { + model = ModelFactory.createOntologyModel(); + } - /** - * @param args - * @throws ComponentInitException - */ - public static void main(String[] args) throws ComponentInitException { - SparqlSimpleExtractor extractor = new SparqlSimpleExtractor(); - extractor.setEndpointURL("http://live.dbpedia.org/sparql"); - extractor.setRecursionDepth(1); - extractor.setDefaultGraphURI("http://dbpedia.org"); - List<String> instances = new ArrayList<String>(7); - instances.add("http://dbpedia.org/resource/Democritus"); - instances.add("http://dbpedia.org/resource/Zeno_of_Elea"); - instances.add("http://dbpedia.org/resource/Plato"); - instances.add("http://dbpedia.org/resource/Socrates"); - instances.add("http://dbpedia.org/resource/Archytas"); - instances.add("http://dbpedia.org/resource/Pythagoras"); - instances.add("http://dbpedia.org/resource/Philolaus"); + /** + * @param args + * @throws ComponentInitException + */ + public static void main(String[] args) throws ComponentInitException { + SparqlSimpleExtractor extractor = new SparqlSimpleExtractor(); + extractor.setEndpointURL("http://live.dbpedia.org/sparql"); + extractor.setRecursionDepth(1); + extractor.setDefaultGraphURI("http://dbpedia.org"); + List<String> instances = new ArrayList<String>(7); + instances.add("http://dbpedia.org/resource/Democritus"); + instances.add("http://dbpedia.org/resource/Zeno_of_Elea"); + instances.add("http://dbpedia.org/resource/Plato"); + instances.add("http://dbpedia.org/resource/Socrates"); + instances.add("http://dbpedia.org/resource/Archytas"); + instances.add("http://dbpedia.org/resource/Pythagoras"); + instances.add("http://dbpedia.org/resource/Philolaus"); - extractor.setInstances(instances); - extractor.init(); - List<String> individuals = new LinkedList<String>(); - individuals.add("People"); - individuals.add("Animals"); - extractor.setInstances(individuals); - // System.out.println(extractor.createQuery()); - } + extractor.setInstances(instances); + extractor.init(); + List<String> individuals = new LinkedList<String>(); + individuals.add("People"); + individuals.add("Animals"); + extractor.setInstances(individuals); + // System.out.println(extractor.createQuery()); + } - @Override - public void init() throws ComponentInitException { - if (endpointURL == null) { - throw new ComponentInitException( - "Parameter endpoint URL is required"); - } - if (instances == null) { - throw new ComponentInitException("Parameter instances is required"); - } - if (recursionDepth == 0) { - throw new ComponentInitException( - "A value bigger than 0 is required for parameter recursionDepth"); - } - if (ontologyFile == null) { - throw new ComponentInitException( - "An ontology schema description file (ontologyFile) in RDF ist required"); - } - Monitor monComp = MonitorFactory.start("Simple SPARQL Component") - .start(); - Monitor monIndexer = MonitorFactory.start("Schema Indexer").start(); - indexer = new SchemaIndexer(); - indexer.setOntologySchema(ontologyFile); - indexer.init(); - monIndexer.stop(); + @Override + public void init() throws ComponentInitException { + if (endpointURL == null) { + throw new ComponentInitException( + "Parameter endpoint URL is required"); + } + if (instances == null) { + throw new ComponentInitException("Parameter instances is required"); + } + if (recursionDepth == 0) { + throw new ComponentInitException( + "A value bigger than 0 is required for parameter recursionDepth"); + } + if (ontologyFile == null) { + throw new ComponentInitException( + "An ontology schema description file (ontologyFile) in RDF ist required"); + } + Monitor monComp = MonitorFactory.start("Simple SPARQL Component") + .start(); + Monitor monIndexer = MonitorFactory.start("Schema Indexer").start(); + indexer = new SchemaIndexer(); + indexer.setOntologySchema(ontologyFile); + indexer.init(); + monIndexer.stop(); - Monitor monAquery; - Monitor monQuerying; - QueryExecutor executor = new QueryExecutor(); - String queryString; - if (sparqlQuery == null) { - ABoxQueryGenerator aGenerator = new ABoxQueryGenerator(); - for (int i = 0; i < recursionDepth - 1; i++) { - monAquery = MonitorFactory.getTimeMonitor("A query generator") - .start(); - queryString = aGenerator.createQuery(instances, model, filters); - monAquery.stop(); - log.debug("SPARQL: {}", queryString); - monQuerying = MonitorFactory.start("Querying"); - executor.executeQuery(queryString, endpointURL, model, - defaultGraphURI); - monQuerying.stop(); - } - monAquery = MonitorFactory.getTimeMonitor("A query generator") - .start(); - queryString = aGenerator.createLastQuery(instances, model, filters); - monAquery.stop(); - log.debug("SPARQL: {}", queryString); - monQuerying = MonitorFactory.start("Querying"); - executor.executeQuery(queryString, endpointURL, model, defaultGraphURI); - monQuerying.stop(); - } else { - monQuerying=MonitorFactory.getTimeMonitor("Querying").start(); - executor.executeQuery(sparqlQuery, endpointURL, model); - monQuerying.stop(); - } - + Monitor monQueryingABox; + QueryExecutor executor = new QueryExecutor(); + String queryString; + if (sparqlQuery == null) { + ABoxQueryGenerator aGenerator = new ABoxQueryGenerator(); + for (int i = 0; i < recursionDepth - 1; i++) { - TBoxQueryGenerator tGenerator = new TBoxQueryGenerator(); - Monitor monTquery = MonitorFactory.getTimeMonitor("T query generator") - .start(); - queryString = tGenerator.createQuery(model, filters, instances); - monTquery.stop(); - monQuerying = MonitorFactory.start("Querying"); - executor.executeQuery(queryString, endpointURL, model, defaultGraphURI); - monQuerying.stop(); - Set<OntClass> classes = model.listClasses().toSet(); - for (OntClass ontClass : classes) { - OntModel hierarchy = indexer.getHierarchyForURI(ontClass.getURI()); - if (hierarchy != null) { - model.add(hierarchy); - log.debug("{}", model); - } - } - JenaToOwlapiConverter converter = new JenaToOwlapiConverter(); - owlOntology = converter.convert(this.model); - monComp.stop(); - log.info("*******Simple SPARQL Extractor********"); - for (Monitor monitor : MonitorFactory.getRootMonitor().getMonitors()) { - log.info("* {} *", monitor); - } - log.info("**************************************"); - } + queryString = aGenerator.createQuery(instances, model, filters); + log.debug("SPARQL: {}", queryString); + monQueryingABox = MonitorFactory.start("ABox query time"); + executor.executeQuery(queryString, endpointURL, model, + defaultGraphURI); + monQueryingABox.stop(); + } - public String getEndpointURL() { - return endpointURL; - } - public void setEndpointURL(String endpointURL) { - this.endpointURL = endpointURL; - } + queryString = aGenerator.createLastQuery(instances, model, filters); - public String getDefaultGraphURI() { - return defaultGraphURI; - } + log.debug("SPARQL: {}", queryString); - public void setDefaultGraphURI(String defaultGraphURI) { - this.defaultGraphURI = defaultGraphURI; - } + monQueryingABox = MonitorFactory.start("ABox query time"); + Monitor monQueryingABox2 = MonitorFactory.start("ABox query time last query"); + executor.executeQuery(queryString, endpointURL, model, defaultGraphURI); + monQueryingABox.stop(); + monQueryingABox2.stop(); - public Model getModel() { - return model; - } + } else { + monQueryingABox = MonitorFactory.getTimeMonitor("ABox query time").start(); + executor.executeQuery(sparqlQuery, endpointURL, model); + monQueryingABox.stop(); + } - public void setModel(OntModel model) { - this.model = model; - } - /** - * @return the filters - */ - public List<String> getFilters() { - return filters; - } + TBoxQueryGenerator tGenerator = new TBoxQueryGenerator(); - /** - * @param filters - * the filters to set - */ - public void setFilters(List<String> filters) { - this.filters = filters; - } + //TODO check if all instances are queried. model.listIndividuals().toSet() + queryString = tGenerator.createQuery(model, filters, instances); - /** - * @return the instances - */ - public List<String> getInstances() { - return instances; - } + Monitor monQueryingTBox = MonitorFactory.start("TBox query time"); + executor.executeQuery(queryString, endpointURL, model, defaultGraphURI); + monQueryingTBox.stop(); - /** - * @param instances - * the instances to set - */ - public void setInstances(List<String> instances) { - this.instances = instances; - } + Monitor monIndexing = MonitorFactory.start("Querying index and conversion"); + Set<OntClass> classes = model.listClasses().toSet(); + for (OntClass ontClass : classes) { + OntModel hierarchy = indexer.getHierarchyForURI(ontClass.getURI()); + if (hierarchy != null) { + model.add(hierarchy); + log.debug("{}", model); + } + } + JenaToOwlapiConverter converter = new JenaToOwlapiConverter(); + owlOntology = converter.convert(this.model); + monIndexing.stop(); + monComp.stop(); + log.info("*******Simple SPARQL Extractor********"); + for (Monitor monitor : MonitorFactory.getRootMonitor().getMonitors()) { + log.info("* {} *", monitor); + } + log.info("**************************************"); + } - /** - * @return the recursionDepth - */ - public int getRecursionDepth() { - return recursionDepth; - } + public String getEndpointURL() { + return endpointURL; + } - /** - * @param recursionDepth - * the recursionDepth to set - */ - public void setRecursionDepth(int recursionDepth) { - this.recursionDepth = recursionDepth; - } + public void setEndpointURL(String endpointURL) { + this.endpointURL = endpointURL; + } - /** - * @return - */ - public OWLOntology getOWLOntology() { - return owlOntology; - } + public String getDefaultGraphURI() { + return defaultGraphURI; + } - public File getOntologyFile() { - return ontologyFile; - } + public void setDefaultGraphURI(String defaultGraphURI) { + this.defaultGraphURI = defaultGraphURI; + } - public void setOntologyFile(File ontologyFile) { - this.ontologyFile = ontologyFile; - } + public Model getModel() { + return model; + } + public void setModel(OntModel model) { + this.model = model; + } + + /** + * @return the filters + */ + public List<String> getFilters() { + return filters; + } + + /** + * @param filters the filters to set + */ + public void setFilters(List<String> filters) { + this.filters = filters; + } + + /** + * @return the instances + */ + public List<String> getInstances() { + return instances; + } + + /** + * @param instances the instances to set + */ + public void setInstances(List<String> instances) { + this.instances = instances; + } + + /** + * @return the recursionDepth + */ + public int getRecursionDepth() { + return recursionDepth; + } + + /** + * @param recursionDepth the recursionDepth to set + */ + public void setRecursionDepth(int recursionDepth) { + this.recursionDepth = recursionDepth; + } + + /** + * @return + */ + public OWLOntology getOWLOntology() { + return owlOntology; + } + + public File getOntologyFile() { + return ontologyFile; + } + + public void setOntologyFile(File ontologyFile) { + this.ontologyFile = ontologyFile; + } + } Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/TBoxQueryGenerator.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/TBoxQueryGenerator.java 2012-04-11 12:51:42 UTC (rev 3632) +++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/simple/TBoxQueryGenerator.java 2012-04-11 13:48:27 UTC (rev 3633) @@ -8,6 +8,8 @@ import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; /** * @author didierc @@ -16,6 +18,8 @@ public class TBoxQueryGenerator { public String createQuery(OntModel model, List<String> filters, List<String> individuals) { + Monitor monTquery = MonitorFactory.getTimeMonitor("TBox query generator") + .start(); StringBuilder builder = new StringBuilder( "CONSTRUCT { ?example a ?class . } "); builder.append("{ ?example a ?class . "); @@ -34,6 +38,7 @@ } } builder.append("}"); + monTquery.stop(); return builder.toString(); } Modified: trunk/components-core/src/main/java/org/nlp2rdf/ontology/ClassIndexer.java =================================================================== --- trunk/components-core/src/main/java/org/nlp2rdf/ontology/ClassIndexer.java 2012-04-11 12:51:42 UTC (rev 3632) +++ trunk/components-core/src/main/java/org/nlp2rdf/ontology/ClassIndexer.java 2012-04-11 13:48:27 UTC (rev 3633) @@ -25,9 +25,13 @@ import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.rdf.model.ModelFactory; +import com.hp.hpl.jena.util.iterator.ExtendedIterator; +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.naming.ldap.ExtendedRequest; import java.util.*; @@ -55,11 +59,24 @@ } public void index(OntModel from) { - Set<OntClass> classes = from.listClasses().toSet(); + + // Set<OntClass> classes = from.listClasses(); int i = 0; - for (OntClass cl : classes) { + OntClass cl; + for (ExtendedIterator<OntClass> it = from.listClasses(); it.hasNext(); ) { + Monitor m0 = MonitorFactory.start("Indexer listClasses"); + cl = it.next(); + m0.stop(); + //for (OntClass cl : classes) { + Monitor m1 = MonitorFactory.start("Indexer generating tree"); Tree t = new Tree(cl); - classUriToClassHierarchy.put(cl.getURI(), t.toModel()); + m1.stop(); + Monitor m2 = MonitorFactory.start("Indexer generating model"); + OntModel m = t.toModel(); + m2.stop(); + Monitor m3 = MonitorFactory.start("Indexer generating hashmap"); + classUriToClassHierarchy.put(cl.getURI(), m); + m3.stop(); } } Modified: trunk/examples/sparql/difference/DifferenceDBpediaYAGO_angela_vs_hillary.conf =================================================================== --- trunk/examples/sparql/difference/DifferenceDBpediaYAGO_angela_vs_hillary.conf 2012-04-11 12:51:42 UTC (rev 3632) +++ trunk/examples/sparql/difference/DifferenceDBpediaYAGO_angela_vs_hillary.conf 2012-04-11 13:48:27 UTC (rev 3633) @@ -20,7 +20,7 @@ // SPARQL options sparql.type = "SPARQL endpoint fragment" -sparql.url = "http://dbpedia.openlinksw.com:8890/sparql" +sparql.url = "http://live.dbpedia.org/sparql" sparql.defaultGraphURIs = {"http://dbpedia.org"} sparql.recursionDepth = 1 //TODOREFACTOR check if predefinedFilter works at all Modified: trunk/test/newcomponent/AristotlePosNeg.conf =================================================================== --- trunk/test/newcomponent/AristotlePosNeg.conf 2012-04-11 12:51:42 UTC (rev 3632) +++ trunk/test/newcomponent/AristotlePosNeg.conf 2012-04-11 13:48:27 UTC (rev 3633) @@ -14,6 +14,7 @@ sparql.endpointURL = "http://live.dbpedia.org/sparql" sparql.defaultGraphURI = "http://dbpedia.org" sparql.recursionDepth = 1 +sparql.ontologyFile= "http://downloads.dbpedia.org/3.6/dbpedia_3.6.owl" sparql.instances = { "http://dbpedia.org/resource/Democritus", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |