You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(120) |
Sep
(36) |
Oct
(116) |
Nov
(17) |
Dec
(44) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(143) |
Feb
(192) |
Mar
(74) |
Apr
(84) |
May
(105) |
Jun
(64) |
Jul
(49) |
Aug
(120) |
Sep
(159) |
Oct
(156) |
Nov
(51) |
Dec
(28) |
2009 |
Jan
(17) |
Feb
(55) |
Mar
(33) |
Apr
(57) |
May
(54) |
Jun
(28) |
Jul
(6) |
Aug
(16) |
Sep
(38) |
Oct
(30) |
Nov
(26) |
Dec
(52) |
2010 |
Jan
(7) |
Feb
(91) |
Mar
(65) |
Apr
(2) |
May
(14) |
Jun
(25) |
Jul
(38) |
Aug
(48) |
Sep
(80) |
Oct
(70) |
Nov
(75) |
Dec
(77) |
2011 |
Jan
(68) |
Feb
(53) |
Mar
(51) |
Apr
(35) |
May
(65) |
Jun
(101) |
Jul
(29) |
Aug
(230) |
Sep
(95) |
Oct
(49) |
Nov
(110) |
Dec
(63) |
2012 |
Jan
(41) |
Feb
(42) |
Mar
(25) |
Apr
(46) |
May
(51) |
Jun
(44) |
Jul
(45) |
Aug
(29) |
Sep
(12) |
Oct
(9) |
Nov
(17) |
Dec
(2) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(7) |
Apr
(16) |
May
(54) |
Jun
(27) |
Jul
(11) |
Aug
(5) |
Sep
(85) |
Oct
(27) |
Nov
(37) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(29) |
Mar
(5) |
Apr
(3) |
May
(22) |
Jun
(3) |
Jul
(4) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <jen...@us...> - 2008-02-22 15:19:01
|
Revision: 627 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=627&view=rev Author: jenslehmann Date: 2008-02-22 07:18:56 -0800 (Fri, 22 Feb 2008) Log Message: ----------- minor parser change Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/parser/KBParser.java Modified: trunk/src/dl-learner/org/dllearner/parser/KBParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-22 15:16:02 UTC (rev 626) +++ trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-22 15:18:56 UTC (rev 627) @@ -7,7 +7,7 @@ public @SuppressWarnings("all") class KBParser implements KBParserConstants { - public static final String internalNamespace = "http://localhost/foo#"; + public static String internalNamespace = "http://localhost/foo#"; // method to give all internal stuff an URI (not necessary for DLs, but for OWL ontologies // and it should be possible to represent the internal KB as OWL ontology) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-22 15:16:40
|
Revision: 626 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=626&view=rev Author: jenslehmann Date: 2008-02-22 07:16:02 -0800 (Fri, 22 Feb 2008) Log Message: ----------- implemented lightning fast instance check algorithm Modified Paths: -------------- trunk/lib/components.ini trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/core/ReasoningMethodUnsupportedException.java trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/parser/kb.jj trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java trunk/src/dl-learner/org/dllearner/reasoning/ReasonerType.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Modified: trunk/lib/components.ini =================================================================== --- trunk/lib/components.ini 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/lib/components.ini 2008-02-22 15:16:02 UTC (rev 626) @@ -8,6 +8,7 @@ org.dllearner.reasoning.OWLAPIReasoner org.dllearner.reasoning.DIGReasoner org.dllearner.reasoning.FastRetrievalReasoner +org.dllearner.reasoning.FastInstanceChecker # learning problems org.dllearner.learningproblems.PosNegDefinitionLP org.dllearner.learningproblems.PosNegInclusionLP Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-02-22 15:16:02 UTC (rev 626) @@ -621,6 +621,8 @@ // System.out.println("properness max recursion depth: " + maxRecDepth); // System.out.println("max. number of one-step refinements: " + maxNrOfRefinements); // System.out.println("max. number of children of a node: " + maxNrOfChildren); + System.out.println("subsumption time: " + Helper.prettyPrintNanoSeconds(rs.getSubsumptionReasoningTimeNs())); + System.out.println("instance check time: " + Helper.prettyPrintNanoSeconds(rs.getInstanceCheckReasoningTimeNs())); } if(computeBenchmarkInformation) { Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2008-02-22 15:16:02 UTC (rev 626) @@ -900,6 +900,8 @@ // System.out.println("properness max recursion depth: " + maxRecDepth); // System.out.println("max. number of one-step refinements: " + maxNrOfRefinements); // System.out.println("max. number of children of a node: " + maxNrOfChildren); + logger.debug("subsumption time: " + Helper.prettyPrintNanoSeconds(rs.getSubsumptionReasoningTimeNs())); + logger.debug("instance check time: " + Helper.prettyPrintNanoSeconds(rs.getInstanceCheckReasoningTimeNs())); } if(showBenchmarkInformation) { Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-22 15:16:02 UTC (rev 626) @@ -78,6 +78,7 @@ import org.dllearner.parser.ParseException; import org.dllearner.parser.TokenMgrError; import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.FastRetrievalReasoner; import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.ConceptComparator; @@ -751,6 +752,8 @@ reasonerClass = OWLAPIReasoner.class; else if (reasonerOption.getStringValue().equals("fastRetrieval")) reasonerClass = FastRetrievalReasoner.class; + else if (reasonerOption.getStringValue().equals("fastInstanceChecker")) + reasonerClass = FastInstanceChecker.class; else { handleError("Unknown value " + reasonerOption.getStringValue() + " for option \"reasoner\"."); Modified: trunk/src/dl-learner/org/dllearner/core/ReasoningMethodUnsupportedException.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasoningMethodUnsupportedException.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/core/ReasoningMethodUnsupportedException.java 2008-02-22 15:16:02 UTC (rev 626) @@ -1,7 +1,44 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.core; +/** + * Exception indicating that a reasoner implementation cannot support + * the requested operation. Either the operation itself is not implemented + * or does not support certain features, e.g. a reasoner could support + * instance checks but not if the class description contains datatype + * constructs. + * + * @author Jens Lehmann + * + */ public class ReasoningMethodUnsupportedException extends Exception { private static final long serialVersionUID = -7045236443032695475L; + + public ReasoningMethodUnsupportedException() { + super(); + } + + public ReasoningMethodUnsupportedException(String message) { + super(message); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2008-02-22 15:16:02 UTC (rev 626) @@ -30,7 +30,7 @@ * @author Jens Lehmann * */ -public class NamedClass extends Description implements NamedKBElement { +public class NamedClass extends Description implements NamedKBElement, Comparable<NamedClass> { String name; @@ -79,4 +79,8 @@ public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { return Helper.getAbbreviatedString(name, baseURI, prefixes); } + + public int compareTo(NamedClass o) { + return name.compareTo(o.name); + } } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java 2008-02-22 15:16:02 UTC (rev 626) @@ -30,7 +30,7 @@ * @author Jens Lehmann * */ -public class ObjectProperty extends ObjectPropertyExpression implements Property, NamedKBElement { +public class ObjectProperty extends ObjectPropertyExpression implements Property, NamedKBElement, Comparable<ObjectProperty> { public ObjectProperty(String name) { super(name); @@ -51,5 +51,9 @@ public void accept(KBElementVisitor visitor) { visitor.visit(this); + } + + public int compareTo(ObjectProperty o) { + return name.compareTo(o.name); } } Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-22 15:16:02 UTC (rev 626) @@ -169,6 +169,8 @@ File confTrainFile = new File("examples/carcinogenesis/train.conf"); Files.clearFile(confTrainFile); String confHeader = "import(\"pte.owl\");\n\n"; + confHeader += "refinement.writeSearchTree = true;"; + confHeader += "refinement.searchTreeFile = \"log/carcinogenesis/searchTree.log\""; confHeader += "reasoner = owlAPI;\n"; Files.appendFile(confTrainFile, confHeader); Modified: trunk/src/dl-learner/org/dllearner/parser/kb.jj =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-22 15:16:02 UTC (rev 626) @@ -36,7 +36,7 @@ public class KBParser { - public static final String internalNamespace = "http://localhost/foo#"; + public static String internalNamespace = "http://localhost/foo#"; // method to give all internal stuff an URI (not necessary for DLs, but for OWL ontologies // and it should be possible to represent the internal KB as OWL ontology) Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-22 15:16:02 UTC (rev 626) @@ -19,50 +19,96 @@ */ package org.dllearner.reasoning; -import java.util.HashMap; +import java.io.File; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedSet; +import java.util.TreeMap; +import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningMethodUnsupportedException; import org.dllearner.core.ReasoningService; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.InvalidConfigOptionValueException; -import org.dllearner.core.owl.FlatABox; +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.Negation; +import org.dllearner.core.owl.Nothing; +import org.dllearner.core.owl.ObjectAllRestriction; import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.core.owl.ObjectPropertyExpression; +import org.dllearner.core.owl.ObjectPropertyHierarchy; +import org.dllearner.core.owl.ObjectSomeRestriction; +import org.dllearner.core.owl.SubsumptionHierarchy; +import org.dllearner.core.owl.Thing; +import org.dllearner.core.owl.Union; +import org.dllearner.kb.OWLFile; +import org.dllearner.parser.KBParser; +import org.dllearner.parser.ParseException; /** * Reasoner for fast instance checks. It works by completely dematerialising the knowledge - * base to speed up later reasoning requests. It + * base to speed up later reasoning requests. It then continues by only considering one + * model of the knowledge base (TODO: more explanation), which is neither correct nor + * complete, but sufficient in many cases. A big advantage of the algorithm is that it + * does not need even need to perform any set modifications (union, intersection, difference), + * so it avoids any object creation, which makes it very fast compared to standard + * reasoners (TODO: maybe add some benchmarks once it is implemented). * + * Note: This algorithm works only on concepts in negation normal form! + * * @author Jens Lehmann * */ public class FastInstanceChecker extends ReasonerComponent { + private static Logger logger = Logger + .getLogger(FastInstanceChecker.class); + private Set<NamedClass> atomicConcepts; private Set<ObjectProperty> atomicRoles; private SortedSet<Individual> individuals; private ReasoningService rs; private ReasonerComponent rc; + private Set<KnowledgeSource> sources; + // we use sorted sets (map indices) here, because they have only log(n) + // complexity for checking whether an element is contained in them // instances of classes - public Map<NamedClass,SortedSet<Individual>> classInstancesPos = new HashMap<NamedClass,SortedSet<Individual>>(); - public Map<NamedClass,SortedSet<Individual>> classInstancesNeg = new HashMap<NamedClass,SortedSet<Individual>>(); - + private Map<NamedClass,SortedSet<Individual>> classInstancesPos = new TreeMap<NamedClass,SortedSet<Individual>>(); + private Map<NamedClass,SortedSet<Individual>> classInstancesNeg = new TreeMap<NamedClass,SortedSet<Individual>>(); // object property mappings - public Map<ObjectProperty,Map<Individual,SortedSet<Individual>>> opPos = new HashMap<ObjectProperty,Map<Individual,SortedSet<Individual>>>(); - public Map<ObjectProperty,Map<Individual,SortedSet<Individual>>> opNeg = new HashMap<ObjectProperty,Map<Individual,SortedSet<Individual>>>(); - + private Map<ObjectProperty,Map<Individual,SortedSet<Individual>>> opPos = new TreeMap<ObjectProperty,Map<Individual,SortedSet<Individual>>>(); + // TODO: datatype properties public FastInstanceChecker(Set<KnowledgeSource> sources) { - rc = new OWLAPIReasoner(sources); + this.sources = sources; + } + + + /* (non-Javadoc) + * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.config.ConfigEntry) + */ + @Override + public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { + + } + + /* (non-Javadoc) + * @see org.dllearner.core.Component#init() + */ + @Override + public void init() throws ComponentInitException { + rc = new DIGReasoner(sources); try { rc.init(); } catch (ComponentInitException e1) { @@ -77,50 +123,97 @@ // be done (maybe this can be merge again with the FastRetrievalReasoner later) long dematStartTime = System.currentTimeMillis(); - FlatABox aBox = new FlatABox(); for (NamedClass atomicConcept : rs.getAtomicConcepts()) { - // aBox.atomicConceptsPos.put(atomicConcept.getName(), getStringSet(rs - // .retrieval(atomicConcept))); -// Negation negatedAtomicConcept = new Negation(atomicConcept); - // aBox.atomicConceptsNeg.put(atomicConcept.getName(), getStringSet(rs - // .retrieval(negatedAtomicConcept))); - aBox.concepts.add(atomicConcept.getName()); + classInstancesPos.put(atomicConcept, rs.retrieval(atomicConcept)); + Negation negatedAtomicConcept = new Negation(atomicConcept); + classInstancesNeg.put(atomicConcept, rs.retrieval(negatedAtomicConcept)); } for (ObjectProperty atomicRole : rs.getAtomicRoles()) { - // aBox.rolesPos.put(atomicRole.getName(), getStringMap(rs.getRoleMembers(atomicRole))); - aBox.roles.add(atomicRole.getName()); + opPos.put(atomicRole, rs.getRoleMembers(atomicRole)); } - // aBox.domain = getStringSet(rs.getIndividuals()); - // aBox.top = aBox.domain; - - // System.out.println(aBox); - long dematDuration = System.currentTimeMillis() - dematStartTime; - System.out.println("OK (" + dematDuration + " ms)"); + logger.info("TBox dematerialised in " + dematDuration + " ms"); - } - - - /* (non-Javadoc) - * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.config.ConfigEntry) - */ - @Override - public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { - // TODO Auto-generated method stub - } - /* (non-Javadoc) - * @see org.dllearner.core.Component#init() - */ @Override - public void init() throws ComponentInitException { - // TODO Auto-generated method stub - - } - + public boolean instanceCheck(Description description, Individual individual) throws ReasoningMethodUnsupportedException { + if(description instanceof NamedClass) { + return classInstancesPos.get((NamedClass)description).contains(individual); + } else if(description instanceof Negation) { + Description child = description.getChild(0); + if(child instanceof NamedClass) { + return classInstancesNeg.get((NamedClass)child).contains(individual); + } else { + throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Description needs to be in negation normal form."); + } + } else if(description instanceof Thing) { + return true; + } else if(description instanceof Nothing) { + return false; + } else if(description instanceof Union) { + // if the individual is instance of any of the subdescription of + // the union, we return true + List<Description> children = description.getChildren(); + for(Description child : children) { + if(instanceCheck(child, individual)) + return true; + } + return false; + } else if(description instanceof Intersection) { + // if the individual is instance of all of the subdescription of + // the union, we return true + List<Description> children = description.getChildren(); + for(Description child : children) { + if(!instanceCheck(child, individual)) + return false; + } + return true; + } else if(description instanceof ObjectSomeRestriction) { + ObjectPropertyExpression ope = ((ObjectSomeRestriction)description).getRole(); + if(!(ope instanceof ObjectProperty)) + throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Inverse object properties not supported."); + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual,SortedSet<Individual>> mapping = opPos.get(op);; + if(mapping == null) { + logger.warn("Instance check of a description with an undefinied property (" + op + ")."); + return false; + } + SortedSet<Individual> roleFillers = opPos.get(op).get(individual); + if(roleFillers == null) + return false; + for(Individual roleFiller : roleFillers) { + if(instanceCheck(child, roleFiller)) + return true; + } + return false; + } else if(description instanceof ObjectAllRestriction) { + ObjectPropertyExpression ope = ((ObjectAllRestriction)description).getRole(); + if(!(ope instanceof ObjectProperty)) + throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported. Inverse object properties not supported."); + ObjectProperty op = (ObjectProperty) ope; + Description child = description.getChild(0); + Map<Individual,SortedSet<Individual>> mapping = opPos.get(op);; + if(mapping == null) { + logger.warn("Instance check of a description with an undefinied property (" + op + ")."); + return true; + } + SortedSet<Individual> roleFillers = opPos.get(op).get(individual); + if(roleFillers == null) + return true; + for(Individual roleFiller : roleFillers) { + if(!instanceCheck(child, roleFiller)) + return false; + } + return true; + } + + throw new ReasoningMethodUnsupportedException("Instance check for description " + description + " unsupported."); + } + /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getAtomicConcepts() */ @@ -146,24 +239,62 @@ * @see org.dllearner.core.Reasoner#getReasonerType() */ public ReasonerType getReasonerType() { - // TODO Auto-generated method stub - return null; + return ReasonerType.FAST_INSTANCE_CHECKER; } /* (non-Javadoc) * @see org.dllearner.core.Reasoner#prepareSubsumptionHierarchy(java.util.Set) */ public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) { - // TODO Auto-generated method stub + rs.prepareSubsumptionHierarchy(); + } + @Override + public SubsumptionHierarchy getSubsumptionHierarchy() { + return rs.getSubsumptionHierarchy(); + } + + @Override + public void prepareRoleHierarchy(Set<ObjectProperty> allowedRoles) { + rs.prepareRoleHierarchy(allowedRoles); + } + + @Override + public ObjectPropertyHierarchy getRoleHierarchy() { + return rs.getRoleHierarchy(); } - + + @Override + public boolean subsumes(Description superConcept, Description subConcept) { +// Negation neg = new Negation(subConcept); +// Intersection c = new Intersection(neg,superConcept); +// return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); + return rs.subsumes(superConcept, subConcept); + } + /** - * @param args + * Test method for fast instance checker. + * @param args No arguments supported. + * @throws ComponentInitException + * @throws ParseException + * @throws ReasoningMethodUnsupportedException */ - public static void main(String[] args) { - // TODO Auto-generated method stub - + public static void main(String[] args) throws ComponentInitException, ParseException, ReasoningMethodUnsupportedException { + ComponentManager cm = ComponentManager.getInstance(); + OWLFile owl = cm.knowledgeSource(OWLFile.class); + String owlFile = new File("examples/family/father.owl").toURI().toString(); + cm.applyConfigEntry(owl, "url", owlFile); + owl.init(); + ReasonerComponent reasoner = cm.reasoner(FastInstanceChecker.class, owl); + cm.reasoningService(reasoner); + reasoner.init(); + + KBParser.internalNamespace = "http://example.com/father#"; + String query = "(male AND EXISTS hasChild.TOP)"; + Description d = KBParser.parseConcept(query); + System.out.println(d); + Individual i = new Individual("http://example.com/father#markus"); + System.out.println(reasoner.instanceCheck(d, i)); } } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-02-22 15:16:02 UTC (rev 626) @@ -114,9 +114,10 @@ // C \sqsubseteq D is rewritten to a retrieval for \not C \sqcap D @Override public boolean subsumes(Description superConcept, Description subConcept) { - Negation neg = new Negation(subConcept); - Intersection c = new Intersection(neg,superConcept); - return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); +// Negation neg = new Negation(subConcept); +// Intersection c = new Intersection(neg,superConcept); +// return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); + return rs.subsumes(superConcept, subConcept); } @Override Modified: trunk/src/dl-learner/org/dllearner/reasoning/ReasonerType.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/ReasonerType.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/reasoning/ReasonerType.java 2008-02-22 15:16:02 UTC (rev 626) @@ -4,5 +4,5 @@ package org.dllearner.reasoning; public enum ReasonerType { - KAON2, DIG, FAST_RETRIEVAL, FACT, PELLET + KAON2, DIG, FAST_RETRIEVAL, FACT, PELLET, FAST_INSTANCE_CHECKER } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2008-02-22 12:50:11 UTC (rev 625) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2008-02-22 15:16:02 UTC (rev 626) @@ -88,7 +88,12 @@ for (Class<? extends ReasonerComponent> reasonerClass : reasonerClasses) { ReasonerComponent reasoner = cm.reasoner(reasonerClass, ks); reasoner.init(); - boolean result = reasoner.instanceCheck(d, i); +// long startTime = System.nanoTime(); + boolean result = false; +// for(int n=0; n<10000; n++) { + result = reasoner.instanceCheck(d, i); +// } +// long time = System.nanoTime() - startTime; logger.debug("instance check: " + reasoner + " " + d + " " + i + " " + result); assertTrue(result); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-22 12:50:17
|
Revision: 625 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=625&view=rev Author: tonytacker Date: 2008-02-22 04:50:11 -0800 (Fri, 22 Feb 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-22 00:38:27 UTC (rev 624) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-22 12:50:11 UTC (rev 625) @@ -157,8 +157,8 @@ public void updateComboBox() { if (config.getReasoner() != null) for (int i = 0; i < reasoner.size(); i++) - if (config.getKnowledgeSource().getClass().equals( - config.getComponentManager().getKnowledgeSources().get(i))) { + if (config.getReasoner().getClass().equals( + config.getComponentManager().getReasonerComponents().get(i))) { cb.setSelectedIndex(i); } this.choosenClassIndex = cb.getSelectedIndex(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-22 00:38:34
|
Revision: 624 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=624&view=rev Author: tonytacker Date: 2008-02-21 16:38:27 -0800 (Thu, 21 Feb 2008) Log Message: ----------- new public method in startCLI - should be the best way for me - using this methods in configload.java and it works Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-21 21:21:21 UTC (rev 623) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-22 00:38:27 UTC (rev 624) @@ -167,62 +167,26 @@ // step 2: detect used reasoner ConfFileOption reasonerOption = parser.getConfOptionsByName("reasoner"); - Class<? extends ReasonerComponent> reasonerClass = null; - // default value - if (reasonerOption == null || reasonerOption.getStringValue().equals("dig")) - reasonerClass = DIGReasoner.class; - else if (reasonerOption.getStringValue().equals("owlAPI")) - reasonerClass = OWLAPIReasoner.class; - else if (reasonerOption.getStringValue().equals("fastRetrieval")) - reasonerClass = FastRetrievalReasoner.class; - else { - handleError("Unknown value " + reasonerOption.getStringValue() - + " for option \"reasoner\"."); - } - ReasonerComponent reasoner = cm.reasoner(reasonerClass, sources); + ReasonerComponent reasoner = cm.reasoner(getReasonerClass(reasonerOption), sources); configureComponent(cm, reasoner, componentPrefixMapping, parser); initComponent(cm, reasoner); rs = cm.reasoningService(reasoner); // step 3: detect learning problem ConfFileOption problemOption = parser.getConfOptionsByName("problem"); - Class<? extends LearningProblem> lpClass = null; - if (problemOption == null || problemOption.getStringValue().equals("posNegDefinition")) - lpClass = PosNegDefinitionLP.class; - else if (problemOption.getStringValue().equals("posNegInclusion")) - lpClass = PosNegInclusionLP.class; - else if (problemOption.getStringValue().equals("posOnlyDefinition")) - lpClass = PosOnlyDefinitionLP.class; - else - handleError("Unknown value " + problemOption.getValue() + " for option \"problem\"."); - - lp = cm.learningProblem(lpClass, rs); + lp = cm.learningProblem(getLearningProblemClass(problemOption), rs); SortedSet<String> posExamples = parser.getPositiveExamples(); SortedSet<String> negExamples = parser.getNegativeExamples(); cm.applyConfigEntry(lp, "positiveExamples", posExamples); - if (lpClass != PosOnlyDefinitionLP.class) + if (getLearningProblemClass(problemOption) != PosOnlyDefinitionLP.class) cm.applyConfigEntry(lp, "negativeExamples", negExamples); configureComponent(cm, lp, componentPrefixMapping, parser); initComponent(cm, lp); // step 4: detect learning algorithm ConfFileOption algorithmOption = parser.getConfOptionsByName("algorithm"); - Class<? extends LearningAlgorithm> laClass = null; - if (algorithmOption == null || algorithmOption.getStringValue().equals("refinement")) - laClass = ROLearner.class; - else if (algorithmOption.getStringValue().equals("refexamples")) - laClass = ExampleBasedROLComponent.class; - else if (algorithmOption.getStringValue().equals("gp")) - laClass = GP.class; - else if (algorithmOption.getStringValue().equals("bruteForce")) - laClass = BruteForceLearner.class; - else if (algorithmOption.getStringValue().equals("randomGuesser")) - laClass = RandomGuesser.class; - else - handleError("Unknown value in " + algorithmOption); - try { - la = cm.learningAlgorithm(laClass, lp, rs); + la = cm.learningAlgorithm(getLearningAlgorithm(algorithmOption), lp, rs); } catch (LearningProblemUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -368,7 +332,7 @@ } /** - * detects all imported files and their format + * detects all imported files and their format */ public static Map<URL, Class<? extends KnowledgeSource>> getImportedFiles(ConfParser parser, String baseDir) { @@ -770,4 +734,73 @@ return rs; } + // edit by Tilo Hielscher + + /** + * Set Reasoner class. Define here all possible reasoners. + * + * @param reasonerOption + * from config file + * @return reasonerClass reasoner class + */ + public static Class<? extends ReasonerComponent> getReasonerClass(ConfFileOption reasonerOption) { + Class<? extends ReasonerComponent> reasonerClass = null; + if (reasonerOption == null || reasonerOption.getStringValue().equals("dig")) + reasonerClass = DIGReasoner.class; + else if (reasonerOption.getStringValue().equals("owlAPI")) + reasonerClass = OWLAPIReasoner.class; + else if (reasonerOption.getStringValue().equals("fastRetrieval")) + reasonerClass = FastRetrievalReasoner.class; + else { + handleError("Unknown value " + reasonerOption.getStringValue() + + " for option \"reasoner\"."); + } + return reasonerClass; + } + + /** + * Set LearningProblem class. Define here all possible problems. + * + * @param problemOption + * from config file + * @return lpClass learning problem class + */ + public static Class<? extends LearningProblem> getLearningProblemClass(ConfFileOption problemOption) { + Class<? extends LearningProblem> lpClass = null; + if (problemOption == null || problemOption.getStringValue().equals("posNegDefinition")) + lpClass = PosNegDefinitionLP.class; + else if (problemOption.getStringValue().equals("posNegInclusion")) + lpClass = PosNegInclusionLP.class; + else if (problemOption.getStringValue().equals("posOnlyDefinition")) + lpClass = PosOnlyDefinitionLP.class; + else + handleError("Unknown value " + problemOption.getValue() + " for option \"problem\"."); + + return lpClass; + } + + /** + * Set LearningAlorithm class. Define here all possible learning algorithms. + * + * @param algorithmOption + * from config file + * @return laClass learning algorithm class + */ + public static Class<? extends LearningAlgorithm> getLearningAlgorithm(ConfFileOption algorithmOption) { + Class<? extends LearningAlgorithm> laClass = null; + if (algorithmOption == null || algorithmOption.getStringValue().equals("refinement")) + laClass = ROLearner.class; + else if (algorithmOption.getStringValue().equals("refexamples")) + laClass = ExampleBasedROLComponent.class; + else if (algorithmOption.getStringValue().equals("gp")) + laClass = GP.class; + else if (algorithmOption.getStringValue().equals("bruteForce")) + laClass = BruteForceLearner.class; + else if (algorithmOption.getStringValue().equals("randomGuesser")) + laClass = RandomGuesser.class; + else + handleError("Unknown value in " + algorithmOption); + + return laClass; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-21 21:21:21 UTC (rev 623) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-22 00:38:27 UTC (rev 624) @@ -20,40 +20,16 @@ * */ -import java.io.File; // import java.net.URL; -import java.net.URL; // import java.util.HashSet; -import java.util.Map; // import java.util.Set; -import java.util.SortedSet; // import java.util.List; -// import java.util.Map; -import org.dllearner.algorithms.BruteForceLearner; -import org.dllearner.algorithms.RandomGuesser; -import org.dllearner.algorithms.gp.GP; -import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; -import org.dllearner.algorithms.refinement.ROLearner; +import java.io.File; +import java.net.URL; +import java.util.Map; +import java.util.SortedSet; import org.dllearner.core.ComponentInitException; -import org.dllearner.core.KnowledgeSource; // import -import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.LearningProblem; +import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningProblemUnsupportedException; -import org.dllearner.core.ReasonerComponent; // org.dllearner.core.LearningProblem; -// import org.dllearner.core.ReasoningService; -// import org.dllearner.core.LearningAlgorithm; -// import org.dllearner.core.ReasonerComponent; -// import org.dllearner.core.config.ConfigEntry; -// import org.dllearner.core.config.InvalidConfigOptionValueException; -// import org.dllearner.core.config.StringConfigOption; -import org.dllearner.learningproblems.PosNegDefinitionLP; -import org.dllearner.learningproblems.PosNegInclusionLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.parser.ConfParser; -import org.dllearner.reasoning.DIGReasoner; -import org.dllearner.reasoning.FastRetrievalReasoner; -import org.dllearner.reasoning.OWLAPIReasoner; // import -// org.dllearner.kb.KBFile; -// import org.dllearner.kb.OWLFile; -// import org.dllearner.kb.sparql.SparqlKnowledgeSource; -import org.dllearner.core.Component; // import -// org.dllearner.cli.ConfFileOption; +import org.dllearner.core.Component; import org.dllearner.cli.ConfFileOption; import org.dllearner.cli.Start; @@ -131,20 +107,8 @@ // REASONER ConfFileOption reasonerOption = parser.getConfOptionsByName("reasoner"); - Class<? extends ReasonerComponent> reasonerClass = null; - // default value - if (reasonerOption == null || reasonerOption.getStringValue().equals("dig")) - reasonerClass = DIGReasoner.class; - else if (reasonerOption.getStringValue().equals("owlAPI")) - reasonerClass = OWLAPIReasoner.class; - else if (reasonerOption.getStringValue().equals("fastRetrieval")) - reasonerClass = FastRetrievalReasoner.class; - else { - Start.handleError("Unknown value " + reasonerOption.getStringValue() - + " for option \"reasoner\"."); - } - config.setReasoner(config.getComponentManager().reasoner(reasonerClass, - config.getKnowledgeSource())); + config.setReasoner(config.getComponentManager().reasoner( + Start.getReasonerClass(reasonerOption), config.getKnowledgeSource())); Start.configureComponent(config.getComponentManager(), config.getReasoner(), componentPrefixMapping, parser); if (config.getKnowledgeSource() != null && config.getReasoner() != null) { @@ -164,23 +128,13 @@ // LEARNING PROBLEM ConfFileOption problemOption = parser.getConfOptionsByName("problem"); - Class<? extends LearningProblem> lpClass = null; - if (problemOption == null || problemOption.getStringValue().equals("posNegDefinition")) - lpClass = PosNegDefinitionLP.class; - else if (problemOption.getStringValue().equals("posNegInclusion")) - lpClass = PosNegInclusionLP.class; - else if (problemOption.getStringValue().equals("posOnlyDefinition")) - lpClass = PosOnlyDefinitionLP.class; - else - Start.handleError("Unknown value " + problemOption.getValue() - + " for option \"problem\"."); - config.setLearningProblem(config.getComponentManager().learningProblem(lpClass, - config.getReasoningService())); + config.setLearningProblem(config.getComponentManager().learningProblem( + Start.getLearningProblemClass(problemOption), config.getReasoningService())); SortedSet<String> posExamples = parser.getPositiveExamples(); SortedSet<String> negExamples = parser.getNegativeExamples(); config.getComponentManager().applyConfigEntry(config.getLearningProblem(), "positiveExamples", posExamples); - if (lpClass != PosOnlyDefinitionLP.class) + if (Start.getLearningProblemClass(problemOption) != PosOnlyDefinitionLP.class) config.getComponentManager().applyConfigEntry(config.getLearningProblem(), "negativeExamples", negExamples); Start.configureComponent(config.getComponentManager(), config.getLearningProblem(), @@ -198,30 +152,17 @@ // LEARNING ALGORITHM ConfFileOption algorithmOption = parser.getConfOptionsByName("algorithm"); - Class<? extends LearningAlgorithm> laClass = null; - if (algorithmOption == null || algorithmOption.getStringValue().equals("refinement")) - laClass = ROLearner.class; - else if(algorithmOption.getStringValue().equals("refexamples")) - laClass = ExampleBasedROLComponent.class; - else if(algorithmOption.getStringValue().equals("gp")) - laClass = GP.class; - else if(algorithmOption.getStringValue().equals("bruteForce")) - laClass = BruteForceLearner.class; - else if(algorithmOption.getStringValue().equals("randomGuesser")) - laClass = RandomGuesser.class; - else - Start.handleError("Unknown value in " + algorithmOption); - if (config.getLearningProblem() != null && config.getReasoningService() != null) { try { config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm( - laClass, config.getLearningProblem(), - config.getReasoningService())); + Start.getLearningAlgorithm(algorithmOption), + config.getLearningProblem(), config.getReasoningService())); } catch (LearningProblemUnsupportedException e) { e.printStackTrace(); } } - Start.configureComponent(config.getComponentManager(), config.getLearningAlgorithm(), componentPrefixMapping, parser); + Start.configureComponent(config.getComponentManager(), config.getLearningAlgorithm(), + componentPrefixMapping, parser); if (config.getLearningProblem() != null) { try { config.getLearningAlgorithm().init(); @@ -231,15 +172,9 @@ e.printStackTrace(); } } - + // update graphic startGUI.updateTabColors(); - - //System.out.println("reasoner: " + parser.getConfOptionsByName("reasoner")); - //System.out.println("confoptions: " + parser.getConfOptions()); - //System.out.println("posExamples: " + parser.getPositiveExamples()); - //System.out.println("confoptionbyname: " + parser.getConfOptionsByName()); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-21 21:21:31
|
Revision: 623 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=623&view=rev Author: tonytacker Date: 2008-02-21 13:21:21 -0800 (Thu, 21 Feb 2008) Log Message: ----------- some more PUBLIC methods to use their inside GUI for loading a configuration file Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-21 21:20:02 UTC (rev 622) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-21 21:21:21 UTC (rev 623) @@ -368,7 +368,7 @@ } /** - * detects all imported files and their format + * detects all imported files and their format */ public static Map<URL, Class<? extends KnowledgeSource>> getImportedFiles(ConfParser parser, String baseDir) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-21 21:20:14
|
Revision: 622 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=622&view=rev Author: tonytacker Date: 2008-02-21 13:20:02 -0800 (Thu, 21 Feb 2008) Log Message: ----------- some more private methods to use their inside GUI for loading a configuration file Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-21 21:13:33 UTC (rev 621) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-02-21 21:20:02 UTC (rev 622) @@ -94,12 +94,12 @@ */ public class Start { - private static Logger logger = Logger.getRootLogger(); - + private static Logger logger = Logger.getRootLogger(); + private LearningAlgorithm la; private LearningProblem lp; private ReasoningService rs; - + /** * Entry point for CLI interface. * @@ -111,7 +111,7 @@ boolean inQueryMode = false; if (args.length > 1 && args[0].equals("-q")) inQueryMode = true; - + // create logger (a simple logger which outputs // its messages to the console) SimpleLayout layout = new SimpleLayout(); @@ -119,7 +119,7 @@ logger.removeAllAppenders(); logger.addAppender(consoleAppender); logger.setLevel(Level.DEBUG); - + Start start = null; start = new Start(file); start.start(inQueryMode); @@ -127,12 +127,14 @@ /** * Initialise all components based on conf file. - * @param file Conf file to read. - * @throws ComponentInitException + * + * @param file + * Conf file to read. + * @throws ComponentInitException */ public Start(File file) throws ComponentInitException { - String baseDir = file.getParentFile().getPath(); - + String baseDir = file.getParentFile().getPath(); + // create component manager instance String message = "starting component manager ... "; long cmStartTime = System.nanoTime(); @@ -140,7 +142,7 @@ long cmTime = System.nanoTime() - cmStartTime; message += "OK (" + Helper.prettyPrintNanoSeconds(cmTime) + ")"; logger.info(message); - + // create a mapping between components and prefixes in the conf file Map<Class<? extends Component>, String> componentPrefixMapping = createComponentPrefixMapping(); @@ -169,9 +171,9 @@ // default value if (reasonerOption == null || reasonerOption.getStringValue().equals("dig")) reasonerClass = DIGReasoner.class; - else if(reasonerOption.getStringValue().equals("owlAPI")) + else if (reasonerOption.getStringValue().equals("owlAPI")) reasonerClass = OWLAPIReasoner.class; - else if(reasonerOption.getStringValue().equals("fastRetrieval")) + else if (reasonerOption.getStringValue().equals("fastRetrieval")) reasonerClass = FastRetrievalReasoner.class; else { handleError("Unknown value " + reasonerOption.getStringValue() @@ -198,24 +200,24 @@ SortedSet<String> posExamples = parser.getPositiveExamples(); SortedSet<String> negExamples = parser.getNegativeExamples(); cm.applyConfigEntry(lp, "positiveExamples", posExamples); - if(lpClass != PosOnlyDefinitionLP.class) + if (lpClass != PosOnlyDefinitionLP.class) cm.applyConfigEntry(lp, "negativeExamples", negExamples); configureComponent(cm, lp, componentPrefixMapping, parser); initComponent(cm, lp); - + // step 4: detect learning algorithm ConfFileOption algorithmOption = parser.getConfOptionsByName("algorithm"); Class<? extends LearningAlgorithm> laClass = null; if (algorithmOption == null || algorithmOption.getStringValue().equals("refinement")) laClass = ROLearner.class; - else if(algorithmOption.getStringValue().equals("refexamples")) - laClass = ExampleBasedROLComponent.class; - else if(algorithmOption.getStringValue().equals("gp")) + else if (algorithmOption.getStringValue().equals("refexamples")) + laClass = ExampleBasedROLComponent.class; + else if (algorithmOption.getStringValue().equals("gp")) laClass = GP.class; - else if(algorithmOption.getStringValue().equals("bruteForce")) + else if (algorithmOption.getStringValue().equals("bruteForce")) laClass = BruteForceLearner.class; - else if(algorithmOption.getStringValue().equals("randomGuesser")) - laClass = RandomGuesser.class; + else if (algorithmOption.getStringValue().equals("randomGuesser")) + laClass = RandomGuesser.class; else handleError("Unknown value in " + algorithmOption); @@ -232,9 +234,9 @@ performExports(parser, baseDir, sources, rs); // handle any CLI options - processCLIOptions(cm, parser, rs, lp); + processCLIOptions(cm, parser, rs, lp); } - + public void start(boolean inQueryMode) { if (inQueryMode) processQueryMode(lp, rs); @@ -245,11 +247,13 @@ long algDuration = System.nanoTime() - algStartTime; printConclusions(rs, algDuration); - } + } } - - // creates a mapping from components to option prefix strings - private static Map<Class<? extends Component>, String> createComponentPrefixMapping() { + + /** + * creates a mapping from components to option prefix strings + */ + public static Map<Class<? extends Component>, String> createComponentPrefixMapping() { Map<Class<? extends Component>, String> componentPrefixMapping = new HashMap<Class<? extends Component>, String>(); // knowledge sources componentPrefixMapping.put(SparqlKnowledgeSource.class, "sparql"); @@ -265,12 +269,13 @@ return componentPrefixMapping; } - // convenience method - // basically every prefix (e.g. "refinement" in - // "refinement.horizontalExpFactor) - // corresponds to a specific component - this way the CLI will automatically - // support any configuration options supported by the component - private static void configureComponent(ComponentManager cm, Component component, + /** + * convenience method basically every prefix (e.g. "refinement" in + * "refinement.horizontalExpFactor) corresponds to a specific component - + * this way the CLI will automatically support any configuration options + * supported by the component + */ + public static void configureComponent(ComponentManager cm, Component component, Map<Class<? extends Component>, String> componentPrefixMapping, ConfParser parser) { String prefix = componentPrefixMapping.get(component.getClass()); if (prefix != null) @@ -292,7 +297,7 @@ // the name of the option is suboption-part (the first part refers // to its component) String optionName = option.getSubOption(); - + ConfigOption<?> configOption = cm.getConfigOption(component.getClass(), optionName); // check whether such an option exists if (configOption != null) { @@ -339,14 +344,18 @@ (StringSetConfigOption) configOption, option.getSetValues()); cm.applyConfigEntry(component, entry); - } else if (configOption instanceof StringTupleListConfigOption && option.isListOption()) { + } else if (configOption instanceof StringTupleListConfigOption + && option.isListOption()) { ConfigEntry<List<StringTuple>> entry = new ConfigEntry<List<StringTuple>>( (StringTupleListConfigOption) configOption, option.getListTuples()); cm.applyConfigEntry(component, entry); } else { - handleError("The type of conf file entry \"" + option.getFullName() + "\" is not correct: value \"" + option.getValue() + "\" not valid for option type \"" + configOption.getClass().getName() + "\"."); + handleError("The type of conf file entry \"" + option.getFullName() + + "\" is not correct: value \"" + option.getValue() + + "\" not valid for option type \"" + configOption.getClass().getName() + + "\"."); } } catch (InvalidConfigOptionValueException e) { @@ -358,85 +367,88 @@ handleError("Unknow option " + option + "."); } - // detects all imported files and their format + /** + * detects all imported files and their format + */ public static Map<URL, Class<? extends KnowledgeSource>> getImportedFiles(ConfParser parser, String baseDir) { List<List<String>> imports = parser.getFunctionCalls().get("import"); Map<URL, Class<? extends KnowledgeSource>> importedFiles = new HashMap<URL, Class<? extends KnowledgeSource>>(); - if(imports != null) { - for (List<String> arguments : imports) { - // step 1: detect URL - URL url = null; - try { - String fileString = arguments.get(0); - if (fileString.startsWith("http:")) { - url = new URL(fileString); - } else { - File f = new File(baseDir, arguments.get(0)); - url = f.toURI().toURL(); + if (imports != null) { + for (List<String> arguments : imports) { + // step 1: detect URL + URL url = null; + try { + String fileString = arguments.get(0); + if (fileString.startsWith("http:")) { + url = new URL(fileString); + } else { + File f = new File(baseDir, arguments.get(0)); + url = f.toURI().toURL(); + } + } catch (MalformedURLException e) { + e.printStackTrace(); } - } catch (MalformedURLException e) { - e.printStackTrace(); - } - // step 2: detect format - Class<? extends KnowledgeSource> ksClass; - if (arguments.size() == 1) { - String filename = url.getPath(); - String ending = filename.substring(filename.lastIndexOf(".") + 1); + // step 2: detect format + Class<? extends KnowledgeSource> ksClass; + if (arguments.size() == 1) { + String filename = url.getPath(); + String ending = filename.substring(filename.lastIndexOf(".") + 1); - if (ending.equals("rdf") || ending.equals("owl")) - ksClass = OWLFile.class; - else if (ending.equals("nt")) - ksClass = OWLFile.class; - else if (ending.equals("kb")) - ksClass = KBFile.class; - else { - System.err.println("Warning: no format given for " + arguments.get(0) - + " and could not detect it. Chosing RDF/XML."); - ksClass = OWLFile.class; - } + if (ending.equals("rdf") || ending.equals("owl")) + ksClass = OWLFile.class; + else if (ending.equals("nt")) + ksClass = OWLFile.class; + else if (ending.equals("kb")) + ksClass = KBFile.class; + else { + System.err.println("Warning: no format given for " + arguments.get(0) + + " and could not detect it. Chosing RDF/XML."); + ksClass = OWLFile.class; + } - importedFiles.put(url, ksClass); - } else { - String formatString = arguments.get(1); + importedFiles.put(url, ksClass); + } else { + String formatString = arguments.get(1); - if (formatString.equals("RDF/XML")) - ksClass = OWLFile.class; - else if (formatString.equals("KB")) - ksClass = KBFile.class; - else if (formatString.equals("SPARQL")) - ksClass = SparqlKnowledgeSource.class; - else if (formatString.equals("NT")) - ksClass = OWLFile.class; - else { - throw new RuntimeException("Unsupported knowledge source format " - + formatString + ". Exiting."); + if (formatString.equals("RDF/XML")) + ksClass = OWLFile.class; + else if (formatString.equals("KB")) + ksClass = KBFile.class; + else if (formatString.equals("SPARQL")) + ksClass = SparqlKnowledgeSource.class; + else if (formatString.equals("NT")) + ksClass = OWLFile.class; + else { + throw new RuntimeException("Unsupported knowledge source format " + + formatString + ". Exiting."); + } + + importedFiles.put(url, ksClass); } - - importedFiles.put(url, ksClass); } } - } return importedFiles; } - private static void performExports(ConfParser parser, String baseDir, Set<KnowledgeSource> sources, ReasoningService rs) { + private static void performExports(ConfParser parser, String baseDir, + Set<KnowledgeSource> sources, ReasoningService rs) { List<List<String>> exports = parser.getFunctionCalls().get("export"); if (exports == null) return; - + File file = null; - OntologyFormat format = null; + OntologyFormat format = null; for (List<String> export : exports) { file = new File(baseDir, export.get(0)); if (export.size() == 1) // use RDF/XML by default format = OntologyFormat.RDF_XML; - // rs.saveOntology(file, OntologyFileFormat.RDF_XML); + // rs.saveOntology(file, OntologyFileFormat.RDF_XML); else { String formatString = export.get(1); // OntologyFileFormat format; @@ -448,14 +460,14 @@ } } // hack: ideally we would have the possibility to export each knowledge - // source to specified files with specified formats (and maybe including + // source to specified files with specified formats (and maybe including // the option to merge them all in one file) // however implementing this requires quite some effort so for the // moment we just stick to exporting KB files (moreover all but the last // export statement are ignored) - for(KnowledgeSource source : sources) { - if(source instanceof KBFile) - ((KBFile)source).export(file, format); + for (KnowledgeSource source : sources) { + if (source instanceof KBFile) + ((KBFile) source).export(file, format); } } @@ -469,18 +481,21 @@ for (ConfFileOption cliOption : cliOptions) { String name = cliOption.getSubOption(); if (name.equals("showExamples")) { - // show examples (display each one if they do not take up much space, + // show examples (display each one if they do not take up + // much space, // otherwise just show the number of examples) SortedSet<String> posExamples = parser.getPositiveExamples(); - SortedSet<String> negExamples = parser.getNegativeExamples(); + SortedSet<String> negExamples = parser.getNegativeExamples(); boolean oneLineExampleInfo = true; - int maxExampleStringLength = Math.max(posExamples.toString().length(), negExamples - .toString().length()); + int maxExampleStringLength = Math.max(posExamples.toString().length(), + negExamples.toString().length()); if (maxExampleStringLength > 100) oneLineExampleInfo = false; if (oneLineExampleInfo) { - System.out.println("positive examples[" + posExamples.size() + "]: " + posExamples); - System.out.println("negative examples[" + negExamples.size() + "]: " + negExamples); + System.out.println("positive examples[" + posExamples.size() + "]: " + + posExamples); + System.out.println("negative examples[" + negExamples.size() + "]: " + + negExamples); } else { System.out.println("positive examples[" + posExamples.size() + "]: "); for (String ex : posExamples) @@ -488,7 +503,7 @@ System.out.println("negative examples[" + negExamples.size() + "]: "); for (String ex : negExamples) System.out.println(" " + ex); - } + } } else if (name.equals("showIndividuals")) { if (cliOption.getStringValue().equals("true")) { int stringLength = rs.getIndividuals().toString().length(); @@ -541,31 +556,32 @@ if (!satisfiable) System.exit(0); } - } else if( name.equals("logLevel")) { + } else if (name.equals("logLevel")) { String level = cliOption.getStringValue(); - if(level.equals("off")) + if (level.equals("off")) logger.setLevel(Level.OFF); - else if(level.equals("trace")) - logger.setLevel(Level.TRACE); - else if(level.equals("info")) + else if (level.equals("trace")) + logger.setLevel(Level.TRACE); + else if (level.equals("info")) logger.setLevel(Level.INFO); - else if(level.equals("debug")) + else if (level.equals("debug")) logger.setLevel(Level.DEBUG); - else if(level.equals("warn")) + else if (level.equals("warn")) logger.setLevel(Level.WARN); - else if(level.equals("error")) + else if (level.equals("error")) logger.setLevel(Level.ERROR); - else if(level.equals("fatal")) - logger.setLevel(Level.FATAL); + else if (level.equals("fatal")) + logger.setLevel(Level.FATAL); } else handleError("Unknown CLI option \"" + name + "\"."); } } } - private static void initComponent(ComponentManager cm, Component component) throws ComponentInitException { - String startMessage = "initialising component \"" + cm.getComponentName(component.getClass()) - + "\" ... "; + private static void initComponent(ComponentManager cm, Component component) + throws ComponentInitException { + String startMessage = "initialising component \"" + + cm.getComponentName(component.getClass()) + "\" ... "; long initStartTime = System.nanoTime(); component.init(); // standard messsage is just "OK" but can be more detailed for certain @@ -580,8 +596,8 @@ } long initTime = System.nanoTime() - initStartTime; - logger.info(startMessage + message + " (" + Helper.prettyPrintNanoSeconds(initTime, false, false) - + ")"); + logger.info(startMessage + message + " (" + + Helper.prettyPrintNanoSeconds(initTime, false, false) + ")"); } private static void printConclusions(ReasoningService rs, long algorithmDuration) { @@ -635,8 +651,8 @@ private static void processQueryMode(LearningProblem lp, ReasoningService rs) { System.out.println("Entering query mode. Enter a concept for performing " - + "retrieval or q to quit. Use brackets for complex expresssions," + - "e.g. (a AND b)."); + + "retrieval or q to quit. Use brackets for complex expresssions," + + "e.g. (a AND b)."); String queryStr = ""; do { @@ -649,7 +665,7 @@ } catch (IOException e) { e.printStackTrace(); } - + if (!queryStr.equals("q")) { // parse concept @@ -682,11 +698,11 @@ // substract existing roles/concepts from detected // roles/concepts -> the resulting sets should be // empty, otherwise print a warning (the DIG reasoner - // will just treat them as concepts about which it + // will just treat them as concepts about which it // has no knowledge - this makes it hard to - // detect typos - // (note that removeAll currently gives a different - // result here, because the comparator of the argument + // detect typos + // (note that removeAll currently gives a different + // result here, because the comparator of the argument // is used) for (NamedClass ac : rs.getAtomicConcepts()) occurringConcepts.remove(ac); @@ -705,13 +721,15 @@ } if (!nonExistingConstructs) { - - if(!queryStr.startsWith("(") && (queryStr.contains("AND") || queryStr.contains("OR"))) { - System.out.println("Make sure you did not forget to use outer brackets."); + + if (!queryStr.startsWith("(") + && (queryStr.contains("AND") || queryStr.contains("OR"))) { + System.out + .println("Make sure you did not forget to use outer brackets."); } - + System.out.println("The query is: " + concept + "."); - + // pose retrieval query Set<Individual> result = null; result = rs.retrieval(concept); @@ -729,7 +747,13 @@ } - private static void handleError(String message) { + /** + * error handling over the logger + * + * @param message + * is a string and you message for problem + */ + public static void handleError(String message) { logger.error(message); System.exit(0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-21 21:13:38
|
Revision: 621 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=621&view=rev Author: tonytacker Date: 2008-02-21 13:13:33 -0800 (Thu, 21 Feb 2008) Log Message: ----------- using startCLI to load a config file Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-21 21:13:33 UTC (rev 621) @@ -21,22 +21,41 @@ */ import java.io.File; // import java.net.URL; -// import java.util.List; +import java.net.URL; // import java.util.HashSet; +import java.util.Map; // import java.util.Set; +import java.util.SortedSet; // import java.util.List; // import java.util.Map; +import org.dllearner.algorithms.BruteForceLearner; +import org.dllearner.algorithms.RandomGuesser; +import org.dllearner.algorithms.gp.GP; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.algorithms.refinement.ROLearner; import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; // import -// org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasonerComponent; // org.dllearner.core.LearningProblem; // import org.dllearner.core.ReasoningService; // import org.dllearner.core.LearningAlgorithm; // import org.dllearner.core.ReasonerComponent; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.InvalidConfigOptionValueException; -import org.dllearner.core.config.StringConfigOption; +// import org.dllearner.core.config.ConfigEntry; +// import org.dllearner.core.config.InvalidConfigOptionValueException; +// import org.dllearner.core.config.StringConfigOption; +import org.dllearner.learningproblems.PosNegDefinitionLP; +import org.dllearner.learningproblems.PosNegInclusionLP; +import org.dllearner.learningproblems.PosOnlyDefinitionLP; import org.dllearner.parser.ConfParser; -import org.dllearner.kb.KBFile; -import org.dllearner.kb.OWLFile; -import org.dllearner.kb.sparql.SparqlKnowledgeSource; -import org.dllearner.core.Component; +import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.reasoning.FastRetrievalReasoner; +import org.dllearner.reasoning.OWLAPIReasoner; // import +// org.dllearner.kb.KBFile; +// import org.dllearner.kb.OWLFile; +// import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.core.Component; // import +// org.dllearner.cli.ConfFileOption; +import org.dllearner.cli.ConfFileOption; +import org.dllearner.cli.Start; /** * Open a config file. @@ -49,8 +68,10 @@ private Config config; private StartGUI startGUI; - private Class<? extends KnowledgeSource> componentOption; + // private Start cli; + // private Class<? extends KnowledgeSource> componentOption; + /** * set config and startGUI * @@ -79,63 +100,146 @@ public void startParser() { if (this.file.exists()) { ConfParser parser = ConfParser.parseFile(file); + // create a mapping between components and prefixes in the conf file + Map<Class<? extends Component>, String> componentPrefixMapping = Start + .createComponentPrefixMapping(); + // KNOWLEDGE SOURCE - // filename - String value = parser.getFunctionCalls().get("import").get(0).get(0); - // only first of imported files - if (value.endsWith(".kb")) { - componentOption = KBFile.class; - } else if (value.endsWith(".owl")) { - componentOption = OWLFile.class; - } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { - if (parser.getFunctionCalls().get("import").get(0).get(1) - .equalsIgnoreCase("sparql")) { - System.out.println("IT IS SPARQL"); - componentOption = SparqlKnowledgeSource.class; + Map<URL, Class<? extends KnowledgeSource>> importedFiles = Start.getImportedFiles( + parser, file.getParentFile().getPath()); + for (Map.Entry<URL, Class<? extends KnowledgeSource>> entry : importedFiles.entrySet()) { + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + entry.getValue())); + config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", + entry.getKey().toString()); + // sources.add(ks); + // TODO more then 1 KnowledgeSource + config.setKnowledgeSource(config.getKnowledgeSource()); + Start.configureComponent(config.getComponentManager(), config.getKnowledgeSource(), + componentPrefixMapping, parser); + // init + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + } catch (ComponentInitException e) { + e.printStackTrace(); + } } } - // check if class was set and set knwoledgeSource - if (componentOption != null) - config.setKnowledgeSource(config.getComponentManager().knowledgeSource( - componentOption)); - // set url - value = makeURL(value); - Component component = config.getKnowledgeSource(); - StringConfigOption specialOption = (StringConfigOption) config.getComponentManager() - .getConfigOption(componentOption, "url"); - try { - ConfigEntry<String> specialEntry = new ConfigEntry<String>(specialOption, value); - config.getComponentManager().applyConfigEntry(component, specialEntry); - System.out.println("set String: " + "url" + " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); + + // REASONER + ConfFileOption reasonerOption = parser.getConfOptionsByName("reasoner"); + Class<? extends ReasonerComponent> reasonerClass = null; + // default value + if (reasonerOption == null || reasonerOption.getStringValue().equals("dig")) + reasonerClass = DIGReasoner.class; + else if (reasonerOption.getStringValue().equals("owlAPI")) + reasonerClass = OWLAPIReasoner.class; + else if (reasonerOption.getStringValue().equals("fastRetrieval")) + reasonerClass = FastRetrievalReasoner.class; + else { + Start.handleError("Unknown value " + reasonerOption.getStringValue() + + " for option \"reasoner\"."); } - // widgets - - - // startGUI.updateTabColors(); - // init - if (config.getKnowledgeSource() != null && config.isSetURL()) { + config.setReasoner(config.getComponentManager().reasoner(reasonerClass, + config.getKnowledgeSource())); + Start.configureComponent(config.getComponentManager(), config.getReasoner(), + componentPrefixMapping, parser); + if (config.getKnowledgeSource() != null && config.getReasoner() != null) { try { - config.getKnowledgeSource().init(); - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); + config.getReasoner().init(); + System.out.println("init Reasoner"); + // set ReasoningService + config.setReasoningService(config.getComponentManager().reasoningService( + config.getReasoner())); + System.out.println("init ReasoningService"); + config.setInitReasoner(true); + startGUI.updateTabColors(); } catch (ComponentInitException e) { e.printStackTrace(); } } - // update + // LEARNING PROBLEM + ConfFileOption problemOption = parser.getConfOptionsByName("problem"); + Class<? extends LearningProblem> lpClass = null; + if (problemOption == null || problemOption.getStringValue().equals("posNegDefinition")) + lpClass = PosNegDefinitionLP.class; + else if (problemOption.getStringValue().equals("posNegInclusion")) + lpClass = PosNegInclusionLP.class; + else if (problemOption.getStringValue().equals("posOnlyDefinition")) + lpClass = PosOnlyDefinitionLP.class; + else + Start.handleError("Unknown value " + problemOption.getValue() + + " for option \"problem\"."); + config.setLearningProblem(config.getComponentManager().learningProblem(lpClass, + config.getReasoningService())); + SortedSet<String> posExamples = parser.getPositiveExamples(); + SortedSet<String> negExamples = parser.getNegativeExamples(); + config.getComponentManager().applyConfigEntry(config.getLearningProblem(), + "positiveExamples", posExamples); + if (lpClass != PosOnlyDefinitionLP.class) + config.getComponentManager().applyConfigEntry(config.getLearningProblem(), + "negativeExamples", negExamples); + Start.configureComponent(config.getComponentManager(), config.getLearningProblem(), + componentPrefixMapping, parser); + if (config.getReasoner() != null && config.getLearningProblem() != null) { + try { + config.getLearningProblem().init(); + config.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + + // LEARNING ALGORITHM + ConfFileOption algorithmOption = parser.getConfOptionsByName("algorithm"); + Class<? extends LearningAlgorithm> laClass = null; + if (algorithmOption == null || algorithmOption.getStringValue().equals("refinement")) + laClass = ROLearner.class; + else if(algorithmOption.getStringValue().equals("refexamples")) + laClass = ExampleBasedROLComponent.class; + else if(algorithmOption.getStringValue().equals("gp")) + laClass = GP.class; + else if(algorithmOption.getStringValue().equals("bruteForce")) + laClass = BruteForceLearner.class; + else if(algorithmOption.getStringValue().equals("randomGuesser")) + laClass = RandomGuesser.class; + else + Start.handleError("Unknown value in " + algorithmOption); + + if (config.getLearningProblem() != null && config.getReasoningService() != null) { + try { + config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm( + laClass, config.getLearningProblem(), + config.getReasoningService())); + } catch (LearningProblemUnsupportedException e) { + e.printStackTrace(); + } + } + Start.configureComponent(config.getComponentManager(), config.getLearningAlgorithm(), componentPrefixMapping, parser); + if (config.getLearningProblem() != null) { + try { + config.getLearningAlgorithm().init(); + config.setInitLearningAlgorithm(true); + System.out.println("init LearningAlgorithm"); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + + // update graphic startGUI.updateTabColors(); - System.out.println("reasoner: " + parser.getConfOptionsByName("reasoner")); - System.out.println("confoptions: " + parser.getConfOptions()); - System.out.println("posExamples: " + parser.getPositiveExamples()); - System.out.println("confoptionbyname: " + parser.getConfOptionsByName()); + //System.out.println("reasoner: " + parser.getConfOptionsByName("reasoner")); + //System.out.println("confoptions: " + parser.getConfOptions()); + //System.out.println("posExamples: " + parser.getPositiveExamples()); + //System.out.println("confoptionbyname: " + parser.getConfOptionsByName()); - // do it - // only url from first entry, ignore others - // parser.getFunctionCalls().get("import").get(0); } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-21 21:13:33 UTC (rev 621) @@ -43,7 +43,7 @@ private Config config; private StartGUI startGUI; - private List<Class<? extends LearningAlgorithm>> learners; + private List<Class<? extends LearningAlgorithm>> learner; private JPanel choosePanel = new JPanel(); private OptionPanel optionPanel; private JPanel initPanel = new JPanel(); @@ -57,7 +57,7 @@ this.config = config; this.startGUI = startGUI; - learners = config.getComponentManager().getLearningAlgorithms(); + learner = config.getComponentManager().getLearningAlgorithms(); initButton = new JButton("Init LearingAlgorithm"); initButton.addActionListener(this); @@ -67,8 +67,8 @@ autoInitButton.addActionListener(this); // add into comboBox - for (int i = 0; i < learners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); + for (int i = 0; i < learner.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(learner.get(i))); } choosePanel.add(cb); @@ -76,7 +76,7 @@ cb.addActionListener(this); optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), config - .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); + .getOldLearningAlgorithm(), learner.get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); @@ -108,7 +108,7 @@ if (config.getLearningProblem() != null && config.getReasoningService() != null) { try { config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm( - learners.get(choosenClassIndex), config.getLearningProblem(), + learner.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); updateOptionPanel(); } catch (LearningProblemUnsupportedException e) { @@ -126,7 +126,6 @@ try { config.getLearningAlgorithm().init(); } catch (ComponentInitException e) { - // TODO Auto-generated catch block e.printStackTrace(); } config.setInitLearningAlgorithm(true); @@ -136,12 +135,34 @@ } /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } + + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getLearningAlgorithm() != null) + for (int i = 0; i < learner.size(); i++) + if (config.getLearningAlgorithm().getClass().equals( + config.getComponentManager().getLearningAlgorithms().get(i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + + /** * update OptionPanel with new selection */ public void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningAlgorithm(), config.getOldLearningAlgorithm(), - learners.get(choosenClassIndex)); + optionPanel.update(config.getLearningAlgorithm(), config.getOldLearningAlgorithm(), learner + .get(choosenClassIndex)); } /** Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-21 21:13:33 UTC (rev 621) @@ -42,7 +42,7 @@ private Config config; private StartGUI startGUI; - private List<Class<? extends LearningProblem>> problems; + private List<Class<? extends LearningProblem>> problem; private String[] lpBoxItems = {}; private JComboBox cb = new JComboBox(lpBoxItems); private JPanel choosePanel = new JPanel(); @@ -56,7 +56,7 @@ this.config = config; this.startGUI = startGUI; - problems = config.getComponentManager().getLearningProblems(); + problem = config.getComponentManager().getLearningProblems(); initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); @@ -69,15 +69,15 @@ cb.addActionListener(this); // add into comboBox - for (int i = 0; i < problems.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName(problems.get(i))); + for (int i = 0; i < problem.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(problem.get(i))); } // read choosen LearningProblem choosenClassIndex = cb.getSelectedIndex(); optionPanel = new OptionPanel(config, config.getLearningProblem(), config - .getOldLearningProblem(), problems.get(choosenClassIndex)); + .getOldLearningProblem(), problem.get(choosenClassIndex)); add(choosePanel, BorderLayout.PAGE_START); add(optionPanel, BorderLayout.CENTER); @@ -109,7 +109,7 @@ private void setLearningProblem() { if (config.isInitReasoner()) { config.setLearningProblem(config.getComponentManager().learningProblem( - problems.get(choosenClassIndex), config.getReasoningService())); + problem.get(choosenClassIndex), config.getReasoningService())); startGUI.updateTabColors(); updateOptionPanel(); } @@ -133,11 +133,33 @@ } /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } + + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getLearningProblem() != null) + for (int i = 0; i < problem.size(); i++) + if (config.getLearningProblem().getClass().equals( + config.getComponentManager().getLearningProblems().get(i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + + /** * update OptionPanel with new selection */ private void updateOptionPanel() { // update OptionPanel - optionPanel.update(config.getLearningProblem(), config.getOldLearningProblem(), problems + optionPanel.update(config.getLearningProblem(), config.getOldLearningProblem(), problem .get(choosenClassIndex)); } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-21 21:13:33 UTC (rev 621) @@ -43,7 +43,7 @@ private Config config; private StartGUI startGUI; - private List<Class<? extends ReasonerComponent>> reasoners; + private List<Class<? extends ReasonerComponent>> reasoner; private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); private OptionPanel optionPanel; @@ -57,7 +57,7 @@ this.config = config; this.startGUI = startGUI; - reasoners = config.getComponentManager().getReasonerComponents(); + reasoner = config.getComponentManager().getReasonerComponents(); initButton = new JButton("Init Reasoner"); initButton.addActionListener(this); @@ -69,12 +69,12 @@ choosePanel.add(cb); // add into comboBox - for (int i = 0; i < reasoners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName(reasoners.get(i))); + for (int i = 0; i < reasoner.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(reasoner.get(i))); } optionPanel = new OptionPanel(config, config.getReasoner(), config.getOldReasonerSet(), - reasoners.get(choosenClassIndex)); + reasoner.get(choosenClassIndex)); choosePanel.add(setButton); cb.addActionListener(this); @@ -112,7 +112,7 @@ public void setReasoner() { if (config.isInitKnowledgeSource()) { config.setReasoner(config.getComponentManager().reasoner( - reasoners.get(choosenClassIndex), config.getKnowledgeSource())); + reasoner.get(choosenClassIndex), config.getKnowledgeSource())); updateOptionPanel(); startGUI.updateTabColors(); config.setInitReasoner(false); @@ -143,10 +143,32 @@ } /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } + + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getReasoner() != null) + for (int i = 0; i < reasoner.size(); i++) + if (config.getKnowledgeSource().getClass().equals( + config.getComponentManager().getKnowledgeSources().get(i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + + /** * update OptionPanel with new selection */ public void updateOptionPanel() { - optionPanel.update(config.getReasoner(), config.getOldReasonerSet(), reasoners + optionPanel.update(config.getReasoner(), config.getOldReasonerSet(), reasoner .get(choosenClassIndex)); } Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-21 16:25:48 UTC (rev 620) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-21 21:13:33 UTC (rev 621) @@ -169,9 +169,9 @@ tabPane.setForegroundAt(4, Color.RED); } tab0.updateAll(); - tab1.updateInitButtonColor(); - tab2.updateInitButtonColor(); - tab3.updateInitButtonColor(); + tab1.updateAll(); + tab2.updateAll(); + tab3.updateAll(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-21 16:25:57
|
Revision: 620 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=620&view=rev Author: jenslehmann Date: 2008-02-21 08:25:48 -0800 (Thu, 21 Feb 2008) Log Message: ----------- instance check code preparation Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/FlatABox.java trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/utilities/Helper.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/FlatABox.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/FlatABox.java 2008-02-21 16:21:05 UTC (rev 619) +++ trunk/src/dl-learner/org/dllearner/core/owl/FlatABox.java 2008-02-21 16:25:48 UTC (rev 620) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.core.owl; import java.util.HashMap; @@ -6,28 +25,18 @@ import java.util.TreeSet; /** - * TODO: Später mal eine Singleton-Klasse daraus machen und get-und set-Methoden - * für alle Klassenvariablen. - * TODO: Diese Klasse soll später mal alles geparstes DL-Wissen enthalten. Es muss - * also irgendwie die "geparste ABox" (für eigenen Algorithmus) und das unveränderte - * Wissen enthalten (für KAON2). Eventuell ist auch eine Trennung in 2 Klassen möglich. + * A flat ABox can be used to store knowledge of a completely dematerialised knowledge base. * - * TODO: Singleton wieder rueckgaengig machen, da FlatABox nur noch - * Mittel zum Zweck fuer die neue abstrakte Reasoner-Klasse ist - * * @author Jens Lehmann * */ public class FlatABox { - - // singleton-instance - // private static FlatABox singleton = new FlatABox(); public SortedSet<String> roles = new TreeSet<String>(); public SortedSet<String> concepts = new TreeSet<String>(); public SortedSet<String> domain = new TreeSet<String>(); public SortedSet<String> top = new TreeSet<String>(); - public SortedSet<String> bottom = new TreeSet<String>(); + public SortedSet<String> bottom = new TreeSet<String>(); public Map<String,SortedSet<String>> atomicConceptsPos = new HashMap<String,SortedSet<String>>(); public Map<String,SortedSet<String>> atomicConceptsNeg = new HashMap<String,SortedSet<String>>(); @@ -37,29 +46,10 @@ public Map<String,SortedSet<String>> exampleConceptsPos = new HashMap<String,SortedSet<String>>(); public Map<String,SortedSet<String>> exampleConceptsNeg = new HashMap<String,SortedSet<String>>(); - // f�r bessere GP-Initialisierungs-Performance - private Object[] roleArray; - private Object[] conceptArray; - public FlatABox() { } - /* - public static FlatABox getInstance() { - return singleton; - } - */ - - // ABox vorbereiten f�r Algorithmus, hier wird nur eine Listenansicht auf - // Konzepte und Rollen erstellt, damit diese bei der GP-Initialisierung - // verwendet werden kann (es ist ansonsten nicht m�glich auf ein zuf�lliges - // Konzept zuzugreifen) - public void prepare() { - roleArray = roles.toArray(); - conceptArray = concepts.toArray(); - } - public SortedSet<String> getPositiveInstances(String conceptName) { return atomicConceptsPos.get(conceptName); } @@ -68,14 +58,6 @@ return atomicConceptsPos.get(conceptName); } - public String getConcept(int nr) { - return (String) conceptArray[nr]; - } - - public String getRole(int nr) { - return (String) roleArray[nr]; - } - @Override public String toString() { String output = ""; @@ -95,42 +77,41 @@ return (String) exampleConceptsPos.keySet().toArray()[0]; } - /* - public void createExampleABox() { - domain = new TreeSet<String>(); - domain.add("stefan"); - domain.add("markus"); - - top = domain; - bottom = new TreeSet<String>(); - - atomicConceptsPos = new HashMap<String,Set<String>>(); - Set<String> male = new TreeSet<String>(); - male.add("stefan"); - male.add("markus"); - atomicConceptsPos.put("male",male); - - atomicConceptsNeg = new HashMap<String,Set<String>>(); - Set<String> maleNeg = new TreeSet<String>(); - atomicConceptsNeg.put("male",maleNeg); - - rolesPos = new HashMap<String,Map<String,Set<String>>>(); - Map<String,Set<String>> hasChild = new HashMap<String,Set<String>>(); - Set<String> childsStefan = new TreeSet<String>(); - childsStefan.add("markus"); - hasChild.put("stefan",childsStefan); - Set<String> childsMarkus = new TreeSet<String>(); - hasChild.put("markus", childsMarkus); - rolesPos.put("hasChild", hasChild); - - rolesNeg = new HashMap<String,Map<String,Set<String>>>(); - Map<String,Set<String>> hasChildNeg = new HashMap<String,Set<String>>(); - Set<String> childsStefanNeg = new TreeSet<String>(); - hasChildNeg.put("stefan",childsStefanNeg); - Set<String> childsMarkusNeg = new TreeSet<String>(); - hasChildNeg.put("markus", childsMarkusNeg); - rolesNeg.put("hasChild", hasChildNeg); - } - */ +// public void createExampleABox() { +// domain = new TreeSet<String>(); +// domain.add("stefan"); +// domain.add("markus"); +// +// top = domain; +// bottom = new TreeSet<String>(); +// +// atomicConceptsPos = new HashMap<String,Set<String>>(); +// Set<String> male = new TreeSet<String>(); +// male.add("stefan"); +// male.add("markus"); +// atomicConceptsPos.put("male",male); +// +// atomicConceptsNeg = new HashMap<String,Set<String>>(); +// Set<String> maleNeg = new TreeSet<String>(); +// atomicConceptsNeg.put("male",maleNeg); +// +// rolesPos = new HashMap<String,Map<String,Set<String>>>(); +// Map<String,Set<String>> hasChild = new HashMap<String,Set<String>>(); +// Set<String> childsStefan = new TreeSet<String>(); +// childsStefan.add("markus"); +// hasChild.put("stefan",childsStefan); +// Set<String> childsMarkus = new TreeSet<String>(); +// hasChild.put("markus", childsMarkus); +// rolesPos.put("hasChild", hasChild); +// +// rolesNeg = new HashMap<String,Map<String,Set<String>>>(); +// Map<String,Set<String>> hasChildNeg = new HashMap<String,Set<String>>(); +// Set<String> childsStefanNeg = new TreeSet<String>(); +// hasChildNeg.put("stefan",childsStefanNeg); +// Set<String> childsMarkusNeg = new TreeSet<String>(); +// hasChildNeg.put("markus", childsMarkusNeg); +// rolesNeg.put("hasChild", hasChildNeg); +// } + } Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-21 16:21:05 UTC (rev 619) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-21 16:25:48 UTC (rev 620) @@ -19,23 +19,90 @@ */ package org.dllearner.reasoning; +import java.util.HashMap; +import java.util.Map; import java.util.Set; import java.util.SortedSet; import org.dllearner.core.ComponentInitException; +import org.dllearner.core.KnowledgeSource; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningService; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.owl.FlatABox; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; /** + * Reasoner for fast instance checks. It works by completely dematerialising the knowledge + * base to speed up later reasoning requests. It + * * @author Jens Lehmann * */ public class FastInstanceChecker extends ReasonerComponent { + private Set<NamedClass> atomicConcepts; + private Set<ObjectProperty> atomicRoles; + private SortedSet<Individual> individuals; + + private ReasoningService rs; + private ReasonerComponent rc; + + // instances of classes + public Map<NamedClass,SortedSet<Individual>> classInstancesPos = new HashMap<NamedClass,SortedSet<Individual>>(); + public Map<NamedClass,SortedSet<Individual>> classInstancesNeg = new HashMap<NamedClass,SortedSet<Individual>>(); + + // object property mappings + public Map<ObjectProperty,Map<Individual,SortedSet<Individual>>> opPos = new HashMap<ObjectProperty,Map<Individual,SortedSet<Individual>>>(); + public Map<ObjectProperty,Map<Individual,SortedSet<Individual>>> opNeg = new HashMap<ObjectProperty,Map<Individual,SortedSet<Individual>>>(); + + // TODO: datatype properties + + public FastInstanceChecker(Set<KnowledgeSource> sources) { + rc = new OWLAPIReasoner(sources); + try { + rc.init(); + } catch (ComponentInitException e1) { + e1.printStackTrace(); + } + atomicConcepts = rc.getAtomicConcepts(); + atomicRoles = rc.getAtomicRoles(); + individuals = rc.getIndividuals(); + rs = new ReasoningService(rc); + + // TODO: some code taken from Helper.createFlatABox, but pasted here because additional things need to + // be done (maybe this can be merge again with the FastRetrievalReasoner later) + long dematStartTime = System.currentTimeMillis(); + + FlatABox aBox = new FlatABox(); + for (NamedClass atomicConcept : rs.getAtomicConcepts()) { + // aBox.atomicConceptsPos.put(atomicConcept.getName(), getStringSet(rs + // .retrieval(atomicConcept))); +// Negation negatedAtomicConcept = new Negation(atomicConcept); + // aBox.atomicConceptsNeg.put(atomicConcept.getName(), getStringSet(rs + // .retrieval(negatedAtomicConcept))); + aBox.concepts.add(atomicConcept.getName()); + } + + for (ObjectProperty atomicRole : rs.getAtomicRoles()) { + // aBox.rolesPos.put(atomicRole.getName(), getStringMap(rs.getRoleMembers(atomicRole))); + aBox.roles.add(atomicRole.getName()); + } + + // aBox.domain = getStringSet(rs.getIndividuals()); + // aBox.top = aBox.domain; + + // System.out.println(aBox); + + long dematDuration = System.currentTimeMillis() - dematStartTime; + System.out.println("OK (" + dematDuration + " ms)"); + + } + + /* (non-Javadoc) * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.config.ConfigEntry) */ @@ -58,24 +125,21 @@ * @see org.dllearner.core.Reasoner#getAtomicConcepts() */ public Set<NamedClass> getAtomicConcepts() { - // TODO Auto-generated method stub - return null; + return atomicConcepts; } /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getAtomicRoles() */ public Set<ObjectProperty> getAtomicRoles() { - // TODO Auto-generated method stub - return null; + return atomicRoles; } /* (non-Javadoc) * @see org.dllearner.core.Reasoner#getIndividuals() */ public SortedSet<Individual> getIndividuals() { - // TODO Auto-generated method stub - return null; + return individuals; } /* (non-Javadoc) Modified: trunk/src/dl-learner/org/dllearner/utilities/Helper.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2008-02-21 16:21:05 UTC (rev 619) +++ trunk/src/dl-learner/org/dllearner/utilities/Helper.java 2008-02-21 16:25:48 UTC (rev 620) @@ -539,8 +539,6 @@ aBox.domain = getStringSet(rs.getIndividuals()); aBox.top = aBox.domain; - // ab hier keine �nderungen mehr an FlatABox - aBox.prepare(); // System.out.println(aBox); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-21 16:21:16
|
Revision: 619 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=619&view=rev Author: tonytacker Date: 2008-02-21 08:21:05 -0800 (Thu, 21 Feb 2008) Log Message: ----------- fixed bug on loading *.kb file Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-21 15:42:21 UTC (rev 618) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-21 16:21:05 UTC (rev 619) @@ -64,9 +64,8 @@ * @return true, if url was set otherwise false */ public Boolean isSetURL() { - // return this.isURL; - // String value = (String) cm.getConfigOptionValue(source, "url"); - if (cm.getConfigOptionValue(source, "url") != null) + if (cm.getConfigOptionValue(source, "url") != null + || cm.getConfigOptionValue(source, "filename") != null) return true; else return false; Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-21 15:42:21 UTC (rev 618) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-21 16:21:05 UTC (rev 619) @@ -94,12 +94,11 @@ componentOption = SparqlKnowledgeSource.class; } } - // check if class was set + // check if class was set and set knwoledgeSource if (componentOption != null) config.setKnowledgeSource(config.getComponentManager().knowledgeSource( componentOption)); // set url - // value = parser.getFunctionCalls().get("import").get(0).get(0); value = makeURL(value); Component component = config.getKnowledgeSource(); StringConfigOption specialOption = (StringConfigOption) config.getComponentManager() @@ -111,6 +110,9 @@ } catch (InvalidConfigOptionValueException s) { s.printStackTrace(); } + // widgets + + // startGUI.updateTabColors(); // init if (config.getKnowledgeSource() != null && config.isSetURL()) { Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-21 15:42:21 UTC (rev 618) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-21 16:21:05 UTC (rev 619) @@ -61,8 +61,6 @@ this.startGUI = startGUI; sources = config.getComponentManager().getKnowledgeSources(); - System.out.println("SOURCES: " + sources); - setButton = new JButton("Set"); setButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); @@ -87,7 +85,7 @@ add(optionPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); - // setSource(); + setSource(); updateAll(); } @@ -112,17 +110,8 @@ * after this, you can change widgets */ public void setSource() { - System.out.println("cm: " + config.getComponentManager()); - System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); - config.setKnowledgeSource(config.getComponentManager().knowledgeSource( sources.get(choosenClassIndex))); - // KBFile.class doesn't work - // config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); - - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out.println("ABC: " + config.getComponentManager().getComponentName(sources.get(0))); - config.setInitKnowledgeSource(false); updateAll(); } @@ -131,8 +120,6 @@ * after this, next tab can be used */ public void init() { - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out.println("isSetURL: " + config.isSetURL()); if (config.getKnowledgeSource() != null && config.isSetURL()) { try { config.getKnowledgeSource().init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-21 15:42:27
|
Revision: 618 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=618&view=rev Author: jenslehmann Date: 2008-02-21 07:42:21 -0800 (Thu, 21 Feb 2008) Log Message: ----------- fix for positive only learning Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java 2008-02-20 12:58:55 UTC (rev 617) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosOnlyDefinitionLP.java 2008-02-21 15:42:21 UTC (rev 618) @@ -19,12 +19,9 @@ */ package org.dllearner.learningproblems; -import java.util.SortedSet; - import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; import org.dllearner.core.owl.Description; -import org.dllearner.core.owl.Individual; import org.dllearner.utilities.Helper; /** @@ -34,9 +31,6 @@ * */ public class PosOnlyDefinitionLP extends PosOnlyLP implements DefinitionLP { - - protected SortedSet<Individual> positiveExamples; - protected SortedSet<Individual> pseudoNegatives; private PosNegDefinitionLP definitionLP; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-20 12:58:58
|
Revision: 617 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=617&view=rev Author: jenslehmann Date: 2008-02-20 04:58:55 -0800 (Wed, 20 Feb 2008) Log Message: ----------- added PHP example of how to use the web service for threaded learning Added Paths: ----------- trunk/src/php-examples/LearningThreaded.php Added: trunk/src/php-examples/LearningThreaded.php =================================================================== --- trunk/src/php-examples/LearningThreaded.php (rev 0) +++ trunk/src/php-examples/LearningThreaded.php 2008-02-20 12:58:55 UTC (rev 617) @@ -0,0 +1,104 @@ +<?php +/** + * 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/>. + * + */ + + /** + * Small example showing how to use DL-Learner for learning + * a class definition using a separate learning thread. + * + * @author Jens Lehmann + */ + +include('Utilities.php'); + +// load WSDL files (has to be done due to a Java web service bug) +ini_set("soap.wsdl_cache_enabled","0"); +$wsdluri="http://localhost:8181/services?wsdl"; +Utilities::loadWSDLfiles($wsdluri); + +// specifiy ontology +$ontology = 'file:'.realpath("../../examples/family/uncle.owl"); + +// create DL-Learner client +$client = new SoapClient("main.wsdl"); + +// load owl file in DIG reasoner (you need a running DIG reasoner) +$id = $client->generateID(); +$ksID = $client->addKnowledgeSource($id, "owlfile", $ontology); +$rID = $client->setReasoner($id, "dig"); + +// create a learning problem +$posExamples = array( + 'http://localhost/foo#heinrich', + 'http://localhost/foo#alfred', + 'http://localhost/foo#heinz', + 'http://localhost/foo#hans', + 'http://localhost/foo#alex'); +$negExamples = array( + 'http://localhost/foo#jan', + 'http://localhost/foo#markus', + 'http://localhost/foo#susi', + 'http://localhost/foo#anna', + 'http://localhost/foo#maria', + 'http://localhost/foo#katrin', + 'http://localhost/foo#johanna', + 'http://localhost/foo#mandy', + 'http://localhost/foo#miriam', + 'http://localhost/foo#hanna'); +$client->setLearningProblem($id, "posNegDefinition"); +$client->setPositiveExamples($id, $posExamples); +$client->setNegativeExamples($id, $negExamples); + +// choose refinement operator approach +$client->setLearningAlgorithm($id, "refinement"); + +$client->initAll($id); + +// start learning process in DL-Learner +$client->learnThreaded($id); + +$sleeptime = 2; +$seconds = 0; + +do { + // sleep a while + sleep($sleeptime); + + // see what we have learned so far + $concept=$client->getCurrentlyBestConcept($id); + $running=$client->isAlgorithmRunning($id); + + $seconds += $sleeptime; + if($seconds == 10) + $sleeptime = 5; + + echo 'result after '.$seconds.' seconds: '.$concept.'<br />'; + flush(); + +} while($running); + +// print best concepts found (not all of are +// necessarily perfect solutions) +echo '<br />Algorithm finished. Best concepts: '; +echo '<pre>'; +print_r($client->getCurrentlyBestConcepts($id, 10)); +echo '</pre>'; + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-20 10:35:31
|
Revision: 616 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=616&view=rev Author: jenslehmann Date: 2008-02-20 02:35:28 -0800 (Wed, 20 Feb 2008) Log Message: ----------- added web service learning example for Maria Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Added Paths: ----------- trunk/src/php-examples/LearningSimple.php Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-02-19 18:28:23 UTC (rev 615) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-02-20 10:35:28 UTC (rev 616) @@ -100,8 +100,8 @@ learningProblemMapping.put("posOnlyDefinition", PosOnlyDefinitionLP.class); learningAlgorithmMapping.put("random", RandomGuesser.class); learningAlgorithmMapping.put("bruteForce", BruteForceLearner.class); - learningAlgorithmMapping.put("genetic", ROLearner.class); - learningAlgorithmMapping.put("refinement", GP.class); + learningAlgorithmMapping.put("gp", GP.class); + learningAlgorithmMapping.put("refinement", ROLearner.class); learningAlgorithmMapping.put("refexamples", ExampleBasedROLComponent.class); components = Helper.union(knowledgeSourceMapping.keySet(),reasonerMapping.keySet()); components = Helper.union(components, learningProblemMapping.keySet()); Added: trunk/src/php-examples/LearningSimple.php =================================================================== --- trunk/src/php-examples/LearningSimple.php (rev 0) +++ trunk/src/php-examples/LearningSimple.php 2008-02-20 10:35:28 UTC (rev 616) @@ -0,0 +1,68 @@ +<?php +/** + * 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/>. + * + */ + + /** + * Small example showing how to use DL-Learner for learning class definitions. + * + * @author Jens Lehmann + */ + +include('Utilities.php'); + +// load WSDL files (has to be done due to a Java web service bug) +ini_set("soap.wsdl_cache_enabled","0"); +$wsdluri="http://localhost:8181/services?wsdl"; +Utilities::loadWSDLfiles($wsdluri); + +// specifiy ontology +$ontology = 'file:'.realpath("../../examples/family/father.owl"); + +// create DL-Learner client +$client = new SoapClient("main.wsdl"); + +// load owl file in DIG reasoner (you need a running DIG reasoner) +$id = $client->generateID(); +$ksID = $client->addKnowledgeSource($id, "owlfile", $ontology); +$rID = $client->setReasoner($id, "dig"); + +// create a learning problem +$posExamples = array('http://example.com/father#stefan', + 'http://example.com/father#markus', + 'http://example.com/father#martin'); +$negExamples = array('http://example.com/father#heinz', + 'http://example.com/father#anna', + 'http://example.com/father#michelle'); +$client->setLearningProblem($id, "posNegDefinition"); +$client->setPositiveExamples($id, $posExamples); +$client->setNegativeExamples($id, $negExamples); + +// choose refinement operator approach +$client->setLearningAlgorithm($id, "refinement"); + +$client->initAll($id); + +// learn concept +echo 'start learning ... '; +$concept = $client->learn($id); +echo 'OK <br />'; +echo 'solution: ' . $concept; + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-19 18:28:34
|
Revision: 615 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=615&view=rev Author: jenslehmann Date: 2008-02-19 10:28:23 -0800 (Tue, 19 Feb 2008) Log Message: ----------- extended KBparser to be able to read object/datatype property domain/range Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/KB.java trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/parser/KBParser.java trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java trunk/src/dl-learner/org/dllearner/parser/kb.jj trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/KB.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/KB.java 2008-02-19 16:44:57 UTC (rev 614) +++ trunk/src/dl-learner/org/dllearner/core/owl/KB.java 2008-02-19 18:28:23 UTC (rev 615) @@ -165,6 +165,19 @@ rbox.add(axiom); } + /** + * Add another knowledge base to this one. + * @param kb The knowledge base to add. + */ + public void addKB(KB kb) { + for(AssertionalAxiom axiom : kb.getAbox()) + abox.add(axiom); + for(PropertyAxiom axiom : kb.getRbox()) + rbox.add(axiom); + for(TerminologicalAxiom axiom : kb.getTbox()) + tbox.add(axiom); + } + public int getLength() { int length = 0; for(Axiom a : abox) Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-19 16:44:57 UTC (rev 614) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-19 18:28:23 UTC (rev 615) @@ -42,6 +42,7 @@ import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.ObjectPropertyAssertion; import org.dllearner.core.owl.SubClassAxiom; +import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.parser.PrologParser; import org.dllearner.prolog.Atom; @@ -139,7 +140,9 @@ kb.addAxiom(sc); } // define properties including domain and range - // ... TODO ... + String kbString = "DPDOMAIN(" + getURI2("charge") + ") = " + getURI2("Atom") + "."; + KB kb2 = KBParser.parseKBFile(kbString); + kb.addKB(kb2); // mapping clauses to axioms System.out.print("Mapping clauses to axioms ... "); @@ -332,6 +335,15 @@ return new NamedClass(ontologyURI + "#" + name); } + private static String getURI(String name) { + return ontologyURI + "#" + name; + } + + // returns URI including quotationsmark (need for KBparser) + private static String getURI2(String name) { + return "\"" + getURI(name) + "\""; + } + private static String getFullElementName(String abbreviation) { // return corresponding element or throw an error if it // is not in the list Modified: trunk/src/dl-learner/org/dllearner/parser/KBParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-19 16:44:57 UTC (rev 614) +++ trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-19 18:28:23 UTC (rev 615) @@ -63,6 +63,11 @@ case 30: case 31: case 32: + case 34: + case 35: + case 36: + case 37: + case 38: ; break; default: @@ -97,6 +102,17 @@ rBoxAxiom = Subrole(); kb.addRBoxAxiom(rBoxAxiom); break; + case 34: + case 35: + case 36: + rBoxAxiom = ObjectPropertyDomainAxiom(); + kb.addRBoxAxiom(rBoxAxiom); + break; + case 37: + case 38: + rBoxAxiom = DatatypePropertyDomainAxiom(); + kb.addRBoxAxiom(rBoxAxiom); + break; default: jj_la1[1] = jj_gen; if (jj_2_3(2147483647)) { @@ -248,6 +264,125 @@ throw new Error("Missing return statement in function"); } + final public ObjectPropertyDomainAxiom ObjectPropertyDomainAxiom() throws ParseException { + ObjectProperty op; Description domain; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 34: + jj_consume_token(34); + break; + case 35: + jj_consume_token(35); + break; + case 36: + jj_consume_token(36); + break; + default: + jj_la1[4] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(22); + op = ObjectProperty(); + jj_consume_token(23); + jj_consume_token(25); + domain = Concept(); + jj_consume_token(COMMAND_END); + {if (true) return new ObjectPropertyDomainAxiom(op, domain);} + throw new Error("Missing return statement in function"); + } + + final public DatatypePropertyDomainAxiom DatatypePropertyDomainAxiom() throws ParseException { + DatatypeProperty op; Description domain; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 37: + jj_consume_token(37); + break; + case 38: + jj_consume_token(38); + break; + default: + jj_la1[5] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(22); + op = DatatypeProperty(); + jj_consume_token(23); + jj_consume_token(25); + domain = Concept(); + jj_consume_token(COMMAND_END); + {if (true) return new DatatypePropertyDomainAxiom(op, domain);} + throw new Error("Missing return statement in function"); + } + + final public ObjectPropertyRangeAxiom ObjectPropertyRangeAxiom() throws ParseException { + ObjectProperty op; Description range; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 39: + jj_consume_token(39); + break; + case 40: + jj_consume_token(40); + break; + case 41: + jj_consume_token(41); + break; + default: + jj_la1[6] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(22); + op = ObjectProperty(); + jj_consume_token(23); + jj_consume_token(25); + range = Concept(); + jj_consume_token(COMMAND_END); + {if (true) return new ObjectPropertyRangeAxiom(op, range);} + throw new Error("Missing return statement in function"); + } + + final public DatatypePropertyRangeAxiom DatatypePropertyRangeAxiom() throws ParseException { + DatatypeProperty op; DataRange range; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 42: + jj_consume_token(42); + break; + case 43: + jj_consume_token(43); + break; + default: + jj_la1[7] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(22); + op = DatatypeProperty(); + jj_consume_token(23); + jj_consume_token(25); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 44: + jj_consume_token(44); + range = new Datatype(Datatype.Type.DOUBLE); + break; + case 45: + jj_consume_token(45); + range = new Datatype(Datatype.Type.BOOLEAN); + break; + case 46: + jj_consume_token(46); + range = new Datatype(Datatype.Type.INT); + break; + default: + jj_la1[8] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(COMMAND_END); + {if (true) return new DatatypePropertyRangeAxiom(op, range);} + throw new Error("Missing return statement in function"); + } + final public Description Concept() throws ParseException { Description c,c1,c2; NamedClass ac; @@ -269,7 +404,7 @@ {if (true) return ac;} break; default: - jj_la1[4] = jj_gen; + jj_la1[9] = jj_gen; if (jj_2_5(2147483647)) { jj_consume_token(22); c1 = Concept(); @@ -322,7 +457,7 @@ {if (true) return new ObjectMaxCardinalityRestriction(i,ar,c);} break; default: - jj_la1[5] = jj_gen; + jj_la1[10] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -377,7 +512,7 @@ name = String(); break; default: - jj_la1[6] = jj_gen; + jj_la1[11] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -385,6 +520,24 @@ throw new Error("Missing return statement in function"); } + final public DatatypeProperty DatatypeProperty() throws ParseException { + String name; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ID: + name = Id(); + break; + case STRING: + name = String(); + break; + default: + jj_la1[12] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + {if (true) return new DatatypeProperty(getInternalURI(name));} + throw new Error("Missing return statement in function"); + } + final public ObjectProperty ObjectProperty() throws ParseException { String name; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -395,7 +548,7 @@ name = String(); break; default: - jj_la1[7] = jj_gen; + jj_la1[13] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -413,7 +566,7 @@ name = String(); break; default: - jj_la1[8] = jj_gen; + jj_la1[14] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -499,6 +652,53 @@ finally { jj_save(5, xla); } } + final private boolean jj_3_1() { + if (jj_3R_2()) return true; + if (jj_scan_token(22)) return true; + if (jj_3R_3()) return true; + if (jj_scan_token(23)) return true; + if (jj_scan_token(COMMAND_END)) return true; + return false; + } + + final private boolean jj_3R_22() { + if (jj_scan_token(STRING)) return true; + return false; + } + + final private boolean jj_3R_14() { + if (jj_scan_token(20)) return true; + if (jj_3R_20()) return true; + if (jj_3R_4()) return true; + if (jj_scan_token(COMMAND_END)) return true; + if (jj_3R_2()) return true; + return false; + } + + final private boolean jj_3R_17() { + if (jj_3R_21()) return true; + return false; + } + + final private boolean jj_3R_4() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_17()) { + jj_scanpos = xsp; + if (jj_3R_18()) return true; + } + return false; + } + + final private boolean jj_3R_13() { + if (jj_scan_token(19)) return true; + if (jj_3R_20()) return true; + if (jj_3R_4()) return true; + if (jj_scan_token(COMMAND_END)) return true; + if (jj_3R_2()) return true; + return false; + } + final private boolean jj_3_6() { if (jj_scan_token(22)) return true; if (jj_3R_2()) return true; @@ -512,12 +712,8 @@ return false; } - final private boolean jj_3_1() { - if (jj_3R_2()) return true; - if (jj_scan_token(22)) return true; - if (jj_3R_3()) return true; - if (jj_scan_token(23)) return true; - if (jj_scan_token(COMMAND_END)) return true; + final private boolean jj_3R_20() { + if (jj_scan_token(NUMBER)) return true; return false; } @@ -541,21 +737,6 @@ return false; } - final private boolean jj_3R_17() { - if (jj_3R_21()) return true; - return false; - } - - final private boolean jj_3R_4() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_17()) { - jj_scanpos = xsp; - if (jj_3R_18()) return true; - } - return false; - } - final private boolean jj_3R_10() { if (jj_scan_token(16)) return true; if (jj_3R_4()) return true; @@ -573,8 +754,14 @@ return false; } - final private boolean jj_3R_20() { - if (jj_scan_token(NUMBER)) return true; + final private boolean jj_3_4() { + if (jj_3R_2()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(26)) { + jj_scanpos = xsp; + if (jj_scan_token(27)) return true; + } return false; } @@ -587,6 +774,12 @@ return false; } + final private boolean jj_3_3() { + if (jj_3R_2()) return true; + if (jj_scan_token(25)) return true; + return false; + } + final private boolean jj_3R_23() { if (jj_3R_21()) return true; return false; @@ -602,6 +795,11 @@ return false; } + final private boolean jj_3R_16() { + if (jj_3R_22()) return true; + return false; + } + final private boolean jj_3R_7() { if (jj_3R_19()) return true; return false; @@ -651,28 +849,6 @@ return false; } - final private boolean jj_3R_16() { - if (jj_3R_22()) return true; - return false; - } - - final private boolean jj_3_4() { - if (jj_3R_2()) return true; - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(26)) { - jj_scanpos = xsp; - if (jj_scan_token(27)) return true; - } - return false; - } - - final private boolean jj_3_3() { - if (jj_3R_2()) return true; - if (jj_scan_token(25)) return true; - return false; - } - final private boolean jj_3R_21() { if (jj_scan_token(ID)) return true; return false; @@ -683,15 +859,6 @@ return false; } - final private boolean jj_3R_14() { - if (jj_scan_token(20)) return true; - if (jj_3R_20()) return true; - if (jj_3R_4()) return true; - if (jj_scan_token(COMMAND_END)) return true; - if (jj_3R_2()) return true; - return false; - } - final private boolean jj_3R_15() { if (jj_3R_21()) return true; return false; @@ -707,20 +874,6 @@ return false; } - final private boolean jj_3R_13() { - if (jj_scan_token(19)) return true; - if (jj_3R_20()) return true; - if (jj_3R_4()) return true; - if (jj_scan_token(COMMAND_END)) return true; - if (jj_3R_2()) return true; - return false; - } - - final private boolean jj_3R_22() { - if (jj_scan_token(STRING)) return true; - return false; - } - final private boolean jj_3_2() { Token xsp; xsp = jj_scanpos; @@ -741,7 +894,7 @@ public boolean lookingAhead = false; private boolean jj_semLA; private int jj_gen; - final private int[] jj_la1 = new int[9]; + final private int[] jj_la1 = new int[15]; static private int[] jj_la1_0; static private int[] jj_la1_1; static { @@ -749,10 +902,10 @@ jj_la1_1(); } private static void jj_la1_0() { - jj_la1_0 = new int[] {0xf07f3200,0xf0000000,0x40000,0xc000000,0x203200,0x1f0000,0x200200,0x200200,0x200200,}; + jj_la1_0 = new int[] {0xf07f3200,0xf0000000,0x40000,0xc000000,0x0,0x0,0x0,0x0,0x0,0x203200,0x1f0000,0x200200,0x200200,0x200200,0x200200,}; } private static void jj_la1_1() { - jj_la1_1 = new int[] {0x1,0x1,0x0,0x2,0x0,0x0,0x0,0x0,0x0,}; + jj_la1_1 = new int[] {0x7d,0x7d,0x0,0x2,0x1c,0x60,0x380,0xc00,0x7000,0x0,0x0,0x0,0x0,0x0,0x0,}; } final private JJCalls[] jj_2_rtns = new JJCalls[6]; private boolean jj_rescan = false; @@ -767,7 +920,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; + for (int i = 0; i < 15; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -780,7 +933,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; + for (int i = 0; i < 15; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -790,7 +943,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; + for (int i = 0; i < 15; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -800,7 +953,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; + for (int i = 0; i < 15; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -809,7 +962,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; + for (int i = 0; i < 15; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -818,7 +971,7 @@ token = new Token(); jj_ntk = -1; jj_gen = 0; - for (int i = 0; i < 9; i++) jj_la1[i] = -1; + for (int i = 0; i < 15; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } @@ -929,12 +1082,12 @@ public ParseException generateParseException() { jj_expentries.removeAllElements(); - boolean[] la1tokens = new boolean[34]; + boolean[] la1tokens = new boolean[47]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } - for (int i = 0; i < 9; i++) { + for (int i = 0; i < 15; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { @@ -946,7 +1099,7 @@ } } } - for (int i = 0; i < 34; i++) { + for (int i = 0; i < 47; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; Modified: trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java 2008-02-19 16:44:57 UTC (rev 614) +++ trunk/src/dl-learner/org/dllearner/parser/KBParserConstants.java 2008-02-19 18:28:23 UTC (rev 615) @@ -59,6 +59,19 @@ "\"Inverse\"", "\"Subrole\"", "\"SUBCONCEPTOF\"", + "\"DOMAIN\"", + "\"OPDOMAIN\"", + "\"OBJECTPROPERTYDOMAIN\"", + "\"DPDOMAIN\"", + "\"DATATYPEPROPERTYDOMAIN\"", + "\"RANGE\"", + "\"OPRANGE\"", + "\"OBJECTPROPERTYRANGE\"", + "\"DPRANGE\"", + "\"DATATYPEPROPERTYRANGE\"", + "\"DOUBLE\"", + "\"BOOLEAN\"", + "\"INTEGER\"", }; } Modified: trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java 2008-02-19 16:44:57 UTC (rev 614) +++ trunk/src/dl-learner/org/dllearner/parser/KBParserTokenManager.java 2008-02-19 18:28:23 UTC (rev 615) @@ -63,13 +63,17 @@ case 65: return jjMoveStringLiteralDfa1_0(0x4000L); case 66: - return jjMoveStringLiteralDfa1_0(0x2000L); + return jjMoveStringLiteralDfa1_0(0x200000002000L); + case 68: + return jjMoveStringLiteralDfa1_0(0x1c6400000000L); case 70: return jjMoveStringLiteralDfa1_0(0x20000000L); case 73: - return jjMoveStringLiteralDfa1_0(0x80000000L); + return jjMoveStringLiteralDfa1_0(0x400080000000L); case 79: - return jjMoveStringLiteralDfa1_0(0x8000L); + return jjMoveStringLiteralDfa1_0(0x31800008000L); + case 82: + return jjMoveStringLiteralDfa1_0(0x8000000000L); case 83: return jjMoveStringLiteralDfa1_0(0x34c000000L); case 84: @@ -93,10 +97,16 @@ else if ((active0 & 0x100000L) != 0L) return jjStopAtPos(1, 20); break; + case 65: + return jjMoveStringLiteralDfa2_0(active0, 0x8c000000000L); + case 66: + return jjMoveStringLiteralDfa2_0(active0, 0x21000000000L); case 78: - return jjMoveStringLiteralDfa2_0(active0, 0x4000L); + return jjMoveStringLiteralDfa2_0(active0, 0x400000004000L); case 79: - return jjMoveStringLiteralDfa2_0(active0, 0x3000L); + return jjMoveStringLiteralDfa2_0(active0, 0x300400003000L); + case 80: + return jjMoveStringLiteralDfa2_0(active0, 0x52800000000L); case 82: if ((active0 & 0x8000L) != 0L) return jjStopAtPos(1, 15); @@ -137,13 +147,25 @@ case 68: if ((active0 & 0x4000L) != 0L) return jjStopAtPos(2, 14); - break; + return jjMoveStringLiteralDfa3_0(active0, 0x2800000000L); + case 74: + return jjMoveStringLiteralDfa3_0(active0, 0x21000000000L); + case 77: + return jjMoveStringLiteralDfa3_0(active0, 0x400000000L); + case 78: + return jjMoveStringLiteralDfa3_0(active0, 0x8000000000L); + case 79: + return jjMoveStringLiteralDfa3_0(active0, 0x200000000000L); case 80: if ((active0 & 0x1000L) != 0L) return jjStopAtPos(2, 12); break; + case 82: + return jjMoveStringLiteralDfa3_0(active0, 0x50000000000L); case 84: - return jjMoveStringLiteralDfa3_0(active0, 0x2000L); + return jjMoveStringLiteralDfa3_0(active0, 0x484000002000L); + case 85: + return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L); case 97: return jjMoveStringLiteralDfa3_0(active0, 0x10000000L); case 98: @@ -170,8 +192,20 @@ } switch(curChar) { + case 65: + return jjMoveStringLiteralDfa4_0(active0, 0xd4400000000L); + case 66: + return jjMoveStringLiteralDfa4_0(active0, 0x100000000000L); case 67: return jjMoveStringLiteralDfa4_0(active0, 0x204000000L); + case 69: + return jjMoveStringLiteralDfa4_0(active0, 0x421000000000L); + case 71: + return jjMoveStringLiteralDfa4_0(active0, 0x8000000000L); + case 76: + return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L); + case 79: + return jjMoveStringLiteralDfa4_0(active0, 0x2800000000L); case 84: return jjMoveStringLiteralDfa4_0(active0, 0x2000L); case 99: @@ -200,10 +234,26 @@ } switch(curChar) { + case 67: + return jjMoveStringLiteralDfa5_0(active0, 0x21000000000L); + case 69: + if ((active0 & 0x8000000000L) != 0L) + return jjStopAtPos(4, 39); + return jjMoveStringLiteralDfa5_0(active0, 0x200000000000L); + case 71: + return jjMoveStringLiteralDfa5_0(active0, 0x400000000000L); + case 73: + return jjMoveStringLiteralDfa5_0(active0, 0x400000000L); case 76: - return jjMoveStringLiteralDfa5_0(active0, 0x4000000L); + return jjMoveStringLiteralDfa5_0(active0, 0x100004000000L); + case 77: + return jjMoveStringLiteralDfa5_0(active0, 0x2800000000L); + case 78: + return jjMoveStringLiteralDfa5_0(active0, 0x50000000000L); case 79: return jjMoveStringLiteralDfa5_0(active0, 0x200002000L); + case 84: + return jjMoveStringLiteralDfa5_0(active0, 0x84000000000L); case 101: return jjMoveStringLiteralDfa5_0(active0, 0x40000000L); case 111: @@ -231,13 +281,25 @@ switch(curChar) { case 65: - return jjMoveStringLiteralDfa6_0(active0, 0x4000000L); + return jjMoveStringLiteralDfa6_0(active0, 0x202804000000L); + case 69: + if ((active0 & 0x100000000000L) != 0L) + return jjStopAtPos(5, 44); + return jjMoveStringLiteralDfa6_0(active0, 0x400000000000L); + case 71: + return jjMoveStringLiteralDfa6_0(active0, 0x50000000000L); case 77: if ((active0 & 0x2000L) != 0L) return jjStopAtPos(5, 13); break; case 78: + if ((active0 & 0x400000000L) != 0L) + return jjStopAtPos(5, 34); return jjMoveStringLiteralDfa6_0(active0, 0x200000000L); + case 84: + return jjMoveStringLiteralDfa6_0(active0, 0x21000000000L); + case 89: + return jjMoveStringLiteralDfa6_0(active0, 0x84000000000L); case 105: return jjMoveStringLiteralDfa6_0(active0, 0x30000000L); case 108: @@ -264,6 +326,24 @@ { case 67: return jjMoveStringLiteralDfa7_0(active0, 0x200000000L); + case 69: + if ((active0 & 0x10000000000L) != 0L) + return jjStopAtPos(6, 40); + else if ((active0 & 0x40000000000L) != 0L) + return jjStopAtPos(6, 42); + break; + case 73: + return jjMoveStringLiteralDfa7_0(active0, 0x2800000000L); + case 78: + if ((active0 & 0x200000000000L) != 0L) + return jjStopAtPos(6, 45); + break; + case 80: + return jjMoveStringLiteralDfa7_0(active0, 0xa5000000000L); + case 82: + if ((active0 & 0x400000000000L) != 0L) + return jjStopAtPos(6, 46); + break; case 83: return jjMoveStringLiteralDfa7_0(active0, 0x4000000L); case 101: @@ -295,7 +375,15 @@ switch(curChar) { case 69: - return jjMoveStringLiteralDfa8_0(active0, 0x200000000L); + return jjMoveStringLiteralDfa8_0(active0, 0x84200000000L); + case 78: + if ((active0 & 0x800000000L) != 0L) + return jjStopAtPos(7, 35); + else if ((active0 & 0x2000000000L) != 0L) + return jjStopAtPos(7, 37); + break; + case 82: + return jjMoveStringLiteralDfa8_0(active0, 0x21000000000L); case 83: return jjMoveStringLiteralDfa8_0(active0, 0x4000000L); case 105: @@ -319,9 +407,9 @@ switch(curChar) { case 79: - return jjMoveStringLiteralDfa9_0(active0, 0x4000000L); + return jjMoveStringLiteralDfa9_0(active0, 0x21004000000L); case 80: - return jjMoveStringLiteralDfa9_0(active0, 0x200000000L); + return jjMoveStringLiteralDfa9_0(active0, 0x84200000000L); case 97: return jjMoveStringLiteralDfa9_0(active0, 0x20000000L); case 99: @@ -350,6 +438,10 @@ if ((active0 & 0x4000000L) != 0L) return jjStopAtPos(9, 26); break; + case 80: + return jjMoveStringLiteralDfa10_0(active0, 0x21000000000L); + case 82: + return jjMoveStringLiteralDfa10_0(active0, 0x84000000000L); case 84: return jjMoveStringLiteralDfa10_0(active0, 0x200000000L); case 101: @@ -376,8 +468,10 @@ } switch(curChar) { + case 69: + return jjMoveStringLiteralDfa11_0(active0, 0x21000000000L); case 79: - return jjMoveStringLiteralDfa11_0(active0, 0x200000000L); + return jjMoveStringLiteralDfa11_0(active0, 0x84200000000L); default : break; } @@ -398,11 +492,237 @@ if ((active0 & 0x200000000L) != 0L) return jjStopAtPos(11, 33); break; + case 80: + return jjMoveStringLiteralDfa12_0(active0, 0x84000000000L); + case 82: + return jjMoveStringLiteralDfa12_0(active0, 0x21000000000L); default : break; } return jjStartNfa_0(10, active0); } +private final int jjMoveStringLiteralDfa12_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(10, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(11, active0); + return 12; + } + switch(curChar) + { + case 69: + return jjMoveStringLiteralDfa13_0(active0, 0x84000000000L); + case 84: + return jjMoveStringLiteralDfa13_0(active0, 0x21000000000L); + default : + break; + } + return jjStartNfa_0(11, active0); +} +private final int jjMoveStringLiteralDfa13_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(11, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(12, active0); + return 13; + } + switch(curChar) + { + case 82: + return jjMoveStringLiteralDfa14_0(active0, 0x84000000000L); + case 89: + return jjMoveStringLiteralDfa14_0(active0, 0x21000000000L); + default : + break; + } + return jjStartNfa_0(12, active0); +} +private final int jjMoveStringLiteralDfa14_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(12, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(13, active0); + return 14; + } + switch(curChar) + { + case 68: + return jjMoveStringLiteralDfa15_0(active0, 0x1000000000L); + case 82: + return jjMoveStringLiteralDfa15_0(active0, 0x20000000000L); + case 84: + return jjMoveStringLiteralDfa15_0(active0, 0x84000000000L); + default : + break; + } + return jjStartNfa_0(13, active0); +} +private final int jjMoveStringLiteralDfa15_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(13, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(14, active0); + return 15; + } + switch(curChar) + { + case 65: + return jjMoveStringLiteralDfa16_0(active0, 0x20000000000L); + case 79: + return jjMoveStringLiteralDfa16_0(active0, 0x1000000000L); + case 89: + return jjMoveStringLiteralDfa16_0(active0, 0x84000000000L); + default : + break; + } + return jjStartNfa_0(14, active0); +} +private final int jjMoveStringLiteralDfa16_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(14, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(15, active0); + return 16; + } + switch(curChar) + { + case 68: + return jjMoveStringLiteralDfa17_0(active0, 0x4000000000L); + case 77: + return jjMoveStringLiteralDfa17_0(active0, 0x1000000000L); + case 78: + return jjMoveStringLiteralDfa17_0(active0, 0x20000000000L); + case 82: + return jjMoveStringLiteralDfa17_0(active0, 0x80000000000L); + default : + break; + } + return jjStartNfa_0(15, active0); +} +private final int jjMoveStringLiteralDfa17_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(15, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(16, active0); + return 17; + } + switch(curChar) + { + case 65: + return jjMoveStringLiteralDfa18_0(active0, 0x81000000000L); + case 71: + return jjMoveStringLiteralDfa18_0(active0, 0x20000000000L); + case 79: + return jjMoveStringLiteralDfa18_0(active0, 0x4000000000L); + default : + break; + } + return jjStartNfa_0(16, active0); +} +private final int jjMoveStringLiteralDfa18_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(16, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(17, active0); + return 18; + } + switch(curChar) + { + case 69: + if ((active0 & 0x20000000000L) != 0L) + return jjStopAtPos(18, 41); + break; + case 73: + return jjMoveStringLiteralDfa19_0(active0, 0x1000000000L); + case 77: + return jjMoveStringLiteralDfa19_0(active0, 0x4000000000L); + case 78: + return jjMoveStringLiteralDfa19_0(active0, 0x80000000000L); + default : + break; + } + return jjStartNfa_0(17, active0); +} +private final int jjMoveStringLiteralDfa19_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(17, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(18, active0); + return 19; + } + switch(curChar) + { + case 65: + return jjMoveStringLiteralDfa20_0(active0, 0x4000000000L); + case 71: + return jjMoveStringLiteralDfa20_0(active0, 0x80000000000L); + case 78: + if ((active0 & 0x1000000000L) != 0L) + return jjStopAtPos(19, 36); + break; + default : + break; + } + return jjStartNfa_0(18, active0); +} +private final int jjMoveStringLiteralDfa20_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(18, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(19, active0); + return 20; + } + switch(curChar) + { + case 69: + if ((active0 & 0x80000000000L) != 0L) + return jjStopAtPos(20, 43); + break; + case 73: + return jjMoveStringLiteralDfa21_0(active0, 0x4000000000L); + default : + break; + } + return jjStartNfa_0(19, active0); +} +private final int jjMoveStringLiteralDfa21_0(long old0, long active0) +{ + if (((active0 &= old0)) == 0L) + return jjStartNfa_0(19, old0); + try { curChar = input_stream.readChar(); } + catch(java.io.IOException e) { + jjStopStringLiteralDfa_0(20, active0); + return 21; + } + switch(curChar) + { + case 78: + if ((active0 & 0x4000000000L) != 0L) + return jjStopAtPos(21, 38); + break; + default : + break; + } + return jjStartNfa_0(20, active0); +} private final void jjCheckNAdd(int state) { if (jjrounds[state] != jjround) @@ -818,12 +1138,18 @@ "\76\75", "\74\75", null, "\50", "\51", "\54", "\75", "\123\125\102\103\114\101\123\123\117\106", "\123\125\102", "\124\162\141\156\163\151\164\151\166\145", "\106\165\156\143\164\151\157\156\141\154", "\123\171\155\155\145\164\162\151\143", "\111\156\166\145\162\163\145", -"\123\165\142\162\157\154\145", "\123\125\102\103\117\116\103\105\120\124\117\106", }; +"\123\165\142\162\157\154\145", "\123\125\102\103\117\116\103\105\120\124\117\106", +"\104\117\115\101\111\116", "\117\120\104\117\115\101\111\116", +"\117\102\112\105\103\124\120\122\117\120\105\122\124\131\104\117\115\101\111\116", "\104\120\104\117\115\101\111\116", +"\104\101\124\101\124\131\120\105\120\122\117\120\105\122\124\131\104\117\115\101\111\116", "\122\101\116\107\105", "\117\120\122\101\116\107\105", +"\117\102\112\105\103\124\120\122\117\120\105\122\124\131\122\101\116\107\105", "\104\120\122\101\116\107\105", +"\104\101\124\101\124\131\120\105\120\122\117\120\105\122\124\131\122\101\116\107\105", "\104\117\125\102\114\105", "\102\117\117\114\105\101\116", +"\111\116\124\105\107\105\122", }; public static final String[] lexStateNames = { "DEFAULT", }; static final long[] jjtoToken = { - 0x3ffffff01L, + 0x7fffffffff01L, }; static final long[] jjtoSkip = { 0xfeL, Modified: trunk/src/dl-learner/org/dllearner/parser/kb.jj =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-19 16:44:57 UTC (rev 614) +++ trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-19 18:28:23 UTC (rev 615) @@ -123,6 +123,10 @@ { kb.addRBoxAxiom(rBoxAxiom); } | rBoxAxiom = Subrole() { kb.addRBoxAxiom(rBoxAxiom); } + | rBoxAxiom = ObjectPropertyDomainAxiom() + { kb.addRBoxAxiom(rBoxAxiom); } + | rBoxAxiom = DatatypePropertyDomainAxiom() + { kb.addRBoxAxiom(rBoxAxiom); } // da Konfigurationsoptionen ausgeschlossen sind, reicht es bis zum "=" zu suchen | LOOKAHEAD(Concept() "=") equality = TBoxEquiv() { kb.addTBoxAxiom(equality); } @@ -198,6 +202,34 @@ { return new SubClassAxiom(c1,c2);} } +ObjectPropertyDomainAxiom ObjectPropertyDomainAxiom() : {ObjectProperty op; Description domain; } +{ + ("DOMAIN" | "OPDOMAIN" | "OBJECTPROPERTYDOMAIN") "(" op=ObjectProperty() ")" "=" domain=Concept() <COMMAND_END> + { return new ObjectPropertyDomainAxiom(op, domain); } +} + +DatatypePropertyDomainAxiom DatatypePropertyDomainAxiom() : {DatatypeProperty op; Description domain; } +{ + ( "DPDOMAIN" | "DATATYPEPROPERTYDOMAIN" ) "(" op=DatatypeProperty() ")" "=" domain=Concept() <COMMAND_END> + { return new DatatypePropertyDomainAxiom(op, domain); } +} + +ObjectPropertyRangeAxiom ObjectPropertyRangeAxiom() : {ObjectProperty op; Description range; } +{ + ("RANGE" | "OPRANGE" | "OBJECTPROPERTYRANGE") "(" op=ObjectProperty() ")" "=" range=Concept() <COMMAND_END> + { return new ObjectPropertyRangeAxiom(op, range); } +} + +DatatypePropertyRangeAxiom DatatypePropertyRangeAxiom() : {DatatypeProperty op; DataRange range; } +{ + ( "DPRANGE" | "DATATYPEPROPERTYRANGE") "(" op=DatatypeProperty() ")" "=" + ( "DOUBLE" { range = new Datatype(Datatype.Type.DOUBLE); } + | "BOOLEAN" { range = new Datatype(Datatype.Type.BOOLEAN); } + | "INTEGER" { range = new Datatype(Datatype.Type.INT); } ) + <COMMAND_END> + { return new DatatypePropertyRangeAxiom(op, range); } +} + Description Concept() : { Description c,c1,c2; @@ -259,6 +291,17 @@ } } +DatatypeProperty DatatypeProperty() : +{ + String name; +} +{ + (name=Id() | name=String()) + { + return new DatatypeProperty(getInternalURI(name)); + } +} + ObjectProperty ObjectProperty() : { String name; Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-19 16:44:57 UTC (rev 614) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-19 18:28:23 UTC (rev 615) @@ -240,8 +240,10 @@ * @see org.dllearner.core.owl.PropertyAxiomVisitor#visit(org.dllearner.core.owl.DatatypePropertyDomainAxiom) */ public void visit(DatatypePropertyDomainAxiom datatypePropertyDomainAxiom) { - // TODO Auto-generated method stub - + OWLDescription d = getOWLDescription(datatypePropertyDomainAxiom.getDomain()); + OWLDataProperty dp = factory.getOWLDataProperty(URI.create(datatypePropertyDomainAxiom.getProperty().getName())); + OWLAxiom axiomOWLAPI = factory.getOWLDataPropertyDomainAxiom(dp, d); + addAxiom(axiomOWLAPI); } /* (non-Javadoc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-19 16:45:32
|
Revision: 614 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=614&view=rev Author: jenslehmann Date: 2008-02-19 08:44:57 -0800 (Tue, 19 Feb 2008) Log Message: ----------- - example set for carcinogenesis PTE-1 extracted - first run indicates that OWL reasoners (at least Pellet) cannot handle reasoning requests in reasonable time (ontology currently contains approx. 65k triples) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-19 15:54:02 UTC (rev 613) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-19 16:44:57 UTC (rev 614) @@ -75,7 +75,7 @@ private static URI ontologyURI = URI.create("http://dl-learner.org/carcinogenesis"); // directory of Prolog files - private static String prologDirectory = "examples/carcinogenesis/prolog/"; + private static final String prologDirectory = "examples/carcinogenesis/prolog/"; // mapping of symbols to names of chemical elements private static Map<String, String> chemElements; @@ -163,10 +163,12 @@ System.out.println("OK (" + time + ")."); // generating conf files - File confTrainFile = new File("examples/carcinogenesis/train.conf"); - String confHeader = ""; + File confTrainFile = new File("examples/carcinogenesis/train.conf"); + Files.clearFile(confTrainFile); + String confHeader = "import(\"pte.owl\");\n\n"; + confHeader += "reasoner = owlAPI;\n"; Files.appendFile(confTrainFile, confHeader); - + // generating training examples File trainingFilePositives = new File(prologDirectory + "train.f"); File trainingFileNegatives = new File(prologDirectory + "train.n"); @@ -176,11 +178,21 @@ appendPosExamples(confTrainFile, posTrainExamples); appendNegExamples(confTrainFile, negTrainExamples); - // generating testExamples -// File confTestFile = new File("examples/carcinogenesis/test.conf"); -// File testFilePositives = new File(prologDirectory + "train.f"); -// File testFileNegatives = new File(prologDirectory + "train.n"); -// + // generating test examples for PTE-1 + File confPTE1File = new File("examples/carcinogenesis/testpte1.conf"); + Files.clearFile(confPTE1File); + File testPTE1Positives = new File(prologDirectory + "pte1.f"); + File testPTE1Negatives = new File(prologDirectory + "pte1.n"); + + List<Individual> posPTE1Examples = getExamples(testPTE1Positives); + List<Individual> negPTE1Examples = getExamples(testPTE1Negatives); + appendPosExamples(confPTE1File, posPTE1Examples); + appendNegExamples(confPTE1File, negPTE1Examples); + + // TODO: how to get PTE-2 predictions? the pte-2 directory suggests + // that all are positive which is not true (according to the papers) + // solution: go to "http://ntp-server.niehs.nih.gov/" and click + // on "Testing Status of Agents at NTP" } private static List<Axiom> mapClause(Clause clause) { @@ -253,7 +265,7 @@ // takes a *.f or *.n file as input and returns the // contained examples private static List<Individual> getExamples(File file) throws FileNotFoundException, IOException, ParseException { - String content = Files.readFile(new File(prologDirectory + file)); + String content = Files.readFile(file); PrologParser pp = new PrologParser(); Program programPos = pp.parseProgram(content); List<Individual> ret = new LinkedList<Individual>(); @@ -267,7 +279,7 @@ private static void appendPosExamples(File file, List<Individual> examples) { StringBuffer content = new StringBuffer(); for(Individual example : examples) { - content.append("+\""+example.toString()+"\""); + content.append("+\""+example.toString()+"\"\n"); } Files.appendFile(file, content.toString()); } @@ -275,7 +287,7 @@ private static void appendNegExamples(File file, List<Individual> examples) { StringBuffer content = new StringBuffer(); for(Individual example : examples) { - content.append("-\""+example.toString()+"\""); + content.append("-\""+example.toString()+"\"\n"); } Files.appendFile(file, content.toString()); } Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-02-19 15:54:02 UTC (rev 613) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-02-19 16:44:57 UTC (rev 614) @@ -118,7 +118,7 @@ @Override public void init() throws ComponentInitException { try { - if(kb == null) + if(url != null) kb = KBParser.parseKBFile(url); } catch (IOException e) { throw new ComponentInitException("KB file " + url + " could not be read.", e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-02-19 15:54:29
|
Revision: 613 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=613&view=rev Author: tonytacker Date: 2008-02-19 07:54:02 -0800 (Tue, 19 Feb 2008) Log Message: ----------- formated Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/RunPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/ThreadRun.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelAbstract.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDouble.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringSet.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelStringTupleList.java Modified: trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/CheckBoxList.java 2008-02-19 15:54:02 UTC (rev 613) @@ -34,83 +34,83 @@ * @author Tilo Hielscher */ public class CheckBoxList extends JPanel { - private static final long serialVersionUID = -7119007550662195455L; - private JPanel checkBoxPanel = new JPanel(); - private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); - private GridBagLayout gridbag = new GridBagLayout(); - private GridBagConstraints constraints = new GridBagConstraints(); + private static final long serialVersionUID = -7119007550662195455L; + private JPanel checkBoxPanel = new JPanel(); + private LinkedList<JCheckBox> list = new LinkedList<JCheckBox>(); + private GridBagLayout gridbag = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); - /** - * Make a JPanel with GridBagLayout. - */ - public CheckBoxList() { - checkBoxPanel.setLayout(gridbag); - add(checkBoxPanel, BorderLayout.CENTER); - constraints.anchor = GridBagConstraints.WEST; - } + /** + * Make a JPanel with GridBagLayout. + */ + public CheckBoxList() { + checkBoxPanel.setLayout(gridbag); + add(checkBoxPanel, BorderLayout.CENTER); + constraints.anchor = GridBagConstraints.WEST; + } - /** - * Add new entry and make a new JCheckBox. - * - * @param label - * This text will be shown. It is the name of new JCheckBox - * and will add to list. - */ - public void add(String label) { - list.add(new JCheckBox(label)); - update(); - } + /** + * Add new entry and make a new JCheckBox. + * + * @param label + * This text will be shown. It is the name of new JCheckBox and + * will add to list. + */ + public void add(String label) { + list.add(new JCheckBox(label)); + update(); + } - /** - * Return a set of selected items. - */ - public Set<String> getSelections() { - Set<String> selectionSet = new HashSet<String>(); - selectionSet.clear(); // remove all - for (int i = 0; i < list.size(); i++) { - if (list.get(i).isSelected()) - selectionSet.add(list.get(i).getText()); + /** + * Return a set of selected items. + */ + public Set<String> getSelections() { + Set<String> selectionSet = new HashSet<String>(); + selectionSet.clear(); // remove all + for (int i = 0; i < list.size(); i++) { + if (list.get(i).isSelected()) + selectionSet.add(list.get(i).getText()); + } + return selectionSet; } - return selectionSet; - } - /** - * Select items. - * - * @param selectionSet - * Is a Set of Strings. - */ - public void setSelections(Set<String> selectionSet) { - for (int i = 0; i < this.list.size(); i++) { - if (selectionSet.contains(list.get(i).getText())) - list.get(i).setSelected(true); - else - this.list.get(i).setSelected(false); + /** + * Select items. + * + * @param selectionSet + * Is a Set of Strings. + */ + public void setSelections(Set<String> selectionSet) { + for (int i = 0; i < this.list.size(); i++) { + if (selectionSet.contains(list.get(i).getText())) + list.get(i).setSelected(true); + else + this.list.get(i).setSelected(false); + } } - } - /** - * update JCheckBox's - */ - private void update() { - checkBoxPanel.removeAll(); - for (int i = 0; i < list.size(); i++) { - buildConstraints(constraints, 0, i, 1, 1, 100, 100); - gridbag.setConstraints(list.get(i), constraints); - checkBoxPanel.add(list.get(i), constraints); + /** + * update JCheckBox's + */ + private void update() { + checkBoxPanel.removeAll(); + for (int i = 0; i < list.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 100, 100); + gridbag.setConstraints(list.get(i), constraints); + checkBoxPanel.add(list.get(i), constraints); + } } - } - /** - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, - int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; - } + /** + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, + int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 15:54:02 UTC (rev 613) @@ -37,242 +37,242 @@ * @author Tilo Hielscher */ public class Config { - private ComponentManager cm = ComponentManager.getInstance(); - private KnowledgeSource source; - private KnowledgeSource oldSource; - private ReasonerComponent reasoner; - private ReasonerComponent oldReasoner; - private ReasoningService rs; - private LearningProblem lp; - private LearningProblem oldLearningProblem; - private LearningAlgorithm la; - private LearningAlgorithm oldLearningAlgorithm; - private boolean[] isInit = new boolean[4]; + private ComponentManager cm = ComponentManager.getInstance(); + private KnowledgeSource source; + private KnowledgeSource oldSource; + private ReasonerComponent reasoner; + private ReasonerComponent oldReasoner; + private ReasoningService rs; + private LearningProblem lp; + private LearningProblem oldLearningProblem; + private LearningAlgorithm la; + private LearningAlgorithm oldLearningAlgorithm; + private boolean[] isInit = new boolean[4]; - /** - * Get ComponentManager. - * - * @return ComponentManager - */ - public ComponentManager getComponentManager() { - return this.cm; - } + /** + * Get ComponentManager. + * + * @return ComponentManager + */ + public ComponentManager getComponentManager() { + return this.cm; + } - /** - * It is necessary for init KnowledgeSource. - * - * @return true, if url was set otherwise false - */ - public Boolean isSetURL() { - // return this.isURL; - // String value = (String) cm.getConfigOptionValue(source, "url"); - if (cm.getConfigOptionValue(source, "url") != null) - return true; - else - return false; - } + /** + * It is necessary for init KnowledgeSource. + * + * @return true, if url was set otherwise false + */ + public Boolean isSetURL() { + // return this.isURL; + // String value = (String) cm.getConfigOptionValue(source, "url"); + if (cm.getConfigOptionValue(source, "url") != null) + return true; + else + return false; + } - /** - * Set KnowledgeSource. - * - * @param knowledgeSource - */ - public void setKnowledgeSource(KnowledgeSource knowledgeSource) { - this.oldSource = this.source; - this.source = knowledgeSource; - } + /** + * Set KnowledgeSource. + * + * @param knowledgeSource + */ + public void setKnowledgeSource(KnowledgeSource knowledgeSource) { + this.oldSource = this.source; + this.source = knowledgeSource; + } - /** - * Get KnowledgeSource. - * - * @return KnowledgeSource - */ - public KnowledgeSource getKnowledgeSource() { - return this.source; - } + /** + * Get KnowledgeSource. + * + * @return KnowledgeSource + */ + public KnowledgeSource getKnowledgeSource() { + return this.source; + } - /** - * Get old KnowledgeSource. - * - * @return old KnowledgeSource - */ - public KnowledgeSource getOldKnowledgeSource() { - return this.oldSource; - } + /** + * Get old KnowledgeSource. + * + * @return old KnowledgeSource + */ + public KnowledgeSource getOldKnowledgeSource() { + return this.oldSource; + } - /** - * Set Reasoner. - * - * @param reasoner - */ - public void setReasoner(ReasonerComponent reasoner) { - this.oldReasoner = this.reasoner; - this.reasoner = reasoner; - } + /** + * Set Reasoner. + * + * @param reasoner + */ + public void setReasoner(ReasonerComponent reasoner) { + this.oldReasoner = this.reasoner; + this.reasoner = reasoner; + } - /** - * Get Reasoner. - * - * @return reasoner - */ - public ReasonerComponent getReasoner() { - return this.reasoner; - } + /** + * Get Reasoner. + * + * @return reasoner + */ + public ReasonerComponent getReasoner() { + return this.reasoner; + } - /** - * Get old Reasoner as a set. - * - * @return oldReasonerSet. - */ - public ReasonerComponent getOldReasonerSet() { - return this.oldReasoner; - } + /** + * Get old Reasoner as a set. + * + * @return oldReasonerSet. + */ + public ReasonerComponent getOldReasonerSet() { + return this.oldReasoner; + } - /** - * Set ReasoningService. - * - * @param reasoningService - */ - public void setReasoningService(ReasoningService reasoningService) { - this.rs = reasoningService; - } + /** + * Set ReasoningService. + * + * @param reasoningService + */ + public void setReasoningService(ReasoningService reasoningService) { + this.rs = reasoningService; + } - /** - * Get ReasoningService. - * - * @return ReasoningService - */ - public ReasoningService getReasoningService() { - return this.rs; - } + /** + * Get ReasoningService. + * + * @return ReasoningService + */ + public ReasoningService getReasoningService() { + return this.rs; + } - /** - * Set LearningProblem. - * - * @param learningProblem - */ - public void setLearningProblem(LearningProblem learningProblem) { - this.oldLearningProblem = this.lp; - this.lp = learningProblem; - } + /** + * Set LearningProblem. + * + * @param learningProblem + */ + public void setLearningProblem(LearningProblem learningProblem) { + this.oldLearningProblem = this.lp; + this.lp = learningProblem; + } - /** - * Get LearningProblem. - * - * @return learningProblem - */ - public LearningProblem getLearningProblem() { - return this.lp; - } + /** + * Get LearningProblem. + * + * @return learningProblem + */ + public LearningProblem getLearningProblem() { + return this.lp; + } - /** - * Get old LearningProblem as a set. - * - * @return old learningProblemSet. - */ - public LearningProblem getOldLearningProblem() { - return this.oldLearningProblem; - } + /** + * Get old LearningProblem as a set. + * + * @return old learningProblemSet. + */ + public LearningProblem getOldLearningProblem() { + return this.oldLearningProblem; + } - /** - * Set LearningAlgorithm. - * - * @param learningAlgorithm - */ - public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { - this.oldLearningAlgorithm = this.la; - this.la = learningAlgorithm; - } + /** + * Set LearningAlgorithm. + * + * @param learningAlgorithm + */ + public void setLearningAlgorithm(LearningAlgorithm learningAlgorithm) { + this.oldLearningAlgorithm = this.la; + this.la = learningAlgorithm; + } - /** - * Get LearningAlgorithm. - * - * @return LearningAlgorithm - */ - public LearningAlgorithm getLearningAlgorithm() { - return this.la; - } + /** + * Get LearningAlgorithm. + * + * @return LearningAlgorithm + */ + public LearningAlgorithm getLearningAlgorithm() { + return this.la; + } - /** - * Get old LearningAlgorithmSet. - * - * @return old LearningAlgorithmSet - */ - public LearningAlgorithm getOldLearningAlgorithm() { - return this.oldLearningAlgorithm; - } + /** + * Get old LearningAlgorithmSet. + * + * @return old LearningAlgorithmSet + */ + public LearningAlgorithm getOldLearningAlgorithm() { + return this.oldLearningAlgorithm; + } - /** - * KnowledgeSource.init has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitKnowledgeSource() { - return isInit[0]; - } + /** + * KnowledgeSource.init has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitKnowledgeSource() { + return isInit[0]; + } - /** - * Set true if you run KnowwledgeSource.init. The inits from other tabs - * behind will automatic set to false. - */ - public void setInitKnowledgeSource(Boolean is) { - isInit[0] = is; - for (int i = 1; i < 4; i++) - isInit[i] = false; - } + /** + * Set true if you run KnowwledgeSource.init. The inits from other tabs + * behind will automatic set to false. + */ + public void setInitKnowledgeSource(Boolean is) { + isInit[0] = is; + for (int i = 1; i < 4; i++) + isInit[i] = false; + } - /** - * Reasoner.init has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitReasoner() { - return isInit[1]; - } + /** + * Reasoner.init has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitReasoner() { + return isInit[1]; + } - /** - * Set true if you run Reasoner.init. The inits from other tabs behind will - * automatic set to false. - */ - public void setInitReasoner(Boolean is) { - isInit[1] = is; - for (int i = 2; i < 4; i++) - isInit[i] = false; - } + /** + * Set true if you run Reasoner.init. The inits from other tabs behind will + * automatic set to false. + */ + public void setInitReasoner(Boolean is) { + isInit[1] = is; + for (int i = 2; i < 4; i++) + isInit[i] = false; + } - /** - * LearningProblem.init has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitLearningProblem() { - return isInit[2]; - } + /** + * LearningProblem.init has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitLearningProblem() { + return isInit[2]; + } - /** - * Set true if you run LearningProblem.init. The inits from other tabs - * behind will automatic set to false. - */ - public void setInitLearningProblem(Boolean is) { - isInit[2] = is; - for (int i = 3; i < 4; i++) - isInit[i] = false; - } + /** + * Set true if you run LearningProblem.init. The inits from other tabs + * behind will automatic set to false. + */ + public void setInitLearningProblem(Boolean is) { + isInit[2] = is; + for (int i = 3; i < 4; i++) + isInit[i] = false; + } - /** - * LearningAlgorithm.init() has run? - * - * @return true, if init was made, false if not - */ - public boolean isInitLearningAlgorithm() { - return isInit[3]; - } + /** + * LearningAlgorithm.init() has run? + * + * @return true, if init was made, false if not + */ + public boolean isInitLearningAlgorithm() { + return isInit[3]; + } - /** - * set true if you run LearningAlgorithm.init - */ - public void setInitLearningAlgorithm(Boolean is) { - isInit[3] = is; - } + /** + * set true if you run LearningAlgorithm.init + */ + public void setInitLearningAlgorithm(Boolean is) { + isInit[3] = is; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-19 15:54:02 UTC (rev 613) @@ -45,117 +45,110 @@ */ public class ConfigLoad { - private File file; - private Config config; - private StartGUI startGUI; + private File file; + private Config config; + private StartGUI startGUI; - private Class<? extends KnowledgeSource> componentOption; + private Class<? extends KnowledgeSource> componentOption; - /** - * set config and startGUI - * - * @param config - * @param startGUI - */ - public ConfigLoad(Config config, StartGUI startGUI) { - this.config = config; - this.startGUI = startGUI; - } + /** + * set config and startGUI + * + * @param config + * @param startGUI + */ + public ConfigLoad(Config config, StartGUI startGUI) { + this.config = config; + this.startGUI = startGUI; + } - /** - * set your file to read - * - * @param file - * @return true if file exist - */ - public boolean openFile(File file) { - this.file = file; - return file.exists(); - } + /** + * set your file to read + * + * @param file + * @return true if file exist + */ + public boolean openFile(File file) { + this.file = file; + return file.exists(); + } - /** - * parse file - */ - public void startParser() { - if (this.file.exists()) { - ConfParser parser = ConfParser.parseFile(file); - // KNOWLEDGE SOURCE - // filename - String value = parser.getFunctionCalls().get("import").get(0) - .get(0); - // only first of imported files - if (value.endsWith(".kb")) { - componentOption = KBFile.class; - } else if (value.endsWith(".owl")) { - componentOption = OWLFile.class; - } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { - if (parser.getFunctionCalls().get("import").get(0).get(1) - .equalsIgnoreCase("sparql")) { - System.out.println("IT IS SPARQL"); - componentOption = SparqlKnowledgeSource.class; - } - } - // check if class was set - if (componentOption != null) - config.setKnowledgeSource(config.getComponentManager() - .knowledgeSource(componentOption)); - // set url - // value = parser.getFunctionCalls().get("import").get(0).get(0); - value = makeURL(value); - Component component = config.getKnowledgeSource(); - StringConfigOption specialOption = (StringConfigOption) config - .getComponentManager().getConfigOption(componentOption, - "url"); - try { - ConfigEntry<String> specialEntry = new ConfigEntry<String>( - specialOption, value); - config.getComponentManager().applyConfigEntry(component, - specialEntry); - System.out.println("set String: " + "url" + " = " + value); - } catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } - // startGUI.updateTabColors(); - // init - if (config.getKnowledgeSource() != null && config.isSetURL()) { - try { - config.getKnowledgeSource().init(); - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); - } catch (ComponentInitException e) { - e.printStackTrace(); - } - } + /** + * parse file + */ + public void startParser() { + if (this.file.exists()) { + ConfParser parser = ConfParser.parseFile(file); + // KNOWLEDGE SOURCE + // filename + String value = parser.getFunctionCalls().get("import").get(0).get(0); + // only first of imported files + if (value.endsWith(".kb")) { + componentOption = KBFile.class; + } else if (value.endsWith(".owl")) { + componentOption = OWLFile.class; + } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { + if (parser.getFunctionCalls().get("import").get(0).get(1) + .equalsIgnoreCase("sparql")) { + System.out.println("IT IS SPARQL"); + componentOption = SparqlKnowledgeSource.class; + } + } + // check if class was set + if (componentOption != null) + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + componentOption)); + // set url + // value = parser.getFunctionCalls().get("import").get(0).get(0); + value = makeURL(value); + Component component = config.getKnowledgeSource(); + StringConfigOption specialOption = (StringConfigOption) config.getComponentManager() + .getConfigOption(componentOption, "url"); + try { + ConfigEntry<String> specialEntry = new ConfigEntry<String>(specialOption, value); + config.getComponentManager().applyConfigEntry(component, specialEntry); + System.out.println("set String: " + "url" + " = " + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + // startGUI.updateTabColors(); + // init + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } - // update - startGUI.updateTabColors(); + // update + startGUI.updateTabColors(); - System.out.println("reasoner: " - + parser.getConfOptionsByName("reasoner")); - System.out.println("confoptions: " + parser.getConfOptions()); - System.out.println("posExamples: " + parser.getPositiveExamples()); - System.out.println("confoptionbyname: " - + parser.getConfOptionsByName()); + System.out.println("reasoner: " + parser.getConfOptionsByName("reasoner")); + System.out.println("confoptions: " + parser.getConfOptions()); + System.out.println("posExamples: " + parser.getPositiveExamples()); + System.out.println("confoptionbyname: " + parser.getConfOptionsByName()); - // do it - // only url from first entry, ignore others - // parser.getFunctionCalls().get("import").get(0); + // do it + // only url from first entry, ignore others + // parser.getFunctionCalls().get("import").get(0); + } } - } - /** - * If value is not a valid url and starts with "http://" or "file://" then - * add "file://" - * - * @param value - * is a string - * @return a valid url made from value - */ - public String makeURL(String value) { - if (!value.startsWith("http://") && !value.startsWith("file://")) - value = "file://".concat(file.getPath().replace(file.getName(), "") - .concat(value)); - return value; - } + /** + * If value is not a valid url and starts with "http://" or "file://" then + * add "file://" + * + * @param value + * is a string + * @return a valid url made from value + */ + public String makeURL(String value) { + if (!value.startsWith("http://") && !value.startsWith("file://")) + value = "file://".concat(file.getPath().replace(file.getName(), "").concat(value)); + return value; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -29,8 +29,9 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; -import org.dllearner.kb.*; +// import org.dllearner.kb.*; + /** * KnowledgeSourcePanel, tab 0. Choose Source, change Options and final initiate * KnowledgeSource. @@ -39,154 +40,149 @@ */ public class KnowledgeSourcePanel extends JPanel implements ActionListener { - private static final long serialVersionUID = -7678275020058043937L; + private static final long serialVersionUID = -7678275020058043937L; - private Config config; - private StartGUI startGUI; - private JButton initButton; - private JButton setButton; - private String[] kbBoxItems = {}; - private JComboBox cb = new JComboBox(kbBoxItems); - private JPanel choosePanel = new JPanel(); - private JPanel initPanel = new JPanel(); - private int choosenClassIndex; - private List<Class<? extends KnowledgeSource>> sources; - private OptionPanel optionPanel; + private Config config; + private StartGUI startGUI; + private JButton initButton; + private JButton setButton; + private String[] kbBoxItems = {}; + private JComboBox cb = new JComboBox(kbBoxItems); + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); + private int choosenClassIndex; + private List<Class<? extends KnowledgeSource>> sources; + private OptionPanel optionPanel; - KnowledgeSourcePanel(final Config config, StartGUI startGUI) { - super(new BorderLayout()); + KnowledgeSourcePanel(final Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - sources = config.getComponentManager().getKnowledgeSources(); + this.config = config; + this.startGUI = startGUI; + sources = config.getComponentManager().getKnowledgeSources(); - System.out.println("SOURCES: " + sources); + System.out.println("SOURCES: " + sources); - setButton = new JButton("Set"); - setButton.addActionListener(this); - initButton = new JButton("Init KnowledgeSource"); - initButton.addActionListener(this); - initButton.setEnabled(true); + setButton = new JButton("Set"); + setButton.addActionListener(this); + initButton = new JButton("Init KnowledgeSource"); + initButton.addActionListener(this); + initButton.setEnabled(true); - // add to comboBox - for (int i = 0; i < sources.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - sources.get(i))); - } - cb.addActionListener(this); + // add to comboBox + for (int i = 0; i < sources.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(sources.get(i))); + } + cb.addActionListener(this); - choosePanel.add(cb); - choosePanel.add(setButton); - choosenClassIndex = cb.getSelectedIndex(); + choosePanel.add(cb); + choosePanel.add(setButton); + choosenClassIndex = cb.getSelectedIndex(); - optionPanel = new OptionPanel(config, config.getKnowledgeSource(), - config.getOldKnowledgeSource(), sources.get(choosenClassIndex)); - initPanel.add(initButton); + optionPanel = new OptionPanel(config, config.getKnowledgeSource(), config + .getOldKnowledgeSource(), sources.get(choosenClassIndex)); + initPanel.add(initButton); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - // setSource(); - updateAll(); - } - - public void actionPerformed(ActionEvent e) { - // read selected KnowledgeSourceClass - // choosenClassIndex = cb.getSelectedIndex(); - if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); - config.setInitKnowledgeSource(false); - setSource(); + // setSource(); + updateAll(); } - if (e.getSource() == setButton) { - setSource(); + public void actionPerformed(ActionEvent e) { + // read selected KnowledgeSourceClass + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitKnowledgeSource(false); + setSource(); + } + + if (e.getSource() == setButton) { + setSource(); + } + + if (e.getSource() == initButton) + init(); } - if (e.getSource() == initButton) - init(); - } + /** + * after this, you can change widgets + */ + public void setSource() { + System.out.println("cm: " + config.getComponentManager()); + System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); - /** - * after this, you can change widgets - */ - public void setSource() { - System.out.println("cm: " + config.getComponentManager()); - System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); - - config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); -// KBFile.class doesn't work -// config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); - - - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out - .println("ABC: " - + config.getComponentManager().getComponentName( - sources.get(0))); + config.setKnowledgeSource(config.getComponentManager().knowledgeSource( + sources.get(choosenClassIndex))); + // KBFile.class doesn't work + // config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); - config.setInitKnowledgeSource(false); - updateAll(); - } + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out.println("ABC: " + config.getComponentManager().getComponentName(sources.get(0))); - /** - * after this, next tab can be used - */ - public void init() { - System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); - System.out.println("isSetURL: " + config.isSetURL()); - if (config.getKnowledgeSource() != null && config.isSetURL()) { - try { - config.getKnowledgeSource().init(); - config.setInitKnowledgeSource(true); - System.out.println("init KnowledgeSource"); - startGUI.updateTabColors(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } + config.setInitKnowledgeSource(false); + updateAll(); } - } - /** - * updateAll - */ - public void updateAll() { - updateComboBox(); - updateOptionPanel(); - updateInitButtonColor(); - } - - /** - * set ComboBox to selected class - */ - public void updateComboBox() { - if (config.getKnowledgeSource() != null) - for (int i = 0; i < sources.size(); i++) - if (config.getKnowledgeSource().getClass().equals( - config.getComponentManager().getKnowledgeSources().get( - i))) { - cb.setSelectedIndex(i); + /** + * after this, next tab can be used + */ + public void init() { + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out.println("isSetURL: " + config.isSetURL()); + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } } - this.choosenClassIndex = cb.getSelectedIndex(); - } + } - /** - * update OptionPanel with new selection - */ - public void updateOptionPanel() { - optionPanel.update(config.getKnowledgeSource(), config - .getOldKnowledgeSource(), sources.get(choosenClassIndex)); - } + /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } - /** - * make init-button red if you have to click - */ - public void updateInitButtonColor() { - if (!config.isInitKnowledgeSource()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getKnowledgeSource() != null) + for (int i = 0; i < sources.size(); i++) + if (config.getKnowledgeSource().getClass().equals( + config.getComponentManager().getKnowledgeSources().get(i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + /** + * update OptionPanel with new selection + */ + public void updateOptionPanel() { + optionPanel.update(config.getKnowledgeSource(), config.getOldKnowledgeSource(), sources + .get(choosenClassIndex)); + } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitKnowledgeSource()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -39,122 +39,118 @@ */ public class LearningAlgorithmPanel extends JPanel implements ActionListener { - private static final long serialVersionUID = 8721490771860452959L; + private static final long serialVersionUID = 8721490771860452959L; - private Config config; - private StartGUI startGUI; - private List<Class<? extends LearningAlgorithm>> learners; - private JPanel choosePanel = new JPanel(); - private OptionPanel optionPanel; - private JPanel initPanel = new JPanel(); - private JButton initButton, autoInitButton; - private String[] cbItems = {}; - private JComboBox cb = new JComboBox(cbItems); - private int choosenClassIndex; + private Config config; + private StartGUI startGUI; + private List<Class<? extends LearningAlgorithm>> learners; + private JPanel choosePanel = new JPanel(); + private OptionPanel optionPanel; + private JPanel initPanel = new JPanel(); + private JButton initButton, autoInitButton; + private String[] cbItems = {}; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; - LearningAlgorithmPanel(Config config, StartGUI startGUI) { - super(new BorderLayout()); + LearningAlgorithmPanel(Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - learners = config.getComponentManager().getLearningAlgorithms(); + this.config = config; + this.startGUI = startGUI; + learners = config.getComponentManager().getLearningAlgorithms(); - initButton = new JButton("Init LearingAlgorithm"); - initButton.addActionListener(this); - initPanel.add(initButton); - initButton.setEnabled(true); - autoInitButton = new JButton("Set"); - autoInitButton.addActionListener(this); + initButton = new JButton("Init LearingAlgorithm"); + initButton.addActionListener(this); + initPanel.add(initButton); + initButton.setEnabled(true); + autoInitButton = new JButton("Set"); + autoInitButton.addActionListener(this); - // add into comboBox - for (int i = 0; i < learners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - learners.get(i))); - } + // add into comboBox + for (int i = 0; i < learners.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); + } - choosePanel.add(cb); - choosePanel.add(autoInitButton); - cb.addActionListener(this); + choosePanel.add(cb); + choosePanel.add(autoInitButton); + cb.addActionListener(this); - optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), - config.getOldLearningAlgorithm(), learners - .get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), config + .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - updateInitButtonColor(); - } - - public void actionPerformed(ActionEvent e) { - // read selected Class - // choosenClassIndex = cb.getSelectedIndex(); - if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); - config.setInitLearningAlgorithm(false); - setLearningAlgorithm(); + updateInitButtonColor(); } - if (e.getSource() == autoInitButton) - setLearningAlgorithm(); + public void actionPerformed(ActionEvent e) { + // read selected Class + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitLearningAlgorithm(false); + setLearningAlgorithm(); + } - if (e.getSource() == initButton) - init(); - } + if (e.getSource() == autoInitButton) + setLearningAlgorithm(); - /** - * after this, you can change widgets - */ - public void setLearningAlgorithm() { - if (config.getLearningProblem() != null - && config.getReasoningService() != null) { - try { - config.setLearningAlgorithm(config.getComponentManager() - .learningAlgorithm(learners.get(choosenClassIndex), - config.getLearningProblem(), - config.getReasoningService())); - updateOptionPanel(); - } catch (LearningProblemUnsupportedException e) { - e.printStackTrace(); - } + if (e.getSource() == initButton) + init(); } - } - /** - * after this, next tab can be used - */ - public void init() { - setLearningAlgorithm(); - if (config.getLearningProblem() != null) { - try { - config.getLearningAlgorithm().init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - config.setInitLearningAlgorithm(true); - System.out.println("init LearningAlgorithm"); - startGUI.updateTabColors(); + /** + * after this, you can change widgets + */ + public void setLearningAlgorithm() { + if (config.getLearningProblem() != null && config.getReasoningService() != null) { + try { + config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm( + learners.get(choosenClassIndex), config.getLearningProblem(), + config.getReasoningService())); + updateOptionPanel(); + } catch (LearningProblemUnsupportedException e) { + e.printStackTrace(); + } + } } - } - /** - * update OptionPanel with new selection - */ - public void updateOptionPanel() { - // update OptionPanel - optionPanel.update(config.getLearningAlgorithm(), config - .getOldLearningAlgorithm(), learners.get(choosenClassIndex)); - } + /** + * after this, next tab can be used + */ + public void init() { + setLearningAlgorithm(); + if (config.getLearningProblem() != null) { + try { + config.getLearningAlgorithm().init(); + } catch (ComponentInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + config.setInitLearningAlgorithm(true); + System.out.println("init LearningAlgorithm"); + startGUI.updateTabColors(); + } + } - /** - * make init-button red if you have to click - */ - public void updateInitButtonColor() { - if (!config.isInitLearningAlgorithm()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } + /** + * update OptionPanel with new selection + */ + public void updateOptionPanel() { + // update OptionPanel + optionPanel.update(config.getLearningAlgorithm(), config.getOldLearningAlgorithm(), + learners.get(choosenClassIndex)); + } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitLearningAlgorithm()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -38,118 +38,116 @@ */ public class LearningProblemPanel extends JPanel implements ActionListener { - private static final long serialVersionUID = -3819627680918930203L; + private static final long serialVersionUID = -3819627680918930203L; - private Config config; - private StartGUI startGUI; - private List<Class<? extends LearningProblem>> problems; - private String[] lpBoxItems = {}; - private JComboBox cb = new JComboBox(lpBoxItems); - private JPanel choosePanel = new JPanel(); - private OptionPanel optionPanel; - private JPanel initPanel = new JPanel(); - private JButton initButton, setButton; - private int choosenClassIndex; + private Config config; + private StartGUI startGUI; + private List<Class<? extends LearningProblem>> problems; + private String[] lpBoxItems = {}; + private JComboBox cb = new JComboBox(lpBoxItems); + private JPanel choosePanel = new JPanel(); + private OptionPanel optionPanel; + private JPanel initPanel = new JPanel(); + private JButton initButton, setButton; + private int choosenClassIndex; - LearningProblemPanel(final Config config, StartGUI startGUI) { - super(new BorderLayout()); + LearningProblemPanel(final Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - problems = config.getComponentManager().getLearningProblems(); + this.config = config; + this.startGUI = startGUI; + problems = config.getComponentManager().getLearningProblems(); - initButton = new JButton("Init LearningProblem"); - initButton.addActionListener(this); - initPanel.add(initButton); - initButton.setEnabled(true); - setButton = new JButton("Set"); - setButton.addActionListener(this); - choosePanel.add(cb); - choosePanel.add(setButton); - cb.addActionListener(this); + initButton = new JButton("Init LearningProblem"); + initButton.addActionListener(this); + initPanel.add(initButton); + initButton.setEnabled(true); + setButton = new JButton("Set"); + setButton.addActionListener(this); + choosePanel.add(cb); + choosePanel.add(setButton); + cb.addActionListener(this); - // add into comboBox - for (int i = 0; i < problems.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - problems.get(i))); - } + // add into comboBox + for (int i = 0; i < problems.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(problems.get(i))); + } - // read choosen LearningProblem - choosenClassIndex = cb.getSelectedIndex(); + // read choosen LearningProblem + choosenClassIndex = cb.getSelectedIndex(); - optionPanel = new OptionPanel(config, config.getLearningProblem(), - config.getOldLearningProblem(), problems.get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getLearningProblem(), config + .getOldLearningProblem(), problems.get(choosenClassIndex)); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - choosenClassIndex = cb.getSelectedIndex(); - // setLearningProblem(); - updateInitButtonColor(); - } - - public void actionPerformed(ActionEvent e) { - // read selected LearningProblemClass - if (choosenClassIndex != cb.getSelectedIndex()) { - this.choosenClassIndex = cb.getSelectedIndex(); - config.setInitLearningProblem(false); - setLearningProblem(); + choosenClassIndex = cb.getSelectedIndex(); + // setLearningProblem(); + updateInitButtonColor(); } - if (e.getSource() == setButton) - setLearningProblem(); + public void actionPerformed(ActionEvent e) { + // read selected LearningProblemClass + if (choosenClassIndex != cb.getSelectedIndex()) { + this.choosenClassIndex = cb.getSelectedIndex(); + config.setInitLearningProblem(false); + setLearningProblem(); + } - if (e.getSource() == initButton) - init(); - } + if (e.getSource() == setButton) + setLearningProblem(); - /** - * after this, you can change widgets - */ - private void setLearningProblem() { - if (config.isInitReasoner()) { - config.setLearningProblem(config.getComponentManager() - .learningProblem(problems.get(choosenClassIndex), - config.getReasoningService())); - startGUI.updateTabColors(); - updateOptionPanel(); + if (e.getSource() == initButton) + init(); } - } - /** - * after this, next tab can be used - */ - private void init() { - setLearningProblem(); - if (config.getReasoner() != null && config.getLearningProblem() != null) { - try { - config.getLearningProblem().init(); - config.setInitLearningProblem(true); - System.out.println("init LearningProblem"); - startGUI.updateTabColors(); - } catch (ComponentInitException e) { - e.printStackTrace(); - } + /** + * after this, you can change widgets + */ + private void setLearningProblem() { + if (config.isInitReasoner()) { + config.setLearningProblem(config.getComponentManager().learningProblem( + problems.get(choosenClassIndex), config.getReasoningService())); + startGUI.updateTabColors(); + updateOptionPanel(); + } } - } - /** - * update OptionPanel with new selection - */ - private void updateOptionPanel() { - // update OptionPanel - optionPanel.update(config.getLearningProblem(), config - .getOldLearningProblem(), problems.get(choosenClassIndex)); - } + /** + * after this, next tab can be used + */ + private void init() { + setLearningProblem(); + if (config.getReasoner() != null && config.getLearningProblem() != null) { + try { + config.getLearningProblem().init(); + config.setInitLearningProblem(true); + System.out.println("init LearningProblem"); + startGUI.updateTabColors(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + } - /** - * make init-button red if you have to click - */ - public void updateInitButtonColor() { - if (!config.isInitLearningProblem()) { - initButton.setForeground(Color.RED); - } else - initButton.setForeground(Color.BLACK); - } + /** + * update OptionPanel with new selection + */ + private void updateOptionPanel() { + // update OptionPanel + optionPanel.update(config.getLearningProblem(), config.getOldLearningProblem(), problems + .get(choosenClassIndex)); + } + + /** + * make init-button red if you have to click + */ + public void updateInitButtonColor() { + if (!config.isInitLearningProblem()) { + initButton.setForeground(Color.RED); + } else + initButton.setForeground(Color.BLACK); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -43,105 +43,100 @@ */ public class OptionPanel extends JPanel { - private static final long serialVersionUID = -3053205578443575240L; - private Config config; - private Class<? extends Component> componentOption; - private List<ConfigOption<?>> optionList; - private JPanel centerPanel = new JPanel(); - private Component component; - private Component oldComponent; - private GridBagLayout gridBagLayout = new GridBagLayout(); - private GridBagConstraints constraints = new GridBagConstraints(); + private static final long serialVersionUID = -3053205578443575240L; + private Config config; + private Class<? extends Component> componentOption; + private List<ConfigOption<?>> optionList; + private JPanel centerPanel = new JPanel(); + private Component component; + private Component oldComponent; + private GridBagLayout gridBagLayout = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); - public OptionPanel(Config config, Component component, - Component oldComponent, Class<? extends Component> componentOption) { - super(new BorderLayout()); + public OptionPanel(Config config, Component component, Component oldComponent, + Class<? extends Component> componentOption) { + super(new BorderLayout()); - this.config = config; - this.component = component; - this.oldComponent = oldComponent; - this.componentOption = componentOption; + this.config = config; + this.component = component; + this.oldComponent = oldComponent; + this.componentOption = componentOption; - optionList = ComponentManager.getConfigOptions(componentOption); + optionList = ComponentManager.getConfigOptions(componentOption); - // define GridBagLayout - centerPanel.setLayout(gridBagLayout); - constraints.anchor = GridBagConstraints.NORTHWEST; + // define GridBagLayout + centerPanel.setLayout(gridBagLayout); + constraints.anchor = GridBagConstraints.NORTHWEST; - // add scrollPane - JScrollPane centerScroller = new JScrollPane(centerPanel); - centerScroller.setPreferredSize(new Dimension(400, 200)); - // add Panels - add(centerScroller, BorderLayout.CENTER); - // show widgets - showWidgets(); - } + // add scrollPane + JScrollPane centerScroller = new JScrollPane(centerPanel); + centerScroller.setPreferredSize(new Dimension(400, 200)); + // add Panels + add(centerScroller, BorderLayout.CENTER); + // show widgets + showWidgets(); + } - /** update this OptionPanel */ - public void update(Component component, Component oldComponent, - Class<? extends Component> componentOption) { - this.component = component; - this.oldComponent = oldComponent; - this.componentOption = componentOption; - showWidgets(); + /** update this OptionPanel */ + public void update(Component component, Component oldComponent, + Class<? extends Component> componentOption) { + this.component = component; + this.oldComponent = oldComponent; + this.componentOption = componentOption; + showWidgets(); - } + } - /** - * Define here what core.config.class is what type of widget. - * WidgetPanelDefault is for none defined classes. - */ - private void showWidgets() { - JPanel widgetPanel; - optionList = ComponentManager.getConfigOptions(componentOption); - centerPanel.removeAll(); // clear panel - for (int i = 0; i < optionList.size(); i++) { - buildConstraints(constraints, 0, i, 1, 1, 0, 0); - if (optionList.get(i).getClass().toString().contains( - "IntegerConfigOption")) { - widgetPanel = new WidgetPanelInteger(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "BooleanConfigOption")) { - widgetPanel = new WidgetPanelBoolean(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "DoubleConfigOption")) { - widgetPanel = new WidgetPanelDouble(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "StringConfigOption")) { - widgetPanel = new WidgetPanelString(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "StringSetConfigOption")) { - widgetPanel = new WidgetPanelStringSet(config, component, - oldComponent, componentOption, optionList.get(i)); - } else if (optionList.get(i).getClass().toString().contains( - "StringTupleListConfigOption")) { - widgetPanel = new WidgetPanelStringTupleList(config, component, - oldComponent, componentOption, optionList.get(i)); - } else { - widgetPanel = new WidgetPanelDefault(config, component, - /* oldComponent, */componentOption, optionList.get(i)); - } - gridBagLayout.setConstraints(widgetPanel, constraints); - centerPanel.add(widgetPanel); + /** + * Define here what core.config.class is what type of widget. + * WidgetPanelDefault is for none defined classes. + */ + private void showWidgets() { + JPanel widgetPanel; + optionList = ComponentManager.getConfigOptions(componentOption); + centerPanel.removeAll(); // clear panel + for (int i = 0; i < optionList.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 0, 0); + if (optionList.get(i).getClass().toString().contains("IntegerConfigOption")) { + widgetPanel = new WidgetPanelInteger(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("BooleanConfigOption")) { + widgetPanel = new WidgetPanelBoolean(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("DoubleConfigOption")) { + widgetPanel = new WidgetPanelDouble(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("StringConfigOption")) { + widgetPanel = new WidgetPanelString(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains("StringSetConfigOption")) { + widgetPanel = new WidgetPanelStringSet(config, component, oldComponent, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "StringTupleListConfigOption")) { + widgetPanel = new WidgetPanelStringTupleList(config, component, oldComponent, + componentOption, optionList.get(i)); + } else { + widgetPanel = new WidgetPanelDefault(config, component, + /* oldComponent, */componentOption, optionList.get(i)); + } + gridBagLayout.setConstraints(widgetPanel, constraints); + centerPanel.add(widgetPanel); + } + centerPanel.updateUI(); // update graphic } - centerPanel.updateUI(); // update graphic - } - /** - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, - int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; - } + /** + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, + int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-19 15:04:01 UTC (rev 612) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-19 15:54:02 UTC (rev 613) @@ -39,126 +39,124 @@ */ public class ReasonerPanel extends JPanel implements ActionListener { - private static final long serialVersionUID = -7678275020058043937L; + private static final long serialVersionUID = -7678275020058043937L; - private Config config; - private StartGUI startGUI; - private List<Class<? extends ReasonerComponent>> reasoners; - private JPanel choosePanel = new JPanel(); - private JPanel initPanel = new JPanel(); - private OptionPanel optionPanel; - private JButton initButton, setButton; - private String[] cbItems = {}; - private JComboBox cb = new JComboBox(cbItems); - private int choosenClassIndex; + private Config config; + private StartGUI startGUI; + private List<Class<? extends ReasonerComponent>> reasoners; + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); + private OptionPanel optionPanel; + private JButton initButton, setButton; + private String[] cbItems = {}; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; - ReasonerPanel(final Config config, StartGUI startGUI) { - super(new BorderLayout()); + ReasonerPanel(final Config config, StartGUI startGUI) { + super(new BorderLayout()); - this.config = config; - this.startGUI = startGUI; - reasoners = config.getComponentManager().getReasonerComponents(); + this.config = config; + this.startGUI = startGUI; + reasoners = config.getComponentManager().getReasonerComponents(); - initButton = new JButton("Init Reasoner"); - initButton.addActionListener(this); - initPanel.add(initButton); - initButton.setEnabled(true); - setButton = new JButton("Set"); - setButton.addActionListener(this); + initButton = new JButton("Init Reasoner"); + initButton.addActionListener(this); + initPanel.add(initButton); + initButton.setEnabled(true); + setButton = new JButton("Set"); + setButton.addActionListener(this); - choosePanel.add(cb); + choosePanel.add(cb); - // add into comboBox - for (int i = 0; i < reasoners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName( - reasoners.get(i))); - } + // add into comboBox + for (int i = 0; i < reasoners.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName(reasoners.get(i))); + } - optionPanel = new OptionPanel(config, config.getReasoner(), config - .getOldReasonerSet(), reasoners.get(choosenClassIndex)); + optionPanel = new OptionPanel(config, config.getReasoner(), config.getOldReasonerSet(), + reasoners.get(choosenClassIndex)); - choosePanel.add(setButton); - cb.addActionListener(this); + choosePanel.add(setButton); + cb.addActionListener(this); - add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(choosePanel, BorderLayout.PAGE_START); + add(optionPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); - choosenClassIndex = cb.getSelectedIndex(); - setReasoner(); - updateInitButtonColor(); - } + choosenClassIndex = cb.getSelectedIndex(); + setReasoner(); + updateInitButtonColor(); + } - public void actionPerformed(ActionEvent e) { - // read selected Class - // choosenClassIndex = cb.getSelectedIndex(); - if (choosenClassIndex != cb.getSelectedIndex()) { - choosenClassIndex = cb.getSelectedIndex(); - config.setInitReasoner(false); - setReasoner(); + public void actionPerformed(ActionEvent e) { + // read selected Class + // choosenClassIndex = cb.getSelectedIndex(); + if (choosenClassIndex != cb.getSelectedIndex()) { + choosenClassIndex = cb.getSelectedIndex(); + config.setInitReasoner(false); + setReasoner(); + } + + if (e.getSource() == setButton) { + config.setInitReasoner(false); + setReasoner(); + } + + if (e.getSource() == initButton) + init(); } - if (e.getSource() == setButton) { - config.setInitReasoner(false); - setReasoner(); + /** + * after this, you can change widgets + */ + public void setReasoner() { + if (config.isInitKnowledgeSource()) { + config.setReasoner(config.getComponentManager().reasoner( + reasoners.get(choosenClassIndex), config.getKnowledgeSource())); + updateOptionPanel(); + startGUI.updateTabColors(); + config.setInitReasoner(false); + updateInitButtonColor(); + } } - if (e.getSource() == initButton) - init(); - } + /** + * after this, next tab can be used + */ + public void init() { + setReasoner(); + if (config.getKnowledgeSource() != null && config.getReasoner() != null) { + try { + config.getReasoner().init(); + System.out.println("init Reasoner"); + // set ReasoningService + config.setReasoningService(config.getComponentManager().reasoningService( + config.getReasoner())); + System.out.println("init ReasoningService"); + config.setInitReasoner(true); + startGUI.update... [truncated message content] |
From: <ton...@us...> - 2008-02-19 15:04:42
|
Revision: 612 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=612&view=rev Author: tonytacker Date: 2008-02-19 07:04:01 -0800 (Tue, 19 Feb 2008) Log Message: ----------- first try to load *.config Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-02-19 15:04:01 UTC (rev 612) @@ -27,6 +27,8 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.ReasonerComponent; +// import org.dllearner.core.Component; + /** * Config save all together used variables: ComponentManager, KnowledgeSource, * Reasoner, ReasoningService, LearningProblem, LearningAlgorithm; also inits of @@ -38,7 +40,6 @@ private ComponentManager cm = ComponentManager.getInstance(); private KnowledgeSource source; private KnowledgeSource oldSource; - private String uri; private ReasonerComponent reasoner; private ReasonerComponent oldReasoner; private ReasoningService rs; @@ -60,23 +61,18 @@ /** * It is necessary for init KnowledgeSource. * - * @return URI + * @return true, if url was set otherwise false */ - public String getURI() { - return this.uri; + public Boolean isSetURL() { + // return this.isURL; + // String value = (String) cm.getConfigOptionValue(source, "url"); + if (cm.getConfigOptionValue(source, "url") != null) + return true; + else + return false; } /** - * Set an URI. - * - * @param uri - * it's a Link like "http://example.com" or "file://myfile" - */ - public void setURI(String uri) { - this.uri = uri; - } - - /** * Set KnowledgeSource. * * @param knowledgeSource Added: trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/ConfigLoad.java 2008-02-19 15:04:01 UTC (rev 612) @@ -0,0 +1,161 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import java.io.File; // import java.net.URL; +// import java.util.List; +// import java.util.Map; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.KnowledgeSource; // import +// org.dllearner.core.LearningProblem; +// import org.dllearner.core.ReasoningService; +// import org.dllearner.core.LearningAlgorithm; +// import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.config.StringConfigOption; +import org.dllearner.parser.ConfParser; +import org.dllearner.kb.KBFile; +import org.dllearner.kb.OWLFile; +import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.core.Component; + +/** + * Open a config file. + * + * @author Tilo Hielscher + */ +public class ConfigLoad { + + private File file; + private Config config; + private StartGUI startGUI; + + private Class<? extends KnowledgeSource> componentOption; + + /** + * set config and startGUI + * + * @param config + * @param startGUI + */ + public ConfigLoad(Config config, StartGUI startGUI) { + this.config = config; + this.startGUI = startGUI; + } + + /** + * set your file to read + * + * @param file + * @return true if file exist + */ + public boolean openFile(File file) { + this.file = file; + return file.exists(); + } + + /** + * parse file + */ + public void startParser() { + if (this.file.exists()) { + ConfParser parser = ConfParser.parseFile(file); + // KNOWLEDGE SOURCE + // filename + String value = parser.getFunctionCalls().get("import").get(0) + .get(0); + // only first of imported files + if (value.endsWith(".kb")) { + componentOption = KBFile.class; + } else if (value.endsWith(".owl")) { + componentOption = OWLFile.class; + } else if (parser.getFunctionCalls().get("import").get(0).size() > 1) { + if (parser.getFunctionCalls().get("import").get(0).get(1) + .equalsIgnoreCase("sparql")) { + System.out.println("IT IS SPARQL"); + componentOption = SparqlKnowledgeSource.class; + } + } + // check if class was set + if (componentOption != null) + config.setKnowledgeSource(config.getComponentManager() + .knowledgeSource(componentOption)); + // set url + // value = parser.getFunctionCalls().get("import").get(0).get(0); + value = makeURL(value); + Component component = config.getKnowledgeSource(); + StringConfigOption specialOption = (StringConfigOption) config + .getComponentManager().getConfigOption(componentOption, + "url"); + try { + ConfigEntry<String> specialEntry = new ConfigEntry<String>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set String: " + "url" + " = " + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + // startGUI.updateTabColors(); + // init + if (config.getKnowledgeSource() != null && config.isSetURL()) { + try { + config.getKnowledgeSource().init(); + config.setInitKnowledgeSource(true); + System.out.println("init KnowledgeSource"); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + + // update + startGUI.updateTabColors(); + + System.out.println("reasoner: " + + parser.getConfOptionsByName("reasoner")); + System.out.println("confoptions: " + parser.getConfOptions()); + System.out.println("posExamples: " + parser.getPositiveExamples()); + System.out.println("confoptionbyname: " + + parser.getConfOptionsByName()); + + // do it + // only url from first entry, ignore others + // parser.getFunctionCalls().get("import").get(0); + } + } + + /** + * If value is not a valid url and starts with "http://" or "file://" then + * add "file://" + * + * @param value + * is a string + * @return a valid url made from value + */ + public String makeURL(String value) { + if (!value.startsWith("http://") && !value.startsWith("file://")) + value = "file://".concat(file.getPath().replace(file.getName(), "") + .concat(value)); + return value; + } + +} Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-02-19 15:04:01 UTC (rev 612) @@ -29,9 +29,10 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.KnowledgeSource; +import org.dllearner.kb.*; /** - * KnowledgeSourcePanel, tab 1. Choose Source, change Options and final initiate + * KnowledgeSourcePanel, tab 0. Choose Source, change Options and final initiate * KnowledgeSource. * * @author Tilo Hielscher @@ -59,6 +60,8 @@ this.startGUI = startGUI; sources = config.getComponentManager().getKnowledgeSources(); + System.out.println("SOURCES: " + sources); + setButton = new JButton("Set"); setButton.addActionListener(this); initButton = new JButton("Init KnowledgeSource"); @@ -74,6 +77,8 @@ choosePanel.add(cb); choosePanel.add(setButton); + choosenClassIndex = cb.getSelectedIndex(); + optionPanel = new OptionPanel(config, config.getKnowledgeSource(), config.getOldKnowledgeSource(), sources.get(choosenClassIndex)); initPanel.add(initButton); @@ -82,9 +87,8 @@ add(optionPanel, BorderLayout.CENTER); add(initPanel, BorderLayout.PAGE_END); - choosenClassIndex = cb.getSelectedIndex(); - setSource(); - updateInitButtonColor(); + // setSource(); + updateAll(); } public void actionPerformed(ActionEvent e) { @@ -92,13 +96,13 @@ // choosenClassIndex = cb.getSelectedIndex(); if (choosenClassIndex != cb.getSelectedIndex()) { choosenClassIndex = cb.getSelectedIndex(); - config.setURI(null); // default null config.setInitKnowledgeSource(false); setSource(); } - if (e.getSource() == setButton) + if (e.getSource() == setButton) { setSource(); + } if (e.getSource() == initButton) init(); @@ -108,16 +112,31 @@ * after this, you can change widgets */ public void setSource() { - config.setKnowledgeSource(config.getComponentManager().knowledgeSource( - sources.get(choosenClassIndex))); - updateOptionPanel(); + System.out.println("cm: " + config.getComponentManager()); + System.out.println("setSOURCE :" + sources.get(choosenClassIndex)); + + config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); +// KBFile.class doesn't work +// config.setKnowledgeSource(config.getComponentManager().knowledgeSource(KBFile.class)); + + + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out + .println("ABC: " + + config.getComponentManager().getComponentName( + sources.get(0))); + + config.setInitKnowledgeSource(false); + updateAll(); } /** * after this, next tab can be used */ public void init() { - if (config.getKnowledgeSource() != null && config.getURI() != null) { + System.out.println("KNOWLEDGE_SOURCE: " + config.getKnowledgeSource()); + System.out.println("isSetURL: " + config.isSetURL()); + if (config.getKnowledgeSource() != null && config.isSetURL()) { try { config.getKnowledgeSource().init(); config.setInitKnowledgeSource(true); @@ -130,6 +149,29 @@ } /** + * updateAll + */ + public void updateAll() { + updateComboBox(); + updateOptionPanel(); + updateInitButtonColor(); + } + + /** + * set ComboBox to selected class + */ + public void updateComboBox() { + if (config.getKnowledgeSource() != null) + for (int i = 0; i < sources.size(); i++) + if (config.getKnowledgeSource().getClass().equals( + config.getComponentManager().getKnowledgeSources().get( + i))) { + cb.setSelectedIndex(i); + } + this.choosenClassIndex = cb.getSelectedIndex(); + } + + /** * update OptionPanel with new selection */ public void updateOptionPanel() { @@ -146,4 +188,5 @@ } else initButton.setForeground(Color.BLACK); } + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-02-19 15:04:01 UTC (rev 612) @@ -32,7 +32,7 @@ import org.dllearner.core.LearningProblemUnsupportedException; /** - * LearningAlgorithmPanel, tab 4. Choose LearningAlgorithm, change Options and + * LearningAlgorithmPanel, tab 3. Choose LearningAlgorithm, change Options and * final initiate LearningAlgorithm. * * @author Tilo Hielscher Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-02-19 15:04:01 UTC (rev 612) @@ -31,7 +31,7 @@ import org.dllearner.core.LearningProblem; /** - * LearningProblemPanel tab 3. Choose LearingProblem, change Options and final + * LearningProblemPanel tab 2. Choose LearingProblem, change Options and final * initiate LearningProblem. * * @author Tilo Hielscher Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-02-19 15:04:01 UTC (rev 612) @@ -32,7 +32,7 @@ import org.dllearner.core.ReasonerComponent; /** - * ReasonerPanel, tab 2. Choose Resoner, change Options and final initiate + * ReasonerPanel, tab 1. Choose Resoner, change Options and final initiate * Reasoner and ReasoningService. * * @author Tilo Hielscher Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-02-19 15:04:01 UTC (rev 612) @@ -32,6 +32,9 @@ import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import java.io.File; +import javax.swing.filechooser.FileFilter; + /** * StartGUI * @@ -44,6 +47,7 @@ private JTabbedPane tabPane = new JTabbedPane(); private Config config = new Config(); + private ConfigLoad configLoad = new ConfigLoad(config, this);; private KnowledgeSourcePanel tab0; private ReasonerPanel tab1; @@ -61,10 +65,11 @@ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationByPlatform(true); this.setSize(800, 600); - + // set icon - setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("icon.gif"))); - + setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage( + this.getClass().getResource("icon.gif"))); + tab0 = new KnowledgeSourcePanel(config, this); tab1 = new ReasonerPanel(config, this); tab2 = new LearningProblemPanel(config, this); @@ -110,14 +115,37 @@ } public void actionPerformed(ActionEvent e) { + // open config file if (e.getSource() == openItem) { - System.out.println("openItem was pressed"); + // file dialog + JFileChooser fc = new JFileChooser(new File("examples/")); + // FileFilter only *.conf + fc.addChoosableFileFilter(new FileFilter() { + public boolean accept(File f) { + if (f.isDirectory()) + return true; + return f.getName().toLowerCase().endsWith(".conf"); + } + + public String getDescription() { + return "*.conf"; // name for filter + } + }); + if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + System.out.println("FILE: " + fc.getSelectedFile()); + configLoad.openFile(fc.getSelectedFile()); + configLoad.startParser(); + } } + // save config file if (e.getSource() == saveItem) { System.out.println("saveItem was pressed"); } } + /** + * Update colors of tabulators; red should be clicked, black for OK. + */ public void updateTabColors() { if (config.isInitKnowledgeSource()) tabPane.setForegroundAt(0, Color.BLACK); @@ -138,7 +166,7 @@ tabPane.setForegroundAt(3, Color.RED); tabPane.setForegroundAt(4, Color.RED); } - tab0.updateInitButtonColor(); + tab0.updateAll(); tab1.updateInitButtonColor(); tab2.updateInitButtonColor(); tab3.updateInitButtonColor(); Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-19 14:28:23 UTC (rev 611) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelString.java 2008-02-19 15:04:01 UTC (rev 612) @@ -84,8 +84,6 @@ if (returnVal == JFileChooser.APPROVE_OPTION) { value = fc.getSelectedFile().toString(); stringField.setText(value); - config.setURI(value); // save variable - System.out.println("value: " + config.getURI()); } } setEntry(); @@ -93,7 +91,6 @@ // necessary for init knowledge source if (configOption.getName().equalsIgnoreCase("url") && !value.equalsIgnoreCase("")) { - config.setURI(value); } } } @@ -180,7 +177,7 @@ System.out.println("String: not valid value"); } - /* + /** * Widget filename getName() == filename you should open a file dialog in * ActionPerformed */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-19 14:28:37
|
Revision: 611 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=611&view=rev Author: jenslehmann Date: 2008-02-19 06:28:23 -0800 (Tue, 19 Feb 2008) Log Message: ----------- - continued carcinogenesis mapper - fixed bug in KB file (relevant for component creation in ComponentManager) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java Modified: trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-19 13:20:01 UTC (rev 610) +++ trunk/src/dl-learner/org/dllearner/examples/Carcinogenesis.java 2008-02-19 14:28:23 UTC (rev 611) @@ -73,79 +73,77 @@ public class Carcinogenesis { private static URI ontologyURI = URI.create("http://dl-learner.org/carcinogenesis"); + + // directory of Prolog files + private static String prologDirectory = "examples/carcinogenesis/prolog/"; // mapping of symbols to names of chemical elements - private static Map<String,String> chemElements; - + private static Map<String, String> chemElements; + // types of atoms and bonds private static Set<String> atomTypes = new TreeSet<String>(); private static Set<String> bondTypes = new TreeSet<String>(); - + // we need a counter for bonds, because they are instances in OWL // but not in Prolog private static int bondNr = 0; - + /** * @param args * No arguments supported. + * @throws IOException + * @throws FileNotFoundException + * @throws ParseException */ - public static void main(String[] args) { + public static void main(String[] args) throws FileNotFoundException, IOException, + ParseException { - String prologDirectory = "examples/carcinogenesis/prolog/"; String[] files = new String[] { "ames.pl", "atoms.pl", "bonds.pl", "gentoxprops.pl", "ind_nos.pl", "ind_pos.pl", "newgroups.pl", // "train.b" => not a pure Prolog file but Progol/Aleph specific }; File owlFile = new File("examples/carcinogenesis/pte.owl"); - + Program program = null; long startTime, duration; String time; - try { - // reading files - System.out.print("Reading in carcinogenesis Prolog files ... "); - startTime = System.nanoTime(); - String content = ""; - for (String file : files) { - content += Files.readFile(new File(prologDirectory + file)); - } - duration = System.nanoTime() - startTime; - time = Helper.prettyPrintNanoSeconds(duration, false, false); - System.out.println("OK (" + time + ")."); - - // parsing files - System.out.print("Parsing Prolog files ... "); - startTime = System.nanoTime(); - PrologParser pp = new PrologParser(); - program = pp.parseProgram(content); - duration = System.nanoTime() - startTime; - time = Helper.prettyPrintNanoSeconds(duration, false, false); - System.out.println("OK (" + time + ")."); - } catch (ParseException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); + // reading files + System.out.print("Reading in carcinogenesis Prolog files ... "); + startTime = System.nanoTime(); + String content = ""; + for (String file : files) { + content += Files.readFile(new File(prologDirectory + file)); } + duration = System.nanoTime() - startTime; + time = Helper.prettyPrintNanoSeconds(duration, false, false); + System.out.println("OK (" + time + ")."); + // parsing files + System.out.print("Parsing Prolog files ... "); + startTime = System.nanoTime(); + PrologParser pp = new PrologParser(); + program = pp.parseProgram(content); + duration = System.nanoTime() - startTime; + time = Helper.prettyPrintNanoSeconds(duration, false, false); + System.out.println("OK (" + time + ")."); + // prepare mapping - KB kb = new KB(); + KB kb = new KB(); createChemElementsMapping(); // create subclasses of atom NamedClass atomClass = getAtomicConcept("Atom"); - for(String element : chemElements.values()) { + for (String element : chemElements.values()) { NamedClass elClass = getAtomicConcept(element); SubClassAxiom sc = new SubClassAxiom(elClass, atomClass); kb.addAxiom(sc); } // define properties including domain and range // ... TODO ... - + // mapping clauses to axioms System.out.print("Mapping clauses to axioms ... "); - startTime = System.nanoTime(); + startTime = System.nanoTime(); ArrayList<Clause> clauses = program.getClauses(); for (Clause clause : clauses) { List<Axiom> axioms = mapClause(clause); @@ -154,7 +152,7 @@ } duration = System.nanoTime() - startTime; time = Helper.prettyPrintNanoSeconds(duration, false, false); - System.out.println("OK (" + time + ")."); + System.out.println("OK (" + time + ")."); // writing generated knowledge base System.out.print("Writing OWL file ... "); @@ -162,7 +160,27 @@ OWLAPIReasoner.exportKBToOWL(owlFile, kb, ontologyURI); duration = System.nanoTime() - startTime; time = Helper.prettyPrintNanoSeconds(duration, false, false); - System.out.println("OK (" + time + ")."); + System.out.println("OK (" + time + ")."); + + // generating conf files + File confTrainFile = new File("examples/carcinogenesis/train.conf"); + String confHeader = ""; + Files.appendFile(confTrainFile, confHeader); + + // generating training examples + File trainingFilePositives = new File(prologDirectory + "train.f"); + File trainingFileNegatives = new File(prologDirectory + "train.n"); + + List<Individual> posTrainExamples = getExamples(trainingFilePositives); + List<Individual> negTrainExamples = getExamples(trainingFileNegatives); + appendPosExamples(confTrainFile, posTrainExamples); + appendNegExamples(confTrainFile, negTrainExamples); + + // generating testExamples +// File confTestFile = new File("examples/carcinogenesis/test.conf"); +// File testFilePositives = new File(prologDirectory + "train.f"); +// File testFileNegatives = new File(prologDirectory + "train.n"); +// } private static List<Axiom> mapClause(Clause clause) { @@ -180,14 +198,14 @@ String type = head.getArgument(3).toPLString(); double charge = Double.parseDouble(head.getArgument(4).toPLString()); // relate compound and atom - ObjectPropertyAssertion ra = getRoleAssertion("hasAtom", compoundName, atomName); + ObjectPropertyAssertion ra = getRoleAssertion("hasAtom", compoundName, atomName); axioms.add(ra); // atom is made instance of the correct class String atomClass = getAtomClass(elementName, type); - ClassAssertionAxiom ca = getConceptAssertion(atomClass,atomName); + ClassAssertionAxiom ca = getConceptAssertion(atomClass, atomName); axioms.add(ca); // write subclass axiom if doesn't exist already - if(!atomTypes.contains(atomClass)) { + if (!atomTypes.contains(atomClass)) { NamedClass subClass = getAtomicConcept(atomClass); NamedClass superClass = getAtomicConcept(getFullElementName(elementName)); SubClassAxiom sc = new SubClassAxiom(subClass, superClass); @@ -195,9 +213,10 @@ atomTypes.add(atomClass); } // charge of atom - DatatypePropertyAssertion dpa = getDoubleDatatypePropertyAssertion(atomName, "charge", charge); + DatatypePropertyAssertion dpa = getDoubleDatatypePropertyAssertion(atomName, "charge", + charge); axioms.add(dpa); - } else if(headName.equals("bond")) { + } else if (headName.equals("bond")) { String compoundName = head.getArgument(0).toPLString(); String atom1Name = head.getArgument(1).toPLString(); String atom2Name = head.getArgument(2).toPLString(); @@ -207,10 +226,10 @@ ObjectPropertyAssertion op = getRoleAssertion("hasBond", compoundName, "bond" + bondNr); axioms.add(op); // make Bond-X subclass of Bond if that hasn't been done already - if(!bondTypes.contains(bondClass)) { + if (!bondTypes.contains(bondClass)) { NamedClass subClass = getAtomicConcept(bondClass); SubClassAxiom sc = new SubClassAxiom(subClass, getAtomicConcept("Bond")); - axioms.add(sc); + axioms.add(sc); bondTypes.add(bondClass); } // make e.g. bond382 instance of Bond-3 @@ -226,46 +245,77 @@ // print clauses which are not supported yet System.out.println("unsupported clause"); System.out.println(clause.toPLString()); - System.out.println(clause); + System.out.println(clause); } return axioms; } + + // takes a *.f or *.n file as input and returns the + // contained examples + private static List<Individual> getExamples(File file) throws FileNotFoundException, IOException, ParseException { + String content = Files.readFile(new File(prologDirectory + file)); + PrologParser pp = new PrologParser(); + Program programPos = pp.parseProgram(content); + List<Individual> ret = new LinkedList<Individual>(); + for(Clause c : programPos.getClauses()) { + String example = c.getHead().getArgument(0).toPLString(); + ret.add(getIndividual(example)); + } + return ret; + } + private static void appendPosExamples(File file, List<Individual> examples) { + StringBuffer content = new StringBuffer(); + for(Individual example : examples) { + content.append("+\""+example.toString()+"\""); + } + Files.appendFile(file, content.toString()); + } + + private static void appendNegExamples(File file, List<Individual> examples) { + StringBuffer content = new StringBuffer(); + for(Individual example : examples) { + content.append("-\""+example.toString()+"\""); + } + Files.appendFile(file, content.toString()); + } + private static String getAtomClass(String element, String atomType) { return getFullElementName(element) + "-" + atomType; } - + private static ClassAssertionAxiom getConceptAssertion(String concept, String i) { Individual ind = getIndividual(i); NamedClass c = getAtomicConcept(concept); - return new ClassAssertionAxiom(c,ind); + return new ClassAssertionAxiom(c, ind); } - + private static ObjectPropertyAssertion getRoleAssertion(String role, String i1, String i2) { Individual ind1 = getIndividual(i1); Individual ind2 = getIndividual(i2); ObjectProperty ar = getRole(role); - return new ObjectPropertyAssertion(ar,ind1,ind2); + return new ObjectPropertyAssertion(ar, ind1, ind2); } - - private static DoubleDatatypePropertyAssertion getDoubleDatatypePropertyAssertion(String individual, String datatypeProperty, double value) { + + private static DoubleDatatypePropertyAssertion getDoubleDatatypePropertyAssertion( + String individual, String datatypeProperty, double value) { Individual ind = getIndividual(individual); DatatypeProperty dp = getDatatypeProperty(datatypeProperty); - return new DoubleDatatypePropertyAssertion(dp,ind,value); - } - + return new DoubleDatatypePropertyAssertion(dp, ind, value); + } + private static Individual getIndividual(String name) { return new Individual(ontologyURI + "#" + name); - } - + } + private static ObjectProperty getRole(String name) { return new ObjectProperty(ontologyURI + "#" + name); - } - + } + private static DatatypeProperty getDatatypeProperty(String name) { return new DatatypeProperty(ontologyURI + "#" + name); - } - + } + private static NamedClass getAtomicConcept(String name) { return new NamedClass(ontologyURI + "#" + name); } @@ -274,15 +324,15 @@ // return corresponding element or throw an error if it // is not in the list String result = chemElements.get(abbreviation); - if(result == null) + if (result == null) throw new Error("Unknown element " + abbreviation); else - return result; - } - + return result; + } + // create chemical element list private static void createChemElementsMapping() { - chemElements = new HashMap<String,String>(); + chemElements = new HashMap<String, String>(); chemElements.put("as", "Arsenic"); chemElements.put("ba", "Barium"); chemElements.put("br", "Bromine"); Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-02-19 13:20:01 UTC (rev 610) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-02-19 14:28:23 UTC (rev 611) @@ -61,6 +61,13 @@ private KB kb; /** + * Default constructor (needed for reflection in ComponentManager). + */ + public KBFile() { + + } + + /** * Constructor allowing you to treat an already existing KB object * as a KBFile knowledge source. Use it sparingly, because the * standard way to create components is via This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-19 13:20:08
|
Revision: 610 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=610&view=rev Author: jenslehmann Date: 2008-02-19 05:20:01 -0800 (Tue, 19 Feb 2008) Log Message: ----------- extended jUnit reasoner test and fixed a bug which it revealed Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/KB.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Modified: trunk/src/dl-learner/org/dllearner/core/owl/KB.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/KB.java 2008-02-19 12:05:53 UTC (rev 609) +++ trunk/src/dl-learner/org/dllearner/core/owl/KB.java 2008-02-19 13:20:01 UTC (rev 610) @@ -106,6 +106,7 @@ for(String name : conceptNames) { ret.add(new NamedClass(name)); } + return ret; } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-02-19 12:05:53 UTC (rev 609) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-02-19 13:20:01 UTC (rev 610) @@ -21,10 +21,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.OutputStream; import java.nio.charset.Charset; import java.util.Iterator; import java.util.List; Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-19 12:05:53 UTC (rev 609) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-19 13:20:01 UTC (rev 610) @@ -118,9 +118,9 @@ private Set<Description> allowedConceptsInSubsumptionHierarchy; // primitives - Set<NamedClass> atomicConcepts; - Set<ObjectProperty> atomicRoles; - SortedSet<Individual> individuals; + Set<NamedClass> atomicConcepts = new TreeSet<NamedClass>(conceptComparator); + Set<ObjectProperty> atomicRoles = new TreeSet<ObjectProperty>(roleComparator); + SortedSet<Individual> individuals = new TreeSet<Individual>(); public OWLAPIReasoner(Set<KnowledgeSource> sources) { this.sources = sources; @@ -179,9 +179,6 @@ allImports.addAll(manager.getImportsClosure(ontology)); classes.addAll(ontology.getReferencedClasses()); properties.addAll(ontology.getReferencedObjectProperties()); - // does not seem to work => workaround: query all instances of Top - // maybe one can also query for instances of OWLObjectProperty, - // OWLClass, OWLIndividual owlIndividuals.addAll(ontology.getReferencedIndividuals()); } catch (OWLOntologyCreationException e) { e.printStackTrace(); @@ -192,6 +189,8 @@ // OWL API ontology } else { KB kb = source.toKB(); +// System.out.println(kb.toString(null,null)); + URI ontologyURI = URI.create("http://example.com"); OWLOntology ontology = null; try { @@ -200,6 +199,10 @@ e.printStackTrace(); } OWLAPIAxiomConvertVisitor.fillOWLOntology(manager, ontology, kb); + allImports.add(ontology); + atomicConcepts.addAll(kb.findAllAtomicConcepts()); + atomicRoles.addAll(kb.findAllAtomicRoles()); + individuals.addAll(kb.findAllIndividuals()); } } @@ -214,6 +217,8 @@ // instantiate Pellet reasoner reasoner = new org.mindswap.pellet.owlapi.Reasoner(manager); + // change log level to WARN for Pellet, because otherwise log + // output will be very large Logger pelletLogger = Logger.getLogger("org.mindswap.pellet"); pelletLogger.setLevel(Level.WARN); } @@ -257,13 +262,10 @@ // } // read in primitives - atomicConcepts = new TreeSet<NamedClass>(conceptComparator); for(OWLClass owlClass : classes) atomicConcepts.add(new NamedClass(owlClass.getURI().toString())); - atomicRoles = new TreeSet<ObjectProperty>(roleComparator); for(OWLObjectProperty owlProperty : properties) atomicRoles.add(new ObjectProperty(owlProperty.getURI().toString())); - individuals = new TreeSet<Individual>(); for(OWLIndividual owlIndividual : owlIndividuals) individuals.add(new Individual(owlIndividual.getURI().toString())); Modified: trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java 2008-02-19 12:05:53 UTC (rev 609) +++ trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java 2008-02-19 13:20:01 UTC (rev 610) @@ -19,6 +19,10 @@ */ package org.dllearner.test.junit; +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.SimpleLayout; import org.junit.runner.JUnitCore; /** @@ -33,6 +37,15 @@ public class AllTestsRunner { public static void main(String[] args) { + + // create logger + SimpleLayout layout = new SimpleLayout(); + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + Logger logger = Logger.getRootLogger(); + logger.removeAllAppenders(); + logger.addAppender(consoleAppender); + logger.setLevel(Level.INFO); + JUnitCore.main("org.dllearner.test.junit.ComponentTests", "org.dllearner.test.junit.ReasonerTests"); } Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2008-02-19 12:05:53 UTC (rev 609) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2008-02-19 13:20:01 UTC (rev 610) @@ -20,7 +20,9 @@ package org.dllearner.test.junit; import java.io.IOException; +import java.util.List; +import org.apache.log4j.Logger; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; @@ -32,7 +34,6 @@ import org.dllearner.kb.KBFile; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; -import org.dllearner.reasoning.OWLAPIReasoner; import org.junit.Test; import static org.junit.Assert.*; @@ -45,10 +46,18 @@ */ public class ReasonerTests { + private static Logger logger = Logger.getLogger(ReasonerTests.class); + private KB getSimpleKnowledgeBase() { String kb = "person SUB TOP."; kb += "man SUB person."; + kb += "man SUB male."; kb += "woman SUB person."; + kb += "woman SUB female."; + kb += "(male AND female) = BOTTOM."; + kb += "man(stephen)."; + kb += "woman(maria)."; + kb += "hasChild(stephen,maria)."; KB kbObject = null; try { kbObject = KBParser.parseKBFile(kb); @@ -60,6 +69,10 @@ return kbObject; } + /** + * Performs an instance checks on all reasoner components to verify that + * they all return the correct result. + */ @Test public void instanceCheckTest() { try { @@ -67,13 +80,18 @@ KB kb = getSimpleKnowledgeBase(); KnowledgeSource ks = new KBFile(kb); ks.init(); - ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, ks); - reasoner.init(); Description d; - d = KBParser.parseConcept("man"); - Individual i = new Individual("alex"); - boolean result = reasoner.instanceCheck(d, i); - assertFalse(result); + // d = KBParser.parseConcept("man"); + d = KBParser.parseConcept("(person AND EXISTS hasChild.female)"); + Individual i = new Individual(KBParser.getInternalURI("stephen")); + List<Class<? extends ReasonerComponent>> reasonerClasses = cm.getReasonerComponents(); + for (Class<? extends ReasonerComponent> reasonerClass : reasonerClasses) { + ReasonerComponent reasoner = cm.reasoner(reasonerClass, ks); + reasoner.init(); + boolean result = reasoner.instanceCheck(d, i); + logger.debug("instance check: " + reasoner + " " + d + " " + i + " " + result); + assertTrue(result); + } } catch (ParseException e) { e.printStackTrace(); } catch (ReasoningMethodUnsupportedException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-19 12:06:28
|
Revision: 609 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=609&view=rev Author: jenslehmann Date: 2008-02-19 04:05:53 -0800 (Tue, 19 Feb 2008) Log Message: ----------- OWL API reasoner now supports KB files Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/kb/OWLFile.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java trunk/src/dl-learner/org/dllearner/utilities/OntologyClassRewriter.java Modified: trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java 2008-02-18 19:20:47 UTC (rev 608) +++ trunk/src/dl-learner/org/dllearner/core/KnowledgeSource.java 2008-02-19 12:05:53 UTC (rev 609) @@ -22,6 +22,8 @@ import java.io.File; import java.net.URI; +import org.dllearner.core.owl.KB; + /** * Represents a knowledge source component. * @@ -30,6 +32,8 @@ */ public abstract class KnowledgeSource extends Component { + public abstract KB toKB(); + public abstract String toDIG(URI kbURI); public abstract void export(File file, OntologyFormat format) throws OntologyFormatUnsupportedException; Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-02-18 19:20:47 UTC (rev 608) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-02-19 12:05:53 UTC (rev 609) @@ -37,7 +37,7 @@ import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.reasoning.DIGConverter; -import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.reasoning.OWLAPIAxiomConvertVisitor; import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.model.OWLOntologyCreationException; @@ -148,7 +148,8 @@ OWLOntology ontology; try { ontology = manager.createOntology(ontologyURI); - OWLAPIReasoner.fillOWLAPIOntology(manager,ontology,kb); + // OWLAPIReasoner.fillOWLAPIOntology(manager,ontology,kb); + OWLAPIAxiomConvertVisitor.fillOWLOntology(manager, ontology, kb); manager.saveOntology(ontology); } catch (OWLOntologyCreationException e) { // TODO Auto-generated catch block @@ -186,5 +187,10 @@ public URL getURL() { return url; } + + @Override + public KB toKB() { + return kb; + } } Modified: trunk/src/dl-learner/org/dllearner/kb/OWLFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-02-18 19:20:47 UTC (rev 608) +++ trunk/src/dl-learner/org/dllearner/kb/OWLFile.java 2008-02-19 12:05:53 UTC (rev 609) @@ -33,6 +33,7 @@ import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.config.StringConfigOption; +import org.dllearner.core.owl.KB; import org.dllearner.reasoning.OWLAPIDIGConverter; /** @@ -107,4 +108,12 @@ throw new OntologyFormatUnsupportedException("export", format); } + /* (non-Javadoc) + * @see org.dllearner.core.KnowledgeSource#toKB() + */ + @Override + public KB toKB() { + throw new Error("OWL -> KB conversion not implemented yet."); + } + } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-02-18 19:20:47 UTC (rev 608) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-02-19 12:05:53 UTC (rev 609) @@ -396,6 +396,15 @@ return new SparqlQueryThreaded(new Cache("cache"),this.sparqlQuery(query)); } + /* (non-Javadoc) + * @see org.dllearner.core.KnowledgeSource#toKB() + */ + @Override + public KB toKB() { + // TODO Does this work? + return kb; + } + /*public static void main(String[] args) throws MalformedURLException { String query = "SELECT ?pred ?obj\n" + "WHERE {<http://dbpedia.org/resource/Leipzig> ?pred ?obj}"; Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-18 19:20:47 UTC (rev 608) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIAxiomConvertVisitor.java 2008-02-19 12:05:53 UTC (rev 609) @@ -79,7 +79,7 @@ this.ontology = ontology; factory = manager.getOWLDataFactory(); } - + public static void fillOWLOntology(OWLOntologyManager manager, OWLOntology ontology, KB kb) { OWLAPIAxiomConvertVisitor converter = new OWLAPIAxiomConvertVisitor(manager, ontology, kb); for(Axiom axiom : kb.getTbox()) Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-18 19:20:47 UTC (rev 608) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2008-02-19 12:05:53 UTC (rev 609) @@ -99,6 +99,9 @@ */ public class OWLAPIReasoner extends ReasonerComponent { +// private static Logger logger = Logger +// .getLogger(OWLAPIReasoner.class); + private String reasonerType = "pellet"; private Set<KnowledgeSource> sources; @@ -167,19 +170,11 @@ Set<OWLOntology> allImports = new HashSet<OWLOntology>(); for(KnowledgeSource source : sources) { - if(!(source instanceof OWLFile)) { - System.out.println("Currently, only OWL files are supported. Ignoring knowledge source " + source + "."); - } else { + // OWL files are read directly + if(source instanceof OWLFile) { URL url = ((OWLFile)source).getURL(); - /* + try { - url = new URL("http://www.co-ode.org/ontologies/pizza/2007/02/12/pizza.owl"); - } catch (MalformedURLException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - */ - try { OWLOntology ontology = manager.loadOntologyFromPhysicalURI(url.toURI()); allImports.addAll(manager.getImportsClosure(ontology)); classes.addAll(ontology.getReferencedClasses()); @@ -193,6 +188,18 @@ } catch (URISyntaxException e) { e.printStackTrace(); } + // all other sources are converted to KB and then to an + // OWL API ontology + } else { + KB kb = source.toKB(); + URI ontologyURI = URI.create("http://example.com"); + OWLOntology ontology = null; + try { + ontology = manager.createOntology(ontologyURI); + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); + } + OWLAPIAxiomConvertVisitor.fillOWLOntology(manager, ontology, kb); } } @@ -221,9 +228,9 @@ e1.printStackTrace(); }*/ - System.out.println(classes); - System.out.println(properties); - System.out.println(individuals); +// System.out.println(classes); +// System.out.println(properties); +// System.out.println(individuals); // compute class hierarchy and types of individuals // (done here to speed up later reasoner calls) @@ -239,15 +246,15 @@ - try { - if(reasoner.isDefined(factory.getOWLIndividual(URI.create("http://example.com/father#female")))) - System.out.println("DEFINED."); - else - System.out.println("NOT DEFINED."); - } catch (OWLReasonerException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } +// try { +// if(reasoner.isDefined(factory.getOWLIndividual(URI.create("http://example.com/father#female")))) +// System.out.println("DEFINED."); +// else +// System.out.println("NOT DEFINED."); +// } catch (OWLReasonerException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } // read in primitives atomicConcepts = new TreeSet<NamedClass>(conceptComparator); Modified: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2008-02-18 19:20:47 UTC (rev 608) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2008-02-19 12:05:53 UTC (rev 609) @@ -32,7 +32,6 @@ import org.dllearner.kb.KBFile; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; -import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.OWLAPIReasoner; import org.junit.Test; Modified: trunk/src/dl-learner/org/dllearner/utilities/OntologyClassRewriter.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/OntologyClassRewriter.java 2008-02-18 19:20:47 UTC (rev 608) +++ trunk/src/dl-learner/org/dllearner/utilities/OntologyClassRewriter.java 2008-02-19 12:05:53 UTC (rev 609) @@ -27,7 +27,7 @@ import org.dllearner.core.owl.Description; import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; -import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.reasoning.OWLAPIDescriptionConvertVisitor; import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLDataFactory; @@ -71,7 +71,8 @@ // umwandeln in interne KAON2-Darstellung (bereits im DL-Learner implementiert) // Description newConceptKAON2 = KAON2Reasoner.getKAON2Description(newConceptInternal); - OWLDescription newConceptOWLAPI = OWLAPIReasoner.getOWLAPIDescription(newConceptInternal); + // OWLDescription newConceptOWLAPI = OWLAPIReasoner.getOWLAPIDescription(newConceptInternal); + OWLDescription newConceptOWLAPI = OWLAPIDescriptionConvertVisitor.getOWLDescription(newConceptInternal); // Umwandlung Klassenname in atomate KAON2-Klasse // OWLClass classKAON2 = KAON2Manager.factory().owlClass(className); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-18 19:20:52
|
Revision: 608 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=608&view=rev Author: sknappe Date: 2008-02-18 11:20:47 -0800 (Mon, 18 Feb 2008) Log Message: ----------- charset is now utf-8 Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-02-18 19:20:32 UTC (rev 607) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlQuery.java 2008-02-18 19:20:47 UTC (rev 608) @@ -21,6 +21,10 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.OutputStream; import java.nio.charset.Charset; import java.util.Iterator; import java.util.List; @@ -176,7 +180,11 @@ // possible Jena bug: Jena modifies the result set during // JSON transformation, so we need to get it back //resultSet = JSONtoResultSet(baos.toString()); - return baos.toString(); + try{ + return baos.toString("UTF-8"); + }catch (Exception e){ + return baos.toString(); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-18 19:20:37
|
Revision: 607 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=607&view=rev Author: sknappe Date: 2008-02-18 11:20:32 -0800 (Mon, 18 Feb 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-18 18:53:32 UTC (rev 606) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-18 19:20:32 UTC (rev 607) @@ -160,7 +160,7 @@ throw new Exception("Query stopped"); } } while($seconds<$this->ttl); - $this->client->stopSparqlQuery($id,$queryID); + $this->client->stopSparqlThread($id,$queryID); } function getSubjects($label) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-18 18:54:41
|
Revision: 606 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=606&view=rev Author: jenslehmann Date: 2008-02-18 10:53:32 -0800 (Mon, 18 Feb 2008) Log Message: ----------- - started jUnit reasoner tests - small addition to KBparser Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/KBFile.java trunk/src/dl-learner/org/dllearner/parser/KBParser.java trunk/src/dl-learner/org/dllearner/parser/kb.jj trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java Modified: trunk/src/dl-learner/org/dllearner/kb/KBFile.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-02-18 17:28:12 UTC (rev 605) +++ trunk/src/dl-learner/org/dllearner/kb/KBFile.java 2008-02-18 18:53:32 UTC (rev 606) @@ -60,6 +60,18 @@ private URL url; private KB kb; + /** + * Constructor allowing you to treat an already existing KB object + * as a KBFile knowledge source. Use it sparingly, because the + * standard way to create components is via + * {@link org.dllearner.core.ComponentManager}. + * + * @param kb A KB object. + */ + public KBFile(KB kb) { + this.kb = kb; + } + public static String getName() { return "KB file"; } @@ -99,7 +111,8 @@ @Override public void init() throws ComponentInitException { try { - kb = KBParser.parseKBFile(url); + if(kb == null) + kb = KBParser.parseKBFile(url); } catch (IOException e) { throw new ComponentInitException("KB file " + url + " could not be read.", e); } catch (ParseException e) { Modified: trunk/src/dl-learner/org/dllearner/parser/KBParser.java =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-18 17:28:12 UTC (rev 605) +++ trunk/src/dl-learner/org/dllearner/parser/KBParser.java 2008-02-18 18:53:32 UTC (rev 606) @@ -23,6 +23,11 @@ return parser.Concept(); } + public static KB parseKBFile(String content) throws IOException, ParseException { + KBParser parser = new KBParser(new StringReader(content)); + return parser.KB(); + } + public static KB parseKBFile(URL url) throws IOException, ParseException { KBParser parser = new KBParser(url.openStream()); return parser.KB(); @@ -494,31 +499,6 @@ finally { jj_save(5, xla); } } - final private boolean jj_3R_13() { - if (jj_scan_token(19)) return true; - if (jj_3R_20()) return true; - if (jj_3R_4()) return true; - if (jj_scan_token(COMMAND_END)) return true; - if (jj_3R_2()) return true; - return false; - } - - final private boolean jj_3R_22() { - if (jj_scan_token(STRING)) return true; - return false; - } - - final private boolean jj_3_2() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(18)) jj_scanpos = xsp; - if (jj_3R_4()) return true; - if (jj_scan_token(22)) return true; - if (jj_3R_3()) return true; - if (jj_scan_token(24)) return true; - return false; - } - final private boolean jj_3_6() { if (jj_scan_token(22)) return true; if (jj_3R_2()) return true; @@ -727,6 +707,31 @@ return false; } + final private boolean jj_3R_13() { + if (jj_scan_token(19)) return true; + if (jj_3R_20()) return true; + if (jj_3R_4()) return true; + if (jj_scan_token(COMMAND_END)) return true; + if (jj_3R_2()) return true; + return false; + } + + final private boolean jj_3R_22() { + if (jj_scan_token(STRING)) return true; + return false; + } + + final private boolean jj_3_2() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(18)) jj_scanpos = xsp; + if (jj_3R_4()) return true; + if (jj_scan_token(22)) return true; + if (jj_3R_3()) return true; + if (jj_scan_token(24)) return true; + return false; + } + public KBParserTokenManager token_source; SimpleCharStream jj_input_stream; public Token token, jj_nt; Modified: trunk/src/dl-learner/org/dllearner/parser/kb.jj =================================================================== --- trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-18 17:28:12 UTC (rev 605) +++ trunk/src/dl-learner/org/dllearner/parser/kb.jj 2008-02-18 18:53:32 UTC (rev 606) @@ -52,6 +52,11 @@ return parser.Concept(); } + public static KB parseKBFile(String content) throws IOException, ParseException { + KBParser parser = new KBParser(new StringReader(content)); + return parser.KB(); + } + public static KB parseKBFile(URL url) throws IOException, ParseException { KBParser parser = new KBParser(url.openStream()); return parser.KB(); Added: trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastInstanceChecker.java 2008-02-18 18:53:32 UTC (rev 606) @@ -0,0 +1,105 @@ +/** + * 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.reasoning; + +import java.util.Set; +import java.util.SortedSet; + +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.InvalidConfigOptionValueException; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; + +/** + * @author Jens Lehmann + * + */ +public class FastInstanceChecker extends ReasonerComponent { + + /* (non-Javadoc) + * @see org.dllearner.core.Component#applyConfigEntry(org.dllearner.core.config.ConfigEntry) + */ + @Override + public <T> void applyConfigEntry(ConfigEntry<T> entry) throws InvalidConfigOptionValueException { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.dllearner.core.Component#init() + */ + @Override + public void init() throws ComponentInitException { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getAtomicConcepts() + */ + public Set<NamedClass> getAtomicConcepts() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getAtomicRoles() + */ + public Set<ObjectProperty> getAtomicRoles() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getIndividuals() + */ + public SortedSet<Individual> getIndividuals() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#getReasonerType() + */ + public ReasonerType getReasonerType() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.dllearner.core.Reasoner#prepareSubsumptionHierarchy(java.util.Set) + */ + public void prepareSubsumptionHierarchy(Set<NamedClass> allowedConcepts) { + // TODO Auto-generated method stub + + } + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} Modified: trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java 2008-02-18 17:28:12 UTC (rev 605) +++ trunk/src/dl-learner/org/dllearner/test/junit/AllTestsRunner.java 2008-02-18 18:53:32 UTC (rev 606) @@ -33,7 +33,8 @@ public class AllTestsRunner { public static void main(String[] args) { - JUnitCore.main("org.dllearner.test.ComponentTests"); + JUnitCore.main("org.dllearner.test.junit.ComponentTests", + "org.dllearner.test.junit.ReasonerTests"); } } Added: trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/junit/ReasonerTests.java 2008-02-18 18:53:32 UTC (rev 606) @@ -0,0 +1,87 @@ +/** + * 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.test.junit; + +import java.io.IOException; + +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningMethodUnsupportedException; +import org.dllearner.core.owl.Description; +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.KB; +import org.dllearner.kb.KBFile; +import org.dllearner.parser.KBParser; +import org.dllearner.parser.ParseException; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.reasoning.OWLAPIReasoner; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * A suite of JUnit tests related to the DL-Learner reasoning. + * + * @author Jens Lehmann + * + */ +public class ReasonerTests { + + private KB getSimpleKnowledgeBase() { + String kb = "person SUB TOP."; + kb += "man SUB person."; + kb += "woman SUB person."; + KB kbObject = null; + try { + kbObject = KBParser.parseKBFile(kb); + } catch (IOException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } + return kbObject; + } + + @Test + public void instanceCheckTest() { + try { + ComponentManager cm = ComponentManager.getInstance(); + KB kb = getSimpleKnowledgeBase(); + KnowledgeSource ks = new KBFile(kb); + ks.init(); + ReasonerComponent reasoner = cm.reasoner(OWLAPIReasoner.class, ks); + reasoner.init(); + Description d; + d = KBParser.parseConcept("man"); + Individual i = new Individual("alex"); + boolean result = reasoner.instanceCheck(d, i); + assertFalse(result); + } catch (ParseException e) { + e.printStackTrace(); + } catch (ReasoningMethodUnsupportedException e) { + e.printStackTrace(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-18 17:28:25
|
Revision: 605 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=605&view=rev Author: sknappe Date: 2008-02-18 09:28:12 -0800 (Mon, 18 Feb 2008) Log Message: ----------- bugfix Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-02-18 15:54:00 UTC (rev 604) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/Cache.java 2008-02-18 17:28:12 UTC (rev 605) @@ -217,8 +217,7 @@ if (result != null) { return SparqlQuery.JSONtoResultSet(result); } else { - query.send(); - ResultSet rs = query.getResultSet(); + ResultSet rs = query.send(); if (rs!=null){ String json = SparqlQuery.getAsJSON(rs); addToCache(query.getQueryString(), json); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-02-18 15:54:05
|
Revision: 604 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=604&view=rev Author: jenslehmann Date: 2008-02-18 07:54:00 -0800 (Mon, 18 Feb 2008) Log Message: ----------- - updated doc folder - small fix in build script Modified Paths: -------------- trunk/build.xml trunk/src/dl-learner/org/dllearner/Info.java Added Paths: ----------- trunk/doc/kbFileSyntax.txt Removed Paths: ------------- trunk/doc/configOptionsOld.txt trunk/doc/sparqlModule.txt Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2008-02-18 15:35:03 UTC (rev 603) +++ trunk/build.xml 2008-02-18 15:54:00 UTC (rev 604) @@ -92,7 +92,7 @@ <!-- copy source code --> <mkdir dir="${release_tmp_dir}/src/"/> <copy toDir="${release_tmp_dir}/src/"> - <fileset dir="${source_dir}" includes="**/*.java,**/*.jjt,build.xml"/> + <fileset dir="${source_dir}" includes="**/*.java,**/*.html,**/*.gif,**/*.jjt,build.xml"/> </copy> <!-- create copy developer documentation --> Deleted: trunk/doc/configOptionsOld.txt =================================================================== --- trunk/doc/configOptionsOld.txt 2008-02-18 15:35:03 UTC (rev 603) +++ trunk/doc/configOptionsOld.txt 2008-02-18 15:54:00 UTC (rev 604) @@ -1,294 +0,0 @@ -Configuration Files -=================== - -This file gives an overview for running DL-Learner using configuration files -as provided in the examples directory. - -The background knowledge can either be given as OWL DL file (using the import -function in the configuration files) or by specifying it directly in the -configuration file (which we refer to as the internal knowledge base). - -Some examples of the syntax of the background knowledge in the internal -knowledge base: - -person = (male OR female). -mother = (female AND EXISTS hasChild.TOP). -motherManyDaughters = (female AND >= 4 hasChild.female). -(mother AND father) SUBCLASSOF person. - -Also see the example files. - -This is the EBNF description of the input language [slightly outdated]: - -Number = ["1"-"9"] (["0"-"9"])* -Id = ["a"-"z"] (["_","a"-"z","A"-"Z","0"-"9"])* -String: "\"" (~["\"","\\","\n","\r"])* "\"" -Instruction = ConfOption - | FunctionCall - | PosExample - | NegExample - | ABoxConcept - | ABoxRole - | Transitive - | Functional - | Symmetric - | Inverse - | Subrole - | TBoxEquiv - | TBoxSub -ConfOption = Id [ "." Id ] "=" ( Id | Number ) ";" -FunctionCall = Id "(" String ")" ";" -PosExample = "+" Id "(" Id ")" "." -NegExample = "-" Id "(" Id ")" "." -ABoxConcept = Concept "(" Id ")" "." -ABoxRole = Id "(" Id "," Id ")" "." -Transitive = "Transitive" "(" Id ")" "." -Functional = "Functional" "(" Id ")" "." -Symmetric = "Symmetric" "(" Id ")" "." -Inverse = "Inverse" "(" Id "," Id ")" "." -Subrole = "Subrole" "(" Id "," Id ")" "." -TBoxEquiv = Concept "=" Concept "." -TBoxSub = Concept ("SUBCLASSOF" | "SUB" ) Concept "." -Concept = "TOP" - | "BOTTOM" - | Id - | "(" Concept "AND" Concept ")" - | "(" Concept "OR" Concept ")" - | "EXISTS" Id "." Concept - | "ALL" Id "." Concept - | "NOT" Concept - | ">=" Number Id "." Concept - | "<=" Number Id "." Concept - -Configuration Options -===================== - -General -------- - -Option: algorithm -Possible Values: bruteForce, gp, random, refinement, hybridGP -Default: refinement -Effect: Specifies the algorithm to use for solving the learning problem. Note, - that hybridGP is not an algorithm itself, but starts the GP algorithm - with a sensible set of default values for the hybrid algorithm combining - GP with refinement operators. In particular the probability of all - operators except refinement is set to 0. - -Option: reasoner -Possible Values: dig, kaon2, fastRetrieval -Default: dig -Effect: Specifies the reasoner to be used. DIG communicates with a reasoner - using the DIG Interface. KAON2 means to use the KAON2 Java API directly. - FastRetrieval is an internal algorithm, which can only be used for - retrieval (not for subsumption). Currently the DIG reasoner cannot read - OWL files. - -Option: digReasonerURL -Possible Values: a valid URL -Default: http://localhost:8081 -Effect: Specifies the URL to be used to look for a DIG capable reasoner. - -Option: writeDIGProtocol -Possible Values: true, false -Default: false -Effect: Specifies whether to store all DIG communication. - -Option: digProtocolFile -Possible Values: strings -Default: digProtocol.txt -Effect: The file to store all DIG communication if writeDIGProtocol is true. - -Option: useRetrievalForClassification -Possible Values: true, false -Default: false -Effect: To measure which concepts are covered, one can either use one retrieval - or several instance checks (at most one for each example). This option - controls which of both options should be used. - -Option: percentPerLengthUnit -Possible Values: 0-1 -Default: 0.05 -Effect: How much percent (wrt classification accuracy) can a concept be worse to - justify an increase in length of 1. This variable is used for GP and in - refinement when the flexible heuristic is used. For GP, you should use a - value smaller than the default. - -> general options below are ignored < -> by the refinement operator algorithm < - -Option: accuracyPenalty -Possible Values: 1-1000 -Default: 1 -Effect: Sets the penalty for "small misclassifications". - -Option: errorPenalty -Possible Values: 1-1000 -Default: 3 -Effect: Sets the penalty for classification errors. - -Option: maxLength -Possible Values: 1-20 -Default: 7 -Effect: For the brute force learner this specifies the depth limit for the - search. The GP learner currently ignores it. - -Option: scoreMethod -Possible Values: full, positive -Default: positive -Effect: The positive score method ignores if a negative examples cannot be - classified. This is often usefull, because of the limited expressiveness - of SHIQ wrt. negated role assertions. The full method penalizes this. - -Option: showCorrectClassifications -Possible Values: true, false -Default: false -Effect: Controls if correct classifications are printed (does not effect the - algorithm). - -Option: penalizeNeutralExamples -Possible Values: true, false -Default: false -Effect: If true there is a penalty if a neutral (neither positive nor negative) - individual is classified as either positive or negative. This should - usually be set to false. - -Refinement Operator Algorithm Specific --------------------------------------- - -Option: refinement.horizontalExpansionFactor -Possible Values: 0-1 -Default: 0.6 -Effect: Specifies horizontal expansion factor. - -Option: refinement.writeSearchTree -Possible Values: true, false -Default: false -Effect: Specifies whether to write the search tree to a file. - -Option: refinement.searchTreeFile -Possible Values: strings -Default: "searchTree.txt" -Effect: Specifies a file to save the current search tree after each loop of - the refinement algorithm. - -Option: refinement.heuristic -Possible Values: flexible, lexicographic -Default: lexicographic -Effect: The refinement operator together with a heuristic yields a learning - algorithm. The lexicographic heuristic uses a lexicographic order of - covered negative examples and horizontal expansion of a node (i.e. - the covered examples are the first criterion, the horizontal expansion - the second criterion). The flexible heuristic computes a combined node - score of both criteria. Note, that the lexicographic needs a horizontal - expansion factor greater than 0 to ensure correctness of the learning - algorithm. - -Option: refinement.quiet -Possible Values: true, false -Default: false -Effect: If set to true, no messages will be shown during the run of the - algorithm (but there will still be startup and summary messages). - -Option: refinement.applyAllFilter -Possible Values: true, false -Default: true -Effect: Specifies wether all equivalences should be used. - -Option: refinement.applyExistsFilter -Possible Values: true, false -Default: true -Effect: Specifies wether exists equivalences should be used. - -Option: refinement.useTooWeakList -Possible Values: true, false -Default: true -Effect: Specifies wether a too weak list should be used to reduce reasoner - requests. - -Option: refinement.useOverlyGeneralList -Possible Values: true, false -Default: true -Effect: Specifies wether an overly general list should be used to reduce - reasoner requests. - -Option: refinement.useShortConceptConstruction -Possible Values: true, false -Default: true -Effect: Specifies wether the algorithm should try to reduce a concept to a - known more general concept to reduce the number of necessary - subsumption checks for the reasoner. - -Option: refinement.useDIGMultiInstanceChecks -Possible Values: never, twoChecks, oneCheck -Default: twoChecks -Effect: The DIG protocol allows to send several queries to a DIG reasoner at - once. [This is automatically done for subsumption tests.] However, - for instance checks this has the disadvantage that it may not be - necessary to send all instance to the DIG reasoner if one of the - positive examples is not covered (meaning that the concept is - classified as too weak). - If the option is set to never, then each instance check is send - separately. - If the option is set to twoChecks, then first all positive examples will - be send in one query. If all of them are covered, i.e. the concept is - not classified as too weak, then all the negative examples are send in - one query. - If the option is set to oneCheck, then all examples will be send in one - query. - -Genetic Programming Specific ----------------------------- - -Option: gp.algorithmType -Possible Values: steadyState, generational -Default: steadyState -Effect: Uses either a steady state (population partly replaced) or generational - (population completely replaced) algorithm. - -Option: gp.elitism -Possible Values: true, false -Default: true -Effect: If true an the GP algorithm uses elitism, i.e. the best individual is - guarenteed to survive. - -Option: gp.numberOfIndividuals -Possible Values: 1-1000000 -Default: 1000 -Effect: Sets the number of individuals in the population. A higher value - improves classification, but is computationally more expensive. - -Option: gp.numberOfSelectedIndividuals -Possible Values: 1-1000000 -Default: 960 -Effect: Sets the number of individuals, which are selected for replacement in a - steady state GP algorithm. - -Option: gp.crossoverPercent -Possible Values: 0-100 -Default: 95 -Effect: The probability that offspring is produced using crossover (in contrast - to simply being copied over to the next generation). - -Option: gp.mutationPercent -Possible Values: 0-100 -Default: 3 -Effect: The probability that offspring is mutated after reproduction. - -Option: gp.hillClimbingPercent -Possible Values: 0-100 -Default: 0 -Effect: The probability that offspring is produced using the hill climbing - operator. - -Option: gp.refinementPercent -Possible Values: 0-100 -Default: 0 -Effect: The probability that offspring is produced using the genetic refinement - operator. - -Option: gp.postConvergenceGenerations -Possible Values: 10-1000 -Default: 50 -Effect: If the algorithm does not find a better solution for this number of - generations it stops. Added: trunk/doc/kbFileSyntax.txt =================================================================== --- trunk/doc/kbFileSyntax.txt (rev 0) +++ trunk/doc/kbFileSyntax.txt 2008-02-18 15:54:00 UTC (rev 604) @@ -0,0 +1,52 @@ +Some learning examples use background knowledge in *.kb files. These +files use a DL-Learner internal convenience syntax and can be converted +to OWL. + +Here are some examples for axioms in this syntax: + +person = (male OR female). +mother = (female AND EXISTS hasChild.TOP). +motherManyDaughters = (female AND >= 4 hasChild.female). +(mother AND father) SUBCLASSOF person. + +This is the EBNF description of the input language [slightly outdated]: + +Number = ["1"-"9"] (["0"-"9"])* +Id = ["a"-"z"] (["_","a"-"z","A"-"Z","0"-"9"])* +String: "\"" (~["\"","\\","\n","\r"])* "\"" +Instruction = ConfOption + | FunctionCall + | PosExample + | NegExample + | ABoxConcept + | ABoxRole + | Transitive + | Functional + | Symmetric + | Inverse + | Subrole + | TBoxEquiv + | TBoxSub +ConfOption = Id [ "." Id ] "=" ( Id | Number ) ";" +FunctionCall = Id "(" String ")" ";" +PosExample = "+" Id "(" Id ")" "." +NegExample = "-" Id "(" Id ")" "." +ABoxConcept = Concept "(" Id ")" "." +ABoxRole = Id "(" Id "," Id ")" "." +Transitive = "Transitive" "(" Id ")" "." +Functional = "Functional" "(" Id ")" "." +Symmetric = "Symmetric" "(" Id ")" "." +Inverse = "Inverse" "(" Id "," Id ")" "." +Subrole = "Subrole" "(" Id "," Id ")" "." +TBoxEquiv = Concept "=" Concept "." +TBoxSub = Concept ("SUBCLASSOF" | "SUB" ) Concept "." +Concept = "TOP" + | "BOTTOM" + | Id + | "(" Concept "AND" Concept ")" + | "(" Concept "OR" Concept ")" + | "EXISTS" Id "." Concept + | "ALL" Id "." Concept + | "NOT" Concept + | ">=" Number Id "." Concept + | "<=" Number Id "." Concept Deleted: trunk/doc/sparqlModule.txt =================================================================== --- trunk/doc/sparqlModule.txt 2008-02-18 15:35:03 UTC (rev 603) +++ trunk/doc/sparqlModule.txt 2008-02-18 15:54:00 UTC (rev 604) @@ -1,310 +0,0 @@ -SPARQL-module - -The SPARQL module is integrated into the DL-Learner and cannot be run alone any more. -You can just ignore the second part of this file, although it might describe some things -in more detail. - - -Here are some things that have to be included in the .conf file -to get a working example: - -loadJarFile("lib/modules/sparqlModule.jar"); -runPreprocessingModule("org.dllearner.modules.SparqlModule"); - -Options: -======== - -sparqlModule.numberOfRecursion = 2; -(range: 1-3) -Influences how deep the Ontology will be cut out -Default: not sure 2 at the moment -1: means only the selected individuals are loaded -2: adds classes of the individuals and properties -3: adds classes of properties of individuals and superclasses of classes - - -sparqlModule.filterMode = 0; -(range 0-2) -These are presets for SPARQL filters (see below for configurations) -0 only yago classes -1 only categories -2 skos and categories - - -With the next options SPARQL filters can be configured in more detail. -USE EITHER THIS or the filtermode above. - -sparqlModule.sparqlPredicateFilterList={"http://www.w3.org/2004/02/skos/core", - "http://xmlns.com/foaf/0.1/", - "http://dbpedia.org/property/wikipage-", - "http://www.w3.org/2002/07/owl#sameAs", - "http://dbpedia.org/property/reference"}; - -sparqlModule.sparqlObjectFilterList={"http://dbpedia.org/resource/Category:Articles_", - "http://dbpedia.org/resource/Category:Wikipedia_", - "http://xmlns.com/foaf/0.1/", - "http://dbpedia.org/resource/Category", - "http://dbpedia.org/resource/Template", - "http://upload.wikimedia.org/wikipedia/commons"}; - - -With the next option you can state namespaces that shall be typed as classes: -sparqlModule.classList={"http://dbpedia.org/class/yago", - "http://dbpedia.org/resource/Category:", - "http://dbpedia.org/resource/Template:", - "http://www.w3.org/2004/02/skos/core", - "http://dbpedia.org/class/"}; - -Hint: You can maybe export the ontology with the help of kaon2 in rdf format using: -export("file.owl"); -But it is untested. - - - -Attention******************************************* -below is a description of how to run the sparql module as a standalone application -this was disabled though and does NOT work at the moment - -Algorithm: -========= - -Start with: -java dbpedia.SparqlModule ListOfIndividuals - -ListOfIndividuals= Individual | ListOfIndividuals | {} - -The String[] args of the main method is taken as input at the moment. -This will be changed later, it is only for testing. - -Example: -java dbpedia.SparqlModule http://dbpedia.org/resource/Angela_Merkel http://dbpedia.org/resource/Gerhard_Schr%C3%B6der http://dbpedia.org/resource/Helmut_Kohl http://dbpedia.org/resource/Helmut_Schmidt http://dbpedia.org/resource/Ludwig_Erhard http://dbpedia.org/resource/Willy_Brandt - -See bottom for more examples - -*Sparql-Queries*** - -Example Sparql-Query see Options below for more info about FILTERS: - -SELECT * WHERE { -<http://dbpedia.org/resource/Angela_Merkel> ?predicate ?object. -FILTER( -(!isLiteral(?object)) -&&( !regex(str(?predicate), 'http://www.w3.org/2004/02/skos/core#') ) -&&( !regex(str(?predicate), 'http://xmlns.com/foaf/0.1/') ) -&&( !regex(str(?predicate), 'http://dbpedia.org/property/wikipage-') ) -&&( !regex(str(?predicate), 'http://www.w3.org/2002/07/owl#sameAs') ) -&&( !regex(str(?predicate), 'http://dbpedia.org/property/reference') ) -&&( !regex((?object), 'http://xmlns.com/foaf/0.1/') )).} - - -*Typing*** -DBpedia is not typed at all. -I replaced/added the following to comply to OWL-DL: - -Resources are sorted in three categories (Class, Property, Instance) -(implemented as HashSets) according to their uris -Properties are typed as Properties -Classes see below Options -Instances is what is left - -*Output*** -The Ontology is written to a file System.currentMillisec().nt - - - -*Cache*** -the cache remembers: a timestamp, the original sparql-query, the result -key is the subject http://dbpedia.org/resource/Angela_Merkel which is first urlencoded -and so serves as the hash for the filename. -Cache validates if timestamp too old and Sparql-Query the same -before returning the SPARQL xml-result - - - - - -Options: -======== - -All Options cannot be altered right now, except in the source. -This will be later moved to the constructor. -Default is always used. -Some are marked with "NYI", these are Not Yet Implemented and are just ideas I had. - -Main-Algorithm: ---------------- - -*NumberOfRecursion (int)*** - -how deep will the Ontology be cut out - -Default: ??? not sure 2 at the moment - -*ClassRepeat NYI (int)*** - -Recursion can be increased, if the Object is a class. -This will result in deeper, richer hierarchies - - -Server: ------- - -there are no options planned right now hardcoded with: -dbpedia.openlinksw.com:8890 - - -Sparql-queries: ---------------- - -*SparqlFilterPredicate (String[])*** - -removes all rows with the specified String in the PREDICATE from the ResultSet -(integrated in SPARQL query with FILTER !regex) - -Default: -"http://www.w3.org/2004/02/skos/core#" // conflict: no properties between classes allowed -"http://xmlns.com/foaf/0.1/" //foaf is not well defined/unnecessary -"http://dbpedia.org/property/wikipage-" // foreign wikis -fr -es, etc. -"http://www.w3.org/2002/07/owl#sameAs" // contradicts with owl-dl maybe changed later so it will be replaced by owl:equivalentClass for Classes -"http://dbpedia.org/property/reference" //links to homepages - -*SparqlFilterObject (String[])*** -(integrated in SPARQL query with FILTER !regex) - -removes all rows with the specified String in the OBJECT from the ResultSet - -Default: -http://xmlns.com/foaf/0.1/ //foaf is not well defined/unnecessary - -*useLiterals (boolean)*** -(integrated in SPARQL query with FILTER !isLiteral) - -removes all rows with literals as objects from the ResultSet - -Default: false - - - -Type Information: ------------------ - -options that are used to type resources to retain OWL-DL - -*IsClass (String[])*** - -specifies URI's that can be considered classes (and therefore will be typed as classes) - -Default: -"http://dbpedia.org/resource/Category:" //dbpedia categories -"http://www.w3.org/2004/02/skos/core" // concept -"http://dbpedia.org/class/yago" // yago classes -"http://dbpedia.org/class/" // "yago" is missing in some of the Datasets from DBpedia, -I don't actually know if this is a mistake or on purpose - - -Cache: ------- - - -*freshdays (int)*** - -Determines how many days a cached query stays valid - -Default: 15 days - -*path (String)*** - -path of the cache-folder - -Default: cache - - - -Syntactic Sugar NYI ----------------- -Instead of choosing example individuals to put into main, -it could be nice to choose 2 Categories. -The module automatically downloads the individals for both classes itself, -removes the category from the definiton and then runs the DL-Learner. - - - - - -Examples: -========= - -German Leaders: - -Input: -http://dbpedia.org/resource/Adolf_Hitler http://dbpedia.org/resource/Prince_Chlodwig_zu_HohenloheSchillingsf%C3%BCrst http://dbpedia.org/resource/Prince_Maximilian_of_Baden http://dbpedia.org/resource/Franz_von_Papen http://dbpedia.org/resource/Joseph_Goebbels http://dbpedia.org/resource/Gerhard_Schr%C3%B6der http://dbpedia.org/resource/Angela_Merkel http://dbpedia.org/resource/Helmut_Kohl http://dbpedia.org/resource/Helmut_Schmidt http://dbpedia.org/resource/Ludwig_Erhard http://dbpedia.org/resource/Willy_Brandt - -conf: - -+test("http://dbpedia.org/resource/Adolf_Hitler"). -+test("http://dbpedia.org/resource/Prince_Chlodwig_zu_Hohenlohe-Schillingsf%C3%BCrst"). -+test("http://dbpedia.org/resource/Prince_Maximilian_of_Baden"). -+test("http://dbpedia.org/resource/Franz_von_Papen"). -+test("http://dbpedia.org/resource/Joseph_Goebbels"). -+test("http://dbpedia.org/resource/Gerhard_Schr%C3%B6der"). -+test("http://dbpedia.org/resource/Angela_Merkel"). -+test("http://dbpedia.org/resource/Helmut_Kohl"). -+test("http://dbpedia.org/resource/Helmut_Schmidt"). -+test("http://dbpedia.org/resource/Ludwig_Erhard"). -+test("http://dbpedia.org/resource/Willy_Brandt"). - - -Greek Philosophers: - -Input - - http://dbpedia.org/resource/Socrates http://dbpedia.org/resource/Plato http://dbpedia.org/resource/Pythagoras http://dbpedia.org/resource/Zeno_of_Elea http://dbpedia.org/resource/Democritus http://dbpedia.org/resource/Theophrastus http://dbpedia.org/resource/Anaxagoras http://dbpedia.org/resource/Alexander_the_Great http://dbpedia.org/resource/Hephaestion http://dbpedia.org/resource/Diotima http://dbpedia.org/resource/Nicomachus http://dbpedia.org/resource/Harpalus http://dbpedia.org/resource/Menaechmus - -Conf - -+test("http://dbpedia.org/resource/Socrates"). -+test("http://dbpedia.org/resource/Plato"). -+test("http://dbpedia.org/resource/Pythagoras"). - -+test("http://dbpedia.org/resource/Zeno_of_Elea"). -//was a pre-Socratic Greek philosopher -+test("http://dbpedia.org/resource/Democritus"). -//was a pre-Socratic Greek philosopher -//+test("http://dbpedia.org/resource/Theophrastus"). -//a native of Eressos in Lesbos, was the successor of Aristotle in the Peripatetic school. -+test("http://dbpedia.org/resource/Anaxagoras"). -//was a pre-Socratic Greek philosopher. - --test("http://dbpedia.org/resource/Alexander_the_Great"). --test("http://dbpedia.org/resource/Hephaestion"). -//makedonischer Adeliger, der engste Freund, General, Leibw\xE4chter und vielleicht auch Geliebter Alexanders des Gro\xDFen. --test("http://dbpedia.org/resource/Diotima"). -//ist eine literarische Figur Platons, eine Seherin aus Mantin\xE4a, --test("http://dbpedia.org/resource/Nicomachus"). -//Nicomachus sp\xE4tantiker r\xF6mischer Schriftsteller und Politiker --test("http://dbpedia.org/resource/Harpalus"). -//Harpalus was an aristocrat of Macedon and boyhood friend of Alexander the Great --test("http://dbpedia.org/resource/Menaechmus"). -//was a Greek mathematician and geometer born in Alopeconnesus - - - - - - - - - - - - - - - - - - - - - - Modified: trunk/src/dl-learner/org/dllearner/Info.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Info.java 2008-02-18 15:35:03 UTC (rev 603) +++ trunk/src/dl-learner/org/dllearner/Info.java 2008-02-18 15:54:00 UTC (rev 604) @@ -3,6 +3,6 @@ package org.dllearner; public class Info { - public static final String build = "2008-02-06"; + public static final String build = "2008-02-18"; } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-02-18 15:35:55
|
Revision: 603 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=603&view=rev Author: sknappe Date: 2008-02-18 07:35:03 -0800 (Mon, 18 Feb 2008) Log Message: ----------- changed the look of an article a bit Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Added Paths: ----------- trunk/src/dbpedia-navigator/images/flickr.jpg Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-18 14:50:24 UTC (rev 602) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-02-18 15:35:03 UTC (rev 603) @@ -125,7 +125,7 @@ $ret=array(); foreach ($result['results']['bindings'] as $results){ $value=$results['obj']; - if (!(isset($value['xml:lang'])&&($value['xml:lang']!=$this->lang))) $ret[$results['pred']['value']][]=$value['value']; + if (!(isset($value['xml:lang'])&&($value['xml:lang']!=$this->lang))) $ret[$results['pred']['value']][]=$value; } return $ret; Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-18 14:50:24 UTC (rev 602) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-02-18 15:35:03 UTC (rev 603) @@ -87,17 +87,21 @@ // display a picture if there is one if(isset($triples['http://xmlns.com/foaf/0.1/depiction'])) - $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0].'" alt="Picture of '.$subject.'" style="float:right; max-width:200px;" \>'; + $content.='<img src="'.$triples['http://xmlns.com/foaf/0.1/depiction'][0]['value'].'" alt="Picture of '.$subject.'" style="float:right; max-width:200px;" \>'; //display where it was redirected from, if it was redirected - if (isset($triples['http://dbpedia.org/property/redirect'])) $content.="<span id=\"redirectedFrom\">redirected from '$subject'</span>"; + $redirect=""; + if (isset($triples['http://dbpedia.org/property/redirect'])){ + $content.="<span id=\"redirectedFrom\">redirected from '$subject'</span>"; + $redirect=$triples['http://dbpedia.org/property/redirect'][0]['value']; + } // add short description in english - $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0])."</p>"; + $content.="<h4>Short Description</h4><p>".urldecode($triples['http://dbpedia.org/property/abstract'][0]['value'])."</p>"; // give the link to the corresponding Wikipedia article if(isset($triples['http://xmlns.com/foaf/0.1/page'])) - $content .= '<p><img src="'.$_GET['path'].'images/wikipedia_favicon.png" alt="Wikipedia" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0].'">view Wikipedia article</a>, '; + $content .= '<p><img src="'.$_GET['path'].'images/wikipedia_favicon.png" alt="Wikipedia" /> <a href="'.$triples['http://xmlns.com/foaf/0.1/page'][0]['value'].'">view Wikipedia article</a>, '; $content .= '<a href="'.$uri.'">view DBpedia resource description</a></p>'; // display a list of classes @@ -107,33 +111,52 @@ if(isset($triples['http://dbpedia.org/property/reference'])) { $content .= '<p>references: <ul>'; foreach($triples['http://dbpedia.org/property/reference'] as $reference) - $content .= '<li><a href="'.$reference.'">'.$reference.'</a></li>'; + $content .= '<li><a href="'.$reference['value'].'">'.$reference['value'].'</a></li>'; $content .= '</ul></p>'; } //display a Google Map if Geo-koordinates are available if (isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'])&&isset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'])){ - $content.="<br/><img src=\"".$_GET['path']."images/mobmaps_googlemapsicon.jpg\" alt=\"Google Maps\" style=\"max-width:30px;\" /> <a href=\"\" onClick=\"loadGoogleMap(".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0].",".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0].",'".$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]."');return false;\">Toggle a map of the location</a><br/><br/><div id=\"map\" style=\"width: 500px; height: 300px;display:none;\"></div>"; + $content.="<br/><img src=\"".$_GET['path']."images/mobmaps_googlemapsicon.jpg\" alt=\"Google Maps\" style=\"max-width:25px;\" /> <a href=\"\" onClick=\"loadGoogleMap(".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat'][0]['value'].",".$triples['http://www.w3.org/2003/01/geo/wgs84_pos#long'][0]['value'].",'".$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']."');return false;\">Toggle a map of the location</a><br/><br/><div id=\"map\" style=\"width: 500px; height: 300px;display:none;\"></div>"; } + //display photo collection, if there is one + if (isset($triples['http://dbpedia.org/property/hasPhotoCollection'])){ + $content.="<br/><img src=\"".$_GET['path']."images/flickr.jpg\" alt=\"Flickr\" style=\"max-width:25px;\" /> <a href=\"".$triples['http://dbpedia.org/property/hasPhotoCollection'][0]['value']."\">view a photo collection</a><br/>"; + } + //skos-subjects + if (isset($triples['http://www.w3.org/2004/02/skos/core#subject'])){ + $content .= '<br/><p>skos subjects: <ul>'; + foreach($triples['http://www.w3.org/2004/02/skos/core#subject'] as $skos) + $content .= '<li><a href="'.$skos['value'].'">'.$skos['value'].'</a></li>'; + $content .= '</ul></p>'; + } + + //BUILD ARTICLE TITLE + $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]['value']; + // filter out uninteresting properties and properties which // have already been displayed unset($triples['http://xmlns.com/foaf/0.1/page']); unset($triples['http://xmlns.com/foaf/0.1/depiction']); unset($triples['http://dbpedia.org/property/abstract']); unset($triples['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']); + unset($triples['http://dbpedia.org/property/redirect']); + unset($triples['http://dbpedia.org/property/reference']); + unset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#long']); + unset($triples['http://www.w3.org/2003/01/geo/wgs84_pos#lat']); + unset($triples['http://dbpedia.org/property/hasPhotoCollection']); + unset($triples['http://www.w3.org/2004/02/skos/core#subject']); + unset($triples['http://www.w3.org/2000/01/rdf-schema#label']); // display the remaining properties as list which can be used for further navigation - - $content .= '<br/><br/><br/><br/><br/><br/>'.get_triple_table($triples); + $content .= '<br/><br/><br/>'.get_triple_table($triples); //BUILD SEARCHRESULT if ($fromCache==-1) $searchResult.="<a href=\"\" onclick=\"xajax_getsubjects('".$subject."');return false;\">Show more Results</a>"; - //BUILD ARTICLE TITLE - $artTitle=$triples['http://www.w3.org/2000/01/rdf-schema#label'][0]; //Restart the Session session_start(); @@ -151,15 +174,15 @@ //Add Positives to Session if (!isset($_SESSION['positive'])){ - if (isset($triples['http://dbpedia.org/property/redirect'])){ - $array=array($triples['http://dbpedia.org/property/redirect'][0] => $triples['http://dbpedia.org/property/redirect'][0]); + if ($redirect!=""){ + $array=array($redirect => $redirect); } else $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); $_SESSION['positive']=$array; } else{ $array=$_SESSION['positive']; - if (isset($triples['http://dbpedia.org/property/redirect'])) $array[$triples['http://dbpedia.org/property/redirect'][0]] = $triples['http://dbpedia.org/property/redirect'][0]; + if ($redirect!="") $array[$redirect] = $redirect; else $array["http://dbpedia.org/resource/".str_replace(" ","_",$subject)]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); $_SESSION['positive']=$array; } @@ -446,23 +469,57 @@ function get_triple_table($triples) { - $table = '<table border="1"><tr><td>predicate</td><td>object</td></tr>'; - foreach($triples as $predicate=>$object) { - $table .= '<tr><td>'.$predicate.'</td>'; + $table = '<table border="0"><tr><td>predicate</td><td>object</td></tr>'; + $i=1; + foreach($triples as $predicate=>$object) { + if ($i>0) $backgroundcolor="eee"; + else $backgroundcolor="ffffff"; + $table .= '<tr style="background-color:#'.$backgroundcolor.';"><td><a href="'.$predicate.'">'.nicePredicate($predicate).'</a></td>'; $table .= '<td><ul>'; foreach($object as $element) { - $table .= '<li>'.$element.'</li>'; + if ($element['type']=="uri") $table .= '<li><a href="'.$element['value'].'">'.$element['value'].'</a></li>'; + else $table .= '<li>'.$element['value'].'</li>'; } - $table .= '</ul></td>'; + $table .= '</ul></td>'; + $i*=-1; } $table .= '</table>'; return $table; +} + +function nicePredicate($predicate) +{ + if (strripos ($predicate, "#")>strripos ($predicate, "/")){ + $namespace=substr ($predicate,0,strripos ($predicate, "#")); + $name=substr ($predicate,strripos ($predicate, "#")+1); + } + else{ + $namespace=substr ($predicate,0,strripos ($predicate, "/")); + $name=substr ($predicate,strripos ($predicate, "/")+1); + } + + switch ($namespace){ + case "http://www.w3.org/2000/01/rdf-schema": $namespace="rdfs"; + break; + case "http://www.w3.org/2002/07/owl": $namespace="owl"; + break; + case "http://xmlns.com/foaf/0.1": $namespace="foaf"; + break; + case "http://dbpedia.org/property": $namespace="p"; + break; + case "http://www.w3.org/2003/01/geo/wgs84_pos": $namespace="geo"; + break; + case "http://www.w3.org/2004/02/skos/core": $namespace="skos"; + break; + } + + return $namespace.':'.$name; } function formatClassArray($ar) { $string = formatClass($ar[0]); for($i=1; $i<count($ar); $i++) { - $string .= ', ' . formatClass($ar[$i]); + $string .= ', ' . formatClass($ar[$i]['value']); } return $string; } Added: trunk/src/dbpedia-navigator/images/flickr.jpg =================================================================== (Binary files differ) Property changes on: trunk/src/dbpedia-navigator/images/flickr.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |