From: <lor...@us...> - 2011-12-19 13:18:39
|
Revision: 3507 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3507&view=rev Author: lorenz_b Date: 2011-12-19 13:18:28 +0000 (Mon, 19 Dec 2011) Log Message: ----------- Improved script. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/utilities/JustificationBasedCoherentOntologyExtractor.java Modified: trunk/components-core/src/main/java/org/dllearner/utilities/JustificationBasedCoherentOntologyExtractor.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/utilities/JustificationBasedCoherentOntologyExtractor.java 2011-12-19 11:22:43 UTC (rev 3506) +++ trunk/components-core/src/main/java/org/dllearner/utilities/JustificationBasedCoherentOntologyExtractor.java 2011-12-19 13:18:28 UTC (rev 3507) @@ -31,13 +31,15 @@ public class JustificationBasedCoherentOntologyExtractor implements CoherentOntologyExtractor{ - private static final int NUMBER_OF_JUSTIFICATIONS = 1; + private static final int NUMBER_OF_JUSTIFICATIONS = 2; // private PelletReasoner reasoner; private IncrementalClassifier reasoner; private OWLOntology incoherentOntology; private OWLOntology ontology; + private Map<OWLClass, OWLOntology> cls2ModuleMap; + static {PelletExplanation.setup();} @Override @@ -60,6 +62,8 @@ return incoherentOntology; } + cls2ModuleMap = extractModules(unsatClasses); + while(!unsatClasses.isEmpty()){ //for each unsatisfiable class we compute n justifications here and count how often each axiom occurs globally Map<OWLAxiom, Integer> axiom2CountMap = new HashMap<OWLAxiom, Integer>(); @@ -120,17 +124,26 @@ } private Set<Set<OWLAxiom>> computeExplanations(OWLClass unsatClass){ - OWLOntology module = OntologyUtils.getOntologyFromAxioms( - ModularityUtils.extractModule(incoherentOntology, Collections.singleton((OWLEntity)unsatClass), ModuleType.TOP_OF_BOT)); - PelletExplanation expGen = new PelletExplanation(module); + PelletExplanation expGen = new PelletExplanation(cls2ModuleMap.get(unsatClass)); return expGen.getUnsatisfiableExplanations(unsatClass, NUMBER_OF_JUSTIFICATIONS); } + private Map<OWLClass, OWLOntology> extractModules(Set<OWLClass> classes){ + Map<OWLClass, OWLOntology> cls2ModuleMap = new HashMap<OWLClass, OWLOntology>(); + for(OWLClass cls : classes){ + OWLOntology module = OntologyUtils.getOntologyFromAxioms( + ModularityUtils.extractModule(incoherentOntology, Collections.singleton((OWLEntity)cls), ModuleType.TOP_OF_BOT)); + cls2ModuleMap.put(cls, module); + } + return cls2ModuleMap; + } + public static void main(String[] args) throws Exception{ Logger.getLogger(RBox.class.getName()).setLevel(Level.OFF); OWLOntologyManager man = OWLManager.createOWLOntologyManager(); - OWLOntology schema = man.loadOntologyFromOntologyDocument(new File("../components-core/cohaerent.owl")); -// OWLOntology schema = man.loadOntologyFromOntologyDocument(new File("/home/lorenz/arbeit/dbpedia_0.75_no_datapropaxioms.owl")); +// OWLOntology schema = man.loadOntologyFromOntologyDocument(new File("../components-core/cohaerent.owl")); +// System.out.println(schema.getLogicalAxiomCount()); + OWLOntology schema = man.loadOntologyFromOntologyDocument(new File("/home/lorenz/arbeit/dbpedia_0.75_no_datapropaxioms.owl")); JustificationBasedCoherentOntologyExtractor extractor = new JustificationBasedCoherentOntologyExtractor(); OWLOntology coherentOntology = extractor.getCoherentOntology(schema);System.out.println(coherentOntology.getLogicalAxiomCount()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |