From: <sk...@us...> - 2008-09-24 12:23:34
|
Revision: 1251 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1251&view=rev Author: sknappe Date: 2008-09-24 11:49:47 +0000 (Wed, 24 Sep 2008) Log Message: ----------- bugfix in sparqlknowledgesource, changed navigator manipulator (added a rule to filter type tripels that are not yago), changed evaluationdescriptions ws a bit (added method with 3 parameters, bugfix for JSON syntax) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorOtherRule.java trunk/src/dl-learner/org/dllearner/kb/manipulator/Manipulator.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorFilterRule.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-24 08:58:31 UTC (rev 1250) +++ trunk/src/dl-learner/org/dllearner/algorithms/DBpediaNavigationSuggestor.java 2008-09-24 11:49:47 UTC (rev 1251) @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.LinkedList; +import java.util.List; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.ComponentInitException; @@ -180,6 +181,11 @@ public EvaluatedDescription getCurrentlyBestEvaluatedDescription() { return learner.getCurrentlyBestEvaluatedDescription(); } + + @Override + public List<EvaluatedDescription> getCurrentlyBestEvaluatedDescriptions(int nrOfDescriptions, double accuracyThreshold, boolean filterNonMinimalDescriptions){ + return learner.getCurrentlyBestEvaluatedDescriptions(nrOfDescriptions, accuracyThreshold, filterNonMinimalDescriptions); + } @Override public Score getSolutionScore() { Added: trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorFilterRule.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorFilterRule.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorFilterRule.java 2008-09-24 11:49:47 UTC (rev 1251) @@ -0,0 +1,69 @@ +/** + * 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.kb.manipulator; + +import java.util.LinkedList; +import java.util.List; +import java.util.SortedSet; + +import org.dllearner.kb.extraction.Node; +import org.dllearner.utilities.datastructures.RDFNodeTuple; +import org.dllearner.utilities.owl.OWLVocabulary; + +import com.hp.hpl.jena.rdf.model.Literal; +import com.hp.hpl.jena.rdf.model.RDFNode; +import com.hp.hpl.jena.rdf.model.impl.ResourceImpl; + + +public class DBpediaNavigatorFilterRule extends Rule{ + + + public DBpediaNavigatorFilterRule(Months month){ + super(month); + } + // Set<String> classproperties; + + @Override + public SortedSet<RDFNodeTuple> applyRule(Node subject, SortedSet<RDFNodeTuple> tuples){ + RDFNode clazz = null; + RDFNodeTuple typeTuple = null; + List<RDFNodeTuple> toRemove=new LinkedList<RDFNodeTuple>(); + for (RDFNodeTuple tuple : tuples) { + + if (tuple.a.toString().equals(OWLVocabulary.RDF_TYPE)){ + clazz = tuple.b; + typeTuple = tuple; + } + + if (tuple.a.toString().equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#type") && !(tuple.b.toString().startsWith("http://dbpedia.org/class/yago"))){ + toRemove.add(typeTuple); + } + }//end for + for (RDFNodeTuple tuple : toRemove) + tuples.remove(tuple); + return tuples; + } + + @Override + public void logJamon(){ + + } + +} Modified: trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorOtherRule.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorOtherRule.java 2008-09-24 08:58:31 UTC (rev 1250) +++ trunk/src/dl-learner/org/dllearner/kb/manipulator/DBpediaNavigatorOtherRule.java 2008-09-24 11:49:47 UTC (rev 1251) @@ -45,7 +45,7 @@ RDFNode clazz = null; RDFNodeTuple typeTuple = null; for (RDFNodeTuple tuple : tuples) { - + if (tuple.a.toString().equals(OWLVocabulary.RDF_TYPE)){ clazz = tuple.b; typeTuple = tuple; Modified: trunk/src/dl-learner/org/dllearner/kb/manipulator/Manipulator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/manipulator/Manipulator.java 2008-09-24 08:58:31 UTC (rev 1250) +++ trunk/src/dl-learner/org/dllearner/kb/manipulator/Manipulator.java 2008-09-24 11:49:47 UTC (rev 1251) @@ -89,8 +89,9 @@ public static Manipulator getDBpediaNavigatorManipulator(){ Manipulator m = new Manipulator(); - m.addRule(new DBPediaNavigatorCityLocatorRule(Months.JANUARY)); - m.addRule(new DBpediaNavigatorOtherRule(Months.DECEMBER)); + //m.addRule(new DBPediaNavigatorCityLocatorRule(Months.JANUARY)); + //m.addRule(new DBpediaNavigatorOtherRule(Months.DECEMBER)); + m.addRule(new DBpediaNavigatorFilterRule(Months.JANUARY)); return m; } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-24 08:58:31 UTC (rev 1250) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-09-24 11:49:47 UTC (rev 1251) @@ -417,7 +417,7 @@ public Manipulator getManipulator() { // get Options for Filters - if (configurator.getPredefinedManipulator() == null) { + if (configurator.getPredefinedManipulator() != null) { return Manipulator.getManipulatorByName(configurator .getPredefinedManipulator()); Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-09-24 08:58:31 UTC (rev 1250) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-09-24 11:49:47 UTC (rev 1251) @@ -394,12 +394,26 @@ @WebMethod public String getCurrentlyBestEvaluatedDescriptions(int id, int limit) throws ClientNotKnownException{ + return currentlyBestEvaluatedDescriptions(id,limit,-1,false); + } + + @WebMethod + public String getCurrentlyBestEvaluatedDescriptionsFiltered(int id,int nrOfDescriptions, double accuracyThreshold, boolean filterNonMinimalDescriptions) throws ClientNotKnownException + { + return currentlyBestEvaluatedDescriptions(id,nrOfDescriptions,accuracyThreshold,filterNonMinimalDescriptions); + } + + private String currentlyBestEvaluatedDescriptions(int id,int nrOfDescriptions, double accuracyThreshold, boolean filterNonMinimalDescriptions) throws ClientNotKnownException + { ClientState state = getState(id); - List<EvaluatedDescription> descriptions = state.getLearningAlgorithm().getCurrentlyBestEvaluatedDescriptions(limit); + List<EvaluatedDescription> descriptions; + if (accuracyThreshold!=-1) descriptions = state.getLearningAlgorithm().getCurrentlyBestEvaluatedDescriptions(nrOfDescriptions, accuracyThreshold, filterNonMinimalDescriptions); + else descriptions = state.getLearningAlgorithm().getCurrentlyBestEvaluatedDescriptions(nrOfDescriptions); String json = "{"; int count = 1; for(EvaluatedDescription description : descriptions) { - json += "\"solution" + count + "\" : " + description.asJSON(); + if (count>1) json += ",\"solution" + count + "\" : " + description.asJSON(); + else json += "\"solution" + count + "\" : " + description.asJSON(); count++; } json+="}"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |