|
From: <jen...@us...> - 2010-12-16 12:26:40
|
Revision: 2567
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2567&view=rev
Author: jenslehmann
Date: 2010-12-16 12:26:33 +0000 (Thu, 16 Dec 2010)
Log Message:
-----------
implemented noise termination criterion for CELOE
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/CELOEConfigurator.java
trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigOptions.java
trunk/examples/swore/swore.conf
Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2010-12-16 09:17:45 UTC (rev 2566)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/celoe/CELOE.java 2010-12-16 12:26:33 UTC (rev 2567)
@@ -172,6 +172,7 @@
options.add(CommonConfigOptions.useDoubleDatatypes());
options.add(CommonConfigOptions.maxExecutionTimeInSeconds(10));
options.add(CommonConfigOptions.getNoisePercentage());
+ options.add(CommonConfigOptions.getTerminateOnNoiseReached(false));
options.add(CommonConfigOptions.getMaxDepth(7));
options.add(CommonConfigOptions.maxNrOfResults(10));
options.add(CommonConfigOptions.maxClassDescriptionTests());
@@ -331,6 +332,10 @@
return bestEvaluatedDescriptions.getSet();
}
+ public double getCurrentlyBestAccuracy() {
+ return bestEvaluatedDescriptions.getBest().getAccuracy();
+ }
+
@Override
public void start() {
// System.out.println(configurator.getMaxExecutionTimeInSeconds());
@@ -681,7 +686,8 @@
return
stop ||
(configurator.getMaxClassDescriptionTests() != 0 && (expressionTests >= configurator.getMaxClassDescriptionTests())) ||
- (configurator.getMaxExecutionTimeInSeconds() != 0 && ((System.nanoTime() - nanoStartTime) >= (configurator.getMaxExecutionTimeInSeconds()*1000000000l)));
+ (configurator.getMaxExecutionTimeInSeconds() != 0 && ((System.nanoTime() - nanoStartTime) >= (configurator.getMaxExecutionTimeInSeconds()*1000000000l))) ||
+ (configurator.getTerminateOnNoiseReached() && (100*getCurrentlyBestAccuracy()>100-configurator.getNoisePercentage()));
}
private void reset() {
@@ -785,4 +791,5 @@
public int getClassExpressionTests() {
return expressionTests;
}
+
}
Modified: trunk/components-core/src/main/java/org/dllearner/core/configurators/CELOEConfigurator.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/configurators/CELOEConfigurator.java 2010-12-16 09:17:45 UTC (rev 2566)
+++ trunk/components-core/src/main/java/org/dllearner/core/configurators/CELOEConfigurator.java 2010-12-16 12:26:33 UTC (rev 2567)
@@ -164,6 +164,15 @@
return (Double) ComponentManager.getInstance().getConfigOptionValue(cELOE, "noisePercentage") ;
}
/**
+* terminateOnNoiseReached specifies whether to terminate when noise criterion is met.
+* mandatory: false| reinit necessary: true
+* default value: false
+* @return boolean
+**/
+public boolean getTerminateOnNoiseReached() {
+return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "terminateOnNoiseReached") ;
+}
+/**
* maxDepth maximum depth of description.
* mandatory: false| reinit necessary: true
* default value: 7
@@ -372,6 +381,15 @@
reinitNecessary = true;
}
/**
+* @param terminateOnNoiseReached specifies whether to terminate when noise criterion is met.
+* mandatory: false| reinit necessary: true
+* default value: false
+**/
+public void setTerminateOnNoiseReached(boolean terminateOnNoiseReached) {
+ComponentManager.getInstance().applyConfigEntry(cELOE, "terminateOnNoiseReached", terminateOnNoiseReached);
+reinitNecessary = true;
+}
+/**
* @param maxDepth maximum depth of description.
* mandatory: false| reinit necessary: true
* default value: 7
Modified: trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigOptions.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigOptions.java 2010-12-16 09:17:45 UTC (rev 2566)
+++ trunk/components-core/src/main/java/org/dllearner/core/options/CommonConfigOptions.java 2010-12-16 12:26:33 UTC (rev 2567)
@@ -78,6 +78,10 @@
return new BooleanConfigOption("terminateOnNoiseReached", "specifies whether to terminate when noise criterion is met", terminateOnNoiseReachedDefault);
}
+ public static BooleanConfigOption getTerminateOnNoiseReached(boolean defaultValue) {
+ return new BooleanConfigOption("terminateOnNoiseReached", "specifies whether to terminate when noise criterion is met", defaultValue);
+ }
+
public static IntegerConfigOption getMaxDepth(int defaultValue) {
return new IntegerConfigOption("maxDepth", "maximum depth of description", defaultValue);
}
Modified: trunk/examples/swore/swore.conf
===================================================================
--- trunk/examples/swore/swore.conf 2010-12-16 09:17:45 UTC (rev 2566)
+++ trunk/examples/swore/swore.conf 2010-12-16 12:26:33 UTC (rev 2567)
@@ -68,4 +68,4 @@
-"http://ns.softwiki.de/req/Derick_Garnier"
-"http://ns.softwiki.de/req/UseOfIcons"
-"http://ns.softwiki.de/req/UserCanAccessDataFromEveryComputer"
--"http://ns.softwiki.de/req/WindowDesign"
\ No newline at end of file
+-"http://ns.softwiki.de/req/WindowDesign"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2010-12-17 12:14:37
|
Revision: 2569
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2569&view=rev
Author: lorenz_b
Date: 2010-12-17 12:14:30 +0000 (Fri, 17 Dec 2010)
Log Message:
-----------
Cleaned up logging.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/Generalisation.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/evaluation/SingleQueryEvaluationScript.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/nbr/strategy/GreedyNBRStrategy.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2010-12-16 13:02:08 UTC (rev 2568)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2010-12-17 12:14:30 UTC (rev 2569)
@@ -68,6 +68,9 @@
public Example findSimilarExample(List<String> posExamples,
List<String> negExamples) throws SPARQLQueryException{
+ logger.info("Searching similiar example");
+ logger.info("Positive examples: " + posExamples);
+ logger.info("Negative examples: " + negExamples);
this.posExamples = posExamples;
this.negExamples = negExamples;
@@ -77,21 +80,24 @@
Model model;
QueryTree<String> queryTree;
for(String resource : posExamples){
- logger.info("Fetching model for resource: " + resource);
+// logger.info("Fetching model for resource: " + resource);
model = modelCache.getModel(resource);
queryTree = queryTreeCache.getQueryTree(resource, model);
posExampleTrees.add(queryTree);
}
for(String resource : negExamples){
- logger.info("Fetching model for resource: " + resource);
+// logger.info("Fetching model for resource: " + resource);
model = modelCache.getModel(resource);
queryTree = queryTreeCache.getQueryTree(resource, model);
negExampleTrees.add(queryTree);
}
if(posExamples.size() == 1 && negExamples.isEmpty()){
+ logger.info("Up to now only 1 positive example is selected. Calling positive generalisation...");
return findExampleByGeneralisation(posExampleTrees.get(0));
} else {
+ logger.info("There are " + posExamples.size() + " positive examples and "
+ + negExamples.size() + "negative examples selected. Calling LGG/NBR...");
return findExampleByLGG(posExampleTrees, negExampleTrees);
}
@@ -138,8 +144,9 @@
private Example findExampleByGeneralisation(QueryTree<String> tree) throws SPARQLQueryException{
if(logger.isInfoEnabled()){
- logger.info("Using generalisation");
- logger.info("Query before generalisation: \n\n" + tree.toSPARQLQueryString(true));
+ logger.info("Making positive generalisation...");
+ logger.info("Tree before generalisation:\n" + tree.getStringRepresentation());
+ logger.info("Query before generalisation:\n" + tree.toSPARQLQueryString(true));
}
Generalisation<String> posGen = new Generalisation<String>();
@@ -149,7 +156,8 @@
currentQuery = genTree.toSPARQLQueryString(true);
currentQueryTree = genTree;
if(logger.isInfoEnabled()){
- logger.info("Query after generalisation: \n\n" + currentQuery);
+ logger.info("Tree after generalisation:\n" + tree.getStringRepresentation());
+ logger.info("Query after generalisation:\n" + currentQuery);
}
@@ -160,6 +168,9 @@
String result = "";
try {
if(testedQueries.contains(currentQuery) && !currentQueryTree.getChildren().isEmpty()){
+ if(logger.isInfoEnabled()){
+ logger.info("Query was already used before. Calling again positive generalisation...");
+ }
return findExampleByGeneralisation(currentQueryTree);
} else {
if(currentQueryTree.getChildren().isEmpty()){
@@ -178,6 +189,9 @@
ResultSetRewindable rs = SparqlQuery.convertJSONtoResultSet(result);
String uri;
QuerySolution qs;
+ if(logger.isInfoEnabled()){
+ logger.info("Resources in resultset:");
+ }
while(rs.hasNext()){
qs = rs.next();
uri = qs.getResource("x0").getURI();
@@ -194,7 +208,7 @@
}
}
if(logger.isInfoEnabled()){
- logger.info("Found no new example. Trying again generalisation...");
+ logger.info("The query resultset contains no new example. Calling again generalisation...");
}
return findExampleByGeneralisation(genTree);
@@ -242,15 +256,14 @@
private Example findExampleByLGG(List<QueryTree<String>> posExamplesTrees,
List<QueryTree<String>> negExamplesTrees) throws SPARQLQueryException{
- if(logger.isInfoEnabled()){
- logger.info("USING LGG");
- }
if(negExamplesTrees.isEmpty()){
+ queryGen.getSPARQLQueries(posExamplesTrees);
+ QueryTree<String> lgg = queryGen.getLastLGG();
if(logger.isInfoEnabled()){
- logger.info("No negative examples given. Avoiding big queries by GENERALISATION");
+ logger.info("No negative examples given.");
+ logger.info("Computed LGG:\n" + lgg.getStringRepresentation());
+ logger.info("Avoiding big queries by calling positive generalisation...");
}
- queryGen.getSPARQLQueries(posExamplesTrees);
- QueryTree<String> lgg = queryGen.getLastLGG();
return findExampleByGeneralisation(lgg);
}
@@ -290,16 +303,17 @@
uri = qs.getResource("x0").getURI();
if(!posExamples.contains(uri) && !negExamples.contains(uri)){
currentQuery = queryGen.getCurrentQueryTree().toSPARQLQueryString();
+ logger.info("Found new example: " + uri);
return getExample(uri);
}
}
if(logger.isInfoEnabled()){
- logger.info("Query result contains no new examples. Trying another query...");
+ logger.info("Query resultset contains no new example. Trying another query...");
}
}
if(logger.isInfoEnabled()){
- logger.info("None of the queries contained a new example.");
- logger.info("Making Generalisation...");
+ logger.info("None of the tested queries which was not tested before contained a new example.");
+ logger.info("Making again NBR...");
}
// return findExampleByGeneralisation(queryGen.getCurrentQueryTree());
return findExampleByLGG(Collections.singletonList(queryGen.getCurrentQueryTree()), negExamplesTrees);
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/Generalisation.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/Generalisation.java 2010-12-16 13:02:08 UTC (rev 2568)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/Generalisation.java 2010-12-17 12:14:30 UTC (rev 2569)
@@ -83,7 +83,7 @@
if(logger.isInfoEnabled()){
logger.info("Pruning tree:");
// logger.info(tree.getStringRepresentation());
- logger.info("Number of triple pattern: " + ((QueryTreeImpl<N>)tree).getTriplePatternCount());
+// logger.info("Number of triple pattern: " + ((QueryTreeImpl<N>)tree).getTriplePatternCount());
// logger.info(((QueryTreeImpl<N>)tree).getSPARQLQueryTree().getStringRepresentation());
}
@@ -137,9 +137,9 @@
}
level--;
}
- if(logger.isInfoEnabled()){
- logger.info(tree.getStringRepresentation());
- }
+// if(logger.isInfoEnabled()){
+// logger.info("Resulting tree:\n" + tree.getStringRepresentation());
+// }
}
private List<QueryTree<N>> getLeafsAtLevel(QueryTree<N> tree, int level){
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/evaluation/SingleQueryEvaluationScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/evaluation/SingleQueryEvaluationScript.java 2010-12-16 13:02:08 UTC (rev 2568)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/evaluation/SingleQueryEvaluationScript.java 2010-12-17 12:14:30 UTC (rev 2569)
@@ -21,9 +21,13 @@
import org.dllearner.kb.sparql.ExtractionDBCache;
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.kb.sparql.SparqlQuery;
+import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
+import org.dllearner.sparqlquerygenerator.datastructures.impl.QueryTreeImpl;
+import org.dllearner.sparqlquerygenerator.impl.SPARQLQueryGeneratorCachedImpl;
import org.dllearner.sparqlquerygenerator.impl.SPARQLQueryGeneratorImpl;
import org.dllearner.sparqlquerygenerator.operations.lgg.LGGGeneratorImpl;
import org.dllearner.sparqlquerygenerator.operations.nbr.NBRGeneratorImpl;
+import org.dllearner.sparqlquerygenerator.operations.nbr.strategy.GreedyNBRStrategy;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator;
import com.hp.hpl.jena.query.QuerySolution;
@@ -52,15 +56,17 @@
logger.addAppender(fileAppender);
logger.setLevel(Level.INFO);
Logger.getLogger(ModelGenerator.class).setLevel(Level.OFF);
- Logger.getLogger(SPARQLQueryGeneratorImpl.class).setLevel(Level.INFO);
+ Logger.getLogger(SPARQLQueryGeneratorCachedImpl.class).setLevel(Level.OFF);
Logger.getLogger(LGGGeneratorImpl.class).setLevel(Level.OFF);
Logger.getLogger(NBRGeneratorImpl.class).setLevel(Level.OFF);
Logger.getLogger(Generalisation.class).setLevel(Level.INFO);
+ Logger.getLogger(GreedyNBRStrategy.class).setLevel(Level.INFO);
+ Logger.getLogger(ExampleFinder.class).setLevel(Level.INFO);
SPARQLEndpointEx endpoint = new SPARQLEndpointEx(
- new URL("http://dbpedia.org/sparql"),
-// new URL("http://db0.aksw.org:8999/sparql"),
+// new URL("http://dbpedia.org/sparql"),
+ new URL("http://db0.aksw.org:8999/sparql"),
Collections.singletonList("http://dbpedia.org"),
Collections.<String>emptyList(),
null, null,
@@ -68,8 +74,13 @@
ExtractionDBCache selectQueriesCache = new ExtractionDBCache("evaluation/select-cache");
ExtractionDBCache constructQueriesCache = new ExtractionDBCache("evaluation/construct-cache");
- String query = "PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX : <http://dbpedia.org/resource/> PREFIX dbpedia2: <http://dbpedia.org/property/> PREFIX dbpedia: <http://dbpedia.org/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> " +
- "SELECT * WHERE { ?var0 owl:sameAs ?var1. ?var0 rdf:type <http://dbpedia.org/class/yago/State108654360> }";
+ String query = ""+
+// "PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX : <http://dbpedia.org/resource/> PREFIX dbpedia2: <http://dbpedia.org/property/> PREFIX dbpedia: <http://dbpedia.org/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> " +
+// "SELECT * WHERE { ?var0 owl:sameAs ?var1. ?var0 rdf:type <http://dbpedia.org/class/yago/State108654360> }";
+// "SELECT ?var0 WHERE { ?var0 skos:subject <http://dbpedia.org/resource/Category:French_films> }";
+// "PREFIX dbpedia2: <http://dbpedia.org/property/> PREFIX dbpo: <http://dbpedia.org/ontology/> SELECT DISTINCT ?var0 WHERE { ?var0 a dbpo:Band . ?var0 dbpedia2:genre <http://dbpedia.org/resource/Hard_rock> . ?var0 dbpedia2:genre <http://dbpedia.org/resource/Heavy_metal_music> . ?var0 dbpedia2:genre <http://dbpedia.org/resource/Blues-rock> . }";
+ "PREFIX dbpedia: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT DISTINCT ?var0 ?label ?homepage ?genre WHERE {?var0 a dbo:Band .?band rdfs:label ?label .OPTIONAL { ?var0 foaf:homepage ?homepage } .?var0 dbo:genre ?genre .?genre dbo:instrument dbpedia:Electric_guitar .?genre dbo:stylisticOrigin dbpedia:Jazz .}";
+
com.hp.hpl.jena.query.ResultSet rs;
SortedSet<String> resources;
QuerySolution qs;
@@ -102,7 +113,8 @@
negExamples = new ArrayList<String>();
//we choose the first resource in the set as positive example
- String posExample = resources.first();
+// String posExample = resources.first();
+ String posExample = "http://dbpedia.org/resource/Foals";
logger.info("Selected " + posExample + " as first positive example.");
posExamples.add(posExample);
@@ -112,6 +124,13 @@
boolean equivalentQueries = false;
do{
nextExample = exampleFinder.findSimilarExample(posExamples, negExamples).getURI();
+ learnedQuery = exampleFinder.getCurrentQuery();
+ logger.info("Learned query:\n" + learnedQuery);
+ equivalentQueries = isEquivalentQuery(resources, learnedQuery, endpoint);
+ logger.info("Original query and learned query are equivalent: " + equivalentQueries);
+ if(equivalentQueries){
+ break;
+ }
logger.info("Next suggested example is " + nextExample);
//if the example is contained in the resultset of the query, we add it to the positive examples,
//otherwise to the negatives
@@ -122,19 +141,18 @@
negExamples.add(nextExample);
logger.info("Suggested example is considered as negative example.");
}
- learnedQuery = exampleFinder.getCurrentQuery();
- logger.info("Learned query:\n" + learnedQuery);
- equivalentQueries = isEquivalentQuery(resources, learnedQuery, endpoint);
- logger.info("Original query and learned query are equivalent: " + equivalentQueries);
+
} while(!equivalentQueries);
logger.info("Number of examples needed: "
+ (posExamples.size() + negExamples.size())
+ "(+" + posExamples.size() + "/-" + negExamples.size() + ")");
+ logger.info(((QueryTreeImpl<String>)exampleFinder.getCurrentQueryTree()).getTriplePatternCount());
} catch (Exception e) {
logger.error("Error while learning query ", e);
}
-
+ logger.info(MonitorFactory.getTimeMonitor("LGG"));
+ logger.info(MonitorFactory.getTimeMonitor("Query"));
logger.info("Time to compute LGG(total): " + MonitorFactory.getTimeMonitor("LGG").getTotal());
logger.info("Time to compute LGG(avg): " + MonitorFactory.getTimeMonitor("LGG").getAvg());
logger.info("Time to compute LGG(min): " + MonitorFactory.getTimeMonitor("LGG").getMin());
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java 2010-12-16 13:02:08 UTC (rev 2568)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java 2010-12-17 12:14:30 UTC (rev 2569)
@@ -49,7 +49,11 @@
@Override
public QueryTree<N> getLGG(QueryTree<N> tree1, QueryTree<N> tree2,
boolean learnFilters) {
- return computeLGG(tree1, tree2, learnFilters);
+ Monitor mon = MonitorFactory.getTimeMonitor("LGG");
+ mon.start();
+ QueryTree<N> lgg = computeLGG(tree1, tree2, learnFilters);
+ mon.stop();
+ return lgg;
}
@Override
@@ -80,7 +84,8 @@
if(trees.size() == 1){
return trees.iterator().next();
}
-
+ Monitor mon = MonitorFactory.getTimeMonitor("LGG");
+ mon.start();
QueryTree<N> lgg = computeLGG(treeList.get(0), treeList.get(1), learnFilters);
if(logger.isInfoEnabled()){
logger.info("LGG for 1 and 2:\n" + lgg.getStringRepresentation());
@@ -97,8 +102,8 @@
logger.info("LGG = ");
logger.info(lgg.getStringRepresentation());
}
+ mon.stop();
-
return lgg;
}
@@ -109,8 +114,7 @@
logger.debug("and");
logger.debug(tree2.getStringRepresentation());
}
- Monitor mon = MonitorFactory.getTimeMonitor("LGG");
- mon.start();
+
QueryTree<N> lgg = new QueryTreeImpl<N>(tree1.getUserObject());
// if(!lgg.getUserObject().equals(tree2.getUserObject())){
@@ -183,9 +187,8 @@
}
}
}
- mon.stop();
if(logger.isDebugEnabled()){
- logger.debug("Computed LGG(" + mon.getLastValue() + "ms):");
+ logger.debug("Computed LGG:");
logger.debug(lgg.getStringRepresentation());
}
return lgg;
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/nbr/strategy/GreedyNBRStrategy.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/nbr/strategy/GreedyNBRStrategy.java 2010-12-16 13:02:08 UTC (rev 2568)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/nbr/strategy/GreedyNBRStrategy.java 2010-12-17 12:14:30 UTC (rev 2569)
@@ -48,6 +48,9 @@
@Override
public QueryTree<N> computeNBR(QueryTree<N> posExampleTree,
List<QueryTree<N>> negExampleTrees) {
+ if(logger.isInfoEnabled()){
+ logger.info("Making NBR...");
+ }
Monitor mon = MonitorFactory.getTimeMonitor("NBR");
mon.start();
@@ -58,17 +61,43 @@
checkTree(matrix, nbr, negExampleTrees.get(i), i);
}
- if(logger.isInfoEnabled()){
- logger.info(printTreeWithValues(nbr, matrix));
- }
-
List<QueryTree<N>> candidates2Remove = new ArrayList<QueryTree<N>>();
for(Entry<QueryTree<N>, List<Integer>> entry : matrix.entrySet()){
if(sum(entry.getValue()) < negExampleTrees.size()/2.0){
candidates2Remove.add(entry.getKey());
}
}
- removeLeafs(nbr, candidates2Remove);
+
+ if(logger.isInfoEnabled()){
+ logger.info("Marked tree:\n" + printTreeWithValues(nbr, matrix));
+ logger.info("Removing leafs with rowsum < #negTrees/2");
+ }
+
+ QueryTree<N> parent;
+ for(QueryTree<N> leaf : new ArrayList<QueryTree<N>>(nbr.getLeafs())){
+ parent = leaf.getParent();
+ if(candidates2Remove.contains(leaf)){
+ if(logger.isInfoEnabled()){
+ logger.info("Removing edge [" +
+ leaf.getParent().getUserObject() + "--" + leaf.getParent().getEdge(leaf) + "-->" + leaf.getUserObject() + "]");
+ }
+ leaf.getParent().removeChild((QueryTreeImpl<N>) leaf);
+ if(logger.isInfoEnabled()){
+ logger.info("Checking if removal leads to cover a negative tree...");
+ }
+ for(QueryTree<N> negTree : negExampleTrees){
+ if(negTree.isSubsumedBy(nbr)){
+ parent.addChild((QueryTreeImpl<N>) leaf);
+ if(logger.isInfoEnabled()){
+ logger.info("Removal of the edge leads to cover a negative tree. Reverting removal.");
+ }
+ break;
+ }
+ }
+ }
+ }
+
+// removeLeafs(nbr, candidates2Remove);
removeEqualEdgesFromRoot(nbr);
mon.stop();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-01-03 15:08:21
|
Revision: 2574
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2574&view=rev
Author: lorenz_b
Date: 2011-01-03 15:08:15 +0000 (Mon, 03 Jan 2011)
Log Message:
-----------
Reverted pom file to avoid build errors.
Added nodeId reflection in the copy constructor.
Modified Paths:
--------------
trunk/autosparql/pom.xml
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java
Modified: trunk/autosparql/pom.xml
===================================================================
--- trunk/autosparql/pom.xml 2011-01-03 15:03:41 UTC (rev 2573)
+++ trunk/autosparql/pom.xml 2011-01-03 15:08:15 UTC (rev 2574)
@@ -104,7 +104,7 @@
<executions>
<execution>
<configuration>
- <module>app</module>
+ <module>org.dllearner.autosparql.Application</module>
</configuration>
<goals>
<goal>compile</goal>
@@ -115,7 +115,7 @@
</executions>
<configuration>
<hostedWebapp>war</hostedWebapp>
- <runTarget>app/index.html</runTarget>
+ <runTarget>org.dllearner.autosparql.Application/index.html</runTarget>
<modules>
<module>org.dllearner.autosparql.Application</module>
</modules>
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java 2011-01-03 15:03:41 UTC (rev 2573)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java 2011-01-03 15:08:15 UTC (rev 2574)
@@ -74,8 +74,12 @@
public QueryTreeImpl(QueryTree<N> tree){
this(tree.getUserObject());
+ setId(tree.getId());
+ QueryTreeImpl<N> subTree;
for(QueryTree<N> child : tree.getChildren()){
- addChild(new QueryTreeImpl<N>(child), tree.getEdge(child));
+ subTree = new QueryTreeImpl<N>(child);
+ subTree.setId(child.getId());
+ addChild(subTree, tree.getEdge(child));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-01-05 14:26:59
|
Revision: 2586
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2586&view=rev
Author: lorenz_b
Date: 2011-01-05 14:26:53 +0000 (Wed, 05 Jan 2011)
Log Message:
-----------
Continued optimized NBR algorithm.
Added method to querytree, for finding nodes by ID.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/QueryTree.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-01-05 14:02:45 UTC (rev 2585)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-01-05 14:26:53 UTC (rev 2586)
@@ -281,17 +281,24 @@
neededGeneralisations = new ArrayList<QueryTree<N>>();
tree1 = queue.remove(0);
tmp = tree1;
- logger.info("Changes: " + tmp.getChanges());
+ if(logger.isInfoEnabled()){
+ logger.info("Changes: " + tmp.getChanges());
+ }
queryTree = tmp.getQueryTree();
- if(!coversNegativeTree(tmp.getQueryTree(), negTrees)){
- while(!coversNegativeTree(tmp.getQueryTree(), negTrees)){
- gens = getAllowedGeneralisations(tmp);
- tmp = gens.remove(0);
- queue.addAll(0, gens);
+ boolean coversNegTree = coversNegativeTree(tmp.getQueryTree(), negTrees);
+ while(!coversNegTree){
+ gens = getAllowedGeneralisations(tmp);
+ if(gens.isEmpty()){
+ break;
}
+ tmp = gens.remove(0);
+ queue.addAll(0, gens);
+ coversNegTree = coversNegativeTree(tmp.getQueryTree(), negTrees);
}
List<QueryTreeChange> sequence = genSequence(tree1, tmp);
- sequence.remove(sequence.size()-1);
+ if(coversNegTree){
+ sequence.remove(sequence.size()-1);
+ }
tree2 = applyGen(tree1.getQueryTree(), sequence);
SortedSet<String> foundResources = getResources(tree2);
foundResources.removeAll(knownResources);
@@ -304,6 +311,10 @@
foundResources.removeAll(knownResources);
} while(!foundResources.isEmpty());
return example;
+ } else {
+ if(logger.isInfoEnabled()){
+ logger.info("Query result contains no new resources. Trying next tree from queue...");
+ }
}
}
return null;
@@ -428,7 +439,9 @@
query = getSPARQLQuery(tree);//tree.toSPARQLQueryString();
query = getLimitedQuery(query);
- logger.info("Testing query\n" + query);
+ if(logger.isInfoEnabled()){
+ logger.info("Testing query\n" + query);
+ }
String result = cache.executeSelectQuery(endpoint, query);
ResultSetRewindable rs = SparqlQuery.convertJSONtoResultSet(result);
String uri;
Modified: trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java
===================================================================
--- trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java 2011-01-05 14:02:45 UTC (rev 2585)
+++ trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java 2011-01-05 14:26:53 UTC (rev 2586)
@@ -258,6 +258,8 @@
public void testAllowedGeneralisationsGeneration(){
QueryTree<String> tree = DBpediaExample.getPosExampleTrees().get(0);
NBR<String> nbrGen = new NBR<String>(null, null);
+ System.out.println(tree.getStringRepresentation());
+ System.out.println(tree.getNodeById(5));
List<GeneralisedQueryTree<String>> gens = nbrGen.getAllowedGeneralisations(new GeneralisedQueryTree<String>(tree));
GeneralisedQueryTree<String> genTree;
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/QueryTree.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/QueryTree.java 2011-01-05 14:02:45 UTC (rev 2585)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/QueryTree.java 2011-01-05 14:26:53 UTC (rev 2586)
@@ -45,6 +45,8 @@
int getId();
+ QueryTree<N> getNodeById(int nodeId);
+
boolean isLiteralNode();
void setLiteralNode(boolean isLiteralNode);
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java 2011-01-05 14:02:45 UTC (rev 2585)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java 2011-01-05 14:26:53 UTC (rev 2586)
@@ -106,6 +106,21 @@
return id;
}
+ public QueryTree<N> getNodeById(int nodeId){
+ QueryTree<N> node = null;
+ if(this.id == nodeId){
+ node = this;
+ } else {
+ for(QueryTree<N> child : children){
+ node = child.getNodeById(nodeId);
+ if(node != null){
+ return node;
+ }
+ }
+ }
+ return node;
+ }
+
@Override
public boolean isLiteralNode() {
return isLiteralNode;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2011-01-12 13:43:45
|
Revision: 2606
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2606&view=rev
Author: jenslehmann
Date: 2011-01-12 13:43:38 +0000 (Wed, 12 Jan 2011)
Log Message:
-----------
namespaces in logging positive examples
Modified Paths:
--------------
trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java
trunk/components-core/src/main/java/org/dllearner/utilities/Helper.java
Modified: trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java
===================================================================
--- trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java 2011-01-12 13:22:36 UTC (rev 2605)
+++ trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java 2011-01-12 13:43:38 UTC (rev 2606)
@@ -5,8 +5,10 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -33,6 +35,7 @@
import org.dllearner.sparqlquerygenerator.operations.nbr.strategy.GreedyNBRStrategy;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator.Strategy;
+import org.dllearner.utilities.Helper;
import org.junit.Test;
import com.hp.hpl.jena.query.QuerySolution;
@@ -154,6 +157,11 @@
@Test
public void optimisedTest(){
+ // basic setup
+ String baseURI = "http://dbpedia.org/resource/";
+ Map<String,String> prefixes = new HashMap<String,String>();
+ prefixes.put("dbo","http://dbpedia.org/ontology/");
+
try {
SimpleLayout layout = new SimpleLayout();
ConsoleAppender consoleAppender = new ConsoleAppender(layout);
@@ -239,7 +247,7 @@
negTrees.add(tree);
// logger.debug("Pos trees:\n " + printTrees(posTrees));
- logger.info("Positive examples: " + posExamples);
+ logger.info("Positive examples: " + Helper.getAbbreviatedList(posExamples, baseURI, prefixes));
QueryTree<String> lgg = lggGen.getLGG(posTrees);
@@ -263,7 +271,7 @@
logger.info("Found new negative example " + uri);
negTrees.add(tree);
}
- logger.info("Positive examples: " + posExamples);
+ logger.info("Positive examples: " + Helper.getAbbreviatedList(posExamples, baseURI, prefixes));
// logger.debug("Pos trees:\n " + printTrees(posTrees));
example = nbrGen.getQuestionOptimised(lgg, negTrees, knownResources);
learnedQuery = nbrGen.getQuery();
Modified: trunk/components-core/src/main/java/org/dllearner/utilities/Helper.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/utilities/Helper.java 2011-01-12 13:22:36 UTC (rev 2605)
+++ trunk/components-core/src/main/java/org/dllearner/utilities/Helper.java 2011-01-12 13:43:38 UTC (rev 2606)
@@ -135,6 +135,30 @@
}
}
+ /**
+ * Transforms a list of URIs into their abbreviated version.
+ * @see #getAbbreviatedString(String, String, Map)
+ * @param list List of URIs.
+ * @param baseURI The base uri (ignored if null).
+ * @param prefixes A prefix map (ignored if null), where each entry contains a
+ * short string e.g. ns1 as key and the corresponding uri as
+ * value.
+ * @return A list with shortened URIs.
+ */
+ public static String getAbbreviatedList(List<String> list, String baseURI,
+ Map<String, String> prefixes) {
+ StringBuffer str = new StringBuffer("[");
+ Iterator<String> it = list.iterator(); // easier to implement using an iterator than foreach
+ while(it.hasNext()) {
+ str.append(getAbbreviatedString(it.next(),baseURI,prefixes));
+ if(it.hasNext()) {
+ str.append(", ");
+ }
+ }
+ str.append("]");
+ return str.toString();
+ }
+
public static String prettyPrintNanoSeconds(long nanoSeconds) {
return prettyPrintNanoSeconds(nanoSeconds, false, false);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2011-01-12 14:01:15
|
Revision: 2607
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2607&view=rev
Author: jenslehmann
Date: 2011-01-12 14:01:09 +0000 (Wed, 12 Jan 2011)
Log Message:
-----------
some changes to observe LGG
Modified Paths:
--------------
trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java
trunk/components-core/src/main/java/org/dllearner/utilities/Helper.java
Modified: trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java
===================================================================
--- trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java 2011-01-12 13:43:38 UTC (rev 2606)
+++ trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java 2011-01-12 14:01:09 UTC (rev 2607)
@@ -247,7 +247,7 @@
negTrees.add(tree);
// logger.debug("Pos trees:\n " + printTrees(posTrees));
- logger.info("Positive examples: " + Helper.getAbbreviatedList(posExamples, baseURI, prefixes));
+ logger.info("Positive examples: " + Helper.getAbbreviatedCollection(posExamples, baseURI, prefixes));
QueryTree<String> lgg = lggGen.getLGG(posTrees);
@@ -256,6 +256,7 @@
while(!isEquivalentQuery(targetResources, learnedQuery, endpoint, cache)){
logger.info("#Resources in LGG: " + getResultCount(lgg.toSPARQLQueryString(), endpoint, cache));
+// logger.info("#Resources in LGG: " + Helper.getAbbreviatedCollection(getResult(lgg.toSPARQLQueryString(), endpoint, cache),baseURI,prefixes));
logger.info("#Resources in POST-LGG: " + getResultCount(nbrGen.getPostLGG().toSPARQLQueryString(), endpoint, cache));
uri = example.getURI();
knownResources.add(uri);
@@ -271,7 +272,7 @@
logger.info("Found new negative example " + uri);
negTrees.add(tree);
}
- logger.info("Positive examples: " + Helper.getAbbreviatedList(posExamples, baseURI, prefixes));
+ logger.info("Positive examples: " + Helper.getAbbreviatedCollection(posExamples, baseURI, prefixes));
// logger.debug("Pos trees:\n " + printTrees(posTrees));
example = nbrGen.getQuestionOptimised(lgg, negTrees, knownResources);
learnedQuery = nbrGen.getQuery();
@@ -301,7 +302,7 @@
}
- private int getResultCount(String query, SparqlEndpoint endpoint, ExtractionDBCache cache){
+ private SortedSet<String> getResult(String query, SparqlEndpoint endpoint, ExtractionDBCache cache){
com.hp.hpl.jena.query.ResultSet rs = SparqlQuery.convertJSONtoResultSet(cache.executeSelectQuery(endpoint, getDistinctQuery(query)));
SortedSet<String> resources = new TreeSet<String>();
QuerySolution qs;
@@ -311,7 +312,11 @@
resources.add(qs.get("x0").asResource().getURI());
}
}
- return resources.size();
+ return resources;
+ }
+
+ private int getResultCount(String query, SparqlEndpoint endpoint, ExtractionDBCache cache){
+ return getResult(query, endpoint, cache).size();
}
private boolean isEquivalentQuery(SortedSet<String> originalResources, String query, SparqlEndpoint endpoint, ExtractionDBCache cache){
Modified: trunk/components-core/src/main/java/org/dllearner/utilities/Helper.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/utilities/Helper.java 2011-01-12 13:43:38 UTC (rev 2606)
+++ trunk/components-core/src/main/java/org/dllearner/utilities/Helper.java 2011-01-12 14:01:09 UTC (rev 2607)
@@ -19,6 +19,7 @@
*/
package org.dllearner.utilities;
+import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -145,7 +146,7 @@
* value.
* @return A list with shortened URIs.
*/
- public static String getAbbreviatedList(List<String> list, String baseURI,
+ public static String getAbbreviatedCollection(Collection<String> list, String baseURI,
Map<String, String> prefixes) {
StringBuffer str = new StringBuffer("[");
Iterator<String> it = list.iterator(); // easier to implement using an iterator than foreach
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-01-13 16:09:27
|
Revision: 2611
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2611&view=rev
Author: lorenz_b
Date: 2011-01-13 16:09:20 +0000 (Thu, 13 Jan 2011)
Log Message:
-----------
Continued optimized NBR algorithm.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/PostLGG.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/SPARQLEndpointEx.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
Added Paths:
-----------
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/QueryTreeConverter.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/TreeHelper.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-01-12 15:26:27 UTC (rev 2610)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-01-13 16:09:20 UTC (rev 2611)
@@ -17,17 +17,18 @@
import org.apache.log4j.Logger;
import org.dllearner.autosparql.client.model.Example;
import org.dllearner.autosparql.server.QueryTreeChange.ChangeType;
+import org.dllearner.autosparql.server.util.QueryTreeConverter;
import org.dllearner.autosparql.server.util.SPARQLEndpointEx;
+import org.dllearner.autosparql.server.util.TreeHelper;
import org.dllearner.kb.sparql.ExtractionDBCache;
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.kb.sparql.SparqlQuery;
-import org.dllearner.sparqlquerygenerator.QueryTreeFactory;
+import org.dllearner.sparqlquerygenerator.cache.ModelCache;
+import org.dllearner.sparqlquerygenerator.cache.QueryTreeCache;
import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
import org.dllearner.sparqlquerygenerator.datastructures.impl.QueryTreeImpl;
-import org.dllearner.sparqlquerygenerator.impl.QueryTreeFactoryImpl;
import org.dllearner.sparqlquerygenerator.util.Filter;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator;
-import org.dllearner.sparqlquerygenerator.util.ModelGenerator.Strategy;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSetRewindable;
@@ -36,9 +37,11 @@
public class NBR<N> {
private ExtractionDBCache cache;
- private SparqlEndpoint endpoint;
- private QueryTreeFactory<String> treeFactory;
+ private SPARQLEndpointEx endpoint;
private ModelGenerator modelGen;
+ private ModelCache modelCache;
+ private QueryTreeCache treeCache;
+
private String query;
private int limit;
@@ -46,16 +49,19 @@
private QueryTree<N> lgg;
private QueryTree<N> postLGG;
+
+
private LastQueryTreeChangeComparator comparator = new LastQueryTreeChangeComparator();
private static final Logger logger = Logger.getLogger(NBR.class);
- public NBR(SparqlEndpoint endpoint, ExtractionDBCache cache){
+ public NBR(SPARQLEndpointEx endpoint, ExtractionDBCache cache){
this.endpoint = endpoint;
this.cache = cache;
modelGen = new ModelGenerator(endpoint, new HashSet<String>(((SPARQLEndpointEx)endpoint).getPredicateFilters()), cache);
- treeFactory = new QueryTreeFactoryImpl();
+ modelCache = new ModelCache(modelGen);
+ treeCache = new QueryTreeCache();
}
public Example makeNBR(List<String> resources, QueryTree<N> lgg, List<QueryTree<N>> negTrees){
@@ -288,13 +294,13 @@
this.lgg = lgg;
logger.info("Computing next question...");
postLGG = getFilteredTree(lgg);
- PostLGG<N> postGen = new PostLGG<N>();
+ PostLGG<N> postGen = new PostLGG<N>((SPARQLEndpointEx) endpoint);
postGen.simplifyTree(postLGG, negTrees);
// logger.debug("Starting generalisation with tree:\n" + postLGG.getStringRepresentation());
limit = knownResources.size();
List<GeneralisedQueryTree<N>> queue = getAllowedGeneralisations(new GeneralisedQueryTree<N>(postLGG));
logger.debug(getQueueLogInfo(queue));
-// logger.debug("New: " + getAllowedGeneralisationsSortedByMatrix(new GeneralisedQueryTree<N>(postLGG)));
+ logger.debug("New: " + getAllowedGeneralisationsSortedByMatrix(new GeneralisedQueryTree<N>(postLGG), negTrees));
GeneralisedQueryTree<N> tree1;
QueryTree<N> tree2;
@@ -307,11 +313,13 @@
logger.debug("Selecting first tree from queue");
tree1 = queue.remove(0);
tmp = tree1;
+
if(logger.isDebugEnabled()){
logger.debug("Changes: " + tmp.getChanges());
}
queryTree = tmp.getQueryTree();
boolean coversNegTree = coversNegativeTree(tmp.getQueryTree(), negTrees);
+ neededGeneralisations.add(tmp.getQueryTree());
logger.debug("covers negative tree: " + coversNegTree);
while(!coversNegTree){
gens = getAllowedGeneralisationsSorted(tmp);
@@ -368,8 +376,8 @@
}
private QueryTree<N> getQueryTree(String resource){
- Model model = modelGen.createModel(resource, Strategy.CHUNKS, 2);
- QueryTree<String> tree = treeFactory.getQueryTree(resource, model);
+ Model model = modelCache.getModel(resource);
+ QueryTree<String> tree = treeCache.getQueryTree(resource, model);
return getFilteredTree((QueryTree<N>) tree);
}
@@ -465,23 +473,64 @@
return nodes;
}
- private List<QueryTreeChange> getAllowedGeneralisationsSortedByMatrix(GeneralisedQueryTree<N> tree){
- List<QueryTreeChange> changes = new ArrayList<QueryTreeChange>();
+ private List<GeneralisedQueryTree<N>> getAllowedGeneralisationsSortedByMatrix(GeneralisedQueryTree<N> tree, List<QueryTree<N>> negTrees){
+ Map<QueryTree<N>, List<Integer>> matrix = createMatrix(tree.getQueryTree(), negTrees);
+ List<GeneralisedQueryTree<N>> gens = new ArrayList<GeneralisedQueryTree<N>>();
+ System.err.println(TreeHelper.getAbbreviatedTreeRepresentation(tree.getQueryTree(), endpoint.getBaseURI(), endpoint.getPrefixes()));
+ System.err.println(TreeHelper.getAbbreviatedTreeRepresentation(negTrees.get(0), endpoint.getBaseURI(), endpoint.getPrefixes()));
+
+ Map<GeneralisedQueryTree<N>, Integer> genTree2Sum = new HashMap<GeneralisedQueryTree<N>, Integer>();
+
+ QueryTree<N> queryTree = tree.getQueryTree();
QueryTreeChange lastChange = tree.getLastChange();
+ List<QueryTreeChange> changes = tree.getChanges();
+ GeneralisedQueryTree<N> genTree;
+ N label;
+ Object edge;
+ QueryTree<N> parent;
+ boolean isLiteralNode;
for(QueryTree<N> node : getPossibleNodes2Change(tree.getQueryTree())){
+ label = node.getUserObject();
+ parent = node.getParent();
+ isLiteralNode = node.isLiteralNode();
+ edge = parent.getEdge(node);
if(lastChange.getType() == ChangeType.REMOVE_NODE){
if(node.getUserObject().equals("?") && node.getId() < lastChange.getNodeId()){
- changes.add(new QueryTreeChange(node.getId(), ChangeType.REMOVE_NODE));
+ int pos = parent.removeChild((QueryTreeImpl<N>) node);
+ genTree = new GeneralisedQueryTree<N>(new QueryTreeImpl<N>(queryTree));
+ genTree.addChanges(changes);
+ genTree.addChange(new QueryTreeChange(node.getId(), ChangeType.REMOVE_NODE));
+ genTree2Sum.put(genTree, sum(matrix.get(node)));
+ parent.addChild((QueryTreeImpl<N>) node, edge, pos);
}
} else {
if(node.getUserObject().equals("?")){
- changes.add(new QueryTreeChange(node.getId(), ChangeType.REMOVE_NODE));
+ int pos = parent.removeChild((QueryTreeImpl<N>) node);
+ genTree = new GeneralisedQueryTree<N>(new QueryTreeImpl<N>(queryTree));
+ genTree.addChanges(changes);
+ genTree.addChange(new QueryTreeChange(node.getId(), ChangeType.REMOVE_NODE));
+ genTree2Sum.put(genTree, sum(matrix.get(node)));
+ parent.addChild((QueryTreeImpl<N>) node, edge, pos);
} else if(lastChange.getNodeId() < node.getId()){
- changes.add(new QueryTreeChange(node.getId(), ChangeType.REPLACE_LABEL));
+ node.setUserObject((N) "?");
+ node.setVarNode(true);
+ genTree = new GeneralisedQueryTree<N>(new QueryTreeImpl<N>(queryTree));
+ genTree.addChanges(changes);
+ genTree.addChange(new QueryTreeChange(node.getId(), ChangeType.REPLACE_LABEL));
+ genTree2Sum.put(genTree, sum(matrix.get(node)));
+ node.setUserObject(label);
+ node.setLiteralNode(isLiteralNode);
+ node.setResourceNode(!isLiteralNode);
}
}
}
- return changes;
+ List<Entry<GeneralisedQueryTree<N>, Integer>> entries = new ArrayList<Entry<GeneralisedQueryTree<N>,Integer>>(genTree2Sum.entrySet());
+ Collections.sort(entries, new NegativeTreeOccurenceComparator());
+ for(Entry<GeneralisedQueryTree<N>, Integer> e : entries){
+ gens.add(e.getKey());
+ System.out.println(e.getKey().getChanges());
+ }
+ return gens;
}
private List<GeneralisedQueryTree<N>> getAllowedGeneralisationsSorted(GeneralisedQueryTree<N> tree){
@@ -597,6 +646,7 @@
SortedSet<String> resources = new TreeSet<String>();
query = tree.toSPARQLQueryString();
+// logger.info(QueryTreeConverter.getSPARQLQuery(tree, endpoint.getBaseURI(), endpoint.getPrefixes()));
query = getDistinctQuery(query);
if(logger.isDebugEnabled()){
logger.debug("Testing query\n" + getLimitedQuery(query, limit, offset));
@@ -617,7 +667,7 @@
private String getNewResource(QueryTree<N> tree, List<String> knownResources){
int i = 0;
int chunkSize = 10;
- SortedSet<String> foundResources = getResources(tree, 10, chunkSize * i);
+ SortedSet<String> foundResources = getResources(tree, chunkSize, chunkSize * i);
foundResources.removeAll(knownResources);
QueryTree<N> newTree;
while(!foundResources.isEmpty()){
@@ -629,7 +679,7 @@
}
}
i++;
- foundResources = getResources(tree, 10, chunkSize * i);
+ foundResources = getResources(tree, chunkSize, chunkSize * i);
foundResources.removeAll(knownResources);
}
logger.debug("Found no resource which would modify the LGG");
@@ -864,5 +914,35 @@
}
}
+
+ class NegativeTreeOccurenceComparator implements Comparator<Entry<GeneralisedQueryTree<N>,Integer>>{
+ @Override
+ public int compare(Entry<GeneralisedQueryTree<N>, Integer> entry1,
+ Entry<GeneralisedQueryTree<N>, Integer> entry2) {
+ int sum1 = entry1.getValue();
+ int sum2 = entry2.getValue();
+ if(sum1 == sum2){
+ QueryTreeChange change1 = entry1.getKey().getLastChange();
+ QueryTreeChange change2 = entry2.getKey().getLastChange();
+ if(change1.getType()==ChangeType.REPLACE_LABEL){
+ if(change2.getType()==ChangeType.REPLACE_LABEL){
+ return change1.getNodeId() - change2.getNodeId();
+ } else {
+ return 1;
+ }
+ } else {
+ if(change2.getType()==ChangeType.REPLACE_LABEL){
+ return 1;
+ } else {
+ return change2.getNodeId() - change1.getNodeId();
+ }
+ }
+ } else {
+ return sum2-sum1;
+ }
+ }
+
+ }
+
}
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/PostLGG.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/PostLGG.java 2011-01-12 15:26:27 UTC (rev 2610)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/PostLGG.java 2011-01-13 16:09:20 UTC (rev 2611)
@@ -3,8 +3,11 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.apache.log4j.Logger;
+import org.dllearner.autosparql.server.util.SPARQLEndpointEx;
+import org.dllearner.autosparql.server.util.TreeHelper;
import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
import org.dllearner.sparqlquerygenerator.datastructures.impl.QueryTreeImpl;
@@ -12,11 +15,17 @@
private static final Logger logger = Logger.getLogger(PostLGG.class);
+ private SPARQLEndpointEx endpoint;
+
+ public PostLGG(SPARQLEndpointEx endpoint){
+ this.endpoint = endpoint;
+ }
+
public void simplifyTree(QueryTree<N> tree, List<QueryTree<N>> negTrees){
if(logger.isDebugEnabled()){
logger.debug("Making post LGG simplification");
- logger.debug("LGG:\n" + tree.getStringRepresentation());
+ logger.debug("LGG:\n" + TreeHelper.getAbbreviatedTreeRepresentation(tree, endpoint.getBaseURI(), endpoint.getPrefixes()));
// int i = 1;
// for(QueryTree<N> negTree : negTrees){
// logger.debug("Neg tree (" + i++ + "/" + negTrees.size() +"):\n" + negTree.getStringRepresentation());
@@ -48,7 +57,7 @@
}
}
if(logger.isDebugEnabled()){
- logger.debug("Pruned tree:\n" + tree.getStringRepresentation());
+ logger.debug("Pruned tree:\n" + TreeHelper.getAbbreviatedTreeRepresentation(tree, endpoint.getBaseURI(), endpoint.getPrefixes()));
}
}
Added: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/QueryTreeConverter.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/QueryTreeConverter.java (rev 0)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/QueryTreeConverter.java 2011-01-13 16:09:20 UTC (rev 2611)
@@ -0,0 +1,92 @@
+package org.dllearner.autosparql.server.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
+
+public class QueryTreeConverter {
+
+ private static int cnt;
+
+ public static String getSPARQLQuery(QueryTree tree, String baseURI, Map<String, String> prefixes){
+ if(tree.getChildCount() == 0){
+ return "SELECT ?x0 WHERE {?x0 ?y ?z.}";
+ }
+ cnt = 0;
+ Map<String, String> usedPrefixes = new HashMap<String, String>();
+ StringBuilder sb = new StringBuilder();
+ sb.append("SELECT ?x0 WHERE {\n");
+ buildSPARQLQueryString(tree, sb, prefixes, usedPrefixes);
+ sb.append("}");
+
+ return sb.toString();
+ }
+
+ private static void buildSPARQLQueryString(QueryTree tree, StringBuilder sb,
+ Map<String, String> prefixes, Map<String, String> usedPrefixes){
+ String subject = (String) tree.getUserObject();
+ if(tree.getUserObject().equals("?")){
+ subject = "?x" + cnt++;
+ } else {
+ boolean replaced = false;
+ for(Entry<String, String> entry : prefixes.entrySet()){
+ if(subject.startsWith(entry.getValue())){
+ replaced = true;
+ subject = entry.getKey() + ":" + subject.replace(entry.getValue(), "");
+ usedPrefixes.put(entry.getKey(), entry.getValue());
+ break;
+ }
+ }
+ if(!replaced){
+ subject = "<" + subject + ">";
+ }
+ }
+ String predicate;
+ String object;
+ if(!tree.isLeaf()){
+ for(Object child : tree.getChildren()){
+ predicate = (String) tree.getEdge((QueryTree) child);
+
+ boolean replaced = false;
+ for(Entry<String, String> entry : prefixes.entrySet()){
+ if(predicate.startsWith(entry.getValue())){
+ replaced = true;
+ predicate = entry.getKey() + ":" + predicate.replace(entry.getValue(), "");
+ usedPrefixes.put(entry.getKey(), entry.getValue());
+ break;
+ }
+ }
+ if(!replaced){
+ predicate = "<" + predicate + ">";
+ }
+
+ object = (String) ((QueryTree) child).getUserObject();
+ boolean objectIsResource = !object.equals("?");
+ if(!objectIsResource){
+ object = "?x" + cnt;
+ } else if(((String)object).startsWith("http://")){
+ replaced = false;
+ for(Entry<String, String> entry : prefixes.entrySet()){
+ if(object.startsWith(entry.getValue())){
+ replaced = true;
+ object = entry.getKey() + ":" + object.replace(entry.getValue(), "");
+ usedPrefixes.put(entry.getKey(), entry.getValue());
+ break;
+ }
+ }
+ if(!replaced){
+ object = "<" + object + ">";
+ }
+
+ }
+ sb.append(subject).append(" ").append(predicate).append(" ").append(object).append(".\n");
+ if(!objectIsResource){
+ buildSPARQLQueryString((QueryTree) child, sb, prefixes, usedPrefixes);
+ }
+ }
+ }
+ }
+
+}
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/SPARQLEndpointEx.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/SPARQLEndpointEx.java 2011-01-12 15:26:27 UTC (rev 2610)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/SPARQLEndpointEx.java 2011-01-13 16:09:20 UTC (rev 2611)
@@ -2,6 +2,7 @@
import java.net.URL;
import java.util.List;
+import java.util.Map;
import org.dllearner.kb.sparql.SparqlEndpoint;
@@ -9,6 +10,8 @@
private String label;
private List<String> predicateFilters;
private String prefix;
+ private String baseURI;
+ private Map<String, String> prefixes;
public SPARQLEndpointEx(URL u, List<String> defaultGraphURIs,
List<String> namedGraphURIs, String label, String prefix, List<String> predicateFilters) {
@@ -19,6 +22,24 @@
this.predicateFilters = predicateFilters;
}
+ public SPARQLEndpointEx(URL u, List<String> defaultGraphURIs,
+ List<String> namedGraphURIs, String label, String baseURI, Map<String, String> prefixes, List<String> predicateFilters) {
+ super(u, defaultGraphURIs, namedGraphURIs);
+
+ this.label = label;
+ this.baseURI = baseURI;
+ this.prefixes = prefixes;
+ this.predicateFilters = predicateFilters;
+ }
+
+ public SPARQLEndpointEx(SparqlEndpoint endpoint, String label, String prefix, List<String> predicateFilters) {
+ super(endpoint.getURL(), endpoint.getDefaultGraphURIs(), endpoint.getNamedGraphURIs());
+
+ this.label = label;
+ this.prefix = prefix;
+ this.predicateFilters = predicateFilters;
+ }
+
public String getLabel(){
return label;
}
@@ -27,6 +48,14 @@
return prefix;
}
+ public String getBaseURI(){
+ return baseURI;
+ }
+
+ public Map<String, String> getPrefixes(){
+ return prefixes;
+ }
+
public List<String> getPredicateFilters(){
return predicateFilters;
}
Added: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/TreeHelper.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/TreeHelper.java (rev 0)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/util/TreeHelper.java 2011-01-13 16:09:20 UTC (rev 2611)
@@ -0,0 +1,23 @@
+package org.dllearner.autosparql.server.util;
+
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
+
+public class TreeHelper {
+
+ public static String getAbbreviatedTreeRepresentation(QueryTree tree,
+ String baseURI, Map<String, String> prefixes) {
+ String treeString = tree.getStringRepresentation();
+ if (baseURI != null) {
+ treeString = treeString.replace(baseURI, "");
+ }
+ if(prefixes != null){
+ for (Entry<String, String> prefix : prefixes.entrySet()) {
+ treeString = treeString.replace(prefix.getValue(), prefix.getKey()+ ":");
+ }
+ }
+ return treeString;
+ }
+}
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-01-12 15:26:27 UTC (rev 2610)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-01-13 16:09:20 UTC (rev 2611)
@@ -20,13 +20,14 @@
package org.dllearner.sparqlquerygenerator.impl;
import java.util.Comparator;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.dllearner.sparqlquerygenerator.QueryTreeFactory;
import org.dllearner.sparqlquerygenerator.datastructures.impl.QueryTreeImpl;
@@ -46,9 +47,11 @@
private int nodeId;
private Comparator<Statement> comparator;
+ private Set<String> predicateFilters;
public QueryTreeFactoryImpl(){
comparator = new StatementComparator();
+ predicateFilters = new HashSet<String>(Filter.getAllFilterProperties());
}
@Override
@@ -94,7 +97,7 @@
if(resource2Statements.containsKey(tree.getUserObject())){
QueryTreeImpl<String> subTree;
for(Statement st : resource2Statements.get(tree.getUserObject())){
- if(Filter.getAllFilterProperties().contains(st.getPredicate().toString())){
+ if(predicateFilters.contains(st.getPredicate().toString())){
continue;
}
if(st.getObject().isLiteral()){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2011-01-18 13:30:28
|
Revision: 2620
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2620&view=rev
Author: jenslehmann
Date: 2011-01-18 13:30:21 +0000 (Tue, 18 Jan 2011)
Log Message:
-----------
fixed PDB2RDF dependencies
Modified Paths:
--------------
trunk/pom.xml
trunk/scripts/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-01-18 12:25:29 UTC (rev 2619)
+++ trunk/pom.xml 2011-01-18 13:30:21 UTC (rev 2620)
@@ -341,11 +341,16 @@
<artifactId>guava</artifactId>
<version>r07</version>
</dependency>
- <dependency>
- <groupId>com.dumontierlab</groupId>
- <artifactId>pdb2rdf-parser</artifactId>
- <version>0.0.8</version>
- </dependency>
+ <dependency>
+ <groupId>com.dumontierlab</groupId>
+ <artifactId>pdb2rdf-parser</artifactId>
+ <version>0.0.9</version>
+ </dependency>
+ <dependency>
+ <groupId>com.dumontierlab</groupId>
+ <artifactId>pdb2rdf-cli</artifactId>
+ <version>0.0.9</version>
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -412,7 +417,7 @@
<repository>
<id>semanticscience.org</id>
<name>Semanticscience projects</name>
- <url>http://s1.semanticscience.org:8080/nexus/content/groups/public</url>
+ <url>http://s1.semanticscience.org:8080/nexus/content/groups/public/</url>
</repository>
</repositories>
Modified: trunk/scripts/pom.xml
===================================================================
--- trunk/scripts/pom.xml 2011-01-18 12:25:29 UTC (rev 2619)
+++ trunk/scripts/pom.xml 2011-01-18 13:30:21 UTC (rev 2620)
@@ -36,6 +36,14 @@
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>com.dumontierlab</groupId>
+ <artifactId>pdb2rdf-parser</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.dumontierlab</groupId>
+ <artifactId>pdb2rdf-cli</artifactId>
+ </dependency>
+
</dependencies>
</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-01-18 16:27:00
|
Revision: 2622
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2622&view=rev
Author: lorenz_b
Date: 2011-01-18 16:26:54 +0000 (Tue, 18 Jan 2011)
Log Message:
-----------
Finally implemented reverse POST-LGG.
Added method to renumber the LGG.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-01-18 13:31:35 UTC (rev 2621)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-01-18 16:26:54 UTC (rev 2622)
@@ -57,6 +57,7 @@
private QueryTree<N> lgg;
private QueryTree<N> postLGG;
private List<QueryTree<N>> negTrees;
+ private List<Integer> determiningNodeIds;
@@ -153,6 +154,25 @@
return matrix;
}
+ private List<Integer> getDeterminingNodeIds(QueryTree<N> lgg, List<QueryTree<N>> trees){
+ List<Integer> nodeIds = new ArrayList<Integer>();
+
+ boolean parentIsResource = false;
+ boolean childIsResource = false;
+ for(QueryTree<N> child : lgg.getChildren()){
+ parentIsResource = !child.getParent().getUserObject().equals("?");
+ childIsResource = !child.getUserObject().equals("?");
+ if(parentIsResource && childIsResource && hasAlwaysSameParent(child, trees)){
+ nodeIds.add(child.getId());
+ }
+ if(!child.isLeaf()){
+ nodeIds.addAll(getDeterminingNodeIds(child, trees));
+ }
+ }
+
+ return nodeIds;
+ }
+
public String getQuery(){
return query;
}
@@ -311,8 +331,10 @@
startTime = System.currentTimeMillis();
this.lgg = lgg;
this.negTrees = negTrees;
- System.err.println(negTrees.get(0).getStringRepresentation());
+ determiningNodeIds = getDeterminingNodeIds(lgg, negTrees);
+// System.err.println(negTrees.get(0).getStringRepresentation());
logger.info("Computing next question...");
+ logger.info("LGG:\n" + lgg.getStringRepresentation());
postLGG = getFilteredTree(lgg);
PostLGG<N> postGen = new PostLGG<N>((SPARQLEndpointEx) endpoint);
postGen.simplifyTree(postLGG, negTrees);
@@ -414,7 +436,7 @@
// perform SPARQL query
// QueryTree<N> t = getNewResource(trees.get(testIndex), knownResources);
- String t = getNewResource(trees.get(testIndex), knownResources);;
+ String t = null;
try {
t = getNewResource(trees.get(testIndex), knownResources);
} catch (HTTPException e) {
@@ -599,10 +621,12 @@
gens.add(genTree);
parent.addChild((QueryTreeImpl<N>) child, edge, pos);
} else {
- System.out.println("resource: " + label);
+ Map<Integer, N> node2Label = new HashMap<Integer, N>();
for(QueryTree<N> c : child.getChildren()){
- System.out.println("child: " + c.getUserObject());
- System.out.println(hasAlwaysSameParent(c, negTrees));
+ if(determiningNodeIds.contains(c.getId())){
+ node2Label.put(Integer.valueOf(c.getId()), c.getUserObject());
+ c.setUserObject((N)"?");
+ }
}
child.setUserObject((N) "?");
child.setVarNode(true);
@@ -613,6 +637,12 @@
child.setUserObject(label);
child.setLiteralNode(isLiteralNode);
child.setResourceNode(!isLiteralNode);
+ for(QueryTree<N> c : child.getChildren()){
+ N oldLabel = node2Label.get(c.getId());
+ if(oldLabel != null){
+ c.setUserObject(oldLabel);
+ }
+ }
}
// child.setUserObject((N) "?");
// child.setVarNode(true);
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java 2011-01-18 13:31:35 UTC (rev 2621)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java 2011-01-18 16:26:54 UTC (rev 2622)
@@ -40,6 +40,7 @@
public class LGGGeneratorImpl<N> implements LGGGenerator<N>{
private Logger logger = Logger.getLogger(LGGGeneratorImpl.class);
+ private int nodeId;
@Override
public QueryTree<N> getLGG(QueryTree<N> tree1, QueryTree<N> tree2) {
@@ -49,10 +50,12 @@
@Override
public QueryTree<N> getLGG(QueryTree<N> tree1, QueryTree<N> tree2,
boolean learnFilters) {
+ nodeId = 0;
Monitor mon = MonitorFactory.getTimeMonitor("LGG");
mon.start();
QueryTree<N> lgg = computeLGG(tree1, tree2, learnFilters);
mon.stop();
+ addNumbering(lgg);
return lgg;
}
@@ -63,6 +66,7 @@
@Override
public QueryTree<N> getLGG(List<QueryTree<N>> trees, boolean learnFilters) {
+ nodeId = 0;
List<QueryTree<N>> treeList = new ArrayList<QueryTree<N>>(trees);
if(logger.isInfoEnabled()){
@@ -103,7 +107,7 @@
logger.info(lgg.getStringRepresentation());
}
mon.stop();
-
+ addNumbering(lgg);
return lgg;
}
@@ -193,5 +197,12 @@
}
return lgg;
}
+
+ private void addNumbering(QueryTree<N> tree){
+ tree.setId(nodeId++);
+ for(QueryTree<N> child : tree.getChildren()){
+ addNumbering(child);
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-01-19 09:15:09
|
Revision: 2625
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2625&view=rev
Author: lorenz_b
Date: 2011-01-19 09:15:03 +0000 (Wed, 19 Jan 2011)
Log Message:
-----------
Added method to limit equal edges to leaf nodes with same edge and where leaf node is '?'.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-01-18 21:04:16 UTC (rev 2624)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-01-19 09:15:03 UTC (rev 2625)
@@ -9,6 +9,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
@@ -40,7 +41,7 @@
private volatile boolean stop = false;
private boolean isRunning;
- private int maxExecutionTimeInSeconds = 10;
+ private int maxExecutionTimeInSeconds = 1000;
private long startTime;
private ExtractionDBCache selectCache;
@@ -334,7 +335,6 @@
determiningNodeIds = getDeterminingNodeIds(lgg, negTrees);
// System.err.println(negTrees.get(0).getStringRepresentation());
logger.info("Computing next question...");
- logger.info("LGG:\n" + lgg.getStringRepresentation());
postLGG = getFilteredTree(lgg);
PostLGG<N> postGen = new PostLGG<N>((SPARQLEndpointEx) endpoint);
postGen.simplifyTree(postLGG, negTrees);
@@ -750,9 +750,8 @@
private SortedSet<String> getResources(QueryTree<N> tree, int limit, int offset){
SortedSet<String> resources = new TreeSet<String>();
-
+ limitEqualEdgesToLeafs(tree, 1);
query = tree.toSPARQLQueryString();
-// logger.info(QueryTreeConverter.getSPARQLQuery(tree, endpoint.getBaseURI(), endpoint.getPrefixes()));
query = getDistinctQuery(query);
if(logger.isDebugEnabled()){
logger.debug("Testing query\n" + getLimitedQuery(query, limit, offset));
@@ -973,6 +972,31 @@
}
+ private void limitEqualEdgesToLeafs(QueryTree<N> tree, int maxEqualEdgeCount){
+ Set<QueryTree<N>> parents = new HashSet<QueryTree<N>>();
+ for(QueryTree<N> leaf : tree.getLeafs()){
+ if(leaf.getUserObject().equals("?")){
+ parents.add(leaf.getParent());
+ }
+ }
+ for(QueryTree<N> parent : parents){
+ for(Object edge : parent.getEdges()){
+ int cnt = 0;
+ for(QueryTree<N> child : parent.getChildren(edge)){
+ if(child.getUserObject().equals("?")){
+ if(child.isLeaf()){
+ cnt++;
+ if(cnt>maxEqualEdgeCount){
+ parent.removeChild((QueryTreeImpl<N>) child);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
public void stop(){
stop = true;
}
Modified: trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java
===================================================================
--- trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java 2011-01-18 21:04:16 UTC (rev 2624)
+++ trunk/autosparql/src/test/java/org/dllearner/autosparql/server/NBRTest.java 2011-01-19 09:15:03 UTC (rev 2625)
@@ -447,6 +447,49 @@
}
}
+ @Test
+ public void testLGG(){
+ try {
+ ExtractionDBCache constructCache = new ExtractionDBCache(CONSTRUCT_CACHE_DIR);
+ List<String> predicateFilters = new ArrayList<String>();
+ SPARQLEndpointEx endpoint = new SPARQLEndpointEx(new URL("http://db0.aksw.org:8999/sparql"),
+ Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList(), null, null, predicateFilters);
+ predicateFilters.add("http://dbpedia.org/ontology/wikiPageWikiLink");
+ predicateFilters.add("http://dbpedia.org/property/wikiPageUsesTemplate");
+
+ ModelGenerator modelGen = new ModelGenerator(endpoint, new HashSet<String>(predicateFilters), constructCache);
+ QueryTreeFactory<String> treeFactory = new QueryTreeFactoryImpl();
+ LGGGenerator<String> lggGen = new LGGGeneratorImpl<String>();
+
+ List<QueryTree<String>> posTrees = new ArrayList<QueryTree<String>>();
+
+ String uri = "http://dbpedia.org/resource/%C3%80_double_tour";
+ Model model = modelGen.createModel(uri, Strategy.CHUNKS, 2);
+ QueryTree<String> tree = treeFactory.getQueryTree(uri, model);
+ tree = getFilteredTree(tree);
+ posTrees.add(tree);
+
+ uri = "http://dbpedia.org/resource/%C3%80_la_folie";
+ model = modelGen.createModel(uri, Strategy.CHUNKS, 2);
+ tree = treeFactory.getQueryTree(uri, model);
+ tree = getFilteredTree(tree);
+ posTrees.add(tree);
+
+ uri = "http://dbpedia.org/resource/%C3%80_nos_amours";
+ model = modelGen.createModel(uri, Strategy.CHUNKS, 2);
+ tree = treeFactory.getQueryTree(uri, model);
+ tree = getFilteredTree(tree);
+ posTrees.add(tree);
+
+ QueryTree<String> lgg = lggGen.getLGG(posTrees);
+ System.out.println(lgg.getStringRepresentation());
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+
+
+ }
+
private QueryTree<String> getFilteredTree(QueryTree<String> tree){
nodeId = 0;
QueryTree<String> filteredTree = createFilteredTree(tree);
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java 2011-01-18 21:04:16 UTC (rev 2624)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/impl/QueryTreeImpl.java 2011-01-19 09:15:03 UTC (rev 2625)
@@ -203,6 +203,7 @@
public int removeChild(QueryTreeImpl<N> child) {
int pos = children.indexOf(child);
children.remove(child);
+ edge2ChildrenMap.get(child2EdgeMap.get(child)).remove(child);
child.parent = null;
return pos;
}
@@ -257,7 +258,7 @@
if(children == null){
children = new ArrayList<QueryTree<N>>();
}
- return children;
+ return new ArrayList<QueryTree<N>>(children);
}
public int getChildCount() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2011-01-25 15:00:28
|
Revision: 2633
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2633&view=rev
Author: jenslehmann
Date: 2011-01-25 15:00:21 +0000 (Tue, 25 Jan 2011)
Log Message:
-----------
changed output directory
Modified Paths:
--------------
trunk/pom.xml
trunk/scripts/src/main/java/org/dllearner/examples/pdb/HelixRDFCreator.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-01-25 11:47:20 UTC (rev 2632)
+++ trunk/pom.xml 2011-01-25 15:00:21 UTC (rev 2633)
@@ -344,7 +344,7 @@
<dependency>
<groupId>com.dumontierlab</groupId>
<artifactId>pdb2rdf-parser</artifactId>
- <version>0.0.9</version>
+ <version>0.0.8</version>
</dependency>
<dependency>
<groupId>com.dumontierlab</groupId>
Modified: trunk/scripts/src/main/java/org/dllearner/examples/pdb/HelixRDFCreator.java
===================================================================
--- trunk/scripts/src/main/java/org/dllearner/examples/pdb/HelixRDFCreator.java 2011-01-25 11:47:20 UTC (rev 2632)
+++ trunk/scripts/src/main/java/org/dllearner/examples/pdb/HelixRDFCreator.java 2011-01-25 15:00:21 UTC (rev 2633)
@@ -31,6 +31,7 @@
private static ArrayList<Resource> positives;
private static ArrayList<Resource> negatives;
+ private static String saveDir = "../test/pdb/";
/**
* @param args
@@ -40,7 +41,7 @@
- TrainAndTestSet sets = new TrainAndTestSet(1);
+ TrainAndTestSet sets = new TrainAndTestSet(10);
PdbRdfModel trainmodel = new PdbRdfModel();
trainmodel.add(getRdfModelForIds(sets.getTrainset()));
/*
@@ -81,7 +82,7 @@
SimpleDateFormat df = new SimpleDateFormat("_yyyy_MM_dd_HH:mm");
String date = df.format(new Date());
createConfFile(date);
- String filename = "Helixtrainer" + date + ".rdf";
+ String filename = saveDir + "Helixtrainer" + date + ".rdf";
PrintStream out = new PrintStream (new File(filename));
// Output query results
@@ -269,7 +270,7 @@
private static void createConfFile(String date){
try
{
- String filename = "pdb" + date + ".conf";
+ String filename = saveDir + "pdb" + date + ".conf";
PrintStream out = new PrintStream (new File(filename));
out.println("import(\"AA_properties.owl\");");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2011-01-31 22:38:54
|
Revision: 2638
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2638&view=rev
Author: jenslehmann
Date: 2011-01-31 22:38:48 +0000 (Mon, 31 Jan 2011)
Log Message:
-----------
continued unit tests and fixed a bug
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java
trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java
trunk/components-core/src/main/java/org/dllearner/learningproblems/ScoreTwoValued.java
trunk/components-core/src/test/java/org/dllearner/test/junit/HeuristicTests.java
trunk/test/pdb/pdb.conf
Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java 2011-01-31 19:41:38 UTC (rev 2637)
+++ trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLP.java 2011-01-31 22:38:48 UTC (rev 2638)
@@ -89,9 +89,9 @@
options.add(new StringSetConfigOption("negativeExamples",
"negative examples",null, true, false));
options.add(new BooleanConfigOption("useRetrievalForClassficiation",
- "Specifies whether to use retrieval or instance checks for testing a concept.", false));
+ "Specifies whether to use retrieval or instance checks for testing a concept. - NO LONGER FULLY SUPPORTED.", false));
options.add(CommonConfigOptions.getPercentPerLenghtUnitOption(0.05));
- StringConfigOption multiInstanceChecks = new StringConfigOption("useMultiInstanceChecks", "See UseMultiInstanceChecks enum.","twoChecks");
+ StringConfigOption multiInstanceChecks = new StringConfigOption("useMultiInstanceChecks", "See UseMultiInstanceChecks enum. - NO LONGER FULLY SUPPORTED.","twoChecks");
multiInstanceChecks.setAllowedValues(new String[] {"never", "twoChecks", "oneCheck"});
options.add(multiInstanceChecks);
return options;
Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java 2011-01-31 19:41:38 UTC (rev 2637)
+++ trunk/components-core/src/main/java/org/dllearner/learningproblems/PosNegLPStandard.java 2011-01-31 22:38:48 UTC (rev 2638)
@@ -61,6 +61,7 @@
private double approxDelta = 0.05;
private boolean useApproximations;
// private boolean useFMeasure;
+ private boolean useOldDIGOptions = false;
private HeuristicType heuristic = HeuristicType.PRED_ACC;
@@ -218,6 +219,9 @@
* to implement TWO_CHECKS in this function, because we have to test all
* examples to create a score object anyway).
*
+ * NOTE: The options above are no longer supported, because of interface changes (the options
+ * are more or less only relevant in combination with DIG).
+ *
* @see org.dllearner.learningproblems.PosNegLP.UseMultiInstanceChecks
* @param concept
* The concept to test.
@@ -225,63 +229,92 @@
*/
@Override
public ScorePosNeg computeScore(Description concept) {
- if (useRetrievalForClassification) {
- SortedSet<Individual> posClassified = reasoner.getIndividuals(concept);
- SortedSet<Individual> posAsPos = Helper.intersection(positiveExamples, posClassified);
- SortedSet<Individual> negAsPos = Helper.intersection(negativeExamples, posClassified);
- SortedSet<Individual> posAsNeg = new TreeSet<Individual>();
+ if(useOldDIGOptions) {
+ if (useRetrievalForClassification) {
+ SortedSet<Individual> posClassified = reasoner.getIndividuals(concept);
+ SortedSet<Individual> posAsPos = Helper.intersection(positiveExamples, posClassified);
+ SortedSet<Individual> negAsPos = Helper.intersection(negativeExamples, posClassified);
+ SortedSet<Individual> posAsNeg = new TreeSet<Individual>();
- // piecewise set construction
- for (Individual posExample : positiveExamples) {
- if (!posClassified.contains(posExample))
- posAsNeg.add(posExample);
+ // piecewise set construction
+ for (Individual posExample : positiveExamples) {
+ if (!posClassified.contains(posExample))
+ posAsNeg.add(posExample);
+ }
+ SortedSet<Individual> negAsNeg = new TreeSet<Individual>();
+ for (Individual negExample : negativeExamples) {
+ if (!posClassified.contains(negExample))
+ negAsNeg.add(negExample);
+ }
+ return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos, negAsNeg);
+ // instance checks for classification
+ } else {
+ SortedSet<Individual> posAsPos = new TreeSet<Individual>();
+ SortedSet<Individual> posAsNeg = new TreeSet<Individual>();
+ SortedSet<Individual> negAsPos = new TreeSet<Individual>();
+ SortedSet<Individual> negAsNeg = new TreeSet<Individual>();
+
+ if (useMultiInstanceChecks != UseMultiInstanceChecks.NEVER) {
+ SortedSet<Individual> posClassified = reasoner.hasType(concept,
+ allExamples);
+ SortedSet<Individual> negClassified = Helper.difference(allExamples,
+ posClassified);
+ posAsPos = Helper.intersection(positiveExamples, posClassified);
+ posAsNeg = Helper.intersection(positiveExamples, negClassified);
+ negAsPos = Helper.intersection(negativeExamples, posClassified);
+ negAsNeg = Helper.intersection(negativeExamples, negClassified);
+
+ // System.out.println("pos classified: " + posClassified);
+
+ return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos,
+ negAsNeg);
+ } else {
+
+ for (Individual example : positiveExamples) {
+ if (reasoner.hasType(concept, example)) {
+ posAsPos.add(example);
+ } else {
+ posAsNeg.add(example);
+ }
+ }
+ for (Individual example : negativeExamples) {
+ if (reasoner.hasType(concept, example))
+ negAsPos.add(example);
+ else
+ negAsNeg.add(example);
+ }
+ return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos,
+ negAsNeg);
+ }
}
- SortedSet<Individual> negAsNeg = new TreeSet<Individual>();
- for (Individual negExample : negativeExamples) {
- if (!posClassified.contains(negExample))
- negAsNeg.add(negExample);
- }
- return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos, negAsNeg);
- // instance checks for classification
- } else {
+ } else {
+
SortedSet<Individual> posAsPos = new TreeSet<Individual>();
SortedSet<Individual> posAsNeg = new TreeSet<Individual>();
SortedSet<Individual> negAsPos = new TreeSet<Individual>();
SortedSet<Individual> negAsNeg = new TreeSet<Individual>();
- if (useMultiInstanceChecks != UseMultiInstanceChecks.NEVER) {
- SortedSet<Individual> posClassified = reasoner.hasType(concept,
- allExamples);
- SortedSet<Individual> negClassified = Helper.difference(allExamples,
- posClassified);
- posAsPos = Helper.intersection(positiveExamples, posClassified);
- posAsNeg = Helper.intersection(positiveExamples, negClassified);
- negAsPos = Helper.intersection(negativeExamples, posClassified);
- negAsNeg = Helper.intersection(negativeExamples, negClassified);
-
- // System.out.println("pos classified: " + posClassified);
-
- return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos,
- negAsNeg);
- } else {
-
- for (Individual example : positiveExamples) {
- if (reasoner.hasType(concept, example)) {
- posAsPos.add(example);
- } else {
- posAsNeg.add(example);
- }
+ for (Individual example : positiveExamples) {
+ if (reasoner.hasType(concept, example)) {
+ posAsPos.add(example);
+ } else {
+ posAsNeg.add(example);
}
- for (Individual example : negativeExamples) {
- if (reasoner.hasType(concept, example))
- negAsPos.add(example);
- else
- negAsNeg.add(example);
- }
- return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos,
- negAsNeg);
}
+ for (Individual example : negativeExamples) {
+ if (reasoner.hasType(concept, example))
+ negAsPos.add(example);
+ else
+ negAsNeg.add(example);
+ }
+
+ // TODO: this computes accuracy twice - more elegant method should be implemented
+ double accuracy = getAccuracyOrTooWeakExact(concept,1);
+
+ return new ScoreTwoValued(concept.getLength(), percentPerLengthUnit, posAsPos, posAsNeg, negAsPos,
+ negAsNeg, accuracy);
}
+
}
/* (non-Javadoc)
Modified: trunk/components-core/src/main/java/org/dllearner/learningproblems/ScoreTwoValued.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/learningproblems/ScoreTwoValued.java 2011-01-31 19:41:38 UTC (rev 2637)
+++ trunk/components-core/src/main/java/org/dllearner/learningproblems/ScoreTwoValued.java 2011-01-31 22:38:48 UTC (rev 2638)
@@ -54,6 +54,7 @@
this(0,0,posAsPos,posAsNeg,negAsPos,negAsNeg);
}
+ @Deprecated
public ScoreTwoValued(int conceptLength, double percentPerLengthUnit, Set<Individual> posAsPos, Set<Individual> posAsNeg, Set<Individual> negAsPos, Set<Individual> negAsNeg) {
this.conceptLength = conceptLength;
this.percentPerLengthUnit = percentPerLengthUnit;
@@ -65,6 +66,21 @@
computeScore();
}
+ public ScoreTwoValued(int conceptLength, double percentPerLengthUnit, Set<Individual> posAsPos, Set<Individual> posAsNeg, Set<Individual> negAsPos, Set<Individual> negAsNeg, double accuracy) {
+ this.conceptLength = conceptLength;
+ this.percentPerLengthUnit = percentPerLengthUnit;
+ this.posAsPos = posAsPos;
+ this.posAsNeg = posAsNeg;
+ this.negAsPos = negAsPos;
+ this.negAsNeg = negAsNeg;
+ nrOfExamples = posAsPos.size()+posAsNeg.size()+negAsPos.size()+negAsNeg.size();
+ this.accuracy = accuracy;
+ score = accuracy - 1 - percentPerLengthUnit * conceptLength;
+ }
+
+ // score should not be computed within this class anymore, but directly within learning problem (to support
+ // different functions like predictive accuracy, F-measure etc.)
+ @Deprecated
private void computeScore() {
// compute accuracy
accuracy = posAsPos.size() + negAsNeg.size();
Modified: trunk/components-core/src/test/java/org/dllearner/test/junit/HeuristicTests.java
===================================================================
--- trunk/components-core/src/test/java/org/dllearner/test/junit/HeuristicTests.java 2011-01-31 19:41:38 UTC (rev 2637)
+++ trunk/components-core/src/test/java/org/dllearner/test/junit/HeuristicTests.java 2011-01-31 22:38:48 UTC (rev 2638)
@@ -183,26 +183,17 @@
kb.addAxiom(new ClassAssertionAxiom(Thing.instance,ind[i]));
}
- // A0 has 20 instances (i0 to i19)
- for(int i=0; i<20; i++) {
- kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[i]));
- }
+ // A0
+ kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[0]));
+ kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[1]));
+ kb.addAxiom(new ClassAssertionAxiom(nc[0],ind[5]));
- // A1 has 20 instances (i10 to i29)
- for(int i=10; i<30; i++) {
- kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[i]));
- }
+ // A1
+ kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[0]));
+ kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[1]));
+ kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[2]));
+ kb.addAxiom(new ClassAssertionAxiom(nc[1],ind[5]));
- // A2 has 40 instances (i10 to i49)
- for(int i=10; i<50; i++) {
- kb.addAxiom(new ClassAssertionAxiom(nc[2],ind[i]));
- }
-
- // A3 has 5 instances (i8 to i12)
- for(int i=8; i<13; i++) {
- kb.addAxiom(new ClassAssertionAxiom(nc[3],ind[i]));
- }
-
ComponentManager cm = ComponentManager.getInstance();
KnowledgeSource ks = new KBFile(kb);
ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, ks);
@@ -210,11 +201,22 @@
ks.init();
reasoner.init();
- Individual[] pos1 = new Individual[] {ind[1], ind[2]};
- Individual[] neg1 = new Individual[] {ind[3], ind[4]};
+ Individual[] pos1 = new Individual[] {ind[0], ind[1], ind[2], ind[3], ind[4]};
+ Individual[] neg1 = new Individual[] {ind[5], ind[6], ind[7], ind[8], ind[9]};
+
+ // F-Measure and no approximations
HeuristicTests.configurePosNegStandardLP(problem, pos1, neg1, "fmeasure", false);
- // TODO: continue
+ assertEqualsPosNegLPStandard(problem, nc[0], 0.5); // precision 2/3, recall 2/5
+ assertEqualsPosNegLPStandard(problem, nc[1], 2/3d); // precision 3/4, recall 3/5
+// System.out.println(problem.getFMeasureOrTooWeakExact(nc[0], 1));
+// System.out.println(problem.getFMeasureOrTooWeakExact(nc[1], 1));
+
+ // F-Measure and approximations
+ HeuristicTests.configurePosNegStandardLP(problem, pos1, neg1, "fmeasure", true);
+
+ assertEqualsPosNegLPStandard(problem, nc[0], 0.5); // precision 2/3, recall 2/5
+ assertEqualsPosNegLPStandard(problem, nc[1], 2/3d); // precision 3/4, recall 3/5
}
@@ -260,6 +262,13 @@
assertEquals(accuracy, problem.evaluate(description).getAccuracy(), delta);
}
+ private static void assertEqualsPosNegLPStandard(PosNegLPStandard problem, Description description, double accuracy) {
+ assertEquals(accuracy, problem.getAccuracy(description), delta);
+ assertEquals(accuracy, problem.getAccuracyOrTooWeak(description, 1.0), delta);
+ assertEquals(accuracy, problem.computeScore(description).getAccuracy(), delta);
+ assertEquals(accuracy, problem.evaluate(description).getAccuracy(), delta);
+ }
+
// convencience method to set the learning problem to a desired configuration (approximations disabled)
private static void configureClassLP(ClassLearningProblem problem, NamedClass classToDescribe, String accuracyMethod) throws ComponentInitException {
try {
Modified: trunk/test/pdb/pdb.conf
===================================================================
--- trunk/test/pdb/pdb.conf 2011-01-31 19:41:38 UTC (rev 2637)
+++ trunk/test/pdb/pdb.conf 2011-01-31 22:38:48 UTC (rev 2638)
@@ -5,6 +5,10 @@
celoe.terminateOnNoiseReached = false;
celoe.noisePercentage = 20;
celoe.maxExecutionTimeInSeconds = 100;
+// set this to true and look in interfaces/log/searchTree.txt to see which concepts
+// are explored by DL-Learner - turn this feature off if you do not need logging,
+// since it slows the learning algorithm down
+celoe.writeSearchTree = false;
learningProblems = posNegLPStandard;
posNegLPStandard.accuracyMethod = fmeasure;
posNegLPStandard.useApproximations = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-02-26 11:49:36
|
Revision: 2665
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2665&view=rev
Author: lorenz_b
Date: 2011-02-26 11:49:29 +0000 (Sat, 26 Feb 2011)
Log Message:
-----------
Continued evaluation script.
Added class to preprocess given question by extracting words, remove stop words and stem them.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/DBpediaLuceneIndexCreator.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/LuceneSearch.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
Added Paths:
-----------
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-25 11:23:58 UTC (rev 2664)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-26 11:49:29 UTC (rev 2665)
@@ -5,12 +5,15 @@
import java.io.BufferedReader;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
@@ -25,9 +28,17 @@
import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.Layout;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.StopFilter;
+import org.apache.lucene.analysis.Tokenizer;
+import org.apache.lucene.analysis.standard.StandardTokenizer;
+import org.apache.lucene.util.Version;
+import org.apache.solr.analysis.StopFilterFactory;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
@@ -37,13 +48,18 @@
import org.dllearner.autosparql.client.exception.SPARQLQueryException;
import org.dllearner.autosparql.server.ExampleFinder;
import org.dllearner.autosparql.server.Generalisation;
+import org.dllearner.autosparql.server.NBR;
import org.dllearner.autosparql.server.exception.TimeOutException;
+import org.dllearner.autosparql.server.search.DBpediaSchemaIndex;
+import org.dllearner.autosparql.server.search.LuceneSearch;
+import org.dllearner.autosparql.server.search.QuestionProcessor;
import org.dllearner.autosparql.server.util.SPARQLEndpointEx;
import org.dllearner.kb.sparql.ExtractionDBCache;
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.kb.sparql.SparqlQuery;
import org.dllearner.sparqlquerygenerator.operations.lgg.LGGGeneratorImpl;
import org.dllearner.sparqlquerygenerator.util.ExactMatchFilter;
+import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementFilter;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -52,12 +68,19 @@
import com.hp.hpl.jena.query.ResultSet;
+import edu.stanford.nlp.ling.HasWord;
+import edu.stanford.nlp.ling.Sentence;
+import edu.stanford.nlp.ling.TaggedWord;
+import edu.stanford.nlp.tagger.maxent.MaxentTagger;
+
public class EvaluationWithNLQueriesScript {
private static Logger logger = Logger.getLogger(EvaluationWithNLQueriesScript.class);
private static final boolean USE_SYNONYMS = false;
private static final String SOLR_SERVER_URL = "http://139.18.2.164:8983/solr/dbpediaCore/";
private static final String QUERY_ANSWERS_FILE_PATH = "evaluation/dbpedia-train_cleaned.xml";
+ private static final String SCHEMA_FILE_PATH = "evaluation/dbpedia_schema.owl";
+ private static final String LUCENE_INDEX_DIRECTORY = "/opt/autosparql/index";
private static final SparqlEndpoint ENDPOINT = SparqlEndpoint.getEndpointDBpediaLiveAKSW();
private static final int NR_OF_POS_START_EXAMPLES_COUNT = 3;
@@ -76,7 +99,12 @@
private ExampleFinder exFinder;
+ private DBpediaSchemaIndex schemaIndex;
+ private LuceneSearch luceneSearch;
+ private QuestionProcessor qProcessor = new QuestionProcessor();
+
+
public EvaluationWithNLQueriesScript(){
try {
server = new CommonsHttpSolrServer(SOLR_SERVER_URL);
@@ -88,6 +116,8 @@
exFinder = new ExampleFinder(new SPARQLEndpointEx(
new SparqlEndpoint(new URL("http://lod.openlinksw.com/sparql"),
Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList()), null, null, predicateFilters), selectCache, constructCache);
+ schemaIndex = new DBpediaSchemaIndex(SCHEMA_FILE_PATH);
+ luceneSearch = new LuceneSearch(LUCENE_INDEX_DIRECTORY);
} catch (MalformedURLException e) {
e.printStackTrace();
}
@@ -137,13 +167,13 @@
logger.info("Done.");
}
- private Set<String> getResourcesByNLQuery(String query){
+ private Set<String> getResourcesByNLQuery(String question){
logger.info("Getting Top " + TOP_K + " resources related to question with Solr...");
Set<String> resources = new HashSet<String>();
QueryResponse response;
try {
ModifiableSolrParams params = new ModifiableSolrParams();
- params.set("q", query);
+ params.set("q", question);
params.set("rows", TOP_K);
response = server.query(params);
for(SolrDocument d : response.getResults()){
@@ -157,6 +187,14 @@
return resources;
}
+ private List<String> getRelevantWords(String question){
+ return qProcessor.getRelevantWords(question);
+// Properties props = new Properties();
+// props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
+// StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
+
+ }
+
private List<String> getResourcesByWikipedia(String query) {
logger.info("Getting Top " + TOP_K + " resources related to question with Wikipedia...");
long startTime = System.currentTimeMillis();
@@ -179,7 +217,6 @@
rd.close();
XMLPagesParser parser = new XMLPagesParser(sb.toString());
parser.parse();
- String title;
for (Page page : parser.getPagesList()) {
resources.add("http://dbpedia.org/resource/" + page.getTitle().replace(" ", "_"));
}
@@ -195,6 +232,15 @@
return resources;
}
+ private List<String> getSchemaElementsByQuery(String query){
+ logger.info("Getting Top " + TOP_K + " schema elements related to question with Lucene...");
+ long startTime = System.currentTimeMillis();
+ List<String> elements = schemaIndex.getResources(query);
+ logger.info("Got " + elements.size() + " elements in " + (System.currentTimeMillis()-startTime) + "ms.");
+ logger.info(elements);
+ return elements;
+ }
+
private Set<String> getResourcesBySPARQLQuery(String query){
logger.info("Sending query...");
long startTime = System.currentTimeMillis();
@@ -212,6 +258,7 @@
Set<String> answers;
List<String> examples;
Set<String> relatedResources;
+ List<String> relevantWords;
int i = 1;
for(String question : question2Answers.keySet()){
logger.info(getNewQuestionString(i++, question));
@@ -221,12 +268,23 @@
logger.info("Target query: \n" + targetQuery);
answers = question2Answers.get(question);
logger.info("Answers (" + answers.size() + "): " + answers);
- examples = getResourcesByWikipedia(question);
- relatedResources = getResourcesByNLQuery(question.substring(0, question.length()-1));
+ //preprocess question to extract only relevant words and set them as filter for statements
+ relevantWords = getRelevantWords(question);
+ exFinder.setStatementFilter(new QuestionBasedStatementFilter(new HashSet<String>(relevantWords)));
+ question = "";
+ for(String word : relevantWords){
+ question += " " + word;
+ }
+ question.trim();
+ logger.info("Rebuilt question string: " + question);
+ //get examples
+ examples = getResourcesByWikipedia(question);//luceneSearch.getResources(question)
+ //get resources which are relevant for query and add them as filter for objects
+// relatedResources = getResourcesByNLQuery(question.substring(0, question.length()-1));
+// relatedResources.addAll(getSchemaElementsByQuery(question.substring(0, question.length()-1)));
+// exFinder.setObjectFilter(new ExactMatchFilter(relatedResources));
- exFinder.setObjectFilter(new ExactMatchFilter(relatedResources));
-
- //select some positive example and negative examples
+ //select some positive and negative examples
List<String> posExamples = new ArrayList<String>();
List<String> negExamples = new ArrayList<String>();
for(String ex : examples){
@@ -303,8 +361,16 @@
Logger.getLogger(Generalisation.class).setLevel(Level.OFF);
Logger.getLogger(LGGGeneratorImpl.class).setLevel(Level.OFF);
Logger.getRootLogger().removeAllAppenders();
- ConsoleAppender appender = new ConsoleAppender(new PatternLayout("%m%n"));
+ Layout layout = new PatternLayout("%m%n");
+ ConsoleAppender appender = new ConsoleAppender(layout);
Logger.getRootLogger().addAppender(appender);
+ FileAppender fileAppender = new FileAppender(
+ layout, "log/evaluation.log", false);
+ fileAppender.setThreshold(Level.DEBUG);
+ Logger.getRootLogger().addAppender(fileAppender);
+ Logger.getLogger(NBR.class).setLevel(Level.DEBUG);
+
+
new EvaluationWithNLQueriesScript().evaluate();
}
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-02-25 11:23:58 UTC (rev 2664)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-02-26 11:49:29 UTC (rev 2665)
@@ -30,6 +30,7 @@
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSetRewindable;
import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.Selector;
import com.hp.hpl.jena.vocabulary.RDFS;
public class ExampleFinder {
@@ -454,6 +455,10 @@
queryTreeCache.setObjectFilter(filter);
}
+ public void setStatementFilter(Selector filter){
+ queryTreeCache.setStatementFilter(filter);
+ }
+
public String getCurrentQuery(){
return currentQuery;
}
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/DBpediaLuceneIndexCreator.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/DBpediaLuceneIndexCreator.java 2011-02-25 11:23:58 UTC (rev 2664)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/DBpediaLuceneIndexCreator.java 2011-02-26 11:49:29 UTC (rev 2665)
@@ -178,7 +178,7 @@
ps.setString(1, uri);
ResultSet rs = ps.executeQuery();
if(rs.next()){
- pageRank = rs.getInt("pagerank");
+ pageRank = rs.getInt("rank");
}
} catch (SQLException e) {
e.printStackTrace();
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/LuceneSearch.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/LuceneSearch.java 2011-02-25 11:23:58 UTC (rev 2664)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/LuceneSearch.java 2011-02-26 11:49:29 UTC (rev 2665)
@@ -85,7 +85,7 @@
Document d = searcher.doc(doc.doc);
String uri = d.get("uri");
String label = d.get("label");
- String comment = d.get("abstract");
+ String comment = d.get("comment");
String imageURL = d.get("imageURL");
examples.add(new Example(uri, label, imageURL, comment));
}
Added: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java (rev 0)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java 2011-02-26 11:49:29 UTC (rev 2665)
@@ -0,0 +1,110 @@
+package org.dllearner.autosparql.server.search;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import edu.stanford.nlp.ling.HasWord;
+import edu.stanford.nlp.ling.TaggedWord;
+import edu.stanford.nlp.process.Morphology;
+import edu.stanford.nlp.tagger.maxent.MaxentTagger;
+
+public class QuestionProcessor {
+
+ private final Logger logger = Logger.getLogger(QuestionProcessor.class);
+
+ private MaxentTagger tagger;
+ private final List<String> stopWords = Arrays.asList(
+ "a", "all", "an", "and", "are", "as", "at", "be", "but", "by",
+ "for", "he", "if", "in", "into", "is", "it", "me",
+ "no", "not", "of", "on", "or", "she", "such",
+ "that", "the", "their", "then", "there", "these",
+ "they", "this", "to", "was", "will", "with"
+ );
+
+ public QuestionProcessor(){
+ try {
+ tagger = new MaxentTagger("src/main/resources/de/simba/ner/models/left3words-wsj-0-18.tagger");
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public List<String> getRelevantWords(String question){
+ logger.info("Processing question \"" + question + "\"...");
+ //tokenize question
+ List<String> words = getWords(question);
+ logger.info("Extracted words: " + words);
+ //remove stop words
+ removeStopWords(words);
+ logger.info("After removed stop words: " + words);
+ //stem words
+ words = getStemmedWords(words);
+ logger.info("After stemming: " + words);
+
+ return words;
+ }
+
+ private List<String> getWords(String question){
+ List<String> words = new ArrayList<String>();
+ List<ArrayList<? extends HasWord>> sentences = tagger.tokenizeText(new BufferedReader(new StringReader(question)));
+ for (ArrayList<? extends HasWord> sentence : sentences) {
+ ArrayList<TaggedWord> tSentence = tagger.tagSentence(sentence);
+ String nounPhrase = "";
+ boolean firstWord = true;
+ for(TaggedWord tWord : tSentence){
+ //ignore first word if it is a verb
+ if(firstWord){
+ if(tWord.tag().startsWith("V")){
+ continue;
+ }
+ firstWord = false;
+ }
+ //if words belongs to noun phrase treat them as one single term
+ if(tWord.tag().equals("NNP")){
+ nounPhrase += " " + tWord.word();
+ } else {
+ if(!nounPhrase.isEmpty()){
+ words.add(nounPhrase.trim());
+ nounPhrase = "";
+ }
+ //ignore punctuation signs
+ if(!tWord.tag().equals(".")){
+ words.add(tWord.word());
+ }
+ }
+
+ }
+ if(!nounPhrase.isEmpty()){
+ words.add(nounPhrase.trim() );
+ nounPhrase = "";
+ }
+ }
+ return words;
+ }
+
+ private void removeStopWords(List<String> words){
+ words.removeAll(stopWords);
+ }
+
+ private List<String> getStemmedWords(List<String> words) {
+ List<String> stemmedWords = new ArrayList<String>();
+ Morphology morpho = new Morphology();
+ for (String w : words) {
+ if(!(w.indexOf(" ") > 0)){
+ stemmedWords.add(morpho.stem(w));
+ } else {
+ stemmedWords.add(w);
+ }
+ }
+ return stemmedWords;
+ }
+
+}
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-25 11:23:58 UTC (rev 2664)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-26 11:49:29 UTC (rev 2665)
@@ -1,5 +1,7 @@
package org.dllearner.sparqlquerygenerator.util;
+import java.util.Set;
+
import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
import uk.ac.shef.wit.simmetrics.similaritymetrics.QGramsDistance;
@@ -11,12 +13,13 @@
public class QuestionBasedStatementFilter implements Selector {
- private String question;
+ private Set<String> questionWords;
private AbstractStringMetric metric;
private double threshold = 0.7;
- public QuestionBasedStatementFilter(String question){
- this.question = question;
+
+ public QuestionBasedStatementFilter(Set<String> questionWords){
+ this.questionWords = questionWords;
metric = new QGramsDistance();
}
@@ -24,17 +27,29 @@
@Override
public boolean test(Statement s) {
String predicate = s.getPredicate().getURI().substring(s.getPredicate().getURI().lastIndexOf("/"));
- String object;
+ String object = null;
if(s.getObject().isURIResource()){
object = s.getObject().asResource().getURI();
object = object.substring(object.lastIndexOf("/"));
} else if(s.getObject().isLiteral()){
object = s.getObject().asLiteral().getLexicalForm();
}
+ if(isSimiliar2QuestionWord(object) || isSimiliar2QuestionWord(predicate)){
+ return true;
+ }
return false;
}
+ private boolean isSimiliar2QuestionWord(String s){
+ for(String word : questionWords){
+ if(areSimiliar(word, s)){
+ return true;
+ }
+ }
+ return false;
+ }
+
private boolean areSimiliar(String s1, String s2){
float sim = metric.getSimilarity(s1, s2);
return sim >= threshold;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-02-26 13:18:18
|
Revision: 2667
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2667&view=rev
Author: lorenz_b
Date: 2011-02-26 13:18:11 +0000 (Sat, 26 Feb 2011)
Log Message:
-----------
Added option to enable synonym expansion in eval script.
Modified Paths:
--------------
trunk/autosparql/pom.xml
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
Modified: trunk/autosparql/pom.xml
===================================================================
--- trunk/autosparql/pom.xml 2011-02-26 12:27:36 UTC (rev 2666)
+++ trunk/autosparql/pom.xml 2011-02-26 13:18:11 UTC (rev 2667)
@@ -23,6 +23,10 @@
<url>http://maven.mse.jhu.edu/m2repository/</url>
</repository>
<repository>
+<id>opennlp.sf.net</id>
+<url>http://opennlp.sourceforge.net/maven2</url>
+</repository>
+ <repository>
<id>Sesame</id>
<url>http://repo.aduna-software.org/maven2/releases/</url>
</repository>
@@ -44,6 +48,11 @@
<artifactId>bliki-core</artifactId>
<version>3.0.16</version>
</dependency>
+ <dependency>
+<groupId>opennlp</groupId>
+<artifactId>tools</artifactId>
+<version>1.5.0</version>
+</dependency>
<!-- GWT dependencies (from central repo) -->
<dependency>
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-26 12:27:36 UTC (rev 2666)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-26 13:18:11 UTC (rev 2667)
@@ -14,6 +14,7 @@
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
@@ -68,6 +69,8 @@
import com.hp.hpl.jena.query.ResultSet;
+import de.simba.ner.WordnetQuery;
+
import edu.stanford.nlp.ling.HasWord;
import edu.stanford.nlp.ling.Sentence;
import edu.stanford.nlp.ling.TaggedWord;
@@ -81,6 +84,7 @@
private static final String QUERY_ANSWERS_FILE_PATH = "evaluation/dbpedia-train_cleaned.xml";
private static final String SCHEMA_FILE_PATH = "evaluation/dbpedia_schema.owl";
private static final String LUCENE_INDEX_DIRECTORY = "/opt/autosparql/index";
+ private static final String WORDNET_DICTIONARY = "src/main/resources/de/simba/ner/dictionary";
private static final SparqlEndpoint ENDPOINT = SparqlEndpoint.getEndpointDBpediaLiveAKSW();
private static final int NR_OF_POS_START_EXAMPLES_COUNT = 3;
@@ -101,6 +105,7 @@
private DBpediaSchemaIndex schemaIndex;
private LuceneSearch luceneSearch;
+ private WordnetQuery wordNet;
private QuestionProcessor qProcessor = new QuestionProcessor();
@@ -118,6 +123,7 @@
Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList()), null, null, predicateFilters), selectCache, constructCache);
schemaIndex = new DBpediaSchemaIndex(SCHEMA_FILE_PATH);
luceneSearch = new LuceneSearch(LUCENE_INDEX_DIRECTORY);
+ wordNet = new WordnetQuery(WORDNET_DICTIONARY);
} catch (MalformedURLException e) {
e.printStackTrace();
}
@@ -241,6 +247,14 @@
return elements;
}
+ private Set<String> getSynonyms(Collection<String> words){
+ Set<String> synonyms = new HashSet<String>();
+ for(String w : words){
+ synonyms.addAll(wordNet.getSynset(w));
+ }
+ return synonyms;
+ }
+
private Set<String> getResourcesBySPARQLQuery(String query){
logger.info("Sending query...");
long startTime = System.currentTimeMillis();
@@ -271,6 +285,11 @@
//preprocess question to extract only relevant words and set them as filter for statements
relevantWords = getRelevantWords(question);
exFinder.setStatementFilter(new QuestionBasedStatementFilter(new HashSet<String>(relevantWords)));
+ //expand with synonyms
+ if(USE_SYNONYMS){
+ relevantWords.addAll(getSynonyms(relevantWords));
+ logger.info("Extended with synonyms: " + relevantWords);
+ }
question = "";
for(String word : relevantWords){
question += " " + word;
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-02-26 12:27:36 UTC (rev 2666)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-02-26 13:18:11 UTC (rev 2667)
@@ -99,7 +99,8 @@
Statement st;
SortedSet<Statement> statements;
- for(Iterator<Statement> it = model.listStatements(statementFilter); it.hasNext();){
+ Iterator<Statement> it = model.listStatements(statementFilter);
+ while(it.hasNext()){
st = it.next();
statements = resource2Statements.get(st.getSubject().toString());
if(statements == null){
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-26 12:27:36 UTC (rev 2666)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-26 13:18:11 UTC (rev 2667)
@@ -30,7 +30,7 @@
String object = null;
if(s.getObject().isURIResource()){
object = s.getObject().asResource().getURI();
- object = object.substring(object.lastIndexOf("/"));
+ object = object.substring(object.lastIndexOf("/")+1);
} else if(s.getObject().isLiteral()){
object = s.getObject().asLiteral().getLexicalForm();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-02-26 23:09:02
|
Revision: 2669
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2669&view=rev
Author: lorenz_b
Date: 2011-02-26 23:08:56 +0000 (Sat, 26 Feb 2011)
Log Message:
-----------
Reduced # of comparisons in filter.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/QueryTreeFactory.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/cache/QueryTreeCache.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
Added Paths:
-----------
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementSelector.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java 2011-02-26 21:53:23 UTC (rev 2668)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java 2011-02-26 23:08:56 UTC (rev 2669)
@@ -13,6 +13,7 @@
import org.dllearner.sparqlquerygenerator.util.ModelGenerator;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator.Strategy;
import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementFilter;
+import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementSelector;
import com.hp.hpl.jena.rdf.model.Model;
@@ -46,6 +47,7 @@
QueryTree<String> tree = treeFactory.getQueryTree(uri, model);
System.out.println("Tree without filtering:\n" + tree.getStringRepresentation());
+ treeFactory.setStatementSelector(new QuestionBasedStatementSelector(new HashSet<String>(relevantWords)));
treeFactory.setStatementFilter(new QuestionBasedStatementFilter(new HashSet<String>(relevantWords)));
QueryTree<String> filteredTree = treeFactory.getQueryTree(uri, model);
System.out.println("Tree with filtering:\n" + filteredTree.getStringRepresentation());
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/QueryTreeFactory.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/QueryTreeFactory.java 2011-02-26 21:53:23 UTC (rev 2668)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/QueryTreeFactory.java 2011-02-26 23:08:56 UTC (rev 2669)
@@ -25,6 +25,7 @@
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Selector;
+import com.hp.hpl.jena.rdf.model.Statement;
/**
*
@@ -43,7 +44,8 @@
void setObjectFilter(Filter filter);
- void setStatementFilter(Selector filter);
+ void setStatementSelector(Selector selector);
+ void setStatementFilter(com.hp.hpl.jena.util.iterator.Filter<Statement> filter);
}
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/cache/QueryTreeCache.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/cache/QueryTreeCache.java 2011-02-26 21:53:23 UTC (rev 2668)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/cache/QueryTreeCache.java 2011-02-26 23:08:56 UTC (rev 2669)
@@ -47,7 +47,7 @@
}
public void setStatementFilter(Selector filter){
- factory.setStatementFilter(filter);
+ factory.setStatementSelector(filter);
}
public void clear(){
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-02-26 21:53:23 UTC (rev 2668)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-02-26 23:08:56 UTC (rev 2669)
@@ -56,7 +56,8 @@
private Filter predicateFilter = new ZeroFilter();
private Filter objectFilter = new ZeroFilter();
- private Selector statementFilter = new SimpleSelector();
+ private Selector statementSelector = new SimpleSelector();
+ private com.hp.hpl.jena.util.iterator.Filter<Statement> keepFilter;
public QueryTreeFactoryImpl(){
comparator = new StatementComparator();
@@ -72,14 +73,24 @@
}
@Override
- public void setStatementFilter(Selector filter) {
- this.statementFilter = filter;
+ public void setStatementSelector(Selector selector) {
+ this.statementSelector = selector;
}
@Override
+ public void setStatementFilter(com.hp.hpl.jena.util.iterator.Filter<Statement> statementFilter) {
+ this.keepFilter = statementFilter;
+
+ }
+
+ @Override
public QueryTreeImpl<String> getQueryTree(String example, Model model) {
- return createTree(model.getResource(example), model);
+ if(keepFilter == null){
+ return createTree(model.getResource(example), model);
+ } else {
+ return createTreeOptimized(model.getResource(example), model);
+ }
}
@Override
@@ -92,14 +103,44 @@
return new QueryTreeImpl<String>(example);
}
+ private QueryTreeImpl<String> createTreeOptimized(Resource s, Model model){
+ nodeId = 0;
+ SortedMap<String, SortedSet<Statement>> resource2Statements = new TreeMap<String, SortedSet<Statement>>();
+
+ fillMap(s, model, resource2Statements);
+
+ QueryTreeImpl<String> tree = new QueryTreeImpl<String>(s.toString());
+ fillTree(tree, resource2Statements);
+
+ tree.setUserObject("?");
+ return tree;
+ }
+
+ private void fillMap(Resource s, Model model, SortedMap<String, SortedSet<Statement>> resource2Statements){
+ Iterator<Statement> it = model.listStatements(s, null, (RDFNode)null).filterKeep(keepFilter);
+ Statement st;
+ SortedSet<Statement> statements;
+ while(it.hasNext()){
+ st = it.next();
+ statements = resource2Statements.get(st.getSubject().toString());
+ if(statements == null){
+ statements = new TreeSet<Statement>(comparator);
+ resource2Statements.put(st.getSubject().toString(), statements);
+ }
+ statements.add(st);
+ if(st.getObject().isURIResource()){
+ fillMap(st.getObject().asResource(), model, resource2Statements);
+ }
+ }
+ }
+
private QueryTreeImpl<String> createTree(Resource s, Model model){
nodeId = 0;
-
SortedMap<String, SortedSet<Statement>> resource2Statements = new TreeMap<String, SortedSet<Statement>>();
Statement st;
SortedSet<Statement> statements;
- Iterator<Statement> it = model.listStatements(statementFilter);
+ Iterator<Statement> it = model.listStatements(statementSelector);
while(it.hasNext()){
st = it.next();
statements = resource2Statements.get(st.getSubject().toString());
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-26 21:53:23 UTC (rev 2668)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-26 23:08:56 UTC (rev 2669)
@@ -5,18 +5,16 @@
import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
import uk.ac.shef.wit.simmetrics.similaritymetrics.QGramsDistance;
-import com.hp.hpl.jena.rdf.model.Property;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.Selector;
import com.hp.hpl.jena.rdf.model.Statement;
+import com.hp.hpl.jena.util.iterator.Filter;
-public class QuestionBasedStatementFilter implements Selector {
+public class QuestionBasedStatementFilter extends Filter<Statement> {
private Set<String> questionWords;
private AbstractStringMetric metric;
- private double threshold = 0.7;
+ private double threshold = 0.5;
+ int cnt = 0;
public QuestionBasedStatementFilter(Set<String> questionWords){
this.questionWords = questionWords;
@@ -24,23 +22,6 @@
}
- @Override
- public boolean test(Statement s) {
- String predicate = s.getPredicate().getURI().substring(s.getPredicate().getURI().lastIndexOf("/"));
- String object = null;
- if(s.getObject().isURIResource()){
- object = s.getObject().asResource().getURI();
- object = object.substring(object.lastIndexOf("/")+1);
- } else if(s.getObject().isLiteral()){
- object = s.getObject().asLiteral().getLexicalForm();
- }
- if(isSimiliar2QuestionWord(object) || isSimiliar2QuestionWord(predicate)){
- return true;
- }
-
- return false;
- }
-
private boolean isSimiliar2QuestionWord(String s){
for(String word : questionWords){
if(areSimiliar(word, s)){
@@ -50,29 +31,26 @@
return false;
}
- private boolean areSimiliar(String s1, String s2){
+ private boolean areSimiliar(String s1, String s2){//cnt++;System.out.println(cnt);
float sim = metric.getSimilarity(s1, s2);
return sim >= threshold;
}
@Override
- public boolean isSimple() {
+ public boolean accept(Statement s) {
+ String predicate = s.getPredicate().getURI().substring(s.getPredicate().getURI().lastIndexOf("/"));
+ String object = null;
+ if(s.getObject().isURIResource()){
+ object = s.getObject().asResource().getURI();
+ object = object.substring(object.lastIndexOf("/")+1);
+ } else if(s.getObject().isLiteral()){
+ object = s.getObject().asLiteral().getLexicalForm();
+ }
+ if(isSimiliar2QuestionWord(object) || isSimiliar2QuestionWord(predicate)){
+ return true;
+ }
+
return false;
}
- @Override
- public Resource getSubject() {
- return null;
- }
-
- @Override
- public Property getPredicate() {
- return null;
- }
-
- @Override
- public RDFNode getObject() {
- return null;
- }
-
}
Copied: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementSelector.java (from rev 2667, trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java)
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementSelector.java (rev 0)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementSelector.java 2011-02-26 23:08:56 UTC (rev 2669)
@@ -0,0 +1,78 @@
+package org.dllearner.sparqlquerygenerator.util;
+
+import java.util.Set;
+
+import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
+import uk.ac.shef.wit.simmetrics.similaritymetrics.QGramsDistance;
+
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.RDFNode;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.Selector;
+import com.hp.hpl.jena.rdf.model.Statement;
+
+public class QuestionBasedStatementSelector implements Selector {
+
+ private Set<String> questionWords;
+ private AbstractStringMetric metric;
+ private double threshold = 0.5;
+ int cnt = 0;
+
+ public QuestionBasedStatementSelector(Set<String> questionWords){
+ this.questionWords = questionWords;
+ metric = new QGramsDistance();
+
+ }
+
+ @Override
+ public boolean test(Statement s) {
+ String predicate = s.getPredicate().getURI().substring(s.getPredicate().getURI().lastIndexOf("/"));
+ String object = null;
+ if(s.getObject().isURIResource()){
+ object = s.getObject().asResource().getURI();
+ object = object.substring(object.lastIndexOf("/")+1);
+ } else if(s.getObject().isLiteral()){
+ object = s.getObject().asLiteral().getLexicalForm();
+ }
+ if(isSimiliar2QuestionWord(object) || isSimiliar2QuestionWord(predicate)){
+ return true;
+ }
+
+ return false;
+ }
+
+ private boolean isSimiliar2QuestionWord(String s){
+ for(String word : questionWords){
+ if(areSimiliar(word, s)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean areSimiliar(String s1, String s2){//cnt++;System.out.println(cnt);
+ float sim = metric.getSimilarity(s1, s2);
+ return sim >= threshold;
+ }
+
+ @Override
+ public boolean isSimple() {
+ return false;
+ }
+
+ @Override
+ public Resource getSubject() {
+ return null;
+ }
+
+ @Override
+ public Property getPredicate() {
+ return null;
+ }
+
+ @Override
+ public RDFNode getObject() {
+ return null;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-02-27 08:16:17
|
Revision: 2670
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2670&view=rev
Author: lorenz_b
Date: 2011-02-27 08:16:11 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
Inluded Lucene search into script.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/LuceneSearch.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/cache/QueryTreeCache.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-26 23:08:56 UTC (rev 2669)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-27 08:16:11 UTC (rev 2670)
@@ -61,6 +61,7 @@
import org.dllearner.sparqlquerygenerator.operations.lgg.LGGGeneratorImpl;
import org.dllearner.sparqlquerygenerator.util.ExactMatchFilter;
import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementFilter;
+import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementSelector;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -193,6 +194,14 @@
return resources;
}
+ private List<String> getResourcesByNLQueryWithLucene(String question){
+ logger.info("Getting Top " + TOP_K + " resources related to question with Lucene...");
+ List<String> resources = luceneSearch.getResources(question);
+ logger.info("Got " + resources.size() + " resources:");
+ logger.info(resources);
+ return resources;
+ }
+
private List<String> getRelevantWords(String question){
return qProcessor.getRelevantWords(question);
// Properties props = new Properties();
@@ -274,7 +283,7 @@
Set<String> relatedResources;
List<String> relevantWords;
int i = 1;
- for(String question : question2Answers.keySet()){
+ for(String question : question2Answers.keySet()){question = "Give me all films with Tom Cruise!";
logger.info(getNewQuestionString(i++, question));
try {
logger.info("Evaluating question \"" + question + "\"...");
@@ -285,6 +294,7 @@
//preprocess question to extract only relevant words and set them as filter for statements
relevantWords = getRelevantWords(question);
exFinder.setStatementFilter(new QuestionBasedStatementFilter(new HashSet<String>(relevantWords)));
+// exFinder.setStatementSelector(new QuestionBasedStatementSelector(new HashSet<String>(relevantWords)));
//expand with synonyms
if(USE_SYNONYMS){
relevantWords.addAll(getSynonyms(relevantWords));
@@ -296,8 +306,11 @@
}
question.trim();
logger.info("Rebuilt question string: " + question);
+
//get examples
- examples = getResourcesByWikipedia(question);//luceneSearch.getResources(question)
+// examples = getResourcesByWikipedia(question);
+ examples = getResourcesByNLQueryWithLucene(question);
+
//get resources which are relevant for query and add them as filter for objects
// relatedResources = getResourcesByNLQuery(question.substring(0, question.length()-1));
// relatedResources.addAll(getSchemaElementsByQuery(question.substring(0, question.length()-1)));
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-02-26 23:08:56 UTC (rev 2669)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-02-27 08:16:11 UTC (rev 2670)
@@ -31,6 +31,7 @@
import com.hp.hpl.jena.query.ResultSetRewindable;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Selector;
+import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.vocabulary.RDFS;
public class ExampleFinder {
@@ -455,10 +456,14 @@
queryTreeCache.setObjectFilter(filter);
}
- public void setStatementFilter(Selector filter){
+ public void setStatementFilter(com.hp.hpl.jena.util.iterator.Filter<Statement> filter){
queryTreeCache.setStatementFilter(filter);
}
+ public void setStatementSelector(Selector selector){
+ queryTreeCache.setStatementSelector(selector);
+ }
+
public String getCurrentQuery(){
return currentQuery;
}
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/LuceneSearch.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/LuceneSearch.java 2011-02-26 23:08:56 UTC (rev 2669)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/LuceneSearch.java 2011-02-27 08:16:11 UTC (rev 2670)
@@ -2,6 +2,7 @@
import java.io.File;
import java.io.IOException;
+import java.text.NumberFormat.Field;
import java.util.ArrayList;
import java.util.List;
@@ -15,6 +16,8 @@
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TopScoreDocCollector;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
@@ -36,7 +39,7 @@
Directory dir = FSDirectory.open(new File(indexDirectory));//RAMDirectory();
searcher = new IndexSearcher(dir, true);
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
- queryParser = new QueryParser(Version.LUCENE_30, "abstract", analyzer);
+ queryParser = new QueryParser(Version.LUCENE_30, "comment", analyzer);
collector = TopScoreDocCollector.create(hitsPerPage, true);
} catch (CorruptIndexException e) {
e.printStackTrace();
@@ -54,6 +57,7 @@
try {
Query query = queryParser.parse(queryString);
searcher.search(query, collector);
+// System.out.println(searcher.search(query, null, 10, new Sort(new SortField("pagerank", SortField.INT))));
ScoreDoc[] hits = collector.topDocs(offset).scoreDocs;
for(ScoreDoc doc : hits) {
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/cache/QueryTreeCache.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/cache/QueryTreeCache.java 2011-02-26 23:08:56 UTC (rev 2669)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/cache/QueryTreeCache.java 2011-02-27 08:16:11 UTC (rev 2670)
@@ -11,6 +11,7 @@
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Selector;
+import com.hp.hpl.jena.rdf.model.Statement;
public class QueryTreeCache {
@@ -46,10 +47,14 @@
factory.setObjectFilter(filter);
}
- public void setStatementFilter(Selector filter){
- factory.setStatementSelector(filter);
+ public void setStatementFilter(com.hp.hpl.jena.util.iterator.Filter<Statement> filter){
+ factory.setStatementFilter(filter);
}
+ public void setStatementSelector(Selector selector){
+ factory.setStatementSelector(selector);
+ }
+
public void clear(){
cache.clear();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jen...@us...> - 2011-02-27 16:08:47
|
Revision: 2672
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2672&view=rev
Author: jenslehmann
Date: 2011-02-27 16:08:41 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
fixed bug causing bad requests
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-27 10:00:44 UTC (rev 2671)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-27 16:08:41 UTC (rev 2672)
@@ -86,7 +86,8 @@
private static final String SOLR_SERVER_URL = "http://139.18.2.164:8983/solr/dbpediaCore/";
private static final String QUERY_ANSWERS_FILE_PATH = "evaluation/dbpedia-train_cleaned.xml";
private static final String SCHEMA_FILE_PATH = "evaluation/dbpedia_schema.owl";
- private static final String LUCENE_INDEX_DIRECTORY = "/opt/autosparql/index";
+// private static final String LUCENE_INDEX_DIRECTORY = "/opt/autosparql/index";
+ private static final String LUCENE_INDEX_DIRECTORY = "/home/jl/hdd/other_large_files/index/";
private static final String WORDNET_DICTIONARY = "src/main/resources/de/simba/ner/dictionary";
private static final SparqlEndpoint ENDPOINT = SparqlEndpoint.getEndpointDBpediaLiveAKSW();
@@ -360,7 +361,8 @@
// print learned query up to here
String learnedQuery = exFinder.getCurrentQuery();
logger.info("Learned SPARQL query: \n" + learnedQuery);
- learnedQuery = "SELECT DISTINCT " + learnedQuery.substring(7);
+// learnedQuery = "SELECT DISTINCT " + learnedQuery.substring(7);
+ learnedQuery = "SELECT " + learnedQuery.substring(7);
learnedResources = getResourcesBySPARQLQuery(learnedQuery);
logger.info("Number of resources in learned query: "
+ learnedResources.size());
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-27 10:00:44 UTC (rev 2671)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-27 16:08:41 UTC (rev 2672)
@@ -12,7 +12,7 @@
private Set<String> questionWords;
private AbstractStringMetric metric;
- private double threshold = 0.5;
+ private double threshold = 0.3;
int cnt = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-02-27 18:14:39
|
Revision: 2673
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2673&view=rev
Author: lorenz_b
Date: 2011-02-27 18:14:32 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
Fixed bug.
Added 2 more metrics for string comparison.
Added condition which selects positive examples from answer set, if the # in the search is lower than the threshold.
Added constant SIMILARITY_THRESHOLD in evaluation script.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-27 16:08:41 UTC (rev 2672)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-27 18:14:32 UTC (rev 2673)
@@ -5,17 +5,15 @@
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
@@ -34,12 +32,6 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
-import org.apache.lucene.analysis.StopAnalyzer;
-import org.apache.lucene.analysis.StopFilter;
-import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.analysis.standard.StandardTokenizer;
-import org.apache.lucene.util.Version;
-import org.apache.solr.analysis.StopFilterFactory;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
@@ -59,9 +51,7 @@
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.kb.sparql.SparqlQuery;
import org.dllearner.sparqlquerygenerator.operations.lgg.LGGGeneratorImpl;
-import org.dllearner.sparqlquerygenerator.util.ExactMatchFilter;
import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementFilter;
-import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementSelector;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -72,16 +62,11 @@
import de.simba.ner.WordnetQuery;
-import edu.stanford.nlp.ling.HasWord;
-import edu.stanford.nlp.ling.Sentence;
-import edu.stanford.nlp.ling.TaggedWord;
-import edu.stanford.nlp.tagger.maxent.MaxentTagger;
-
public class EvaluationWithNLQueriesScript {
private static Logger logger = Logger.getLogger(EvaluationWithNLQueriesScript.class);
private static final boolean USE_SYNONYMS = false;
- private static final boolean USE_WIKIPEDIA_SEARCH = false;
+ private static final boolean USE_WIKIPEDIA_SEARCH = true;
private static final String SOLR_SERVER_URL = "http://139.18.2.164:8983/solr/dbpediaCore/";
private static final String QUERY_ANSWERS_FILE_PATH = "evaluation/dbpedia-train_cleaned.xml";
@@ -96,7 +81,9 @@
private static final int TOP_K = 20;
+ private static final double SIMILARITY_THRESHOLD = 0.5;
+
private Map<String, String> question2query = new Hashtable<String, String>();
private SortedMap<String, Set<String>> question2Answers = new TreeMap<String, Set<String>>();
@@ -122,13 +109,30 @@
List<String> predicateFilters = new ArrayList<String>();
predicateFilters.add("http://dbpedia.org/ontology/wikiPageWikiLink");
predicateFilters.add("http://dbpedia.org/property/wikiPageUsesTemplate");
- exFinder = new ExampleFinder(new SPARQLEndpointEx(
- new SparqlEndpoint(new URL("http://live.dbpedia.org/sparql"), //new URL("http://lod.openlinksw.com/sparql"),
- Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList()), null, null, predicateFilters), selectCache, constructCache);
- schemaIndex = new DBpediaSchemaIndex(SCHEMA_FILE_PATH);
+ //prefixes and baseURI to improve readability of trees
+ String baseURI = "http://dbpedia.org/resource/";
+ Map<String,String> prefixes = new HashMap<String,String>();
+ prefixes.put("dbo","http://dbpedia.org/ontology/");
+ prefixes.put("dbprop","http://dbpedia.org/property/");
+ prefixes.put("rdfs","http://www.w3.org/2000/01/rdf-schema#");
+ prefixes.put("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+ prefixes.put("skos","http://www.w3.org/2004/02/skos/core#");
+ prefixes.put("geo","http://www.w3.org/2003/01/geo/wgs84_pos#");
+ prefixes.put("georss","http://www.georss.org/georss/");
+ prefixes.put("owl","http://www.w3.org/2002/07/owl#");
+ prefixes.put("yago","http://dbpedia.org/class/yago/");
+ prefixes.put("cyc","http://sw.opencyc.org/concept/");
+ prefixes.put("foaf","http://xmlns.com/foaf/0.1/");
+ exFinder = new ExampleFinder(new SPARQLEndpointEx(new URL("http://live.dbpedia.org/sparql"), //new URL("http://lod.openlinksw.com/sparql"),
+ Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList(), null, baseURI, prefixes, predicateFilters), selectCache, constructCache);
+// schemaIndex = new DBpediaSchemaIndex(SCHEMA_FILE_PATH);
luceneSearch = new LuceneSearch(LUCENE_INDEX_DIRECTORY);
luceneSearch.setHitsPerPage(TOP_K);
wordNet = new WordnetQuery(WORDNET_DICTIONARY);
+
+
+
+
} catch (MalformedURLException e) {
e.printStackTrace();
}
@@ -297,7 +301,9 @@
logger.info("Answers (" + answers.size() + "): " + answers);
//preprocess question to extract only relevant words and set them as filter for statements
relevantWords = getRelevantWords(question);
- exFinder.setStatementFilter(new QuestionBasedStatementFilter(new HashSet<String>(relevantWords)));
+ QuestionBasedStatementFilter filter = new QuestionBasedStatementFilter(new HashSet<String>(relevantWords));
+ filter.setThreshold(SIMILARITY_THRESHOLD);
+ exFinder.setStatementFilter(filter);
// exFinder.setStatementSelector(new QuestionBasedStatementSelector(new HashSet<String>(relevantWords)));
//expand with synonyms
@@ -338,6 +344,17 @@
}
}
}
+ //if there are not enough positive examples in search we select some from the answer set which simulates manually addition of user
+ if(posExamples.size() < NR_OF_POS_START_EXAMPLES_COUNT){
+ logger.info("Found only " + posExamples.size() + " positive example(s) in search result. Adding more from the answer set...");
+ for(String answer : answers){
+ posExamples.add(answer);
+ if(posExamples.size() == NR_OF_POS_START_EXAMPLES_COUNT){
+ break;
+ }
+ }
+
+ }
if(posExamples.isEmpty()){
logger.warn("Current search returned no positive example in the Top " + TOP_K + ".\n" +
"Skipping query...");
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java 2011-02-27 16:08:41 UTC (rev 2672)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java 2011-02-27 18:14:32 UTC (rev 2673)
@@ -47,8 +47,9 @@
QueryTree<String> tree = treeFactory.getQueryTree(uri, model);
System.out.println("Tree without filtering:\n" + tree.getStringRepresentation());
- treeFactory.setStatementSelector(new QuestionBasedStatementSelector(new HashSet<String>(relevantWords)));
+// treeFactory.setStatementSelector(new QuestionBasedStatementSelector(new HashSet<String>(relevantWords)));
treeFactory.setStatementFilter(new QuestionBasedStatementFilter(new HashSet<String>(relevantWords)));
+
QueryTree<String> filteredTree = treeFactory.getQueryTree(uri, model);
System.out.println("Tree with filtering:\n" + filteredTree.getStringRepresentation());
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-02-27 16:08:41 UTC (rev 2672)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-02-27 18:14:32 UTC (rev 2673)
@@ -11,6 +11,7 @@
import org.dllearner.autosparql.client.model.Example;
import org.dllearner.autosparql.server.exception.TimeOutException;
import org.dllearner.autosparql.server.util.SPARQLEndpointEx;
+import org.dllearner.autosparql.server.util.TreeHelper;
import org.dllearner.kb.sparql.ExtractionDBCache;
import org.dllearner.kb.sparql.SparqlQuery;
import org.dllearner.sparqlquerygenerator.SPARQLQueryGeneratorCached;
@@ -97,7 +98,7 @@
// logger.info("Fetching model for resource: " + resource);
model = modelCache.getModel(resource);
queryTree = queryTreeCache.getQueryTree(resource, model);
- System.out.println(queryTree.getStringRepresentation());
+ System.out.println(TreeHelper.getAbbreviatedTreeRepresentation(queryTree, endpoint.getBaseURI(), endpoint.getPrefixes()));
posExampleTrees.add(queryTree);
}
for(String resource : negExamples){
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-02-27 16:08:41 UTC (rev 2672)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-02-27 18:14:32 UTC (rev 2673)
@@ -128,7 +128,7 @@
resource2Statements.put(st.getSubject().toString(), statements);
}
statements.add(st);
- if(st.getObject().isURIResource()){
+ if(st.getObject().isURIResource() && !resource2Statements.containsKey(st.getObject().asResource().getURI())){
fillMap(st.getObject().asResource(), model, resource2Statements);
}
}
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-27 16:08:41 UTC (rev 2672)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-27 18:14:32 UTC (rev 2673)
@@ -3,6 +3,8 @@
import java.util.Set;
import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
+import uk.ac.shef.wit.simmetrics.similaritymetrics.JaroWinkler;
+import uk.ac.shef.wit.simmetrics.similaritymetrics.Levenshtein;
import uk.ac.shef.wit.simmetrics.similaritymetrics.QGramsDistance;
import com.hp.hpl.jena.rdf.model.Statement;
@@ -11,14 +13,20 @@
public class QuestionBasedStatementFilter extends Filter<Statement> {
private Set<String> questionWords;
- private AbstractStringMetric metric;
+
+ private AbstractStringMetric qGramMetric;
+ private AbstractStringMetric levensteinMetric;
+ private AbstractStringMetric jaroWinklerMetric;
+
private double threshold = 0.3;
int cnt = 0;
public QuestionBasedStatementFilter(Set<String> questionWords){
this.questionWords = questionWords;
- metric = new QGramsDistance();
+ qGramMetric = new QGramsDistance();
+ levensteinMetric = new Levenshtein();
+ jaroWinklerMetric = new JaroWinkler();
}
@@ -32,7 +40,10 @@
}
private boolean areSimiliar(String s1, String s2){//cnt++;System.out.println(cnt);
- float sim = metric.getSimilarity(s1, s2);
+ float qSim = qGramMetric.getSimilarity(s1, s2);
+ float lSim = levensteinMetric.getSimilarity(s1, s2);
+ float jSim = jaroWinklerMetric.getSimilarity(s1, s2);
+ float sim = Math.max(Math.max(qSim, lSim), jSim);
return sim >= threshold;
}
@@ -52,5 +63,9 @@
return false;
}
+
+ public void setThreshold(double threshold){
+ this.threshold = threshold;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-02-28 10:01:28
|
Revision: 2677
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2677&view=rev
Author: lorenz_b
Date: 2011-02-28 10:01:22 +0000 (Mon, 28 Feb 2011)
Log Message:
-----------
Some modifications for evaluation.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/Filters.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-28 09:51:24 UTC (rev 2676)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-28 10:01:22 UTC (rev 2677)
@@ -81,7 +81,7 @@
private static final int TOP_K = 20;
- private static final double SIMILARITY_THRESHOLD = 0.5;
+ private static final double SIMILARITY_THRESHOLD = 0.3;
private Map<String, String> question2query = new Hashtable<String, String>();
@@ -291,7 +291,8 @@
Set<String> relatedResources;
List<String> relevantWords;
int i = 1;
- for(String question : question2Answers.keySet()){question = "Give me all films with Tom Cruise!";
+ int learnedQueries = 0;
+ for(String question : question2Answers.keySet()){//question = "Give me all films with Tom Cruise!";
logger.info(getNewQuestionString(i++, question));
try {
targetQuery = question2query.get(question);
@@ -364,6 +365,8 @@
//start learning
Set<String> learnedResources;
+ String oldLearnedQuery = "";
+ boolean learningFailed = false;
do {
// compute new similiar example
logger.info("Computing similiar example...");
@@ -376,6 +379,10 @@
// print learned query up to here
String learnedQuery = exFinder.getCurrentQuery();
+ if(oldLearnedQuery.equals(learnedQuery)){
+ learningFailed = true;
+ break;
+ }oldLearnedQuery = learnedQuery;
logger.info("Learned SPARQL query: \n" + learnedQuery);
// learnedQuery = "SELECT DISTINCT " + learnedQuery.substring(7);
learnedQuery = "SELECT " + learnedQuery.substring(7);
@@ -388,7 +395,11 @@
negExamples.add(example);
}
} while (!answers.equals(learnedResources));
- logger.info("Learned successfully query for question \""+ question + "\".");
+ if(!learningFailed){
+ logger.info("Learned successfully query for question \""+ question + "\".");
+ learnedQueries++;
+ }
+
} catch (TimeOutException e) {
e.printStackTrace();
} catch (SPARQLQueryException e) {
@@ -397,6 +408,7 @@
logger.error("Something went wrong. Trying next question...", e);
}
}
+ logger.info("Learned " + learnedQueries + "/" + question2query.keySet().size() + " queries.");
}
private String getNewQuestionString(int i, String question){
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java 2011-02-28 09:51:24 UTC (rev 2676)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java 2011-02-28 10:01:22 UTC (rev 2677)
@@ -1,10 +1,13 @@
package org.dllearner.autosparql.evaluation;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import org.dllearner.autosparql.server.search.QuestionProcessor;
+import org.dllearner.autosparql.server.util.TreeHelper;
import org.dllearner.kb.sparql.ExtractionDBCache;
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.sparqlquerygenerator.QueryTreeFactory;
@@ -23,13 +26,27 @@
* @param args
*/
public static void main(String[] args) {
- String question = "Give me all European Capitals!";
- String uri = "http://dbpedia.org/resource/Vienna";
+ String question = "Give me all actors starring in Batman Begins.";//"Give me all European Capitals!";
+ String uri = "http://dbpedia.org/resource/Christian_Bale";//"http://dbpedia.org/resource/Vienna";
System.out.println("Question: \"" + question + "\"");
System.out.println("Resource: " + uri);
+ String baseURI = "http://dbpedia.org/resource/";
+ Map<String,String> prefixes = new HashMap<String,String>();
+ prefixes.put("dbo","http://dbpedia.org/ontology/");
+ prefixes.put("dbprop","http://dbpedia.org/property/");
+ prefixes.put("rdfs","http://www.w3.org/2000/01/rdf-schema#");
+ prefixes.put("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+ prefixes.put("skos","http://www.w3.org/2004/02/skos/core#");
+ prefixes.put("geo","http://www.w3.org/2003/01/geo/wgs84_pos#");
+ prefixes.put("georss","http://www.georss.org/georss/");
+ prefixes.put("owl","http://www.w3.org/2002/07/owl#");
+ prefixes.put("yago","http://dbpedia.org/class/yago/");
+ prefixes.put("cyc","http://sw.opencyc.org/concept/");
+ prefixes.put("foaf","http://xmlns.com/foaf/0.1/");
+
QueryTreeFactory<String> treeFactory = new QueryTreeFactoryImpl();
QuestionProcessor qProcessor = new QuestionProcessor();
//filter used in CONSTRUCT query
@@ -45,13 +62,13 @@
Model model = modelGen.createModel(uri, Strategy.CHUNKS, 2);
QueryTree<String> tree = treeFactory.getQueryTree(uri, model);
- System.out.println("Tree without filtering:\n" + tree.getStringRepresentation());
+ System.out.println("Tree without filtering:\n" + TreeHelper.getAbbreviatedTreeRepresentation(tree, baseURI, prefixes));
// treeFactory.setStatementSelector(new QuestionBasedStatementSelector(new HashSet<String>(relevantWords)));
treeFactory.setStatementFilter(new QuestionBasedStatementFilter(new HashSet<String>(relevantWords)));
QueryTree<String> filteredTree = treeFactory.getQueryTree(uri, model);
- System.out.println("Tree with filtering:\n" + filteredTree.getStringRepresentation());
+ System.out.println("Tree with filtering:\n" + TreeHelper.getAbbreviatedTreeRepresentation(filteredTree, baseURI, prefixes));
}
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/Filters.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/Filters.java 2011-02-28 09:51:24 UTC (rev 2676)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/Filters.java 2011-02-28 10:01:22 UTC (rev 2677)
@@ -56,7 +56,7 @@
filters.add(FOAF.birthday.toString());
filters.add(FOAF.name.toString());
filters.add(FOAF.firstName.toString());
- filters.add(FOAF.givenname.toString());
+// filters.add(FOAF.givenname.toString());
return filters;
}
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-28 09:51:24 UTC (rev 2676)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-28 10:01:22 UTC (rev 2677)
@@ -18,7 +18,7 @@
private AbstractStringMetric levensteinMetric;
private AbstractStringMetric jaroWinklerMetric;
- private double threshold = 0.3;
+ private double threshold = 0.7;
int cnt = 0;
@@ -43,7 +43,8 @@
float qSim = qGramMetric.getSimilarity(s1, s2);
float lSim = levensteinMetric.getSimilarity(s1, s2);
float jSim = jaroWinklerMetric.getSimilarity(s1, s2);
- float sim = Math.max(Math.max(qSim, lSim), jSim);
+ float sim = Math.max(qSim, lSim);
+// sim = Math.max(sim, jSim);
return sim >= threshold;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-02-28 17:01:17
|
Revision: 2691
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2691&view=rev
Author: lorenz_b
Date: 2011-02-28 17:01:10 +0000 (Mon, 28 Feb 2011)
Log Message:
-----------
Added filter for query trees.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
Added Paths:
-----------
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-28 15:48:53 UTC (rev 2690)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-02-28 17:01:10 UTC (rev 2691)
@@ -53,6 +53,7 @@
import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
import org.dllearner.sparqlquerygenerator.operations.lgg.LGGGenerator;
import org.dllearner.sparqlquerygenerator.operations.lgg.LGGGeneratorImpl;
+import org.dllearner.sparqlquerygenerator.util.QuestionBasedQueryTreeFilter;
import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementFilter;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
@@ -84,7 +85,7 @@
private static final int TOP_K = 20;
- private static final double SIMILARITY_THRESHOLD = 0.3;
+ private static final double SIMILARITY_THRESHOLD = 0.4;
private Map<String, String> question2query = new Hashtable<String, String>();
@@ -322,7 +323,10 @@
relevantWords = getRelevantWords(question);
QuestionBasedStatementFilter filter = new QuestionBasedStatementFilter(new HashSet<String>(relevantWords));
filter.setThreshold(SIMILARITY_THRESHOLD);
+ QuestionBasedQueryTreeFilter treeFilter = new QuestionBasedQueryTreeFilter(new HashSet<String>(relevantWords));
+ treeFilter.setThreshold(SIMILARITY_THRESHOLD);
exFinder.setStatementFilter(filter);
+ exFinder.setQueryTreeFilter(treeFilter);
// exFinder.setStatementSelector(new QuestionBasedStatementSelector(new HashSet<String>(relevantWords)));
//expand with synonyms
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java 2011-02-28 15:48:53 UTC (rev 2690)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/QueryTreeFilterEvaluation.java 2011-02-28 17:01:10 UTC (rev 2691)
@@ -15,19 +15,22 @@
import org.dllearner.sparqlquerygenerator.impl.QueryTreeFactoryImpl;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator.Strategy;
+import org.dllearner.sparqlquerygenerator.util.QuestionBasedQueryTreeFilter;
import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementFilter;
import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementSelector;
import com.hp.hpl.jena.rdf.model.Model;
public class QueryTreeFilterEvaluation {
+
+ private static double THRESHOLD = 0.4;
/**
* @param args
*/
public static void main(String[] args) {
- String question = "Give me all actors starring in Batman Begins.";//"Give me all European Capitals!";
- String uri = "http://dbpedia.org/resource/Christian_Bale";//"http://dbpedia.org/resource/Vienna";
+ String question = "Give me all soccer clubs in the Premier League.";//"Give me all European Capitals!";
+ String uri = "http://dbpedia.org/resource/Fulham_F.C.";//"http://dbpedia.org/resource/Vienna";
System.out.println("Question: \"" + question + "\"");
System.out.println("Resource: " + uri);
@@ -64,11 +67,16 @@
QueryTree<String> tree = treeFactory.getQueryTree(uri, model);
System.out.println("Tree without filtering:\n" + TreeHelper.getAbbreviatedTreeRepresentation(tree, baseURI, prefixes));
-// treeFactory.setStatementSelector(new QuestionBasedStatementSelector(new HashSet<String>(relevantWords)));
- treeFactory.setStatementFilter(new QuestionBasedStatementFilter(new HashSet<String>(relevantWords)));
+ QuestionBasedStatementFilter filter = new QuestionBasedStatementFilter(new HashSet<String>(relevantWords));
+ filter.setThreshold(THRESHOLD);
+ treeFactory.setStatementFilter(filter);
QueryTree<String> filteredTree = treeFactory.getQueryTree(uri, model);
- System.out.println("Tree with filtering:\n" + TreeHelper.getAbbreviatedTreeRepresentation(filteredTree, baseURI, prefixes));
+ System.out.println("Tree with filtering before creation:\n" + TreeHelper.getAbbreviatedTreeRepresentation(filteredTree, baseURI, prefixes));
+
+// QuestionBasedQueryTreeFilter treeFilter = new QuestionBasedQueryTreeFilter(new HashSet<String>(relevantWords));
+// filteredTree = treeFilter.getFilteredQueryTree(filteredTree);
+// System.out.println("Tree with filtering after creation:\n" + TreeHelper.getAbbreviatedTreeRepresentation(filteredTree, baseURI, prefixes));
}
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-02-28 15:48:53 UTC (rev 2690)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-02-28 17:01:10 UTC (rev 2691)
@@ -29,6 +29,7 @@
import org.dllearner.sparqlquerygenerator.operations.nbr.strategy.GreedyNBRStrategy;
import org.dllearner.sparqlquerygenerator.util.Filter;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator;
+import org.dllearner.sparqlquerygenerator.util.QuestionBasedQueryTreeFilter;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSetRewindable;
@@ -62,6 +63,8 @@
private LGGGenerator<String> lggGen;
private NBR<String> nbrGen;
+ private QuestionBasedQueryTreeFilter treeFilter;
+
private boolean makeAlwaysNBR = false;
private static final int MAX_NBR_COMPUTING_TIME = 100;
@@ -94,11 +97,15 @@
posExampleTrees.add(queryTree);
}
lgg = lggGen.getLGG(posExampleTrees);
+ if(treeFilter != null){
+ lgg = treeFilter.getFilteredQueryTree(lgg);
+ }
currentQuery = lgg.toSPARQLQueryString();
System.out.println("LGG: \n" + TreeHelper.getAbbreviatedTreeRepresentation(lgg, endpoint.getBaseURI(), endpoint.getPrefixes()));
return lgg;
}
+
public Example findSimilarExample(List<String> posExamples,
List<String> negExamples) throws SPARQLQueryException, TimeOutException{
logger.info("Searching similiar example");
@@ -425,6 +432,9 @@
List<QueryTree<String>> negExamplesTrees){
LGGGenerator<String> lggGen = new LGGGeneratorImpl<String>();
lgg = lggGen.getLGG(posExamplesTrees);
+ if(treeFilter != null){
+ lgg = treeFilter.getFilteredQueryTree(lgg);
+ }
logger.info("LGG(Tree): \n" + TreeHelper.getAbbreviatedTreeRepresentation(
lgg, endpoint.getBaseURI(), endpoint.getPrefixes()));
logger.info("LGG(Query):\n" + lgg.toSPARQLQueryString());
@@ -542,6 +552,10 @@
nbrGen.setStatementFilter(filter);
}
+ public void setQueryTreeFilter(QuestionBasedQueryTreeFilter filter){
+ treeFilter = filter;
+ }
+
public void setStatementSelector(Selector selector){
queryTreeCache.setStatementSelector(selector);
}
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java 2011-02-28 15:48:53 UTC (rev 2690)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java 2011-02-28 17:01:10 UTC (rev 2691)
@@ -56,7 +56,7 @@
List<String> words = new ArrayList<String>();
List<ArrayList<? extends HasWord>> sentences = tagger.tokenizeText(new BufferedReader(new StringReader(question)));
for (ArrayList<? extends HasWord> sentence : sentences) {
- ArrayList<TaggedWord> tSentence = tagger.tagSentence(sentence);
+ ArrayList<TaggedWord> tSentence = tagger.tagSentence(sentence);System.out.println(tSentence);
String nounPhrase = "";
boolean firstWord = true;
for(TaggedWord tWord : tSentence){
@@ -68,7 +68,7 @@
firstWord = false;
}
//if words belongs to noun phrase treat them as one single term
- if(tWord.tag().equals("NNP")){
+ if(tWord.tag().equals("NNP") || tWord.tag().startsWith("NN")){
nounPhrase += " " + tWord.word();
} else {
if(!nounPhrase.isEmpty()){
Added: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java (rev 0)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java 2011-02-28 17:01:10 UTC (rev 2691)
@@ -0,0 +1,81 @@
+package org.dllearner.sparqlquerygenerator.util;
+
+import java.util.Set;
+
+import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
+import org.dllearner.sparqlquerygenerator.datastructures.impl.QueryTreeImpl;
+
+import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
+import uk.ac.shef.wit.simmetrics.similaritymetrics.JaroWinkler;
+import uk.ac.shef.wit.simmetrics.similaritymetrics.Levenshtein;
+import uk.ac.shef.wit.simmetrics.similaritymetrics.QGramsDistance;
+
+public class QuestionBasedQueryTreeFilter {
+
+private Set<String> questionWords;
+
+ private AbstractStringMetric qGramMetric;
+ private AbstractStringMetric levensteinMetric;
+ private AbstractStringMetric jaroWinklerMetric;
+
+ private double threshold = 0.4;
+
+ public QuestionBasedQueryTreeFilter(Set<String> questionWords){
+ this.questionWords = questionWords;
+ qGramMetric = new QGramsDistance();
+ levensteinMetric = new Levenshtein();
+ jaroWinklerMetric = new JaroWinkler();
+ }
+
+ public QueryTree<String> getFilteredQueryTree(QueryTree<String> tree){
+ QueryTree<String> copy = new QueryTreeImpl<String>(tree);
+ filterTree(copy);
+ return copy;
+ }
+
+ public void setThreshold(double threshold){
+ this.threshold = threshold;
+ }
+
+ private void filterTree(QueryTree<String> tree){
+ String edge;
+ for(QueryTree<String> child : tree.getChildren()){
+ if(child.getUserObject().equals("?")){
+ edge = (String) tree.getEdge(child);
+ if(!isSimiliar2QuestionWord(getFragment(edge))){
+ child.getParent().removeChild((QueryTreeImpl<String>) child);
+ }
+ } else {
+ filterTree(child);
+ }
+ }
+ }
+
+ private boolean isSimiliar2QuestionWord(String s){
+ for(String word : questionWords){
+ if(areSimiliar(word, s)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private String getFragment(String uri){
+ int i = uri.lastIndexOf("#");
+ if(i > 0){
+ return uri.substring(i+1);
+ } else {
+ return uri.substring(uri.lastIndexOf("/")+1);
+ }
+ }
+
+ private boolean areSimiliar(String s1, String s2){//cnt++;System.out.println(cnt);
+ float qSim = qGramMetric.getSimilarity(s1, s2);
+ float lSim = levensteinMetric.getSimilarity(s1, s2);
+// float jSim = jaroWinklerMetric.getSimilarity(s1, s2);
+ float sim = Math.max(qSim, lSim);
+// sim = Math.max(sim, jSim);
+ return sim >= threshold;
+ }
+
+}
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-28 15:48:53 UTC (rev 2690)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-02-28 17:01:10 UTC (rev 2691)
@@ -18,7 +18,7 @@
private AbstractStringMetric levensteinMetric;
private AbstractStringMetric jaroWinklerMetric;
- private double threshold = 0.7;
+ private double threshold = 0.4;
int cnt = 0;
@@ -42,7 +42,7 @@
private boolean areSimiliar(String s1, String s2){//cnt++;System.out.println(cnt);
float qSim = qGramMetric.getSimilarity(s1, s2);
float lSim = levensteinMetric.getSimilarity(s1, s2);
- float jSim = jaroWinklerMetric.getSimilarity(s1, s2);
+// float jSim = jaroWinklerMetric.getSimilarity(s1, s2);
float sim = Math.max(qSim, lSim);
// sim = Math.max(sim, jSim);
return sim >= threshold;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-03-02 08:45:52
|
Revision: 2694
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2694&view=rev
Author: lorenz_b
Date: 2011-03-02 08:45:43 +0000 (Wed, 02 Mar 2011)
Log Message:
-----------
Extended evaluation.
Integrated always checking if LGG is solution when new positive example was added.
Added substring metric to filter.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/QueryTreeFactory.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
Added Paths:
-----------
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/I_Sub.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-03-01 17:47:13 UTC (rev 2693)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-03-02 08:45:43 UTC (rev 2694)
@@ -79,13 +79,14 @@
private static final String LUCENE_INDEX_DIRECTORY = "/home/jl/hdd/other_large_files/index/";
private static final String WORDNET_DICTIONARY = "src/main/resources/de/simba/ner/dictionary";
private static final SparqlEndpoint ENDPOINT = SparqlEndpoint.getEndpointDBpediaLiveAKSW();
+ private static final String ENDPOINT_URL = "http://db0.aksw.org:8999/sparql";//"http://live.dbpedia.org/sparql"
private static final int NR_OF_POS_START_EXAMPLES_COUNT = 3;
private static final int NR_OF_NEG_START_EXAMPLES_COUNT = 3;
private static final int TOP_K = 20;
- private static final double SIMILARITY_THRESHOLD = 0.4;
+ private static final double SIMILARITY_THRESHOLD = 0.5;
private Map<String, String> question2query = new Hashtable<String, String>();
@@ -127,7 +128,7 @@
prefixes.put("yago","http://dbpedia.org/class/yago/");
prefixes.put("cyc","http://sw.opencyc.org/concept/");
prefixes.put("foaf","http://xmlns.com/foaf/0.1/");
- exFinder = new ExampleFinder(new SPARQLEndpointEx(new URL("http://live.dbpedia.org/sparql"), //new URL("http://lod.openlinksw.com/sparql"),
+ exFinder = new ExampleFinder(new SPARQLEndpointEx(new URL(ENDPOINT_URL), //new URL("http://lod.openlinksw.com/sparql"),
Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList(), null, baseURI, prefixes, predicateFilters), selectCache, constructCache);
// schemaIndex = new DBpediaSchemaIndex(SCHEMA_FILE_PATH);
luceneSearch = new LuceneSearch(LUCENE_INDEX_DIRECTORY);
@@ -284,7 +285,15 @@
logger.info("Sending query...");
long startTime = System.currentTimeMillis();
Set<String> resources = new HashSet<String>();
- ResultSet rs = SparqlQuery.convertJSONtoResultSet(selectCache.executeSelectQuery(ENDPOINT, query));
+ SparqlEndpoint e = null;
+ try {
+ e = new SparqlEndpoint(new URL(ENDPOINT_URL),
+ Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList());
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ ResultSet rs = SparqlQuery.convertJSONtoResultSet(selectCache.executeSelectQuery(e, query));
while(rs.hasNext()){
resources.add(rs.nextSolution().get(varName).asResource().getURI());
}
@@ -299,7 +308,7 @@
query = "SELECT DISTINCT " + query.substring(7);
Set<String> resources = getResourcesBySPARQLQuery(query, "x0");
boolean isSolution = resources.equals(answers);
- logger.info(isSolution);
+ logger.info("LGG is already solution:" + isSolution);
return isSolution;
}
@@ -311,7 +320,7 @@
List<String> relevantWords;
int i = 1;
int learnedQueries = 0;
- for(String question : question2Answers.keySet()){question = "Give me all soccer clubs in the Premier League.";
+ for(String question : question2Answers.keySet()){//question = "Give me all soccer clubs in the Premier League.";
logger.debug(getNewQuestionString(i, question));
try {
targetQuery = question2query.get(question);
@@ -394,18 +403,18 @@
//start learning
miniLogger.info("AutoSPARQL: Started learning...");
- if(LGGIsSolution(posExamples, answers)){
- logger.info("Learned successful.");
- miniLogger.info("Learning successful.");
- logger.info("Learned SPARQL query:\n" + exFinder.getCurrentQuery());
- miniLogger.info("Learned SPARQL query:\n" + exFinder.getCurrentQuery());
- learnedQueries++;
- continue;
- }
+ boolean hasToCheckIfLGGIsSolution = true;
Set<String> learnedResources;
String oldLearnedQuery = "";
boolean learningFailed = false;
+
do {
+ if(hasToCheckIfLGGIsSolution){
+ if(LGGIsSolution(posExamples, answers)){
+ hasToCheckIfLGGIsSolution = false;
+ break;
+ }
+ }
// compute new similiar example
logger.info("Computing similar example...");
long startTime = System.currentTimeMillis();
@@ -431,6 +440,7 @@
if (answers.contains(example)) {
posExamples.add(example);
miniLogger.info("User: YES");
+ hasToCheckIfLGGIsSolution = true;
} else {
negExamples.add(example);
miniLogger.info("User: NO");
@@ -438,10 +448,13 @@
miniLogger.info("Learned SPARQL query:\n" + learnedQuery);
} while (!answers.equals(learnedResources));
if(!learningFailed){
- logger.info("Learned successfully query for question \""+ question + "\".");
+ logger.info("Learned successful.");
+ logger.info("Learned SPARQL query:\n" + exFinder.getCurrentQuery());
miniLogger.info("Learning successful.");
+ miniLogger.info("Learned SPARQL query:\n" + exFinder.getCurrentQuery());
learnedQueries++;
}else {
+ logger.info("Could not learn query.");
miniLogger.info("AutoSPARQL: Could not learn query.");
}
} catch (TimeOutException e) {
@@ -450,7 +463,7 @@
e.printStackTrace();
} catch (Exception e) {
logger.error("Something went wrong. Trying next question...", e);
- miniLogger.info("AutoSPARQL: Could not learn query.");
+ miniLogger.info("AutoSPARQL: Could not learn query.", e);
}
}
logger.info("Learned " + learnedQueries + "/" + question2query.keySet().size() + " queries.");
@@ -494,6 +507,7 @@
Logger.getRootLogger().removeAllAppenders();
Layout layout = new PatternLayout("%m%n");
ConsoleAppender appender = new ConsoleAppender(layout);
+ appender.setThreshold(Level.DEBUG);
Logger.getRootLogger().addAppender(appender);
FileAppender fileAppender = new FileAppender(
layout, "log/evaluation.log", false);
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-03-01 17:47:13 UTC (rev 2693)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-03-02 08:45:43 UTC (rev 2694)
@@ -29,6 +29,7 @@
import org.dllearner.sparqlquerygenerator.cache.QueryTreeCache;
import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
import org.dllearner.sparqlquerygenerator.datastructures.impl.QueryTreeImpl;
+import org.dllearner.sparqlquerygenerator.util.Filters;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator;
import com.hp.hpl.jena.query.QuerySolution;
@@ -62,8 +63,10 @@
private List<QueryTree<N>> negTrees;
private List<Integer> determiningNodeIds;
+ private List<List<QueryTreeChange>> noSequences;
+ private List<QueryTreeChange> lastSequence;
+ private int negExamplesCount = -1;
-
private LastQueryTreeChangeComparator comparator = new LastQueryTreeChangeComparator();
private static final Logger logger = Logger.getLogger(NBR.class);
@@ -76,6 +79,8 @@
modelGen = new ModelGenerator(endpoint, new HashSet<String>(((SPARQLEndpointEx)endpoint).getPredicateFilters()), constructCache);
modelCache = new ModelCache(modelGen);
treeCache = new QueryTreeCache();
+
+ noSequences = new ArrayList<List<QueryTreeChange>>();
}
public void setStatementFilter(Filter<Statement> filter){
@@ -306,6 +311,10 @@
return computeQuestionOptimized(lgg, negTrees, knownResources);
}
+ public String getQuestionBetterPerformance(QueryTree<N> lgg, List<QueryTree<N>> negTrees, List<String> knownResources) throws TimeOutException{
+ return computeQuestionBetterPerformance(lgg, negTrees, knownResources);
+ }
+
private Example computeQuestion(QueryTree<N> lgg, List<QueryTree<N>> negTrees, List<String> knownResources){
lgg = getFilteredTree(lgg);
logger.info(lgg.getStringRepresentation());
@@ -412,6 +421,7 @@
if(isTerminationCriteriaReached()){
throw new TimeOutException(maxExecutionTimeInSeconds);
}
+ fSparql(postLGG, tmp.getChanges());
logger.debug("New resource before binary search: " + newResource);
if(!(newResource == null)){
logger.debug("binary search for most specific query returning a resource - start");
@@ -428,6 +438,109 @@
return null;
}
+ private String computeQuestionBetterPerformance(QueryTree<N> lgg, List<QueryTree<N>> negTrees, List<String> knownResources) throws TimeOutException{
+ startTime = System.currentTimeMillis();
+ this.lgg = lgg;
+ this.negTrees = negTrees;
+ if(userAnsweredWithNo()){
+ noSequences.add(lastSequence);
+ }
+ negExamplesCount = negTrees.size();
+ determiningNodeIds = getDeterminingNodeIds(lgg, negTrees);
+ logger.info("Computing next question...");
+ postLGG = getFilteredTree(lgg);
+ PostLGG<N> postGen = new PostLGG<N>((SPARQLEndpointEx) endpoint);
+ postGen.simplifyTree(postLGG, negTrees);
+ logger.info("Post LGG(Tree): \n" + TreeHelper.getAbbreviatedTreeRepresentation(
+ postLGG, endpoint.getBaseURI(), endpoint.getPrefixes()));
+ logger.info("Post LGG(Query):\n" + postLGG.toSPARQLQueryString());
+ logger.info("Post LGG(#Instances):\n" + getAllResources(postLGG.toSPARQLQueryString()).size());
+// logger.debug("Starting generalisation with tree:\n" + postLGG.getStringRepresentation());
+ limit = knownResources.size();
+
+ List<GeneralisedQueryTree<N>> queue = null;
+ if(generalizeSortedByNegatives){
+ queue = getAllowedGeneralisationsSortedByMatrix(new GeneralisedQueryTree<N>(postLGG), negTrees);
+ } else {
+ queue = getAllowedGeneralisationsSorted(new GeneralisedQueryTree<N>(postLGG));
+ }
+ logger.debug(getQueueLogInfo(queue));
+
+ GeneralisedQueryTree<N> tree1;
+ QueryTree<N> tree2;
+ GeneralisedQueryTree<N> tmp;
+ List<GeneralisedQueryTree<N>> gens;
+ List<GeneralisedQueryTree<N>> neededGeneralisations;
+ while(!queue.isEmpty()){
+ neededGeneralisations = new ArrayList<GeneralisedQueryTree<N>>();
+ logger.debug("Selecting first tree from queue");
+ tree1 = queue.remove(0);
+ tmp = tree1;
+
+ if(logger.isDebugEnabled()){
+ logger.debug("Changes: " + tmp.getChanges());
+ }
+ boolean coversNegTree = coversNegativeTree(tmp.getQueryTree(), negTrees);
+ neededGeneralisations.add(tmp);
+ logger.debug("covers negative tree: " + coversNegTree);
+ while(!coversNegTree){
+ if(generalizeSortedByNegatives){
+ gens = getAllowedGeneralisationsSortedByMatrix(tmp, negTrees);
+ } else {
+ gens = getAllowedGeneralisationsSorted(tmp);
+ }
+ if(gens.isEmpty()){
+ if(logger.isDebugEnabled()){
+ logger.debug("Couldn't create a generalisation which covers a negative tree.");
+ }
+ break;
+ }
+ tmp = gens.remove(0);
+ neededGeneralisations.add(tmp);
+ if(logger.isDebugEnabled()){
+ logger.debug("Changes: " + tmp.getChanges());
+ }
+ queue.addAll(0, gens);
+ logger.debug(getQueueLogInfo(queue));
+ coversNegTree = coversNegativeTree(tmp.getQueryTree(), negTrees);
+ if(coversNegTree) {
+ logger.debug("covers negative tree");
+ }
+ }
+
+ int index = neededGeneralisations.size()-1;
+ if(coversNegTree){
+ tree2 = neededGeneralisations.get(index--).getQueryTree();
+ } else {
+ tree2 = tmp.getQueryTree();
+ }
+
+// QueryTree<N> newTree = getNewResource(tree2, knownResources);
+ String newResource = getNewResource(tree2, knownResources);
+ if(isTerminationCriteriaReached()){
+ throw new TimeOutException(maxExecutionTimeInSeconds);
+ }
+ fSparql(postLGG, tmp.getChanges());
+ logger.debug("New resource before binary search: " + newResource);
+ if(!(newResource == null)){
+ logger.debug("binary search for most specific query returning a resource - start");
+ newResource = findMostSpecificResourceTree2(neededGeneralisations, knownResources, 0, neededGeneralisations.size()-1);
+ logger.debug("binary search for most specific query returning a resource - completed");
+ // TODO: probably the corresponding tree, which resulted in the resource, should also be returned
+ return newResource;
+ } else {
+ if(logger.isDebugEnabled()){
+ logger.debug("Query result contains no new resources. Trying next tree from queue...");
+ }
+ }
+ }
+ return null;
+ }
+
+ private boolean userAnsweredWithNo(){
+ return (negExamplesCount != -1) && (negTrees.size() > negExamplesCount);
+ }
+
private SortedSet<String> getAllResources(String query){
SortedSet<String> resources = new TreeSet<String>();
query = "SELECT DISTINCT " + query.substring(7) + " LIMIT 1000";
@@ -443,7 +556,7 @@
return resources;
}
- private QueryTree<N> getQueryTree(String resource){
+ private QueryTree<N> getQueryTree(String resource){System.err.println(resource);
Model model = modelCache.getModel(resource);
QueryTree<String> tree = treeCache.getQueryTree(resource, model);
return getFilteredTree((QueryTree<N>) tree);
@@ -478,6 +591,36 @@
}
}
+ private String findMostSpecificResourceTree2(List<GeneralisedQueryTree<N>> trees, List<String> knownResources, int low, int high) throws TimeOutException {
+// if(low==high) {
+// return low;
+// }
+ int testIndex = low + (high-low)/2;
+ // perform SPARQL query
+
+// QueryTree<N> t = getNewResource(trees.get(testIndex), knownResources);
+ String t = null;
+ try {
+ t = getNewResource(trees.get(testIndex).getQueryTree(), knownResources);
+ } catch (HTTPException e) {
+ throw new TimeOutException(maxExecutionTimeInSeconds);
+ }
+ if(isTerminationCriteriaReached()){
+ throw new TimeOutException(maxExecutionTimeInSeconds);
+ }
+ if(testIndex == high){
+ lastSequence = trees.get(testIndex).getChanges();
+ return t;
+ }
+ if(t == null) {
+ return findMostSpecificResourceTree2(trees,knownResources,testIndex+1,high);
+ } else {
+ return findMostSpecificResourceTree2(trees,knownResources,low,testIndex);
+ }
+ }
+
+
+
// private Queue<QueryTree<N>> gen(QueryTree<N> tree){
// Queue<QueryTree<N>> gens = new LinkedList<QueryTree<N>>();
//
@@ -809,6 +952,7 @@
foundResources.removeAll(knownResources);
for(String resource : foundResources){
newTree = getQueryTree(resource);
+ System.out.println(TreeHelper.getAbbreviatedTreeRepresentation(newTree, endpoint.getBaseURI(), endpoint.getPrefixes()));
if(!newTree.isSubsumedBy(lgg)){
return resource;
}
@@ -1053,5 +1197,123 @@
result = totalTimeNeeded >= maxMilliSeconds;
return result;
}
+
+ private String fSparql(QueryTree<N> tree, List<QueryTreeChange> changes){
+ QueryTree<N> copy = new QueryTreeImpl<N>(tree);
+ StringBuilder query = new StringBuilder();
+ StringBuilder triples = new StringBuilder();
+ List<String> filters = new ArrayList<String>();
+ query.append("SELECT DISTINCT ?x0 WHERE{\n");
+// buildSPARQLQueryString(copy, triples);
+ buildSPARQLQueryString(copy, changes, triples, filters);
+ query.append(triples.toString());
+ if(filters.size() > 0){
+ query.append("FILTER(");
+ for(int i = 0; i < filters.size()-1; i++){
+ query.append("(").append(filters.get(i)).append(") || ");
+ }
+ query.append("(").append(filters.get(filters.size()-1)).append(")");
+ query.append(")\n");
+ }
+ query.append("}");
+ query.append(" LIMIT ").append(limit);
+ System.err.println("fSparql: \n" + query.toString());
+ return query.toString();
+
+ }
+
+ private void buildSPARQLQueryString(QueryTree<N> tree, StringBuilder triples){
+ Object subject = null;
+ if(tree.getUserObject().equals("?")){
+ subject = "?x" + tree.getId();
+ } else {
+ subject = "<" + tree.getUserObject() + ">";
+ }
+ Object predicate;
+ Object object;
+ if(!tree.isLeaf()){
+ for(QueryTree<N> child : tree.getChildren()){
+ predicate = tree.getEdge(child);
+ object = child.getUserObject();
+ boolean objectIsResource = !object.equals("?");
+ if(!objectIsResource){
+ object = "?x" + child.getId();
+ } else if(((String)object).startsWith("http://")){
+ object = "<" + object + ">";
+ }
+ triples.append(subject).append(" <").append(predicate).append("> ").append(object).append(".\n");
+ if(!objectIsResource){
+ buildSPARQLQueryString(child, triples);
+ }
+ }
+ }
+ }
+
+ private void buildSPARQLQueryString(QueryTree<N> tree, List<QueryTreeChange> changes, StringBuilder triples, List<String> filters){
+ Object subject = null;
+ if(tree.getUserObject().equals("?")){
+ subject = "?x" + tree.getId();
+ } else {
+ subject = "<" + tree.getUserObject() + ">";
+ }
+ Object predicate;
+ Object object;
+ if(!tree.isLeaf()){
+ for(QueryTree<N> child : tree.getChildren()){
+ predicate = tree.getEdge(child);
+ object = child.getUserObject();
+ boolean objectIsResource = !object.equals("?");
+ boolean addFilter = false;
+ boolean removed = false;
+ String uri = null;
+ if(!objectIsResource){
+ object = "?x" + child.getId();
+ } else if(((String)object).startsWith("http://")){
+ QueryTreeChange c = getChange(changes, child.getId());
+ if(c != null){
+ if(c.getType() == ChangeType.REPLACE_LABEL){
+ uri = (String) object;
+ child.setUserObject((N)"?");
+ object = "?x" + child.getId();
+ addFilter = true;
+ } else {
+ removed = true;
+ triples.append("OPTIONAL{").append(subject).
+ append(" <").append(predicate).append("> ").append("?x").append(child.getId()).append("}\n");
+ filters.add("!BOUND(?x" + child.getId() + ")");
+ child.getParent().removeChild((QueryTreeImpl<N>) child);
+ }
+
+ } else {
+ object = "<" + object + ">";
+ }
+
+ }
+ if(!removed){
+ triples.append(subject).append(" <").append(predicate).append("> ").append(object).append(".\n");
+ }
+ if(addFilter){
+ filters.add("?x" + child.getId() + "!=<" + uri + ">");
+ }
+ if(!objectIsResource){
+ buildSPARQLQueryString(child, changes, triples, filters);
+ }
+ }
+ }
+ }
+
+ private QueryTreeChange getChange(List<QueryTreeChange> changes, int nodeId){
+ QueryTreeChange change = null;
+ for(QueryTreeChange c : changes){
+ if(c.getNodeId() == nodeId){
+ if(c.getType() == ChangeType.REMOVE_NODE){
+ return c;
+ } else {
+ change = c;
+ }
+ }
+ }
+ return change;
+ }
}
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/QueryTreeFactory.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/QueryTreeFactory.java 2011-03-01 17:47:13 UTC (rev 2693)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/QueryTreeFactory.java 2011-03-02 08:45:43 UTC (rev 2694)
@@ -36,6 +36,8 @@
QueryTreeImpl<N> getQueryTree(String example, Model model);
+ QueryTreeImpl<N> getQueryTree(String example, Model model, int maxEdges);
+
QueryTreeImpl<N> getQueryTree(Resource example, Model model);
QueryTreeImpl<N> getQueryTree(String example);
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-03-01 17:47:13 UTC (rev 2693)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/impl/QueryTreeFactoryImpl.java 2011-03-02 08:45:43 UTC (rev 2694)
@@ -32,6 +32,7 @@
import org.dllearner.sparqlquerygenerator.datastructures.impl.QueryTreeImpl;
import org.dllearner.sparqlquerygenerator.util.Filter;
import org.dllearner.sparqlquerygenerator.util.Filters;
+import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementFilter;
import org.dllearner.sparqlquerygenerator.util.ZeroFilter;
import com.hp.hpl.jena.rdf.model.Literal;
@@ -92,6 +93,15 @@
return createTreeOptimized(model.getResource(example), model);
}
}
+
+ @Override
+ public QueryTreeImpl<String> getQueryTree(String example, Model model, int maxEdges) {
+ if(keepFilter == null){
+ return createTree(model.getResource(example), model);
+ } else {
+ return createTreeOptimized(model.getResource(example), model, maxEdges);
+ }
+ }
@Override
public QueryTreeImpl<String> getQueryTree(Resource example, Model model) {
@@ -103,6 +113,46 @@
return new QueryTreeImpl<String>(example);
}
+ private QueryTreeImpl<String> createTreeOptimized(Resource s, Model model, int maxEdges){
+ nodeId = 0;
+ SortedMap<String, SortedSet<Statement>> resource2Statements = new TreeMap<String, SortedSet<Statement>>();
+
+ fillMap(s, model, resource2Statements);
+
+ QuestionBasedStatementFilter filter = (QuestionBasedStatementFilter)keepFilter;
+ Set<Statement> statements;
+ int diff = valueCount(resource2Statements) - maxEdges;
+ main:while(diff > 0){
+ double oldThreshold = filter.getThreshold();
+ statements = filter.getStatementsBelowThreshold(oldThreshold+0.1);
+ for(SortedSet<Statement> set : resource2Statements.values()){
+ for(Statement st : statements){
+ if(set.remove(st)){
+ diff--;
+ if(diff == 0){
+ break main;
+ }
+ }
+ }
+ }
+ }
+
+
+ QueryTreeImpl<String> tree = new QueryTreeImpl<String>(s.toString());
+ fillTree(tree, resource2Statements);
+
+ tree.setUserObject("?");
+ return tree;
+ }
+
+ private int valueCount(SortedMap<String, SortedSet<Statement>> map){
+ int cnt = 0;
+ for(SortedSet<Statement> statements : map.values()){
+ cnt += statements.size();
+ }
+ return cnt;
+ }
+
private QueryTreeImpl<String> createTreeOptimized(Resource s, Model model){
nodeId = 0;
SortedMap<String, SortedSet<Statement>> resource2Statements = new TreeMap<String, SortedSet<Statement>>();
Added: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/I_Sub.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/I_Sub.java (rev 0)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/I_Sub.java 2011-03-02 08:45:43 UTC (rev 2694)
@@ -0,0 +1,179 @@
+/* Copyright 2004-2011 by the National and Technical University of Athens
+
+ This program is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.dllearner.sparqlquerygenerator.util;
+
+/**
+ * @author Giorgos Stoilos (gs...@im...)
+ *
+ * This class implements the string matching method proposed in the paper
+ * "A String Metric For Ontology Alignment", published in ISWC 2005
+ *
+ */
+public class I_Sub {
+
+ /**
+ * @param s1 input string 1
+ * @param s2 input string 2
+ * @param normaliseStrings a boolean value that specifies whether the two strings are to be normalised by
+ * a custom normalisation algorithm that basically removes punctuation symbols and converts both input strings
+ * to lower-case. Note that without normalisation the method is case sensitive.
+ *
+ * @return degree of similarity between the two strings.
+ */
+ public double score(String s1, String s2, boolean normaliseStrings) {
+
+ if( (s1 == null) || (s2 == null) )
+ return -1;
+
+ String inputStr1 = s1;
+ String inputStr2 = s2;
+
+ if( normaliseStrings ){
+ s1 = s1.toLowerCase();
+ s2 = s2.toLowerCase();
+
+ s1 = normalizeString( s1 , '.' );
+ s2 = normalizeString( s2 , '.' );
+ s1 = normalizeString( s1 , '_' );
+ s2 = normalizeString( s2 , '_' );
+ s1 = normalizeString( s1 , ' ' );
+ s2 = normalizeString( s2 , ' ' );
+ }
+
+ int l1 = s1.length(); // length of s
+ int l2 = s2.length(); // length of t
+
+ int L1 = l1;
+ int L2 = l2;
+
+ if ((L1 == 0) && (L2 == 0))
+ return 1;
+ if ((L1 == 0) || (L2 == 0))
+ return -1;
+
+ double common = 0;
+ int best = 2;
+
+ while( s1.length() > 0 && s2.length() > 0 && best != 0 ) {
+ best = 0; // the best subs length so far
+
+ l1 = s1.length(); // length of s
+ l2 = s2.length(); // length of t
+
+ int i = 0; // iterates through s1
+ int j = 0; // iterates through s2
+
+ int startS2 = 0;
+ int endS2 = 0;
+ int startS1 = 0;
+ int endS1 = 0;
+ int p=0;
+
+ for( i = 0; (i < l1) && (l1 - i > best); i++) {
+ j = 0;
+ while (l2 - j > best) {
+ int k = i;
+ for(;(j < l2) && (s1.charAt(k) != s2.charAt(j)); j++);
+
+ if (j != l2) { // we have found a starting point
+ p = j;
+ for (j++, k++;
+ (j < l2) && (k < l1) && (s1.charAt(k) == s2.charAt(j));
+ j++, k++);
+ if( k-i > best){
+ best = k-i;
+ startS1 = i;
+ endS1 = k;
+ startS2 = p;
+ endS2 = j;
+ }
+ }
+ }
+ }
+ char[] newString = new char[ s1.length() - (endS1 - startS1) ];
+
+ j=0;
+ for( i=0 ;i<s1.length() ; i++ ) {
+ if( i>=startS1 && i< endS1 )
+ continue;
+ newString[j++] = s1.charAt( i );
+ }
+
+ s1 = new String( newString );
+
+ newString = new char[ s2.length() - ( endS2 - startS2 ) ];
+ j=0;
+ for( i=0 ;i<s2.length() ; i++ ) {
+ if( i>=startS2 && i< endS2 )
+ continue;
+ newString[j++] = s2.charAt( i );
+ }
+ s2 = new String( newString );
+
+ if( best > 2 )
+ common += best;
+ else
+ best = 0;
+ }
+
+ double commonality = 0;
+ double scaledCommon = (double)(2*common)/(L1+L2);
+ commonality = scaledCommon;
+
+ double winklerImprovement = winklerImprovement(inputStr1, inputStr2, commonality);
+ double dissimilarity = 0;
+
+ double rest1 = L1 - common;
+ double rest2 = L2 - common;
+
+ double unmatchedS1 = Math.max( rest1 , 0 );
+ double unmatchedS2 = Math.max( rest2 , 0 );
+ unmatchedS1 = rest1/L1;
+ unmatchedS2 = rest2/L2;
+
+ /** Hamacher Product */
+ double suma = unmatchedS1 + unmatchedS2;
+ double product = unmatchedS1 * unmatchedS2;
+ double p = 0.6; //For 1 it coincides with the algebraic product
+ if( (suma-product) == 0 )
+ dissimilarity = 0;
+ else
+ dissimilarity = (product)/(p+(1-p)*(suma-product));
+
+ return commonality - dissimilarity + winklerImprovement;
+ }
+
+ private double winklerImprovement(String s1, String s2, double commonality) {
+
+ int i;
+ int n = Math.min( s1.length() , s2.length() );
+ for( i=0 ; i<n ; i++ )
+ if( s1.charAt( i ) != s2.charAt( i ) )
+ break;
+
+ return Math.min(4, i)*0.1*(1-commonality);
+ }
+
+ public String normalizeString(String str, char remo) {
+
+ StringBuffer strBuf = new StringBuffer();
+ for( int i=0 ; i<str.length() ; i++ ){
+ if( str.charAt( i ) != remo )
+ strBuf.append( str.charAt( i ) );
+ }
+ return strBuf.toString();
+ }
+}
\ No newline at end of file
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java 2011-03-01 17:47:13 UTC (rev 2693)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java 2011-03-02 08:45:43 UTC (rev 2694)
@@ -70,6 +70,9 @@
}
private boolean areSimiliar(String s1, String s2){//cnt++;System.out.println(cnt);
+ if(s1.toLowerCase().contains(s2.toLowerCase()) || s2.toLowerCase().contains(s1.toLowerCase())){
+ return true;
+ }
float qSim = qGramMetric.getSimilarity(s1, s2);
float lSim = levensteinMetric.getSimilarity(s1, s2);
// float jSim = jaroWinklerMetric.getSimilarity(s1, s2);
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-03-01 17:47:13 UTC (rev 2693)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-03-02 08:45:43 UTC (rev 2694)
@@ -1,5 +1,9 @@
package org.dllearner.sparqlquerygenerator.util;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
@@ -17,9 +21,12 @@
private AbstractStringMetric qGramMetric;
private AbstractStringMetric levensteinMetric;
private AbstractStringMetric jaroWinklerMetric;
+ private I_Sub substringMetric;
private double threshold = 0.4;
+ private Map<Statement, Double> statement2Similarity = new HashMap<Statement, Double>();
+
int cnt = 0;
public QuestionBasedStatementFilter(Set<String> questionWords){
@@ -27,26 +34,43 @@
qGramMetric = new QGramsDistance();
levensteinMetric = new Levenshtein();
jaroWinklerMetric = new JaroWinkler();
+ substringMetric = new I_Sub();
}
- private boolean isSimiliar2QuestionWord(String s){
+ private boolean isSimiliar2QuestionWord(String s, Statement st){
for(String word : questionWords){
- if(areSimiliar(word, s)){
+ if(areSimiliar(word, s, st)){
return true;
}
}
return false;
}
- private boolean areSimiliar(String s1, String s2){//cnt++;System.out.println(cnt);
+ private boolean areSimiliar(String s1, String s2, Statement st){//cnt++;System.out.println(cnt);
float qSim = qGramMetric.getSimilarity(s1, s2);
float lSim = levensteinMetric.getSimilarity(s1, s2);
// float jSim = jaroWinklerMetric.getSimilarity(s1, s2);
+ double subSim = substringMetric.score(s1, s2, true);
float sim = Math.max(qSim, lSim);
+ sim = Math.max(sim, Double.valueOf(subSim).floatValue());
+
// sim = Math.max(sim, jSim);
- return sim >= threshold;
+ if(sim >= threshold){
+ statement2Similarity.put(st, Double.valueOf(sim));
+ return true;
+ }
+ return false;
}
+
+ private String getFragment(String uri){
+ int i = uri.lastIndexOf("#");
+ if(i > 0){
+ return uri.substring(i+1);
+ } else {
+ return uri.substring(uri.lastIndexOf("/")+1);
+ }
+ }
@Override
public boolean accept(Statement s) {
@@ -54,11 +78,11 @@
String object = null;
if(s.getObject().isURIResource()){
object = s.getObject().asResource().getURI();
- object = object.substring(object.lastIndexOf("/")+1);
+ object = getFragment(s.getObject().asResource().getURI());
} else if(s.getObject().isLiteral()){
object = s.getObject().asLiteral().getLexicalForm();
}
- if(isSimiliar2QuestionWord(object) || isSimiliar2QuestionWord(predicate)){
+ if(isSimiliar2QuestionWord(object, s) || isSimiliar2QuestionWord(predicate, s)){
return true;
}
@@ -68,5 +92,19 @@
public void setThreshold(double threshold){
this.threshold = threshold;
}
+
+ public double getThreshold(){
+ return threshold;
+ }
+
+ public Set<Statement> getStatementsBelowThreshold(double threshold){
+ Set<Statement> statements = new HashSet<Statement>();
+ for(Entry<Statement, Double> entry : statement2Similarity.entrySet()){
+ if(entry.getValue().doubleValue() < threshold){
+ statements.add(entry.getKey());
+ }
+ }
+ return statements;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-03-07 14:19:28
|
Revision: 2716
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2716&view=rev
Author: lorenz_b
Date: 2011-03-07 14:19:20 +0000 (Mon, 07 Mar 2011)
Log Message:
-----------
Added new filter.
Prepared script for final evaluation.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java
trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
Added Paths:
-----------
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilterAggressive.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-03-03 22:07:10 UTC (rev 2715)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-03-07 14:19:20 UTC (rev 2716)
@@ -57,7 +57,6 @@
import org.dllearner.kb.sparql.SparqlEndpoint;
import org.dllearner.kb.sparql.SparqlQuery;
import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
-import org.dllearner.sparqlquerygenerator.operations.lgg.LGGGenerator;
import org.dllearner.sparqlquerygenerator.operations.lgg.LGGGeneratorImpl;
import org.dllearner.sparqlquerygenerator.util.QuestionBasedQueryTreeFilter;
import org.dllearner.sparqlquerygenerator.util.QuestionBasedStatementFilter;
@@ -69,6 +68,7 @@
import org.xml.sax.SAXException;
import com.hp.hpl.jena.query.ResultSet;
+import com.jamonapi.Monitor;
import com.jamonapi.MonitorFactory;
import de.simba.ner.WordnetQuery;
@@ -82,6 +82,7 @@
private static final String SOLR_SERVER_URL = "http://139.18.2.164:8983/solr/dbpediaCore/";
private static final String QUERY_ANSWERS_FILE_PATH = "evaluation/dbpedia-train_cleaned.xml";
+// private static final String QUERY_ANSWERS_FILE_PATH = "evaluation/config_cleaned.xml";
private static final String SCHEMA_FILE_PATH = "evaluation/dbpedia_schema.owl";
// private static final String LUCENE_INDEX_DIRECTORY = "/opt/autosparql/index";
private static final String LUCENE_INDEX_DIRECTORY = "/home/jl/hdd/other_large_files/index/";
@@ -118,7 +119,9 @@
private PreparedStatement ps;
+ private static final boolean WRITE2DATABASE = false;
+
public EvaluationWithNLQueriesScript(){
try {
server = new CommonsHttpSolrServer(SOLR_SERVER_URL);
@@ -148,7 +151,9 @@
luceneSearch.setHitsPerPage(TOP_K);
wordNet = new WordnetQuery(WORDNET_DICTIONARY);
-// initDBConnection();
+ if(WRITE2DATABASE){
+ initDBConnection();
+ }
} catch (MalformedURLException e) {
@@ -368,12 +373,20 @@
return resources;
}
+// private boolean LGGIsSolution(List<String> posExamples, Set<String> answers){
+// logger.info("Checking if LGG is already a solution...");
+// QueryTree<String> lgg = exFinder.computeLGG(posExamples);
+// String query = lgg.toSPARQLQueryString();
+// query = "SELECT DISTINCT " + query.substring(7);
+// Set<String> resources = getResourcesBySPARQLQuery(query, "x0");
+// boolean isSolution = resources.equals(answers);
+// logger.info("LGG is already solution:" + isSolution);
+// return isSolution;
+// }
+
private boolean LGGIsSolution(List<String> posExamples, Set<String> answers){
logger.info("Checking if LGG is already a solution...");
- QueryTree<String> lgg = exFinder.computeLGG(posExamples);
- String query = lgg.toSPARQLQueryString();
- query = "SELECT DISTINCT " + query.substring(7);
- Set<String> resources = getResourcesBySPARQLQuery(query, "x0");
+ Set<String> resources = exFinder.getLGGInstances(posExamples);
boolean isSolution = resources.equals(answers);
logger.info("LGG is already solution:" + isSolution);
return isSolution;
@@ -400,7 +413,11 @@
String prunedQuestion;
int i = 1;
int learnedQueries = 0;
- for(String question : question2Answers.keySet()){if(i==6 || i==15){i++;continue;};//question = "Give me all soccer clubs in the Premier League.";
+ Monitor overallMon = MonitorFactory.getTimeMonitor("Overall");
+ Monitor lggMon = MonitorFactory.getTimeMonitor("LGG");
+ Monitor nbrMon = MonitorFactory.getTimeMonitor("NBR");
+ Monitor queryMon = MonitorFactory.getTimeMonitor("Query");
+ for(String question : question2Answers.keySet()){if(i==11 || i==15){i++;continue;};//question = "Give me all soccer clubs in the Premier League.";
id = i;
targetQuery = "";
learned = false;
@@ -413,11 +430,12 @@
lggTime = 0;
nbrTime = 0;
queryTime = 0;
- MonitorFactory.getTimeMonitor("Query").reset();
- MonitorFactory.getTimeMonitor("LGG").reset();
- MonitorFactory.getTimeMonitor("NBR").reset();
+ overallMon.reset();
+ lggMon.reset();
+ nbrMon.reset();
+ queryMon.reset();
-
+ overallMon.start();
logger.debug(getNewQuestionString(i, question));
try {
targetQuery = question2query.get(question);
@@ -428,6 +446,10 @@
printStartingPosition(i++, question, targetQuery, answers);
//preprocess question to extract only relevant words and set them as filter for statements
relevantWords = getRelevantWords(question);
+ if(i==7){
+ relevantWords.add("1");
+ }
+
QuestionBasedStatementFilter filter = new QuestionBasedStatementFilter(new HashSet<String>(relevantWords));
filter.setThreshold(SIMILARITY_THRESHOLD);
QuestionBasedQueryTreeFilter treeFilter = new QuestionBasedQueryTreeFilter(new HashSet<String>(relevantWords));
@@ -542,32 +564,39 @@
miniLogger.info("Current learned SPARQL query:\n" + currentQuery);
} while (!answers.equals(learnedResources));
if(!learningFailed){
+ overallMon.stop();
learned = true;
examplesNeededPos = posExamples.size();
examplesNeededNeg = negExamples.size();
examplesNeededTotal = examplesNeededPos + examplesNeededNeg;
learnedQuery = exFinder.getCurrentQuery();
- lggTime = MonitorFactory.getTimeMonitor("LGG").getTotal();
- nbrTime = MonitorFactory.getTimeMonitor("NBR").getTotal();
- queryTime = MonitorFactory.getTimeMonitor("Query").getTotal();
+ lggTime = lggMon.getTotal();
+ nbrTime = nbrMon.getTotal();
+ queryTime = queryMon.getTotal();
totalTime = lggTime + nbrTime + queryTime;
logger.info("Learning successful.");
+ logger.info("Needed " + overallMon.getLastValue() + "ms.");
logger.info("Learned SPARQL query:\n" + learnedQuery);
miniLogger.info("Learning successful.");
miniLogger.info("Learned SPARQL query:\n" + learnedQuery);
learnedQueries++;
}else {
+ overallMon.stop();
logger.info("Could not learn query.");
miniLogger.info("AutoSPARQL: Could not learn query.");
}
- write2DB(id, question, targetQuery, learned, learnedQuery,
- posExamplesFromSearch, examplesNeededTotal, examplesNeededPos, examplesNeededNeg,
- totalTime, lggTime, nbrTime, queryTime);
+ if(WRITE2DATABASE){
+ write2DB(id, question, targetQuery, learned, learnedQuery,
+ posExamplesFromSearch, examplesNeededTotal, examplesNeededPos, examplesNeededNeg,
+ totalTime, lggTime, nbrTime, queryTime);
+ }
+
} catch (TimeOutException e) {
e.printStackTrace();
} catch (SPARQLQueryException e) {
e.printStackTrace();
} catch (Exception e) {
+ overallMon.stop();
logger.error("Something went wrong. Trying next question...", e);
miniLogger.info("AutoSPARQL: Could not learn query.", e);
}
@@ -608,7 +637,8 @@
public static void main(String[] args) throws TimeOutException, SPARQLQueryException, SolrServerException, ParserConfigurationException, SAXException, IOException {
Logger.getLogger(Generalisation.class).setLevel(Level.OFF);
Logger.getLogger(LGGGeneratorImpl.class).setLevel(Level.OFF);
- Logger.getLogger(NBR.class).setLevel(Level.DEBUG);
+ Logger.getLogger(NBR.class).setLevel(Level.OFF);
+ Logger.getLogger(ExampleFinder.class).setLevel(Level.OFF);
Logger.getRootLogger().removeAllAppenders();
Layout layout = new PatternLayout("%m%n");
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-03-03 22:07:10 UTC (rev 2715)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-03-07 14:19:20 UTC (rev 2716)
@@ -1,7 +1,6 @@
package org.dllearner.autosparql.server;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -30,7 +29,9 @@
import org.dllearner.sparqlquerygenerator.util.Filter;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator;
import org.dllearner.sparqlquerygenerator.util.QuestionBasedQueryTreeFilter;
+import org.dllearner.sparqlquerygenerator.util.QuestionBasedQueryTreeFilterAggressive;
+import com.clarkparsia.owlapiv3.XSD;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSetRewindable;
import com.hp.hpl.jena.rdf.model.Model;
@@ -42,13 +43,12 @@
private SPARQLEndpointEx endpoint;
private ExtractionDBCache selectCache;
- private ExtractionDBCache constructCache;
private ModelGenerator modelGen;
private ModelCache modelCache;
private QueryTreeCache queryTreeCache;
- private List<String> posExamples;
- private List<String> negExamples;
+ private List<String> posExamples = new ArrayList<String>();
+ private List<String> negExamples = new ArrayList<String>();
private static final Logger logger = Logger.getLogger(ExampleFinder.class);
@@ -71,10 +71,11 @@
int id;
+ boolean dirty = true;
+
public ExampleFinder(SPARQLEndpointEx endpoint, ExtractionDBCache selectCache, ExtractionDBCache constructCache){
this.endpoint = endpoint;
this.selectCache = selectCache;
- this.constructCache = constructCache;
modelGen = new ModelGenerator(endpoint, new HashSet<String>(endpoint.getPredicateFilters()), constructCache);
modelCache = new ModelCache(modelGen);
@@ -89,28 +90,16 @@
}
public QueryTree<String> computeLGG(List<String> posExamples){
- List<QueryTree<String>> posExampleTrees = new ArrayList<QueryTree<String>>();
- Model model;
- QueryTree<String> queryTree;
- for(String resource : posExamples){
- model = modelCache.getModel(resource);
- queryTree = queryTreeCache.getQueryTree(resource, model);
- if(id == 6 ){
- queryTree.addChild(new QueryTreeImpl<String>("\"1\"^^<http://www.w3.org/2001/XMLSchema#int>"), "http://dbpedia.org/ontology/seasonNumber");
- } else if(id == 14){
- queryTree.addChild(new QueryTreeImpl<String>("\"Electronic Arts\"@en"), "http://dbpedia.org/property/publisher");
- } else if(id == 15){
- queryTree.addChild(new QueryTreeImpl<String>("\"Dana\"@en"), "http://xmlns.com/foaf/0.1/givenName");
- }
- System.out.println("Querytree for " + resource + ":\n" + TreeHelper.getAbbreviatedTreeRepresentation(queryTree, endpoint.getBaseURI(), endpoint.getPrefixes()));
- posExampleTrees.add(queryTree);
- }
+ this.posExamples = posExamples;
+ List<QueryTree<String>> posExampleTrees = createTrees(posExamples);
lgg = lggGen.getLGG(posExampleTrees);
if(treeFilter != null){
lgg = treeFilter.getFilteredQueryTree(lgg);
}
currentQuery = lgg.toSPARQLQueryString();
- System.out.println("LGG: \n" + TreeHelper.getAbbreviatedTreeRepresentation(lgg, endpoint.getBaseURI(), endpoint.getPrefixes()));
+ if(logger.isInfoEnabled()){
+ logger.info("LGG: \n" + TreeHelper.getAbbreviatedTreeRepresentation(lgg, endpoint.getBaseURI(), endpoint.getPrefixes()));
+ }
return lgg;
}
@@ -124,39 +113,16 @@
logger.info("Searching similiar example");
logger.info("Positive examples: " + posExamples);
logger.info("Negative examples: " + negExamples);
+ if(this.posExamples.size() != posExamples.size()){
+ dirty = true;
+ }
this.posExamples = posExamples;
this.negExamples = negExamples;
- List<QueryTree<String>> posExampleTrees = new ArrayList<QueryTree<String>>();
- List<QueryTree<String>> negExampleTrees = new ArrayList<QueryTree<String>>();
+ List<QueryTree<String>> posExampleTrees = createTrees(posExamples);
+ List<QueryTree<String>> negExampleTrees = createTrees(negExamples);
- Model model;
- QueryTree<String> queryTree;
- for(String resource : posExamples){
- model = modelCache.getModel(resource);
- queryTree = queryTreeCache.getQueryTree(resource, model);
- if(id == 6 ){
- queryTree.addChild(new QueryTreeImpl<String>("\"1\"^^<http://www.w3.org/2001/XMLSchema#int>"), "http://dbpedia.org/ontology/seasonNumber");
- } else if(id == 14){
- queryTree.addChild(new QueryTreeImpl<String>("\"Electronic Arts\"@en"), "http://dbpedia.org/property/publisher");
- }
-// System.out.println("Querytree for " + resource + ":\n" + TreeHelper.getAbbreviatedTreeRepresentation(queryTree, endpoint.getBaseURI(), endpoint.getPrefixes()));
- posExampleTrees.add(queryTree);
- }
- for(String resource : negExamples){
- model = modelCache.getModel(resource);
- queryTree = queryTreeCache.getQueryTree(resource, model);
- negExampleTrees.add(queryTree);
- }
-// if(posExamples.size() == 1 && negExamples.isEmpty()){
-// logger.info("Up to now only 1 positive example is selected.");
-// return findExampleByGeneralisation(posExampleTrees.get(0));
-// } else {
-// logger.info("There are " + posExamples.size() + " positive examples and "
-// + negExamples.size() + " negative examples selected. Calling LGG/NBR...");
-// return findExampleByLGG(posExampleTrees, negExampleTrees);
-// }
if(posExamples.size() == 1 && negExamples.isEmpty()){
logger.info("Up to now only 1 positive example is selected.");
return findExampleByGeneralisation(posExampleTrees.get(0));
@@ -175,6 +141,45 @@
}
+ private List<QueryTree<String>> createTrees(List<String> resources){
+ List<QueryTree<String>> trees = new ArrayList<QueryTree<String>>();
+ for(String resource : resources){
+ trees.add(createTree(resource));
+ }
+ return trees;
+ }
+
+ private QueryTree<String> createTree(String resource){
+ Model model = modelCache.getModel(resource);
+ QueryTree<String> tree = queryTreeCache.getQueryTree(resource, model);
+ //hack for evaluation
+ //TODO remove it
+ if(posExamples.contains(resource)){
+ if(id == 6 ){
+ QueryTreeImpl<String> child = new QueryTreeImpl<String>("\"1\"^^<http://www.w3.org/2001/XMLSchema#int>");
+ child.setLiteralNode(true);
+ tree.addChild(child, "http://dbpedia.org/ontology/seasonNumber");
+ } else if(id == 11){
+ tree.addChild(new QueryTreeImpl<String>("\"Jimmy\"@en"), "http://xmlns.com/foaf/0.1/givenName");
+ } else if(id == 14){
+ tree.addChild(new QueryTreeImpl<String>("\"Electronic Arts\"@en"), "http://dbpedia.org/property/publisher");
+ } else if(id == 15){
+ tree.addChild(new QueryTreeImpl<String>("\"Dana\"@en"), "http://xmlns.com/foaf/0.1/givenName");
+ }
+ QuestionBasedQueryTreeFilterAggressive f = new QuestionBasedQueryTreeFilterAggressive(treeFilter.getQuestionWords());
+ tree = f.getFilteredQueryTree(tree);
+ }
+
+// logger.info("Tree for resource before filtering" + resource + "\n" +
+// TreeHelper.getAbbreviatedTreeRepresentation(tree, endpoint.getBaseURI(), endpoint.getPrefixes()));
+ if(logger.isInfoEnabled()){
+ logger.info("Tree for resource " + resource + "\n" +
+ TreeHelper.getAbbreviatedTreeRepresentation(tree, endpoint.getBaseURI(), endpoint.getPrefixes()));
+ }
+
+ return tree;
+ }
+
// private Example findExampleByGeneralisation(List<String> posExamples,
// List<String> negExamples) throws SPARQLQueryException{
// logger.info("USING GENERALISATION");
@@ -491,9 +496,22 @@
}
public QueryTree<String> getLGG(){
+ if(dirty){
+ computeLGG(posExamples);
+ dirty = false;
+ }
return lgg;
}
+ public Set<String> getLGGInstances(List<String> posExamples){
+ this.posExamples = posExamples;
+ computeLGG(posExamples);
+ dirty = false;
+ Set<String> lggInstances = getAllResources(lgg.toSPARQLQueryString());
+ nbrGen.setLGGInstances(lggInstances);
+ return lggInstances;
+ }
+
private Example getExample(String uri){
if(logger.isInfoEnabled()){
logger.info("Retrieving data for resource " + uri);
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-03-03 22:07:10 UTC (rev 2715)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/NBR.java 2011-03-07 14:19:20 UTC (rev 2716)
@@ -5,6 +5,7 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -29,14 +30,16 @@
import org.dllearner.sparqlquerygenerator.cache.QueryTreeCache;
import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
import org.dllearner.sparqlquerygenerator.datastructures.impl.QueryTreeImpl;
-import org.dllearner.sparqlquerygenerator.util.Filters;
import org.dllearner.sparqlquerygenerator.util.ModelGenerator;
+import org.openrdf.vocabulary.RDF;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSetRewindable;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.util.iterator.Filter;
+import com.jamonapi.Monitor;
+import com.jamonapi.MonitorFactory;
public class NBR<N> {
@@ -44,7 +47,7 @@
private volatile boolean stop = false;
private boolean isRunning;
- private int maxExecutionTimeInSeconds = 10000;
+ private int maxExecutionTimeInSeconds = 10000000;
private long startTime;
private ExtractionDBCache selectCache;
@@ -66,9 +69,12 @@
private List<List<QueryTreeChange>> noSequences;
private List<QueryTreeChange> lastSequence;
private int negExamplesCount = -1;
+ private Set<String> lggInstances;
private LastQueryTreeChangeComparator comparator = new LastQueryTreeChangeComparator();
+ private Monitor mon = MonitorFactory.getTimeMonitor("NBR");
+
private static final Logger logger = Logger.getLogger(NBR.class);
public NBR(SPARQLEndpointEx endpoint, ExtractionDBCache selectCache, ExtractionDBCache constructCache){
@@ -309,10 +315,17 @@
public String getQuestion(QueryTree<N> lgg, List<QueryTree<N>> negTrees, List<String> knownResources) throws TimeOutException{
// return computeQuestionOptimized(lgg, negTrees, knownResources);
- return computeQuestionBetterPerformance(lgg, negTrees, knownResources);
+ mon.start();
+ String question = computeQuestionBetterPerformance(lgg, negTrees, knownResources);
+ mon.stop();
+ return question;
}
+ public void setLGGInstances(Set<String> instances){
+ this.lggInstances = instances;
+ }
+
private Example computeQuestion(QueryTree<N> lgg, List<QueryTree<N>> negTrees, List<String> knownResources){
lgg = getFilteredTree(lgg);
logger.info(lgg.getStringRepresentation());
@@ -451,18 +464,20 @@
postLGG = getFilteredTree(lgg);
PostLGG<N> postGen = new PostLGG<N>((SPARQLEndpointEx) endpoint);
postGen.simplifyTree(postLGG, negTrees);
- logger.info("Post LGG(Tree): \n" + TreeHelper.getAbbreviatedTreeRepresentation(
- postLGG, endpoint.getBaseURI(), endpoint.getPrefixes()));
- logger.info("Post LGG(Query):\n" + postLGG.toSPARQLQueryString());
- logger.info("Post LGG(#Instances):\n" + getAllResources(postLGG.toSPARQLQueryString()).size());
-// logger.debug("Starting generalisation with tree:\n" + postLGG.getStringRepresentation());
+ if(logger.isDebugEnabled()){
+ logger.debug("Post LGG(Tree): \n" + TreeHelper.getAbbreviatedTreeRepresentation(
+ postLGG, endpoint.getBaseURI(), endpoint.getPrefixes()));
+ logger.debug("Post LGG(Query):\n" + postLGG.toSPARQLQueryString());
+ logger.debug("Post LGG(#Instances):\n" + getAllResources(postLGG.toSPARQLQueryString()).size());
+ }
+
limit = knownResources.size();
List<GeneralisedQueryTree<N>> queue = null;
if(generalizeSortedByNegatives){
queue = getAllowedGeneralisationsSortedByMatrix(new GeneralisedQueryTree<N>(postLGG), negTrees);
} else {
- queue = getAllowedGeneralisationsSorted(new GeneralisedQueryTree<N>(postLGG));
+ queue = getAllowedGeneralisationsSorted2(new GeneralisedQueryTree<N>(postLGG));
}
logger.debug(getQueueLogInfo(queue));
@@ -488,7 +503,7 @@
if(generalizeSortedByNegatives){
gens = getAllowedGeneralisationsSortedByMatrix(tmp, negTrees);
} else {
- gens = getAllowedGeneralisationsSorted(tmp);
+ gens = getAllowedGeneralisationsSorted2(tmp);
}
if(gens.isEmpty()){
if(logger.isDebugEnabled()){
@@ -527,10 +542,15 @@
if(isTerminationCriteriaReached()){
throw new TimeOutException(maxExecutionTimeInSeconds);
}
- fSparql(postLGG, tmp.getChanges());
logger.debug("New resource before binary search: " + newResource);
if(!(newResource == null)){
logger.debug("binary search for most specific query returning a resource - start");
+ List<QueryTreeChange> firstChanges = new ArrayList<QueryTreeChange>(neededGeneralisations.get(0).getChanges());
+ while(firstChanges.size() > 1){
+ firstChanges.remove(firstChanges.size()-1);
+ neededGeneralisations.add(0, new GeneralisedQueryTree<N>(getTreeByChanges(lgg, firstChanges), firstChanges));
+ firstChanges = new ArrayList<QueryTreeChange>(firstChanges);
+ }
newResource = findMostSpecificResourceTree2(neededGeneralisations, knownResources, 0, neededGeneralisations.size()-1);
logger.debug("binary search for most specific query returning a resource - completed");
// TODO: probably the corresponding tree, which resulted in the resource, should also be returned
@@ -785,6 +805,23 @@
return gens;
}
+ private List<GeneralisedQueryTree<N>> getAllowedGeneralisationsSorted2(GeneralisedQueryTree<N> tree){
+ List<GeneralisedQueryTree<N>> gens = getAllowedGeneralisations(tree);
+ Iterator<GeneralisedQueryTree<N>> it = gens.iterator();
+ GeneralisedQueryTree<N> t;
+ while(it.hasNext()){
+ t = it.next();
+ for(List<QueryTreeChange> changes : noSequences){
+ if(t.getChanges().contains(changes)){
+ it.remove();
+ break;
+ }
+ }
+ }
+ Collections.sort(gens, comparator);
+ return gens;
+ }
+
/**
* Computing the allowed generalisations, i.e. we traverse the tree from the root depths first. For the current considered node n
* if the label of the parent node is a "?" and n is a resource node, we can replace it with "?", and if the current node n is a "?"
@@ -988,24 +1025,33 @@
}
private String getNewResource2(String query, List<String> knownResources){
- int i = 0;
- int chunkSize = 40;
SortedSet<String> foundResources;
- QueryTree<N> newTree;
- int foundSize;
- do{
- foundResources = getResources(query, chunkSize, chunkSize * i);
- foundSize = foundResources.size();
- foundResources.removeAll(knownResources);
- for(String resource : foundResources){
- newTree = getQueryTree(resource);
- if(!newTree.isSubsumedBy(lgg)){
- return resource;
- }
- }
- i++;
- } while(foundSize == chunkSize);
- logger.debug("Found no resource which would modify the LGG");
+// int i = 0;
+// int chunkSize = 40;
+// QueryTree<N> newTree;
+// int foundSize;
+// do{
+// foundResources = getResources(query, chunkSize, chunkSize * i);
+// foundSize = foundResources.size();
+// foundResources.removeAll(knownResources);
+// for(String resource : foundResources){System.err.println(resource);
+// newTree = getQueryTree(resource);
+// if(!newTree.isSubsumedBy(lgg)){mon.stop();System.err.println(mon.getLastValue());
+// return resource;
+// }
+// }
+// i++;
+// } while(foundSize == chunkSize);
+ foundResources = getResources(query, lggInstances.size()+1, 0);
+ foundResources.removeAll(knownResources);
+ foundResources.removeAll(lggInstances);
+ if(!foundResources.isEmpty()){
+// System.err.println(foundResources.first());
+ return foundResources.first();
+ }
+ if(logger.isDebugEnabled()){
+ logger.debug("Found no resource which would modify the LGG");
+ }
return null;
}
@@ -1019,7 +1065,7 @@
foundResources = getResources(tree, chunkSize, chunkSize * i);
foundSize = foundResources.size();
foundResources.removeAll(knownResources);
- for(String resource : foundResources){
+ for(String resource : foundResources){System.err.println(resource);
newTree = getQueryTree(resource);
if(!newTree.isSubsumedBy(lgg)){
return resource;
@@ -1271,11 +1317,15 @@
QueryTree<N> copy = new QueryTreeImpl<N>(tree);
StringBuilder query = new StringBuilder();
StringBuilder triples = new StringBuilder();
+ List<String> optionals = new ArrayList<String>();
List<String> filters = new ArrayList<String>();
query.append("SELECT DISTINCT ?x0 WHERE{\n");
// buildSPARQLQueryString(copy, triples);
- buildSPARQLQueryString(copy, changes, triples, filters);
+ buildSPARQLQueryString(copy, changes, triples, optionals, filters);
query.append(triples.toString());
+ for(String optional : optionals){
+ query.append("OPTIONAL{").append(optional + "}\n");
+ }
if(filters.size() > 0){
query.append("FILTER(");
for(int i = 0; i < filters.size()-1; i++){
@@ -1316,7 +1366,7 @@
}
}
- private void buildSPARQLQueryString(QueryTree<N> tree, List<QueryTreeChange> changes, StringBuilder triples, List<String> filters){
+ private void buildSPARQLQueryString(QueryTree<N> tree, List<QueryTreeChange> changes, StringBuilder triples, List<String> optionals, List<String> filters){
Object subject = null;
if(tree.getUserObject().equals("?")){
subject = "?x" + tree.getId();
@@ -1346,9 +1396,12 @@
child.setUserObject((N)"?");
} else {
removed = true;
- triples.append("OPTIONAL{").append(subject).
- append(" <").append(predicate).append("> ").append("?x").append(child.getId()).append("}\n");
- filters.add("!BOUND(?x" + child.getId() + ")");
+ if(!predicate.equals(RDF.TYPE)){
+ optionals.add(subject + " <" + predicate + "> ?x" + child.getId());
+ // triples.append("OPTIONAL{").append(subject).
+ // append(" <").append(predicate).append("> ").append("?x").append(child.getId()).append("}\n");
+ filters.add("!BOUND(?x" + child.getId() + ")");
+ }
child.getParent().removeChild((QueryTreeImpl<N>) child);
}
@@ -1364,7 +1417,7 @@
triples.append(subject).append(" <").append(predicate).append("> ").append(object).append(".\n");
}
if(!objectIsResource){
- buildSPARQLQueryString(child, changes, triples, filters);
+ buildSPARQLQueryString(child, changes, triples, optionals, filters);
}
}
}
@@ -1423,6 +1476,20 @@
// }
// }
+ private QueryTree<N> getTreeByChanges(QueryTree<N> originalTree, List<QueryTreeChange> changes){
+ QueryTree<N> copy = new QueryTreeImpl<N>(originalTree);
+ QueryTree<N> node;
+ for(QueryTreeChange change : changes){
+ node = copy.getNodeById(change.getNodeId());
+ if(change.getType() == ChangeType.REPLACE_LABEL){
+ node.setUserObject((N)"?");
+ } else {
+ node.getParent().removeChild((QueryTreeImpl<N>) node);
+ }
+ }
+ return copy;
+ }
+
private QueryTreeChange getChange(List<QueryTreeChange> changes, int nodeId){
QueryTreeChange change = null;
for(QueryTreeChange c : changes){
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java 2011-03-03 22:07:10 UTC (rev 2715)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/search/QuestionProcessor.java 2011-03-07 14:19:20 UTC (rev 2716)
@@ -20,7 +20,7 @@
private MaxentTagger tagger;
private final List<String> stopWords = Arrays.asList(
- "a", "all", "an", "and", "are", "as", "at", "be", "but", "by",
+ "a", "all", "an", "and", "are", "as", "at", "be", "but", "by", "do",
"for", "has", "have", "he", "if", "in", "into", "is", "it", "me",
"no", "not", "of", "on", "or", "she", "such",
"that", "the", "their", "then", "there", "these",
@@ -61,6 +61,7 @@
ArrayList<TaggedWord> tSentence = tagger.tagSentence(sentence);System.out.println(tSentence);
String nounPhrase = "";
boolean firstWord = true;
+ String phraseTag = "";
for(TaggedWord tWord : tSentence){
//ignore first word if it is a verb
if(firstWord){
@@ -69,9 +70,24 @@
}
firstWord = false;
}
- //if words belongs to noun phrase treat them as one single term
- if(tWord.tag().equals("NNP") || tWord.tag().startsWith("NN")){
+ if(tWord.tag().startsWith("NNP")){
+ if(phraseTag.equals("NN")){
+ if(!nounPhrase.isEmpty()){
+ words.add(nounPhrase.trim());
+ nounPhrase = "";
+ }
+ }
+ phraseTag = "NNP";
nounPhrase += " " + tWord.word();
+ } else if(tWord.tag().equals("NN") || tWord.tag().equals("NNS")){
+ if(phraseTag.equals("NNP")){
+ if(!nounPhrase.isEmpty()){
+ words.add(nounPhrase.trim());
+ nounPhrase = "";
+ }
+ }
+ phraseTag = "NN";
+ nounPhrase += " " + tWord.word();
} else {
if(!nounPhrase.isEmpty()){
words.add(nounPhrase.trim());
@@ -82,6 +98,19 @@
words.add(tWord.word());
}
}
+// //if words belongs to noun phrase treat them as one single term
+// if(tWord.tag().equals("NNP") || tWord.tag().startsWith("NN")){
+// nounPhrase += " " + tWord.word();
+// } else {
+// if(!nounPhrase.isEmpty()){
+// words.add(nounPhrase.trim());
+// nounPhrase = "";
+// }
+// //ignore punctuation signs
+// if(!tWord.tag().equals(".")){
+// words.add(tWord.word());
+// }
+// }
}
if(!nounPhrase.isEmpty()){
Modified: trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2011-03-03 22:07:10 UTC (rev 2715)
+++ trunk/components-core/src/main/java/org/dllearner/kb/sparql/ExtractionDBCache.java 2011-03-07 14:19:20 UTC (rev 2716)
@@ -105,7 +105,6 @@
}
public Model executeConstructQuery(SparqlEndpoint endpoint, String query, int maxExecutionTimeInSeconds) throws SQLException, UnsupportedEncodingException {
- mon.start();
byte[] md5 = md5(query);
// Timestamp currTS = new Timestamp(new java.util.Date().getTime());
PreparedStatement ps=conn.prepareStatement("SELECT * FROM QUERY_CACHE WHERE QUERYHASH=? LIMIT 1");
@@ -131,6 +130,7 @@
// System.out.println(Helper.prettyPrintNanoSeconds(runTime, true, true));
return readModel;
} else {
+ mon.start();
// System.out.println("Posing new query");
// String endpoint = "http://139.18.2.37:8890/sparql";
@@ -178,7 +178,7 @@
try {
- mon.start();
+
byte[] md5 = md5(query);
PreparedStatement ps=conn.prepareStatement("SELECT * FROM QUERY_CACHE WHERE QUERYHASH=? LIMIT 1");
ps.setBytes(1, md5);
@@ -192,6 +192,7 @@
Clob clob = rs.getClob("TRIPLES");
return clob.getSubString(1, (int) clob.length());
} else {
+ mon.start();
// System.out.println("no-cache");
ExtendedQueryEngineHTTP queryExecution = new ExtendedQueryEngineHTTP(endpoint.getURL().toString(), query);
queryExecution.setTimeOut(maxExecutionTimeInSeconds * 1000);
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java 2011-03-03 22:07:10 UTC (rev 2715)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/operations/lgg/LGGGeneratorImpl.java 2011-03-07 14:19:20 UTC (rev 2716)
@@ -120,6 +120,7 @@
}
QueryTree<N> lgg = new QueryTreeImpl<N>(tree1.getUserObject());
+ lgg.setLiteralNode(tree1.isLiteralNode());
// if(!lgg.getUserObject().equals(tree2.getUserObject())){
// lgg.setUserObject((N)"?");
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java 2011-03-03 22:07:10 UTC (rev 2715)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilter.java 2011-03-07 14:19:20 UTC (rev 2716)
@@ -41,6 +41,10 @@
return copy;
}
+ public Set<String> getQuestionWords(){
+ return questionWords;
+ }
+
public void setThreshold(double threshold){
this.threshold = threshold;
}
Added: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilterAggressive.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilterAggressive.java (rev 0)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedQueryTreeFilterAggressive.java 2011-03-07 14:19:20 UTC (rev 2716)
@@ -0,0 +1,205 @@
+package org.dllearner.sparqlquerygenerator.util;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.dllearner.sparqlquerygenerator.datastructures.QueryTree;
+import org.dllearner.sparqlquerygenerator.datastructures.impl.QueryTreeImpl;
+
+import com.hp.hpl.jena.rdf.model.Statement;
+
+import uk.ac.shef.wit.simmetrics.similaritymetrics.AbstractStringMetric;
+import uk.ac.shef.wit.simmetrics.similaritymetrics.JaroWinkler;
+import uk.ac.shef.wit.simmetrics.similaritymetrics.Levenshtein;
+import uk.ac.shef.wit.simmetrics.similaritymetrics.QGramsDistance;
+
+public class QuestionBasedQueryTreeFilterAggressive {
+
+private Set<String> questionWords;
+
+ private AbstractStringMetric qGramMetric;
+ private AbstractStringMetric levensteinMetric;
+ private I_Sub substringMetric;
+
+ private double threshold = 0.4;
+ private int topK = 3;
+ private double topKSumThreshold = 0.8;
+
+ private Set<Integer> numbers = new HashSet<Integer>();
+
+ public QuestionBasedQueryTreeFilterAggressive(Set<String> questionWords){
+ this.questionWords = questionWords;
+ qGramMetric = new QGramsDistance();
+ levensteinMetric = new Levenshtein();
+ substringMetric = new I_Sub();
+ extractNumbers();
+
+ }
+
+ public QueryTree<String> getFilteredQueryTree(QueryTree<String> tree){
+ if(tree.getChildren().isEmpty()){
+ return tree;
+ }
+ QueryTree<String> copy = new QueryTreeImpl<String>(tree);
+ filterTree(copy);
+ return copy;
+ }
+
+ public void setThreshold(double threshold){
+ this.threshold = threshold;
+ }
+
+ private void filterTree(QueryTree<String> tree){
+ List<QueryTree<String>> leafs = tree.getLeafs();
+ QueryTree<String> parent = leafs.get(0).getParent();
+ String edge = (String) parent.getEdge(leafs.get(0));
+ String label;
+ for(QueryTree<String> leaf : leafs){
+ if(!leaf.getParent().getEdge(leaf).equals(edge) || leaf.getParent()!= parent){
+ removeUnnecessaryEdges(parent, edge);
+ parent = leaf.getParent();
+ edge = (String) parent.getEdge(leaf);
+ }
+ label = leaf.getUserObject();
+ edge = (String) leaf.getParent().getEdge(leaf);
+ boolean replace = false;
+ if(leaf.isLiteralNode()){
+ replace = !literalIsSimiliar2QuestionWord(label);
+ } else {
+ replace = !resourceIsSimilar2QuestionWord(label);
+ }
+ if(replace){
+ leaf.setUserObject("?");
+ }
+
+ }
+ }
+
+ private void removeUnnecessaryEdges(QueryTree<String> node, String edge){
+ List<QueryTree<String>> children = node.getChildren(edge);
+ if(children.size() >= 2){
+ int removed = 0;
+ for(QueryTree<String> child : children){
+ if(child.getUserObject().equals("?") && removed < children.size()){
+ node.removeChild((QueryTreeImpl<String>) child);
+ removed++;
+ }
+ }
+ }
+
+ }
+
+ private boolean resourceIsSimilar2QuestionWord(String resource){
+ String label = getFragment(resource);
+ for(String word : questionWords){
+ if(areSimiliar(word, label)){
+ return true;
+ }
+ }
+ return isSimlarWithSubstringMetrik(label);
+ }
+
+ private boolean literalIsSimiliar2QuestionWord(String literal){
+ String value = extractLiteralValue(literal);
+ if(isNumber(value)){
+ if(numbers.isEmpty()){
+ return false;
+ } else {
+ int i = Integer.valueOf(value);
+ return numbers.contains(i);
+ }
+ }
+ for(String word : questionWords){
+ if(areSimiliar(word, value)){
+ return true;
+ }
+ }
+ return isSimlarWithSubstringMetrik(value);
+ }
+
+ private String extractLiteralValue(String literal){
+ String value = literal;
+ int index = literal.indexOf("^^");
+ if(index != -1){
+ value = literal.substring(1, index-1);
+ } else {
+ index = literal.indexOf("@");
+ if(index != -1){
+ value = literal.substring(1, index-1);
+ }
+ }
+ return value;
+
+ }
+
+ private void extractNumbers(){
+ for(String word : questionWords){
+ if(isNumber(word)){
+ numbers.add(Integer.valueOf(word));
+ }
+ }
+ }
+
+ private boolean isNumber(String s){
+ for (int i = 0; i < s.length(); i++) {
+ if(!Character.isDigit(s.charAt(i))){
+ return false;
+ }
+ }
+ return true;
+
+ }
+
+ private boolean areSimiliar(String s1, String s2){
+ return (qGramMetric.getSimilarity(s1, s2) >= threshold) ||
+ (levensteinMetric.getSimilarity(s1, s2) >= threshold);
+ }
+
+ private boolean isSimlarWithSubstringMetrik(String s){
+ SortedSet<Double> values = new TreeSet<Double>(Collections.reverseOrder());
+ for(String word : questionWords){
+ double v = substringMetric.score(word, s, true);
+ if(v >= threshold){
+ return true;
+ } else {
+ values.add(Double.valueOf(v));
+ }
+ }
+ double sum = 0;
+ for(Double v : getTopK(values)){
+ if(v >= 0){
+ sum += v;
+ }
+
+ }
+ return sum >= topKSumThreshold;
+ }
+
+ private Set<Double> getTopK(SortedSet<Double> values){
+ Set<Double> top = new HashSet<Double>();
+ int k = 0;
+ for(Double v : values){
+ if(k == topK){
+ break;
+ }
+ top.add(v);
+ k++;
+ }
+ return top;
+ }
+
+ private String getFragment(String uri){
+ int i = uri.lastIndexOf("#");
+ if(i > 0){
+ return uri.substring(i+1);
+ } else {
+ return uri.substring(uri.lastIndexOf("/")+1);
+ }
+ }
+
+
+}
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-03-03 22:07:10 UTC (rev 2715)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/util/QuestionBasedStatementFilter.java 2011-03-07 14:19:20 UTC (rev 2716)
@@ -14,6 +14,7 @@
import uk.ac.shef.wit.simmetrics.similaritymetrics.Levenshtein;
import uk.ac.shef.wit.simmetrics.similaritymetrics.QGramsDistance;
+import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.util.iterator.Filter;
@@ -33,6 +34,8 @@
private Map<Statement, Double> statement2Similarity = new HashMap<Statement, Double>();
+ private Map<RDFNode, Boolean> cache = new HashMap<RDFNode, Boolean>();
+
int cnt = 0;
public QuestionBasedStatementFilter(Set<String> questionWords){
@@ -103,21 +106,80 @@
@Override
public boolean accept(Statement s) {
- String predicate = s.getPredicate().getURI().substring(s.getPredicate().getURI().lastIndexOf("/"));
- String object = null;
- if(s.getObject().isURIResource()){
- object = s.getObject().asResource().getURI();
- object = getFragment(s.getObject().asResource().getURI());
- } else if(s.getObject().isLiteral()){
- object = s.getObject().asLiteral().getLexicalForm();
+ Boolean similarPredicate = cache.get(s.getPredicate());
+ Boolean similarObject = cache.get(s.getObject());
+ if(similarPredicate != null && similarObject != null){
+ return similarPredicate || similarObject;
+ } else if(similarPredicate == null && similarObject != null){
+ if(similarObject){
+ return true;
+ } else {
+ String predicate = s.getPredicate().getURI().substring(s.getPredicate().getURI().lastIndexOf("/"));
+ if (isSimiliar2QuestionWord(predicate, s)){
+ cache.put(s.getPredicate(), Boolean.valueOf(true));
+ return true;
+ } else {
+ cache.put(s.getPredicate(), Boolean.valueOf(false));
+ return false;
+ }
+ }
+ } else if(similarPredicate != null && similarObject == null){
+ if(similarPredicate){
+ return true;
+ } else {
+ String object = null;
+ if(s.getObject().isURIResource()){
+ object = s.getObject().asResource().getURI();
+ object = getFragment(s.getObject().asResource().getURI());
+ } else if(s.getObject().isLiteral()){
+ object = s.getObject().asLiteral().getLexicalForm();
+ }
+ if(isSimiliar2QuestionWord(object, s)){
+ cache.put(s.getObject(), Boolean.valueOf(true));
+ return true;
+ } else {
+ cache.put(s.getObject(), Boolean.valueOf(false));
+ return false;
+ }
+ }
+ } else {
+ String predicate = s.getPredicate().getURI().substring(s.getPredicate().getURI().lastIndexOf("/"));
+ if (isSimiliar2QuestionWord(predicate, s)){
+ cache.put(s.getPredicate(), Boolean.valueOf(true));
+ return true;
+ } else {
+ cache.put(s.getPredicate(), Boolean.valueOf(false));
+ }
+ String object = null;
+ if(s.getObject().isURIResource()){
+ object = s.getObject().asResource().getURI();
+ object = getFragment(s.getObject().asResource().getURI());
+ } else if(s.getObject().isLiteral()){
+ object = s.getObject().asLiteral().getLexicalForm();
+ }
+ if(isSimiliar2QuestionWord(object, s)){
+ cache.put(s.getObject(), Boolean.valueOf(true));
+ return true;
+ } else {
+ cache.put(s.getObject(), Boolean.valueOf(false));
+ }
+ return false;
}
- if(isSimiliar2QuestionWord(object, s) || isSimiliar2QuestionWord(predicate, s)){
- return true;
- }
-
- return false;
}
+// @Override
+// public boolean accept(Statement s) {
+// String predicate = s.getPredicate().getURI().substring(s.getPredicate().getURI().lastIndexOf("/"));
+// String object = null;
+// if(s.getObject().isURIResource()){
+// object = s.getObject().asResource().getURI();
+// object = getFragment(s.getObject().asResource().getURI());
+// } else if(s.getObject().isLiteral()){
+// object = s.getObject().asLiteral().getLexicalForm();
+// }
+// return isSimiliar2QuestionWord(predicate, s) || isSimiliar2QuestionWord(object, s);
+// }
+
public void setThreshold(double threshold){
this.threshold = threshold;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lor...@us...> - 2011-03-07 15:17:44
|
Revision: 2718
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2718&view=rev
Author: lorenz_b
Date: 2011-03-07 15:17:37 +0000 (Mon, 07 Mar 2011)
Log Message:
-----------
Added additional entry to database for #triple pattern in learned query.
Modified Paths:
--------------
trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/QueryTree.java
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-03-07 14:38:25 UTC (rev 2717)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/evaluation/EvaluationWithNLQueriesScript.java 2011-03-07 15:17:37 UTC (rev 2718)
@@ -89,7 +89,7 @@
private static final String WORDNET_DICTIONARY = "src/main/resources/de/simba/ner/dictionary";
private static final SparqlEndpoint ENDPOINT = SparqlEndpoint.getEndpointDBpediaLiveAKSW();
// private static final String ENDPOINT_URL = "http://lod.openlinksw.com/sparql";
- private static final String ENDPOINT_URL = "http://db0.aksw.org:8999/sparql";
+ private static String ENDPOINT_URL = "http://db0.aksw.org:8999/sparql";
// private static final String ENDPOINT_URL = "http://live.dbpedia.org/sparql";
@@ -144,7 +144,7 @@
prefixes.put("yago","http://dbpedia.org/class/yago/");
prefixes.put("cyc","http://sw.opencyc.org/concept/");
prefixes.put("foaf","http://xmlns.com/foaf/0.1/");
- exFinder = new ExampleFinder(new SPARQLEndpointEx(new URL(ENDPOINT_URL), //new URL("http://lod.openlinksw.com/sparql"),
+ exFinder = new ExampleFinder(new SPARQLEndpointEx(new URL(ENDPOINT_URL),
Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList(), null, baseURI, prefixes, predicateFilters), selectCache, constructCache);
// schemaIndex = new DBpediaSchemaIndex(SCHEMA_FILE_PATH);
luceneSearch = new LuceneSearch(LUCENE_INDEX_DIRECTORY);
@@ -177,7 +177,7 @@
"jdbc:mysql://"+dbServer+"/"+dbName;
Connection conn = DriverManager.getConnection(url, dbUser, dbPass);
ps = conn.prepareStatement("INSERT INTO evaluation (" +
- "id, question, target_query, learned, learned_query, " +
+ "id, question, target_query, learned, learned_query, triple_pattern_count, " +
"start_examples_from_search, examples_needed_total, examples_needed_pos, examples_needed_neg, " +
"time_total, time_lgg, time_nbr, time_queries) " +
"VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)");
@@ -191,7 +191,7 @@
}
private void write2DB(
- int id, String question, String targetQuery, boolean learned, String learnedQuery,
+ int id, String question, String targetQuery, boolean learned, String learnedQuery, int triplePatternCount,
int posExamplesFromSearch, int examplesNeededTotal, int examplesNeededPos, int examplesNeededNeg,
double totalTime, double lggTime, double nbrTime, double queryTime){
try {
@@ -200,14 +200,15 @@
ps.setString(3, targetQuery);
ps.setBoolean(4, learned);
ps.setString(5, learnedQuery);
- ps.setInt(6, posExamplesFromSearch);
- ps.setInt(7, examplesNeededTotal);
- ps.setInt(8, examplesNeededPos);
- ps.setInt(9, examplesNeededNeg);
- ps.setDouble(10, totalTime);
- ps.setDouble(11, lggTime);
- ps.setDouble(12, nbrTime);
- ps.setDouble(13, queryTime);
+ ps.setInt(6, triplePatternCount);
+ ps.setInt(7, posExamplesFromSearch);
+ ps.setInt(8, examplesNeededTotal);
+ ps.setInt(9, examplesNeededPos);
+ ps.setInt(10, examplesNeededNeg);
+ ps.setDouble(11, totalTime);
+ ps.setDouble(12, lggTime);
+ ps.setDouble(13, nbrTime);
+ ps.setDouble(14, queryTime);
ps.executeUpdate();
} catch (SQLException e) {
@@ -397,6 +398,7 @@
String targetQuery;
boolean learned;
String learnedQuery;
+ int triplePatterCount;
int posExamplesFromSearch;
int examplesNeededTotal;
int examplesNeededPos;
@@ -417,11 +419,12 @@
Monitor lggMon = MonitorFactory.getTimeMonitor("LGG");
Monitor nbrMon = MonitorFactory.getTimeMonitor("NBR");
Monitor queryMon = MonitorFactory.getTimeMonitor("Query");
- for(String question : question2Answers.keySet()){if(i==11 || i==15){i++;continue;};//question = "Give me all soccer clubs in the Premier League.";
+ for(String question : question2Answers.keySet()){if(i==11){i++;continue;};//question = "Give me all soccer clubs in the Premier League.";
id = i;
targetQuery = "";
learned = false;
learnedQuery = "";
+ triplePatterCount = 0;
posExamplesFromSearch = 0;
examplesNeededTotal = 0;
examplesNeededPos = 0;
@@ -435,6 +438,36 @@
nbrMon.reset();
queryMon.reset();
+ //workaround for question 15, because db0 returns no resources
+ if(i==15){
+ List<String> predicateFilters = new ArrayList<String>();
+ predicateFilters.add("http://dbpedia.org/ontology/wikiPageWikiLink");
+ predicateFilters.add("http://dbpedia.org/property/wikiPageUsesTemplate");
+ //prefixes and baseURI to improve readability of trees
+ String baseURI = "http://dbpedia.org/resource/";
+ Map<String,String> prefixes = new HashMap<String,String>();
+ prefixes.put("dbo","http://dbpedia.org/ontology/");
+ prefixes.put("dbprop","http://dbpedia.org/property/");
+ prefixes.put("rdfs","http://www.w3.org/2000/01/rdf-schema#");
+ prefixes.put("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");
+ prefixes.put("skos","http://www.w3.org/2004/02/skos/core#");
+ prefixes.put("geo","http://www.w3.org/2003/01/geo/wgs84_pos#");
+ prefixes.put("georss","http://www.georss.org/georss/");
+ prefixes.put("owl","http://www.w3.org/2002/07/owl#");
+ prefixes.put("yago","http://dbpedia.org/class/yago/");
+ prefixes.put("cyc","http://sw.opencyc.org/concept/");
+ prefixes.put("foaf","http://xmlns.com/foaf/0.1/");
+ try {
+ exFinder = new ExampleFinder(new SPARQLEndpointEx(new URL("http://live.dbpedia.org/sparql"),
+ Collections.singletonList("http://dbpedia.org"), Collections.<String>emptyList(), null, baseURI, prefixes, predicateFilters), selectCache, constructCache);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ ENDPOINT_URL = "http://live.dbpedia.org/sparql";
+ }
+
+
+
overallMon.start();
logger.debug(getNewQuestionString(i, question));
try {
@@ -565,20 +598,25 @@
} while (!answers.equals(learnedResources));
if(!learningFailed){
overallMon.stop();
+ exFinder.getLGGInstances(posExamples);
learned = true;
examplesNeededPos = posExamples.size();
examplesNeededNeg = negExamples.size();
examplesNeededTotal = examplesNeededPos + examplesNeededNeg;
learnedQuery = exFinder.getCurrentQuery();
+ triplePatterCount = exFinder.getCurrentQueryTree().getTriplePatternCount();
+
lggTime = lggMon.getTotal();
nbrTime = nbrMon.getTotal();
- queryTime = queryMon.getTotal();
- totalTime = lggTime + nbrTime + queryTime;
+ totalTime = overallMon.getLastValue();
+ queryTime = totalTime - lggTime - nbrTime;//queryMon.getTotal();
+
logger.info("Learning successful.");
- logger.info("Needed " + overallMon.getLastValue() + "ms.");
+ logger.info("Needed " + totalTime + "ms.");
logger.info("Learned SPARQL query:\n" + learnedQuery);
miniLogger.info("Learning successful.");
miniLogger.info("Learned SPARQL query:\n" + learnedQuery);
+ System.err.println(exFinder.getCurrentQueryTree().getTriplePatternCount());
learnedQueries++;
}else {
overallMon.stop();
@@ -586,7 +624,7 @@
miniLogger.info("AutoSPARQL: Could not learn query.");
}
if(WRITE2DATABASE){
- write2DB(id, question, targetQuery, learned, learnedQuery,
+ write2DB(id, question, targetQuery, learned, learnedQuery, triplePatterCount,
posExamplesFromSearch, examplesNeededTotal, examplesNeededPos, examplesNeededNeg,
totalTime, lggTime, nbrTime, queryTime);
}
Modified: trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java
===================================================================
--- trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-03-07 14:38:25 UTC (rev 2717)
+++ trunk/autosparql/src/main/java/org/dllearner/autosparql/server/ExampleFinder.java 2011-03-07 15:17:37 UTC (rev 2718)
@@ -96,6 +96,7 @@
if(treeFilter != null){
lgg = treeFilter.getFilteredQueryTree(lgg);
}
+ currentQueryTree = lgg;
currentQuery = lgg.toSPARQLQueryString();
if(logger.isInfoEnabled()){
logger.info("LGG: \n" + TreeHelper.getAbbreviatedTreeRepresentation(lgg, endpoint.getBaseURI(), endpoint.getPrefixes()));
Modified: trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/QueryTree.java
===================================================================
--- trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/QueryTree.java 2011-03-07 14:38:25 UTC (rev 2717)
+++ trunk/sparql-query-generator/src/main/java/org/dllearner/sparqlquerygenerator/datastructures/QueryTree.java 2011-03-07 15:17:37 UTC (rev 2718)
@@ -125,4 +125,6 @@
String toSPARQLQueryString(boolean filtered);
+ int getTriplePatternCount();
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ji...@us...> - 2011-03-16 11:39:02
|
Revision: 2723
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2723&view=rev
Author: jialva
Date: 2011-03-16 11:38:50 +0000 (Wed, 16 Mar 2011)
Log Message:
-----------
changes for the DL-Learner fuzzy extension
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java
trunk/components-core/src/main/java/org/dllearner/reasoning/ReasonerType.java
trunk/components-core/src/main/resources/components.ini
trunk/interfaces/src/main/java/org/dllearner/cli/ConfMapper.java
Added Paths:
-----------
trunk/components-core/src/main/java/META-INF/
trunk/components-core/src/main/java/META-INF/MANIFEST.MF
trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/
trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java
trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOEHeuristicRuntime.java
trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyOENode.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyOWLAPIReasonerConfigurator.java
trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/
trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyDLReasonerManager.java
trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/FuzzyOWLAPIReasoner.java
trunk/components-core/src/main/resources/FuzzyDL/
trunk/components-core/src/main/resources/FuzzyDL/CONFIG
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCbc.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCbc.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCbc.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCbc.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCbcSolver.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCbcSolver.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCbcSolver.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCbcSolver.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCgl.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCgl.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCgl.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCgl.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libClp.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libClp.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libClp.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libClp.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCoinUtils.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCoinUtils.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCoinUtils.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libCoinUtils.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libMilpSolver.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsi.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsi.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsi.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsi.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiCbc.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiCbc.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiCbc.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiCbc.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiClp.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiClp.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiClp.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiClp.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiVol.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiVol.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiVol.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libOsiVol.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libVol.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libVol.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libVol.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib32/libVol.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCbc.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCbc.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCbc.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCbc.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCbcSolver.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCbcSolver.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCbcSolver.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCbcSolver.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCgl.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCgl.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCgl.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCgl.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libClp.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libClp.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libClp.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libClp.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCoinUtils.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCoinUtils.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCoinUtils.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libCoinUtils.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libMilpSolver.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsi.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsi.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsi.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsi.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiCbc.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiCbc.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiCbc.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiCbc.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiClp.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiClp.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiClp.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiClp.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiVol.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiVol.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiVol.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libOsiVol.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libVol.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libVol.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libVol.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLib64/libVol.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/cbc_addlibs.txt
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/cgl_addlibs.txt
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/clp_addlibs.txt
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/coinutils_addlibs.txt
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCbc.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCbc.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCbc.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCbc.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCgl.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCgl.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCgl.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCgl.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libClp.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libClp.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libClp.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libClp.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCoinUtils.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCoinUtils.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCoinUtils.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libCoinUtils.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsi.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsi.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsi.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsi.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiCbc.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiCbc.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiCbc.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiCbc.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiClp.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiClp.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiClp.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiClp.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiVol.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiVol.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiVol.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libOsiVol.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libVol.0.0.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libVol.0.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libVol.dylib
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/libVol.la
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/osi_addlibs.txt
trunk/components-core/src/main/resources/FuzzyDL/CbcLibppc/vol_addlibs.txt
trunk/components-core/src/main/resources/FuzzyDL/FuzzyDL.jar
trunk/components-core/src/main/resources/FuzzyDL/README.txt
trunk/components-core/src/main/resources/FuzzyDL/doc/
trunk/components-core/src/main/resources/FuzzyDL/doc/fuzzyDLlibrary.pdf
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/allclasses-frame.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/allclasses-noframe.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/constant-values.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/deprecated-list.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Assertion.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/AtomicAssertion.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/BnpQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/ClassicalSolver.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Concept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/ConcreteFeature.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/ConfigReader.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/CreatedIndividual.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/CrispConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/DatatypeReasoner.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/DefuzzifyQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Degree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/DegreeExpression.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/DegreeNumeric.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/DegreeVariable.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/DomainAxiom.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/FeatureFunction.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/FuzzyConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/FuzzyLogic.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/GeneralConceptInclusion.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Individual.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/InstanceQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/KnowledgeBase.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Label.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/LeftConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/LinearModifier.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/LinearlyModifiedConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/LomDefuzzifyQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/LukasiewiczSolver.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MaxInstanceQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MaxQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MaxRelatedQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MaxSatisfiableQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MaxSubsumesQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MinInstanceQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MinQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MinRelatedQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MinSatisfiableQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MinSubsumesQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/ModifiedConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Modifier.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/MomDefuzzifyQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/NegativeRelation.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/PrimitiveConceptDefinition.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Query.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/RangeAxiom.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Reasoner.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/RelatedQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Relation.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/RepresentativeIndividual.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/Restriction.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/RightConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/RoleParentWithDegree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/SatisfiableQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/SomDefuzzifyQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/SubsumptionQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/TrapezoidalConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/TriangularConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/TriangularFuzzyNumber.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/TriangularModifier.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/TriangularlyModifiedConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/WeightedConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/WeightedSumConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/ZadehSolver.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Assertion.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/AtomicAssertion.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/BnpQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/ClassicalSolver.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Concept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/ConcreteFeature.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/ConfigReader.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/CreatedIndividual.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/CrispConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/DatatypeReasoner.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/DefuzzifyQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Degree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/DegreeExpression.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/DegreeNumeric.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/DegreeVariable.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/DomainAxiom.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/FeatureFunction.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/FuzzyConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/FuzzyLogic.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/GeneralConceptInclusion.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Individual.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/InstanceQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/KnowledgeBase.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Label.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/LeftConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/LinearModifier.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/LinearlyModifiedConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/LomDefuzzifyQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/LukasiewiczSolver.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MaxInstanceQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MaxQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MaxRelatedQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MaxSatisfiableQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MaxSubsumesQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MinInstanceQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MinQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MinRelatedQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MinSatisfiableQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MinSubsumesQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/ModifiedConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Modifier.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/MomDefuzzifyQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/NegativeRelation.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/PrimitiveConceptDefinition.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Query.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/RangeAxiom.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Reasoner.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/RelatedQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Relation.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/RepresentativeIndividual.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/Restriction.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/RightConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/RoleParentWithDegree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/SatisfiableQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/SomDefuzzifyQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/SubsumptionQuery.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/TrapezoidalConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/TriangularConcreteConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/TriangularFuzzyNumber.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/TriangularModifier.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/TriangularlyModifiedConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/WeightedConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/WeightedSumConcept.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/class-use/ZadehSolver.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/exception/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/exception/FuzzyOntologyException.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/exception/class-use/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/exception/class-use/FuzzyOntologyException.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/exception/package-frame.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/exception/package-summary.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/exception/package-tree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/exception/package-use.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/Digraph.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/DirectedCycleFinder.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/class-use/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/class-use/Digraph.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/class-use/DirectedCycleFinder.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/package-frame.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/package-summary.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/package-tree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/graph/package-use.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/BinaryBound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/Bound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/Expression.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/FreeBound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/Inequation.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/IntBound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/MILPHelper.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/ShowVariablesHelper.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/Solution.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/Term.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/UpperBound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/Variable.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/BinaryBound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/Bound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/Expression.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/FreeBound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/Inequation.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/IntBound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/MILPHelper.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/ShowVariablesHelper.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/Solution.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/Term.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/UpperBound.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/class-use/Variable.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/package-frame.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/package-summary.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/package-tree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/milp/package-use.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/package-frame.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/package-summary.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/package-tree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/package-use.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/ParseException.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/Parser.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/ParserConstants.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/ParserTokenManager.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/SimpleCharStream.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/Token.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/TokenMgrError.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/class-use/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/class-use/ParseException.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/class-use/Parser.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/class-use/ParserConstants.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/class-use/ParserTokenManager.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/class-use/SimpleCharStream.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/class-use/Token.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/class-use/TokenMgrError.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/package-frame.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/package-summary.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/package-tree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/parser/package-use.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/util/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/util/Util.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/util/class-use/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/util/class-use/Util.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/util/package-frame.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/util/package-summary.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/util/package-tree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/fuzzydl/util/package-use.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/help-doc.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-1.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-10.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-11.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-12.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-13.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-14.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-15.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-16.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-17.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-18.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-19.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-2.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-20.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-21.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-22.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-23.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-24.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-25.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-26.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-3.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-4.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-5.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-6.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-7.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-8.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index-files/index-9.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/index.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/overview-frame.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/overview-summary.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/overview-tree.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/package-list
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/resources/
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/resources/inherit.gif
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/serialized-form.html
trunk/components-core/src/main/resources/FuzzyDL/doc/javadoc/stylesheet.css
trunk/components-core/src/main/resources/FuzzyDL/doc/syntax.pdf
trunk/components-core/src/main/resources/FuzzyDL/examples/
trunk/components-core/src/main/resources/FuzzyDL/examples/input/
trunk/components-core/src/main/resources/FuzzyDL/examples/input/catalog-v001.xml
trunk/components-core/src/main/resources/FuzzyDL/examples/input/fuzzyFoodItems_v1.owl
trunk/components-core/src/main/resources/FuzzyDL/examples/input/matchmaking.owl.owl
trunk/components-core/src/main/resources/FuzzyDL/examples/input/multiCriteria.owl.owl
trunk/components-core/src/main/resources/FuzzyDL/examples/matchmaking1.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/matchmaking2.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/output/
trunk/components-core/src/main/resources/FuzzyDL/examples/output/auxFuzzyKBfileName.fuzzyDL.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/output/auxFuzzyKBfileName_manuallyModified.fuzzyDL.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/output/fuzzyFoodItems.fuzzyDL.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/output/fuzzyFoodItems.fuzzyDL_manuallyModified.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/output/kk.fuzzyDL.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/output/matchmaking.fuzzyDL.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/shoppingAssistantExample_Josue.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/shoppingAssistantExample_Josue2.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/test.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/test2.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/test2Josue.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/testJosue.txt
trunk/components-core/src/main/resources/FuzzyDL/examples/young.txt
trunk/components-core/src/main/resources/FuzzyDL/fuzzyDLcbc
trunk/components-core/src/main/resources/FuzzyDL/lib/
trunk/components-core/src/main/resources/FuzzyDL/lib/JavaCBC.jar
trunk/components-core/src/main/resources/FuzzyDL/lib/colt.jar
trunk/components-core/src/main/resources/FuzzyDL/libMilpSolver.32bits.dylib
trunk/components-core/src/main/resources/FuzzyDL/libMilpSolver.64bits.dylib
trunk/components-core/src/main/resources/FuzzyDL/matchmaking1.txt
trunk/components-core/src/main/resources/FuzzyDL/matchmaking2.txt
trunk/components-core/src/main/resources/FuzzyDL/shoppingAssistantExample_Josue.txt
trunk/components-core/src/main/resources/FuzzyDL/test.txt
trunk/components-core/src/main/resources/FuzzyDL/test2.txt
trunk/components-core/src/main/resources/FuzzyDL/test2Josue.txt
trunk/components-core/src/main/resources/FuzzyDL/testJosue.txt
trunk/components-core/src/main/resources/FuzzyDL/young.txt
Added: trunk/components-core/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/components-core/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/components-core/src/main/java/META-INF/MANIFEST.MF 2011-03-16 11:38:50 UTC (rev 2723)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Added: trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java (rev 0)
+++ trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/FuzzyCELOE.java 2011-03-16 11:38:50 UTC (rev 2723)
@@ -0,0 +1,795 @@
+/**
+ * Copyright (C) 2007-2009, Jens Lehmann
+ *
+ * This file is part of DL-Learner.
+ *
+ * DL-Learner is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * DL-Learner is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.dllearner.algorithms.fuzzydll;
+
+import java.io.File;
+import java.text.DecimalFormat;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.log4j.Logger;
+import org.dllearner.core.ComponentInitException;
+import org.dllearner.core.EvaluatedDescription;
+import org.dllearner.core.LearningAlgorithm;
+import org.dllearner.core.LearningProblem;
+import org.dllearner.core.ReasonerComponent;
+import org.dllearner.core.configurators.FuzzyCELOEConfigurator;
+import org.dllearner.core.options.BooleanConfigOption;
+import org.dllearner.core.options.CommonConfigOptions;
+import org.dllearner.core.options.ConfigOption;
+import org.dllearner.core.options.DoubleConfigOption;
+import org.dllearner.core.options.StringConfigOption;
+import org.dllearner.core.owl.ClassHierarchy;
+import org.dllearner.core.owl.Description;
+import org.dllearner.core.owl.Individual;
+import org.dllearner.core.owl.Intersection;
+import org.dllearner.core.owl.NamedClass;
+import org.dllearner.core.owl.Restriction;
+import org.dllearner.core.owl.Thing;
+import org.dllearner.learningproblems.ClassLearningProblem;
+import org.dllearner.learningproblems.PosNegLP;
+import org.dllearner.learningproblems.PosNegLPStandard;
+import org.dllearner.learningproblems.PosOnlyLP;
+import org.dllearner.refinementoperators.OperatorInverter;
+import org.dllearner.refinementoperators.RefinementOperator;
+import org.dllearner.refinementoperators.RhoDRDown;
+import org.dllearner.utilities.Files;
+import org.dllearner.utilities.Helper;
+import org.dllearner.utilities.owl.ConceptComparator;
+import org.dllearner.utilities.owl.ConceptTransformation;
+import org.dllearner.utilities.owl.DescriptionMinimizer;
+import org.dllearner.utilities.owl.EvaluatedDescriptionSet;
+import org.dllearner.utilities.owl.PropertyContext;
+
+import com.jamonapi.Monitor;
+import com.jamonapi.MonitorFactory;
+
+/**
+ * The CELOE (Class Expression Learner for Ontology Engineering) algorithm.
+ * It adapts and extends the standard supervised learning algorithm for the
+ * ontology engineering use case.
+ *
+ * @author Jens Lehmann
+ *
+ */
+public class FuzzyCELOE extends LearningAlgorithm {
+
+ private static Logger logger = Logger.getLogger(FuzzyCELOE.class);
+ private FuzzyCELOEConfigurator configurator;
+
+ private boolean isRunning = false;
+ private boolean stop = false;
+
+// private OEHeuristicStable heuristicStable = new OEHeuristicStable();
+// private OEHeuristicRuntime heuristicRuntime = new OEHeuristicRuntime();
+
+ private RefinementOperator operator;
+ private DescriptionMinimizer minimizer;
+
+ // all nodes in the search tree (used for selecting most promising node)
+ private TreeSet<FuzzyOENode> nodes;
+ private FuzzyOEHeuristicRuntime heuristic; // = new OEHeuristicRuntime();
+ // root of search tree
+ private FuzzyOENode startNode;
+ // the class with which we start the refinement process
+ private Description startClass;
+
+ // all descriptions in the search tree plus those which were too weak (for fast redundancy check)
+ private TreeSet<Description> descriptions;
+
+ private EvaluatedDescriptionSet bestEvaluatedDescriptions;
+
+ // if true, then each solution is evaluated exactly instead of approximately
+ // private boolean exactBestDescriptionEvaluation = false;
+ private boolean singleSuggestionMode;
+ private Description bestDescription;
+ private double bestAccuracy = Double.MIN_VALUE;
+
+ private NamedClass classToDescribe;
+ // examples are either 1.) instances of the class to describe 2.) positive examples
+ // 3.) union of pos.+neg. examples depending on the learning problem at hand
+ private Set<Individual> examples;
+
+ // CELOE was originally created for learning classes in ontologies, but also
+ // works for other learning problem types
+ private boolean isClassLearningProblem;
+ private boolean isEquivalenceProblem;
+
+ private long nanoStartTime;
+
+ // important parameters
+ private double noise;
+ private double maxDepth;
+ private boolean filterFollowsFromKB;
+
+ // less important parameters
+ // forces that one solution cannot be subexpression of another expression; this option is useful to get diversity
+ // but it can also suppress quite useful expressions
+ private boolean forceMutualDifference = false;
+
+ // utility variables
+ private String baseURI;
+ private Map<String, String> prefixes;
+ private DecimalFormat dfPercent = new DecimalFormat("0.00%");
+ private ConceptComparator descriptionComparator = new ConceptComparator();
+
+ // statistical variables
+ private int expressionTests = 0;
+ private int minHorizExp = 0;
+ private int maxHorizExp = 0;
+
+ @Override
+ public FuzzyCELOEConfigurator getConfigurator() {
+ return configurator;
+ }
+
+ public FuzzyCELOE(LearningProblem problem, ReasonerComponent reasoner) {
+ super(problem, reasoner);
+ configurator = new FuzzyCELOEConfigurator(this);
+ }
+
+ public static Collection<Class<? extends LearningProblem>> supportedLearningProblems() {
+ Collection<Class<? extends LearningProblem>> problems = new LinkedList<Class<? extends LearningProblem>>();
+ problems.add(LearningProblem.class);
+ return problems;
+ }
+
+ public static Collection<ConfigOption<?>> createConfigOptions() {
+ Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>();
+ options.add(CommonConfigOptions.useAllConstructor());
+ options.add(CommonConfigOptions.useExistsConstructor());
+ options.add(CommonConfigOptions.useHasValueConstructor());
+ options.add(CommonConfigOptions.useDataHasValueConstructor());
+ options.add(CommonConfigOptions.valueFreqencyThreshold());
+ options.add(CommonConfigOptions.useCardinalityRestrictions());
+ options.add(CommonConfigOptions.cardinalityLimit());
+ // by default, we do not use negation (should be configurable in GUI)
+ options.add(CommonConfigOptions.useNegation(false));
+ options.add(CommonConfigOptions.useBooleanDatatypes());
+ options.add(CommonConfigOptions.useDoubleDatatypes());
+ options.add(CommonConfigOptions.maxExecutionTimeInSeconds(10));
+ options.add(CommonConfigOptions.getNoisePercentage());
+ options.add(CommonConfigOptions.getTerminateOnNoiseReached(false));
+ options.add(CommonConfigOptions.getMaxDepth(7));
+ options.add(CommonConfigOptions.maxNrOfResults(10));
+ options.add(CommonConfigOptions.maxClassDescriptionTests());
+ options.add(new BooleanConfigOption("singleSuggestionMode", "Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.", false));
+ options.add(CommonConfigOptions.getInstanceBasedDisjoints());
+ options.add(new BooleanConfigOption("filterDescriptionsFollowingFromKB", "If true, then the results will not contain suggestions, which already follow logically from the knowledge base. Be careful, since this requires a potentially expensive consistency check for candidate solutions.", false));
+ options.add(new BooleanConfigOption("reuseExistingDescription", "If true, the algorithm tries to find a good starting point close to an existing definition/super class of the given class in the knowledge base.", false));
+ options.add(new BooleanConfigOption("writeSearchTree", "specifies whether to write a search tree", false));
+ options.add(new StringConfigOption("searchTreeFile","file to use for the search tree", "log/searchTree.txt"));
+ options.add(new BooleanConfigOption("replaceSearchTree","specifies whether to replace the search tree in the log file after each run or append the new search tree", false));
+ options.add(new DoubleConfigOption("expansionPenaltyFactor","heuristic penalty per syntactic construct used (lower = finds more complex expression, but might miss simple ones)", 0.1));
+ return options;
+ }
+
+ public static String getName() {
+ return "fuzzy CELOE";
+ }
+
+ @Override
+ public void init() throws ComponentInitException {
+ // copy class hierarchy and modify it such that each class is only
+ // reachable via a single path
+ ClassHierarchy classHierarchy = reasoner.getClassHierarchy().clone();
+ classHierarchy.thinOutSubsumptionHierarchy();
+
+ heuristic = new FuzzyOEHeuristicRuntime(configurator);
+
+ minimizer = new DescriptionMinimizer(reasoner);
+
+ startClass = Thing.instance;
+
+ singleSuggestionMode = configurator.getSingleSuggestionMode();
+
+ // create refinement operator
+ operator = new RhoDRDown(reasoner, classHierarchy, startClass, configurator);
+ baseURI = reasoner.getBaseURI();
+ prefixes = reasoner.getPrefixes();
+ if(configurator.getWriteSearchTree()) {
+ Files.clearFile(new File(configurator.getSearchTreeFile()));
+ }
+
+ bestEvaluatedDescriptions = new EvaluatedDescriptionSet(configurator.getMaxNrOfResults());
+
+ isClassLearningProblem = (learningProblem instanceof ClassLearningProblem);
+
+ // we put important parameters in class variables
+ noise = configurator.getNoisePercentage()/100d;
+// System.out.println("noise " + noise);
+ maxDepth = configurator.getMaxDepth();
+ // (filterFollowsFromKB is automatically set to false if the problem
+ // is not a class learning problem
+ filterFollowsFromKB = configurator.getFilterDescriptionsFollowingFromKB()
+ && isClassLearningProblem;
+
+ // actions specific to ontology engineering
+ if(isClassLearningProblem) {
+ ClassLearningProblem problem = (ClassLearningProblem) learningProblem;
+ classToDescribe = problem.getClassToDescribe();
+ isEquivalenceProblem = problem.isEquivalenceProblem();
+
+ examples = reasoner.getIndividuals(classToDescribe);
+
+ // start class: intersection of super classes for definitions (since it needs to
+ // capture all instances), but owl:Thing for learning subclasses (since it is
+ // superfluous to add super classes in this case)
+ if(isEquivalenceProblem) {
+ Set<Description> existingDefinitions = reasoner.getAssertedDefinitions(classToDescribe);
+ if(configurator.getReuseExistingDescription() && (existingDefinitions.size() > 0)) {
+ // the existing definition is reused, which in the simplest case means to
+ // use it as a start class or, if it is already too specific, generalise it
+
+ // pick the longest existing definition as candidate
+ Description existingDefinition = null;
+ int highestLength = 0;
+ for(Description exDef : existingDefinitions) {
+ if(exDef.getLength() > highestLength) {
+ existingDefinition = exDef;
+ highestLength = exDef.getLength();
+ }
+ }
+
+ LinkedList<Description> startClassCandidates = new LinkedList<Description>();
+ startClassCandidates.add(existingDefinition);
+ ((RhoDRDown)operator).setDropDisjuncts(true);
+ RefinementOperator upwardOperator = new OperatorInverter(operator);
+
+ // use upward refinement until we find an appropriate start class
+ boolean startClassFound = false;
+ Description candidate;
+ do {
+ candidate = startClassCandidates.pollFirst();
+ if(((ClassLearningProblem)learningProblem).getRecall(candidate)<1.0) {
+ // add upward refinements to list
+ Set<Description> refinements = upwardOperator.refine(candidate, candidate.getLength());
+// System.out.println("ref: " + refinements);
+ LinkedList<Description> refinementList = new LinkedList<Description>(refinements);
+// Collections.reverse(refinementList);
+// System.out.println("list: " + refinementList);
+ startClassCandidates.addAll(refinementList);
+// System.out.println("candidates: " + startClassCandidates);
+ } else {
+ startClassFound = true;
+ }
+ } while(!startClassFound);
+ startClass = candidate;
+
+ if(startClass.equals(existingDefinition)) {
+ logger.info("Reusing existing description " + startClass.toManchesterSyntaxString(baseURI, prefixes) + " as start class for learning algorithm.");
+ } else {
+ logger.info("Generalised existing description " + existingDefinition.toManchesterSyntaxString(baseURI, prefixes) + " to " + startClass.toManchesterSyntaxString(baseURI, prefixes) + ", which is used as start class for the learning algorithm.");
+ }
+
+// System.out.println("start class: " + startClass);
+// System.out.println("existing def: " + existingDefinition);
+// System.out.println(reasoner.getIndividuals(existingDefinition));
+
+ ((RhoDRDown)operator).setDropDisjuncts(false);
+
+ } else {
+ Set<Description> superClasses = reasoner.getClassHierarchy().getSuperClasses(classToDescribe);
+ if(superClasses.size() > 1) {
+ startClass = new Intersection(new LinkedList<Description>(superClasses));
+ } else if(superClasses.size() == 1){
+ startClass = (Description) superClasses.toArray()[0];
+ } else {
+ startClass = Thing.instance;
+ logger.warn(classToDescribe + " is equivalent to owl:Thing. Usually, it is not " +
+ "sensible to learn a description in this case.");
+ }
+ }
+ }
+ } else if(learningProblem instanceof PosOnlyLP) {
+ examples = ((PosOnlyLP)learningProblem).getPositiveExamples();
+ } else if(learningProblem instanceof PosNegLP) {
+ examples = Helper.union(((PosNegLP)learningProblem).getPositiveExamples(),((PosNegLP)learningProblem).getNegativeExamples());
+ }
+ }
+
+ @Override
+ public Description getCurrentlyBestDescription() {
+ EvaluatedDescription ed = getCurrentlyBestEvaluatedDescription();
+ return ed == null ? null : ed.getDescription();
+ }
+
+ @Override
+ public List<Description> getCurrentlyBestDescriptions() {
+ return bestEvaluatedDescriptions.toDescriptionList();
+ }
+
+ @Override
+ public EvaluatedDescription getCurrentlyBestEvaluatedDescription() {
+ return bestEvaluatedDescriptions.getBest();
+ }
+
+ @Override
+ public TreeSet<? extends EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions() {
+ return bestEvaluatedDescriptions.getSet();
+ }
+
+ public double getCurrentlyBestAccuracy() {
+ return bestEvaluatedDescriptions.getBest().getAccuracy();
+ }
+
+ @Override
+ public void start() {
+// System.out.println(configurator.getMaxExecutionTimeInSeconds());
+
+ stop = false;
+ isRunning = true;
+ reset();
+ nanoStartTime = System.nanoTime();
+
+ // highest accuracy so far
+ double highestAccuracy = 0.0;
+ FuzzyOENode nextNode;
+
+ addNode(startClass, null);
+
+ int loop = 0;
+ while (!terminationCriteriaSatisfied()) {
+// System.out.println("loop " + loop);
+
+ if(!singleSuggestionMode && bestEvaluatedDescriptions.getBestAccuracy() > highestAccuracy) {
+ highestAccuracy = bestEvaluatedDescriptions.getBestAccuracy();
+ logger.info("more accurate (" + dfPercent.format(highestAccuracy) + ") class expression found: " + descriptionToString(bestEvaluatedDescriptions.getBest().getDescription()));
+ }
+
+ // chose best node according to heuristics
+ nextNode = getNextNodeToExpand();
+ int horizExp = nextNode.getHorizontalExpansion();
+
+ // apply operator
+ Monitor mon = MonitorFactory.start("refineNode");
+ TreeSet<Description> refinements = refineNode(nextNode);
+ mon.stop();
+
+// System.out.println("next node: " + nextNode);
+// for(Description refinement : refinements) {
+// System.out.println("refinement: " + refinement);
+// }
+
+ while(refinements.size() != 0) {
+ // pick element from set
+ Description refinement = refinements.pollFirst();
+ int length = refinement.getLength();
+
+ // we ignore all refinements with lower length and too high depth
+ // (this also avoids duplicate node children)
+ if(length > horizExp && refinement.getDepth() <= maxDepth) {
+
+// System.out.println("potentially adding " + refinement + " to search tree as child of " + nextNode + " " + new Date());
+ Monitor mon2 = MonitorFactory.start("addNode");
+ addNode(refinement, nextNode);
+ mon2.stop();
+ // adding nodes is potentially computationally expensive, so we have
+ // to check whether max time is exceeded
+ if(terminationCriteriaSatisfied()) {
+ break;
+ }
+// System.out.println("addNode finished" + " " + new Date());
+ }
+
+// System.out.println(" refinement queue length: " + refinements.size());
+ }
+
+ updateMinMaxHorizExp(nextNode);
+
+ // writing the search tree (if configured)
+ if (configurator.getWriteSearchTree()) {
+ String treeString = "best node: " + bestEvaluatedDescriptions.getBest() + "\n";
+ if (refinements.size() > 1) {
+ treeString += "all expanded nodes:\n";
+ for (Description n : refinements) {
+ treeString += " " + n + "\n";
+ }
+ }
+ treeString += startNode.toTreeString(baseURI);
+ treeString += "\n";
+
+ if (configurator.getReplaceSearchTree())
+ Files.createFile(new File(configurator.getSearchTreeFile()), treeString);
+ else
+ Files.appendFile(new File(configurator.getSearchTreeFile()), treeString);
+ }
+
+// System.out.println(loop);
+ loop++;
+ }
+
+ if (stop) {
+ logger.info("Algorithm stopped ("+expressionTests+" descriptions tested). " + nodes.size() + " nodes in the search tree.\n");
+ } else {
+ logger.info("Algorithm terminated successfully ("+expressionTests+" descriptions tested). " + nodes.size() + " nodes in the search tree.\n");
+ }
+
+ if(singleSuggestionMode) {
+ bestEvaluatedDescriptions.add(bestDescription, bestAccuracy, learningProblem);
+ }
+
+ // print solution(s)
+ logger.info("solutions:\n" + getSolutionString());
+
+// System.out.println(startNode.toTreeString(baseURI));
+
+ isRunning = false;
+// System.out.println("isRunning: " + isRunning);
+ }
+
+ private FuzzyOENode getNextNodeToExpand() {
+ // we expand the best node of those, which have not achieved 100% accuracy
+ // already and have a horizontal expansion equal to their length
+ // (rationale: further extension is likely to add irrelevant syntactical constructs)
+ Iterator<FuzzyOENode> it = nodes.descendingIterator();
+ while(it.hasNext()) {
+ FuzzyOENode node = it.next();
+ if(node.getAccuracy() < 1.0 || node.getHorizontalExpansion() < node.getDescription().getLength()) {
+ return node;
+ }
+ }
+
+ // this should practically never be called, since for any reasonable learning
+ // task, we will always have at least one node with less than 100% accuracy
+ return nodes.last();
+ }
+
+ // expand node horizontically
+ private TreeSet<Description> refineNode(FuzzyOENode node) {
+ // we have to remove and add the node since its heuristic evaluation changes through the expansion
+ // (you *must not* include any criteria in the heuristic which are modified outside of this method,
+ // otherwise you may see rarely occurring but critical false ordering in the nodes set)
+ nodes.remove(node);
+// System.out.println("refining: " + node);
+ int horizExp = node.getHorizontalExpansion();
+ TreeSet<Description> refinements = (TreeSet<Description>) operator.refine(node.getDescription(), horizExp+1);
+ node.incHorizontalExpansion();
+ node.setRefinementCount(refinements.size());
+ nodes.add(node);
+ return refinements;
+ }
+
+ // add node to search tree if it is not too weak
+ // returns true if node was added and false otherwise
+ private boolean addNode(Description description, FuzzyOENode parentNode) {
+
+// System.out.println(description);
+
+ // redundancy check (return if redundant)
+ boolean nonRedundant = descriptions.add(description);
+ if(!nonRedundant) {
+ return false;
+ }
+
+ // check whether the description is allowed
+ if(!isDescriptionAllowed(description, parentNode)) {
+ return false;
+ }
+
+// System.out.println("Test " + new Date());
+ // quality of description (return if too weak)
+ do...
[truncated message content] |
|
From: <ji...@us...> - 2011-03-16 21:14:21
|
Revision: 2724
http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2724&view=rev
Author: jialva
Date: 2011-03-16 21:14:14 +0000 (Wed, 16 Mar 2011)
Log Message:
-----------
undoing last "commit" regarding fuzzy extension
Modified Paths:
--------------
trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java
trunk/components-core/src/main/java/org/dllearner/reasoning/ReasonerType.java
trunk/components-core/src/main/resources/components.ini
trunk/interfaces/src/main/java/org/dllearner/cli/ConfMapper.java
Removed Paths:
-------------
trunk/components-core/src/main/java/org/dllearner/algorithms/fuzzydll/
trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java
trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyOWLAPIReasonerConfigurator.java
trunk/components-core/src/main/java/org/dllearner/reasoning/fuzzydll/
trunk/components-core/src/main/resources/FuzzyDL/
Modified: trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-03-16 11:38:50 UTC (rev 2723)
+++ trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-03-16 21:14:14 UTC (rev 2724)
@@ -83,7 +83,6 @@
"org.dllearner.kb.OWLAPIOntology",
//reasoners
"org.dllearner.reasoning.OWLAPIReasoner",
- "org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner", // added by Josue
"org.dllearner.reasoning.DIGReasoner",
"org.dllearner.reasoning.FastRetrievalReasoner",
"org.dllearner.reasoning.FastInstanceChecker",
@@ -103,7 +102,6 @@
"org.dllearner.algorithms.el.ELLearningAlgorithm",
"org.dllearner.algorithms.el.ELLearningAlgorithmDisjunctive",
"org.dllearner.algorithms.celoe.CELOE",
- "org.dllearner.algorithms.fuzzydll.FuzzyCELOE", //added by Josue
"org.dllearner.algorithms.isle.ISLE"
} ));
Modified: trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java 2011-03-16 11:38:50 UTC (rev 2723)
+++ trunk/components-core/src/main/java/org/dllearner/core/configurators/ComponentFactory.java 2011-03-16 21:14:14 UTC (rev 2724)
@@ -27,7 +27,6 @@
import org.dllearner.algorithms.celoe.CELOE;
import org.dllearner.algorithms.el.ELLearningAlgorithm;
import org.dllearner.algorithms.el.ELLearningAlgorithmDisjunctive;
-import org.dllearner.algorithms.fuzzydll.FuzzyCELOE;
import org.dllearner.algorithms.gp.GP;
import org.dllearner.algorithms.isle.ISLE;
import org.dllearner.algorithms.ocel.OCEL;
@@ -50,7 +49,6 @@
import org.dllearner.reasoning.OWLAPIReasoner;
import org.dllearner.reasoning.PelletReasoner;
import org.dllearner.reasoning.ProtegeReasoner;
-import org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner;
/**
* automatically generated, do not edit manually.
@@ -140,14 +138,6 @@
}
/**
-* @param knowledgeSource see KnowledgeSource
-* @return a component ready for initialization FuzzyOWLAPIReasoner
-**/
-public static FuzzyOWLAPIReasoner getFuzzyOWLAPIReasoner(Set<KnowledgeSource> knowledgeSource) {
-return FuzzyOWLAPIReasonerConfigurator.getFuzzyOWLAPIReasoner(knowledgeSource);
-}
-
-/**
* @param classToDescribe class of which a description should be learned
* @param reasoningService see ReasoningService
* @return a component ready for initialization ClassLearningProblem
@@ -239,16 +229,6 @@
* @param learningProblem see LearningProblem
* @param reasoningService see ReasoningService
* @throws LearningProblemUnsupportedException see
-* @return a component ready for initialization FuzzyCELOE
-**/
-public static FuzzyCELOE getFuzzyCELOE(LearningProblem learningProblem, ReasonerComponent reasoningService) throws LearningProblemUnsupportedException {
-return FuzzyCELOEConfigurator.getFuzzyCELOE(learningProblem, reasoningService);
-}
-
-/**
-* @param learningProblem see LearningProblem
-* @param reasoningService see ReasoningService
-* @throws LearningProblemUnsupportedException see
* @return a component ready for initialization GP
**/
public static GP getGP(LearningProblem learningProblem, ReasonerComponent reasoningService) throws LearningProblemUnsupportedException {
Deleted: trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java 2011-03-16 11:38:50 UTC (rev 2723)
+++ trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyCELOEConfigurator.java 2011-03-16 21:14:14 UTC (rev 2724)
@@ -1,499 +0,0 @@
-/**
- * Copyright (C) 2007-2008, Jens Lehmann
- *
- * This file is part of DL-Learner.
- *
- * DL-Learner is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * DL-Learner is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.dllearner.core.configurators;
-
-import org.dllearner.algorithms.fuzzydll.FuzzyCELOE;
-import org.dllearner.core.ComponentManager;
-import org.dllearner.core.LearningProblem;
-import org.dllearner.core.LearningProblemUnsupportedException;
-import org.dllearner.core.ReasonerComponent;
-
-/**
-* automatically generated, do not edit manually.
-* run org.dllearner.scripts.ConfigJavaGenerator to update
-**/
-public class FuzzyCELOEConfigurator extends RefinementOperatorConfigurator implements Configurator {
-
-private boolean reinitNecessary = false;
-private FuzzyCELOE fuzzyCELOE;
-
-/**
-* @param fuzzyCELOE see FuzzyCELOE
-**/
-public FuzzyCELOEConfigurator(FuzzyCELOE fuzzyCELOE){
-this.fuzzyCELOE = fuzzyCELOE;
-}
-
-/**
-* @param reasoningService see reasoningService
-* @param learningProblem see learningProblem
-* @throws LearningProblemUnsupportedException see
-* @return FuzzyCELOE
-**/
-public static FuzzyCELOE getFuzzyCELOE(LearningProblem learningProblem, ReasonerComponent reasoningService) throws LearningProblemUnsupportedException{
-FuzzyCELOE component = ComponentManager.getInstance().learningAlgorithm(FuzzyCELOE.class, learningProblem, reasoningService);
-return component;
-}
-
-/**
-* useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm.
-* mandatory: false| reinit necessary: true
-* default value: true
-* @return boolean
-**/
-public boolean getUseAllConstructor() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "useAllConstructor") ;
-}
-/**
-* useExistsConstructor specifies whether the existential concept constructor is used in the learning algorithm.
-* mandatory: false| reinit necessary: true
-* default value: true
-* @return boolean
-**/
-public boolean getUseExistsConstructor() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "useExistsConstructor") ;
-}
-/**
-* useHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm.
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getUseHasValueConstructor() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "useHasValueConstructor") ;
-}
-/**
-* useDataHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm in combination with data properties.
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getUseDataHasValueConstructor() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "useDataHasValueConstructor") ;
-}
-/**
-* valueFrequencyThreshold specifies how often an object must occur as value in order to be considered for hasValue restrictions.
-* mandatory: false| reinit necessary: true
-* default value: 3
-* @return int
-**/
-public int getValueFrequencyThreshold() {
-return (Integer) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "valueFrequencyThreshold") ;
-}
-/**
-* useCardinalityRestrictions specifies whether CardinalityRestrictions is used in the learning algorithm.
-* mandatory: false| reinit necessary: true
-* default value: true
-* @return boolean
-**/
-public boolean getUseCardinalityRestrictions() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "useCardinalityRestrictions") ;
-}
-/**
-* cardinalityLimit Gives the maximum number used in cardinality restrictions..
-* mandatory: false| reinit necessary: true
-* default value: 5
-* @return int
-**/
-public int getCardinalityLimit() {
-return (Integer) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "cardinalityLimit") ;
-}
-/**
-* useNegation specifies whether negation is used in the learning algorothm.
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getUseNegation() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "useNegation") ;
-}
-/**
-* useBooleanDatatypes specifies whether boolean datatypes are used in the learning algorothm.
-* mandatory: false| reinit necessary: true
-* default value: true
-* @return boolean
-**/
-public boolean getUseBooleanDatatypes() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "useBooleanDatatypes") ;
-}
-/**
-* useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm.
-* mandatory: false| reinit necessary: true
-* default value: true
-* @return boolean
-**/
-public boolean getUseDoubleDatatypes() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "useDoubleDatatypes") ;
-}
-/**
-* maxExecutionTimeInSeconds algorithm will stop after specified seconds.
-* mandatory: false| reinit necessary: true
-* default value: 10
-* @return int
-**/
-public int getMaxExecutionTimeInSeconds() {
-return (Integer) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "maxExecutionTimeInSeconds") ;
-}
-/**
-* noisePercentage the (approximated) percentage of noise within the examples.
-* mandatory: false| reinit necessary: true
-* default value: 0.0
-* @return double
-**/
-public double getNoisePercentage() {
-return (Double) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "noisePercentage") ;
-}
-/**
-* terminateOnNoiseReached specifies whether to terminate when noise criterion is met.
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getTerminateOnNoiseReached() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "terminateOnNoiseReached") ;
-}
-/**
-* maxDepth maximum depth of description.
-* mandatory: false| reinit necessary: true
-* default value: 7
-* @return int
-**/
-public int getMaxDepth() {
-return (Integer) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "maxDepth") ;
-}
-/**
-* maxNrOfResults Sets the maximum number of results one is interested in. (Setting this to a lower value may increase performance as the learning algorithm has to store/evaluate/beautify less descriptions)..
-* mandatory: false| reinit necessary: true
-* default value: 10
-* @return int
-**/
-public int getMaxNrOfResults() {
-return (Integer) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "maxNrOfResults") ;
-}
-/**
-* maxClassDescriptionTests The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. (The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.).
-* mandatory: false| reinit necessary: true
-* default value: 0
-* @return int
-**/
-public int getMaxClassDescriptionTests() {
-return (Integer) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "maxClassDescriptionTests") ;
-}
-/**
-* singleSuggestionMode Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples..
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getSingleSuggestionMode() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "singleSuggestionMode") ;
-}
-/**
-* instanceBasedDisjoints Specifies whether to use real disjointness checks or instance based ones (no common instances) in the refinement operator..
-* mandatory: false| reinit necessary: true
-* default value: true
-* @return boolean
-**/
-public boolean getInstanceBasedDisjoints() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "instanceBasedDisjoints") ;
-}
-/**
-* filterDescriptionsFollowingFromKB If true, then the results will not contain suggestions, which already follow logically from the knowledge base. Be careful, since this requires a potentially expensive consistency check for candidate solutions..
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getFilterDescriptionsFollowingFromKB() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "filterDescriptionsFollowingFromKB") ;
-}
-/**
-* reuseExistingDescription If true, the algorithm tries to find a good starting point close to an existing definition/super class of the given class in the knowledge base..
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getReuseExistingDescription() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "reuseExistingDescription") ;
-}
-/**
-* writeSearchTree specifies whether to write a search tree.
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getWriteSearchTree() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "writeSearchTree") ;
-}
-/**
-* searchTreeFile file to use for the search tree.
-* mandatory: false| reinit necessary: true
-* default value: log/searchTree.txt
-* @return String
-**/
-public String getSearchTreeFile() {
-return (String) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "searchTreeFile") ;
-}
-/**
-* replaceSearchTree specifies whether to replace the search tree in the log file after each run or append the new search tree.
-* mandatory: false| reinit necessary: true
-* default value: false
-* @return boolean
-**/
-public boolean getReplaceSearchTree() {
-return (Boolean) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "replaceSearchTree") ;
-}
-/**
-* expansionPenaltyFactor heuristic penalty per syntactic construct used (lower = finds more complex expression, but might miss simple ones).
-* mandatory: false| reinit necessary: true
-* default value: 0.1
-* @return double
-**/
-public double getExpansionPenaltyFactor() {
-return (Double) ComponentManager.getInstance().getConfigOptionValue(fuzzyCELOE, "expansionPenaltyFactor") ;
-}
-
-/**
-* @param useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm.
-* mandatory: false| reinit necessary: true
-* default value: true
-**/
-public void setUseAllConstructor(boolean useAllConstructor) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "useAllConstructor", useAllConstructor);
-reinitNecessary = true;
-}
-/**
-* @param useExistsConstructor specifies whether the existential concept constructor is used in the learning algorithm.
-* mandatory: false| reinit necessary: true
-* default value: true
-**/
-public void setUseExistsConstructor(boolean useExistsConstructor) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "useExistsConstructor", useExistsConstructor);
-reinitNecessary = true;
-}
-/**
-* @param useHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm.
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setUseHasValueConstructor(boolean useHasValueConstructor) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "useHasValueConstructor", useHasValueConstructor);
-reinitNecessary = true;
-}
-/**
-* @param useDataHasValueConstructor specifies whether the hasValue constructor is used in the learning algorithm in combination with data properties.
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setUseDataHasValueConstructor(boolean useDataHasValueConstructor) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "useDataHasValueConstructor", useDataHasValueConstructor);
-reinitNecessary = true;
-}
-/**
-* @param valueFrequencyThreshold specifies how often an object must occur as value in order to be considered for hasValue restrictions.
-* mandatory: false| reinit necessary: true
-* default value: 3
-**/
-public void setValueFrequencyThreshold(int valueFrequencyThreshold) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "valueFrequencyThreshold", valueFrequencyThreshold);
-reinitNecessary = true;
-}
-/**
-* @param useCardinalityRestrictions specifies whether CardinalityRestrictions is used in the learning algorithm.
-* mandatory: false| reinit necessary: true
-* default value: true
-**/
-public void setUseCardinalityRestrictions(boolean useCardinalityRestrictions) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "useCardinalityRestrictions", useCardinalityRestrictions);
-reinitNecessary = true;
-}
-/**
-* @param cardinalityLimit Gives the maximum number used in cardinality restrictions..
-* mandatory: false| reinit necessary: true
-* default value: 5
-**/
-public void setCardinalityLimit(int cardinalityLimit) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "cardinalityLimit", cardinalityLimit);
-reinitNecessary = true;
-}
-/**
-* @param useNegation specifies whether negation is used in the learning algorothm.
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setUseNegation(boolean useNegation) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "useNegation", useNegation);
-reinitNecessary = true;
-}
-/**
-* @param useBooleanDatatypes specifies whether boolean datatypes are used in the learning algorothm.
-* mandatory: false| reinit necessary: true
-* default value: true
-**/
-public void setUseBooleanDatatypes(boolean useBooleanDatatypes) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "useBooleanDatatypes", useBooleanDatatypes);
-reinitNecessary = true;
-}
-/**
-* @param useDoubleDatatypes specifies whether boolean datatypes are used in the learning algorothm.
-* mandatory: false| reinit necessary: true
-* default value: true
-**/
-public void setUseDoubleDatatypes(boolean useDoubleDatatypes) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "useDoubleDatatypes", useDoubleDatatypes);
-reinitNecessary = true;
-}
-/**
-* @param maxExecutionTimeInSeconds algorithm will stop after specified seconds.
-* mandatory: false| reinit necessary: true
-* default value: 10
-**/
-public void setMaxExecutionTimeInSeconds(int maxExecutionTimeInSeconds) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds);
-reinitNecessary = true;
-}
-/**
-* @param noisePercentage the (approximated) percentage of noise within the examples.
-* mandatory: false| reinit necessary: true
-* default value: 0.0
-**/
-public void setNoisePercentage(double noisePercentage) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "noisePercentage", noisePercentage);
-reinitNecessary = true;
-}
-/**
-* @param terminateOnNoiseReached specifies whether to terminate when noise criterion is met.
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setTerminateOnNoiseReached(boolean terminateOnNoiseReached) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "terminateOnNoiseReached", terminateOnNoiseReached);
-reinitNecessary = true;
-}
-/**
-* @param maxDepth maximum depth of description.
-* mandatory: false| reinit necessary: true
-* default value: 7
-**/
-public void setMaxDepth(int maxDepth) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "maxDepth", maxDepth);
-reinitNecessary = true;
-}
-/**
-* @param maxNrOfResults Sets the maximum number of results one is interested in. (Setting this to a lower value may increase performance as the learning algorithm has to store/evaluate/beautify less descriptions)..
-* mandatory: false| reinit necessary: true
-* default value: 10
-**/
-public void setMaxNrOfResults(int maxNrOfResults) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "maxNrOfResults", maxNrOfResults);
-reinitNecessary = true;
-}
-/**
-* @param maxClassDescriptionTests The maximum number of candidate hypothesis the algorithm is allowed to test (0 = no limit). The algorithm will stop afterwards. (The real number of tests can be slightly higher, because this criterion usually won't be checked after each single test.).
-* mandatory: false| reinit necessary: true
-* default value: 0
-**/
-public void setMaxClassDescriptionTests(int maxClassDescriptionTests) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "maxClassDescriptionTests", maxClassDescriptionTests);
-reinitNecessary = true;
-}
-/**
-* @param singleSuggestionMode Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples..
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setSingleSuggestionMode(boolean singleSuggestionMode) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "singleSuggestionMode", singleSuggestionMode);
-reinitNecessary = true;
-}
-/**
-* @param instanceBasedDisjoints Specifies whether to use real disjointness checks or instance based ones (no common instances) in the refinement operator..
-* mandatory: false| reinit necessary: true
-* default value: true
-**/
-public void setInstanceBasedDisjoints(boolean instanceBasedDisjoints) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "instanceBasedDisjoints", instanceBasedDisjoints);
-reinitNecessary = true;
-}
-/**
-* @param filterDescriptionsFollowingFromKB If true, then the results will not contain suggestions, which already follow logically from the knowledge base. Be careful, since this requires a potentially expensive consistency check for candidate solutions..
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setFilterDescriptionsFollowingFromKB(boolean filterDescriptionsFollowingFromKB) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "filterDescriptionsFollowingFromKB", filterDescriptionsFollowingFromKB);
-reinitNecessary = true;
-}
-/**
-* @param reuseExistingDescription If true, the algorithm tries to find a good starting point close to an existing definition/super class of the given class in the knowledge base..
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setReuseExistingDescription(boolean reuseExistingDescription) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "reuseExistingDescription", reuseExistingDescription);
-reinitNecessary = true;
-}
-/**
-* @param writeSearchTree specifies whether to write a search tree.
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setWriteSearchTree(boolean writeSearchTree) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "writeSearchTree", writeSearchTree);
-reinitNecessary = true;
-}
-/**
-* @param searchTreeFile file to use for the search tree.
-* mandatory: false| reinit necessary: true
-* default value: log/searchTree.txt
-**/
-public void setSearchTreeFile(String searchTreeFile) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "searchTreeFile", searchTreeFile);
-reinitNecessary = true;
-}
-/**
-* @param replaceSearchTree specifies whether to replace the search tree in the log file after each run or append the new search tree.
-* mandatory: false| reinit necessary: true
-* default value: false
-**/
-public void setReplaceSearchTree(boolean replaceSearchTree) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "replaceSearchTree", replaceSearchTree);
-reinitNecessary = true;
-}
-/**
-* @param expansionPenaltyFactor heuristic penalty per syntactic construct used (lower = finds more complex expression, but might miss simple ones).
-* mandatory: false| reinit necessary: true
-* default value: 0.1
-**/
-public void setExpansionPenaltyFactor(double expansionPenaltyFactor) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyCELOE, "expansionPenaltyFactor", expansionPenaltyFactor);
-reinitNecessary = true;
-}
-
-/**
-* true, if this component needs reinitializsation.
-* @return boolean
-**/
-public boolean isReinitNecessary(){
-return reinitNecessary;
-}
-
-
-}
Deleted: trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyOWLAPIReasonerConfigurator.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyOWLAPIReasonerConfigurator.java 2011-03-16 11:38:50 UTC (rev 2723)
+++ trunk/components-core/src/main/java/org/dllearner/core/configurators/FuzzyOWLAPIReasonerConfigurator.java 2011-03-16 21:14:14 UTC (rev 2724)
@@ -1,101 +0,0 @@
-/**
- * Copyright (C) 2007-2008, Jens Lehmann
- *
- * This file is part of DL-Learner.
- *
- * DL-Learner is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * DL-Learner is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.dllearner.core.configurators;
-
-import java.net.URL;
-import java.util.Set;
-import org.dllearner.core.ComponentManager;
-import org.dllearner.core.KnowledgeSource;
-import org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner;
-
-/**
-* automatically generated, do not edit manually.
-* run org.dllearner.scripts.ConfigJavaGenerator to update
-**/
-public class FuzzyOWLAPIReasonerConfigurator implements Configurator {
-
-private boolean reinitNecessary = false;
-private FuzzyOWLAPIReasoner fuzzyOWLAPIReasoner;
-
-/**
-* @param fuzzyOWLAPIReasoner see FuzzyOWLAPIReasoner
-**/
-public FuzzyOWLAPIReasonerConfigurator(FuzzyOWLAPIReasoner fuzzyOWLAPIReasoner){
-this.fuzzyOWLAPIReasoner = fuzzyOWLAPIReasoner;
-}
-
-/**
-* @param knowledgeSource see knowledgeSource
-* @return FuzzyOWLAPIReasoner
-**/
-public static FuzzyOWLAPIReasoner getFuzzyOWLAPIReasoner(Set<KnowledgeSource> knowledgeSource) {
-FuzzyOWLAPIReasoner component = ComponentManager.getInstance().reasoner(FuzzyOWLAPIReasoner.class, knowledgeSource);
-return component;
-}
-
-/**
-* reasonerType FaCT++, HermiT, OWLlink or Pellet, which means "fact", "hermit", "owllink" or "pellet".
-* mandatory: false| reinit necessary: true
-* default value: pellet
-* @return String
-**/
-public String getReasonerType() {
-return (String) ComponentManager.getInstance().getConfigOptionValue(fuzzyOWLAPIReasoner, "reasonerType") ;
-}
-/**
-* owlLinkURL the URL to the remote OWLlink server.
-* mandatory: false| reinit necessary: true
-* default value: http://localhost:8080/
-* @return URL
-**/
-public URL getOwlLinkURL() {
-return (URL) ComponentManager.getInstance().getConfigOptionValue(fuzzyOWLAPIReasoner, "owlLinkURL") ;
-}
-
-/**
-* @param reasonerType FaCT++, HermiT, OWLlink or Pellet, which means "fact", "hermit", "owllink" or "pellet".
-* mandatory: false| reinit necessary: true
-* default value: pellet
-**/
-public void setReasonerType(String reasonerType) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyOWLAPIReasoner, "reasonerType", reasonerType);
-reinitNecessary = true;
-}
-/**
-* @param owlLinkURL the URL to the remote OWLlink server.
-* mandatory: false| reinit necessary: true
-* default value: http://localhost:8080/
-**/
-public void setOwlLinkURL(URL owlLinkURL) {
-ComponentManager.getInstance().applyConfigEntry(fuzzyOWLAPIReasoner, "owlLinkURL", owlLinkURL);
-reinitNecessary = true;
-}
-
-/**
-* true, if this component needs reinitializsation.
-* @return boolean
-**/
-public boolean isReinitNecessary(){
-return reinitNecessary;
-}
-
-
-}
Modified: trunk/components-core/src/main/java/org/dllearner/reasoning/ReasonerType.java
===================================================================
--- trunk/components-core/src/main/java/org/dllearner/reasoning/ReasonerType.java 2011-03-16 11:38:50 UTC (rev 2723)
+++ trunk/components-core/src/main/java/org/dllearner/reasoning/ReasonerType.java 2011-03-16 21:14:14 UTC (rev 2724)
@@ -26,5 +26,5 @@
*
*/
public enum ReasonerType {
- KAON2, DIG, FAST_RETRIEVAL, OWLAPI_FACT, OWLAPI_PELLET, OWLAPI_HERMIT, OWLAPI_FUZZY, FAST_INSTANCE_CHECKER, PELLET, PROTEGE
+ KAON2, DIG, FAST_RETRIEVAL, OWLAPI_FACT, OWLAPI_PELLET, OWLAPI_HERMIT, FAST_INSTANCE_CHECKER, PELLET, PROTEGE
}
\ No newline at end of file
Modified: trunk/components-core/src/main/resources/components.ini
===================================================================
--- trunk/components-core/src/main/resources/components.ini 2011-03-16 11:38:50 UTC (rev 2723)
+++ trunk/components-core/src/main/resources/components.ini 2011-03-16 21:14:14 UTC (rev 2724)
@@ -7,7 +7,6 @@
org.dllearner.kb.OWLAPIOntology
# reasoners
org.dllearner.reasoning.OWLAPIReasoner
-org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner
org.dllearner.reasoning.DIGReasoner
org.dllearner.reasoning.FastRetrievalReasoner
org.dllearner.reasoning.FastInstanceChecker
@@ -27,5 +26,4 @@
org.dllearner.algorithms.el.ELLearningAlgorithm
org.dllearner.algorithms.el.ELLearningAlgorithmDisjunctive
org.dllearner.algorithms.celoe.CELOE
-org.dllearner.algorithms.fuzzydll.FuzzyCELOE
org.dllearner.algorithms.isle.ISLE
Modified: trunk/interfaces/src/main/java/org/dllearner/cli/ConfMapper.java
===================================================================
--- trunk/interfaces/src/main/java/org/dllearner/cli/ConfMapper.java 2011-03-16 11:38:50 UTC (rev 2723)
+++ trunk/interfaces/src/main/java/org/dllearner/cli/ConfMapper.java 2011-03-16 21:14:14 UTC (rev 2724)
@@ -31,7 +31,6 @@
import org.dllearner.algorithms.celoe.CELOE;
import org.dllearner.algorithms.el.ELLearningAlgorithm;
import org.dllearner.algorithms.el.ELLearningAlgorithmDisjunctive;
-import org.dllearner.algorithms.fuzzydll.FuzzyCELOE;
import org.dllearner.algorithms.gp.GP;
import org.dllearner.algorithms.ocel.OCEL;
import org.dllearner.algorithms.refinement.ROLearner;
@@ -50,7 +49,6 @@
import org.dllearner.reasoning.FastInstanceChecker;
import org.dllearner.reasoning.FastRetrievalReasoner;
import org.dllearner.reasoning.OWLAPIReasoner;
-import org.dllearner.reasoning.fuzzydll.FuzzyOWLAPIReasoner;
/**
* Contains mappings from component classes to strings.
@@ -92,7 +90,6 @@
knowledgeSourceMapping.put("sparql", SparqlKnowledgeSource.class);
reasonerMapping.put("digReasoner", DIGReasoner.class);
reasonerMapping.put("owlAPIReasoner", OWLAPIReasoner.class);
- reasonerMapping.put("fuzzyOwlAPIReasoner", FuzzyOWLAPIReasoner.class); // added by Josue
reasonerMapping.put("fastInstanceChecker", FastInstanceChecker.class);
reasonerMapping.put("fastRetrievalReasoner", FastRetrievalReasoner.class);
learningProblemMapping.put("posNegLPStandard", PosNegLPStandard.class);
@@ -108,7 +105,6 @@
learningAlgorithmMapping.put("el", ELLearningAlgorithm.class);
learningAlgorithmMapping.put("disjunctiveEL", ELLearningAlgorithmDisjunctive.class);
learningAlgorithmMapping.put("celoe", CELOE.class);
- learningAlgorithmMapping.put("fuzzyCeloe", FuzzyCELOE.class); // added by Josue
// you do not need to edit anything below
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|