From: <jen...@us...> - 2008-01-28 18:29:03
|
Revision: 442 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=442&view=rev Author: jenslehmann Date: 2008-01-28 10:28:59 -0800 (Mon, 28 Jan 2008) Log Message: ----------- - resurrected and extented the fast retrieval reasoner algorithm; extremely fast reasoning, reasonably correct instance checks, often incorrect subsumption checks - add reasoner = fastRetrieval in the conf files to use it Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-01-28 17:10:02 UTC (rev 441) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-01-28 18:28:59 UTC (rev 442) @@ -76,6 +76,7 @@ import org.dllearner.parser.ParseException; import org.dllearner.parser.TokenMgrError; import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.reasoning.FastRetrievalReasoner; import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Datastructures; @@ -150,9 +151,11 @@ 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\"."); + + " for option \"reasoner\"."); } ReasonerComponent reasoner = cm.reasoner(reasonerClass, sources); configureComponent(cm, reasoner, componentPrefixMapping, parser); Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java 2008-01-28 17:10:02 UTC (rev 441) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java 2008-01-28 18:28:59 UTC (rev 442) @@ -12,6 +12,8 @@ import org.dllearner.core.dl.Disjunction; import org.dllearner.core.dl.Exists; import org.dllearner.core.dl.FlatABox; +import org.dllearner.core.dl.MultiConjunction; +import org.dllearner.core.dl.MultiDisjunction; import org.dllearner.core.dl.Negation; import org.dllearner.core.dl.Top; import org.dllearner.utilities.Helper; @@ -46,6 +48,20 @@ return calculateConjunctionSets(calculateSetsADC(concept.getChild(0),adcSet),calculateSetsADC(concept.getChild(1),adcSet)); } else if(concept instanceof Disjunction) { return calculateDisjunctionSets(calculateSetsADC(concept.getChild(0),adcSet),calculateSetsADC(concept.getChild(1),adcSet)); + } else if(concept instanceof MultiConjunction) { + SortedSetTuple<String> res = + calculateConjunctionSets(calculateSetsADC(concept.getChild(0),adcSet),calculateSetsADC(concept.getChild(1),adcSet)); + for(int i=2; i < concept.getChildren().size(); i++) { + res = calculateConjunctionSets(res,calculateSetsADC(concept.getChild(i),adcSet)); + } + return res; + } else if(concept instanceof MultiDisjunction) { + SortedSetTuple<String> res = + calculateDisjunctionSets(calculateSetsADC(concept.getChild(0),adcSet),calculateSetsADC(concept.getChild(1),adcSet)); + for(int i=2; i < concept.getChildren().size(); i++) { + res = calculateDisjunctionSets(res,calculateSetsADC(concept.getChild(i),adcSet)); + } + return res; } else if(concept instanceof All) { return calculateAllSet(abox,((All)concept).getRole().getName(),calculateSetsADC(concept.getChild(0),adcSet)); } else if(concept instanceof Exists) { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-01-28 17:10:02 UTC (rev 441) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-01-28 18:28:59 UTC (rev 442) @@ -5,14 +5,21 @@ import java.util.SortedSet; import java.util.TreeSet; +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.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Concept; +import org.dllearner.core.dl.Conjunction; import org.dllearner.core.dl.FlatABox; import org.dllearner.core.dl.Individual; +import org.dllearner.core.dl.Negation; +import org.dllearner.core.dl.RoleHierarchy; +import org.dllearner.core.dl.SubsumptionHierarchy; import org.dllearner.utilities.Helper; import org.dllearner.utilities.SortedSetTuple; @@ -24,6 +31,25 @@ Set<AtomicRole> atomicRoles; SortedSet<Individual> individuals; + ReasoningService rs; + ReasonerComponent rc; + + public FastRetrievalReasoner(Set<KnowledgeSource> sources) { + rc = new DIGReasoner(sources); + rc.init(); + atomicConcepts = rc.getAtomicConcepts(); + atomicRoles = rc.getAtomicRoles(); + individuals = rc.getIndividuals(); + rs = new ReasoningService(rc); + try { + abox = Helper.createFlatABox(rs); + } catch (ReasoningMethodUnsupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + fastRetrieval = new FastRetrieval(abox); + } + public FastRetrievalReasoner(FlatABox abox) { this.abox = abox; fastRetrieval = new FastRetrieval(abox); @@ -79,10 +105,43 @@ return abox; } + // C \sqsubseteq D is rewritten to a retrieval for \not C \sqcap D + @Override + public boolean subsumes(Concept superConcept, Concept subConcept) { + Negation neg = new Negation(subConcept); + Conjunction c = new Conjunction(neg,superConcept); + return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); + } + + @Override + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) { + rs.prepareRoleHierarchy(allowedRoles); + } + + @Override + public RoleHierarchy getRoleHierarchy() { + return rs.getRoleHierarchy(); + } + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { - // hier muss nichts getan werden + rs.prepareSubsumptionHierarchy(allowedConcepts); } + @Override + public SubsumptionHierarchy getSubsumptionHierarchy() { + return rs.getSubsumptionHierarchy(); + } + + @Override + public boolean isSatisfiable() { + return rs.isSatisfiable(); + } + + @Override + public boolean instanceCheck(Concept concept, Individual individual) { + return fastRetrieval.calculateSets(concept).getPosSet().contains(individual.getName()); + } + public static String getName() { return "fast retrieval reasoner"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |