From: <lor...@us...> - 2009-09-23 11:26:21
|
Revision: 1858 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1858&view=rev Author: lorenz_b Date: 2009-09-23 11:26:14 +0000 (Wed, 23 Sep 2009) Log Message: ----------- only showing classes that have at least one individual when selected class expression with accuracy 100%, example repair is skipped Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/ore/explanation/RootFinder.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/Wizard.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardController.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ClassChoosePanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/LearningPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/SavePanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/UnsatisfiableExplanationPanelDescriptor.java Modified: trunk/src/dl-learner/org/dllearner/tools/ore/explanation/RootFinder.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/explanation/RootFinder.java 2009-09-23 10:48:09 UTC (rev 1857) +++ trunk/src/dl-learner/org/dllearner/tools/ore/explanation/RootFinder.java 2009-09-23 11:26:14 UTC (rev 1858) @@ -67,6 +67,7 @@ private Set<OWLClass> rootClasses; private Set<OWLClass> derivedClasses; + private Set<OWLClass> unsatClasses; private boolean ontologyChanged = true; @@ -94,6 +95,8 @@ } rootClasses = new HashSet<OWLClass>(); derivedClasses = new HashSet<OWLClass>(); + unsatClasses = new HashSet<OWLClass>(); + depend2Classes = new HashSet<OWLClass>(); depth2UniversalRestrictionPropertyMap = new HashMap<Integer, Set<OWLObjectAllRestriction>>(); depth2ExistsRestrictionPropertyMap = new HashMap<Integer, Set<OWLObjectPropertyExpression>>(); @@ -138,6 +141,7 @@ // } catch (OWLOntologyChangeException e) { // e.printStackTrace(); // } + unsatClasses.clear(); rootClasses.clear(); derivedClasses.clear(); depend2Classes.clear(); @@ -147,14 +151,16 @@ parent2Children.clear(); computePossibleRoots(); pruneRoots(); + derivedClasses.addAll(unsatClasses); derivedClasses.removeAll(rootClasses); rootClasses.remove(manager.getOWLDataFactory().getOWLNothing()); } private void computePossibleRoots(){ - derivedClasses.addAll(reasoner.getInconsistentClasses()); - for(OWLClass cls : derivedClasses){ + unsatClasses.addAll(reasoner.getInconsistentClasses()); + + for(OWLClass cls : unsatClasses){ reset(); for(OWLDescription equi : cls.getEquivalentClasses(ontology)){ equi.accept(this); @@ -243,7 +249,7 @@ filler.accept(this); depth--; } else { - if(!reasoner.isSatisfiable(filler)){ + if(unsatClasses.contains(filler.asOWLClass())){ depend2Classes.add(filler.asOWLClass()); if(restr instanceof OWLObjectAllRestriction){ addAllRestrictionProperty((OWLObjectAllRestriction) restr); @@ -276,13 +282,10 @@ @Override - public void visit(OWLClass cls) { - - - if(!reasoner.isSatisfiable(cls)) { + public void visit(OWLClass cls) { + if(unsatClasses.contains(cls)) { depend2Classes.add(cls); } - } @Override @@ -292,7 +295,7 @@ for(OWLDescription op : and.getOperands()) { if(op.isAnonymous()){ op.accept(this); - } else if(!reasoner.isSatisfiable(op)) { + } else if(unsatClasses.contains(op.asOWLClass())) { depend2Classes.add(op.asOWLClass()); } } @@ -301,21 +304,22 @@ @Override public void visit(OWLObjectUnionOf or) { - - - for(OWLDescription op : or.getOperands()){ - if(reasoner.isSatisfiable(op)){ - return; - } + + // check whether one of the union operands is satisfiable + for (OWLDescription op : or.getOperands()) { + if (!unsatClasses.contains(op)) { + return; } - for(OWLDescription op : or.getOperands()){ - if(op.isAnonymous()){ - op.accept(this); - } else { - depend2Classes.add(op.asOWLClass()); - } + } + // all operands are unsatisfiable + for (OWLDescription op : or.getOperands()) { + if (op.isAnonymous()) { + op.accept(this); + } else { + depend2Classes.add(op.asOWLClass()); } - + } + } @Override Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/Wizard.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/Wizard.java 2009-09-23 10:48:09 UTC (rev 1857) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/Wizard.java 2009-09-23 11:26:14 UTC (rev 1858) @@ -152,17 +152,17 @@ /** - * Returns an instance of the JDialog that this class created. This is useful in - * the event that you want to change any of the JDialog parameters manually. - * @return The JDialog instance that this class created. + * Returns an instance of the JFrame that this class created. This is useful in + * the event that you want to change any of the JFrame parameters manually. + * @return The JFrame instance that this class created. */ public JFrame getDialog() { return wizardDialog; } /** - * Returns the owner of the generated javax.swing.JDialog. - * @return The owner (java.awt.Frame or java.awt.Dialog) of the javax.swing.JDialog generated + * Returns the owner of the generated javax.swing.JFrame. + * @return The owner (java.awt.Frame or java.awt.Dialog) of the javax.swing.JFrame generated * by this class. */ public Component getOwner() { @@ -170,7 +170,7 @@ } /** - * Sets the title of the generated javax.swing.JDialog. + * Sets the title of the generated javax.swing.JFrame. * @param s The title of the dialog. */ public void setTitle(String s) { @@ -186,7 +186,7 @@ } /** - * Sets the modality of the generated javax.swing.JDialog. + * Sets the modality of the generated javax.swing.JFrame. * @param b the modality of the dialog */ public void setModal(boolean b) { @@ -195,7 +195,7 @@ /** * Returns the modality of the dialog. - * @return A boolean indicating whether or not the generated javax.swing.JDialog is modal. + * @return A boolean indicating whether or not the generated javax.swing.JFrame is modal. */ public boolean isModal() {return false; // return wizardDialog.isModal(); @@ -247,11 +247,6 @@ } - public void updatePanel(JPanel panel, Object id){ - cardPanel.remove(4); - cardPanel.add(panel, id); - } - /** * Displays the panel identified by the object passed in. This is the same Object-based * identified used when registering the panel. @@ -374,7 +369,7 @@ } /** - * This method initializes the components for the wizard dialog: it creates a JDialog + * This method initializes the components for the wizard dialog: it creates a JFrame * as a CardLayout panel surrounded by a small amount of space on each side, as well * as three buttons at the bottom. */ Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardController.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardController.java 2009-09-23 10:48:09 UTC (rev 1857) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardController.java 2009-09-23 11:26:14 UTC (rev 1858) @@ -22,11 +22,9 @@ import java.awt.event.ActionListener; -import java.util.List; import javax.swing.JOptionPane; -import org.dllearner.core.owl.Description; import org.dllearner.tools.ore.OREManager; import org.dllearner.tools.ore.ui.wizard.descriptors.ClassChoosePanelDescriptor; import org.dllearner.tools.ore.ui.wizard.descriptors.InconsistencyExplanationPanelDescriptor; @@ -35,7 +33,6 @@ import org.dllearner.tools.ore.ui.wizard.descriptors.RepairPanelDescriptor; import org.dllearner.tools.ore.ui.wizard.descriptors.SavePanelDescriptor; import org.dllearner.tools.ore.ui.wizard.descriptors.UnsatisfiableExplanationPanelDescriptor; -import org.semanticweb.owl.model.OWLOntologyChange; /** * This class is responsible for reacting to events generated by pushing any of the @@ -118,52 +115,64 @@ UnsatisfiableExplanationPanelDescriptor.IDENTIFIER, unsatDescriptor); nextPanelDescriptor = UnsatisfiableExplanationPanelDescriptor.IDENTIFIER; + wizard.setCurrentPanel(nextPanelDescriptor); + unsatDescriptor.fillUnsatisfiableClassesList(); } else { nextPanelDescriptor = ClassChoosePanelDescriptor.IDENTIFIER; ((ClassChoosePanelDescriptor) nextDescriptor).refill(); } } - } else if (currentPanelDescriptor.getPanelDescriptorIdentifier() - .equals(InconsistencyExplanationPanelDescriptor.IDENTIFIER)) { + } else if (currentPanelDescriptor.getPanelDescriptorIdentifier().equals(InconsistencyExplanationPanelDescriptor.IDENTIFIER)) { ore.getReasoner().classify(); if (ore.getReasoner().getInconsistentClasses().size() > 0) { - + UnsatisfiableExplanationPanelDescriptor unsatDescriptor = new UnsatisfiableExplanationPanelDescriptor(); + unsatDescriptor.init(); + wizard.registerWizardPanel( + UnsatisfiableExplanationPanelDescriptor.IDENTIFIER, + unsatDescriptor); + nextPanelDescriptor = UnsatisfiableExplanationPanelDescriptor.IDENTIFIER; } else { nextPanelDescriptor = ClassChoosePanelDescriptor.IDENTIFIER; ((ClassChoosePanelDescriptor) nextDescriptor).refill(); } - } else if (currentPanelDescriptor.getPanelDescriptorIdentifier() - .equals(UnsatisfiableExplanationPanelDescriptor.IDENTIFIER)) { + } else if (currentPanelDescriptor.getPanelDescriptorIdentifier().equals(UnsatisfiableExplanationPanelDescriptor.IDENTIFIER)) { nextPanelDescriptor = ClassChoosePanelDescriptor.IDENTIFIER; ((ClassChoosePanelDescriptor) nextDescriptor).refill(); - } else if (nextPanelDescriptor - .equals(LearningPanelDescriptor.IDENTIFIER)) { - ore.makeOWAToCWA(); + } else if (currentPanelDescriptor.getPanelDescriptorIdentifier().equals(ClassChoosePanelDescriptor.IDENTIFIER)) { +// ore.makeOWAToCWA(); ore.setLearningProblem(); LearningPanelDescriptor learnDescriptor = ((LearningPanelDescriptor) model .getPanelHashMap().get(nextPanelDescriptor)); learnDescriptor.setPanelDefaults(); - } else if (nextPanelDescriptor.equals(RepairPanelDescriptor.IDENTIFIER)) { - RepairPanelDescriptor repair = ((RepairPanelDescriptor) model - .getPanelHashMap().get(nextPanelDescriptor)); - repair.refreshExampleLists(); - - // OWLOntologyChange change = - // model.getOre().getModi().addAxiomToOWL(model.getOre().getConceptToAdd(), - // model.getOre().getIgnoredConcept()); - // repair.getOntologyChanges().add(change); - + } +// else if(currentPanelDescriptor.getPanelDescriptorIdentifier().equals(LearningPanelDescriptor.IDENTIFIER)){ +// if(OREManager.getInstance().getNewClassDescription().getAccuracy() == 1.0){ +// nextPanelDescriptor = SavePanelDescriptor.IDENTIFIER; +// } else { +// nextPanelDescriptor = RepairPanelDescriptor.IDENTIFIER; +// RepairPanelDescriptor repair = ((RepairPanelDescriptor) model +// .getPanelHashMap().get(nextPanelDescriptor)); +// repair.refreshExampleLists(); +// } + + else if(nextPanelDescriptor.equals(RepairPanelDescriptor.IDENTIFIER)){ + RepairPanelDescriptor repair = ((RepairPanelDescriptor) model + .getPanelHashMap().get(nextPanelDescriptor)); + repair.refreshExampleLists(); + + + } else if (nextPanelDescriptor.equals(SavePanelDescriptor.IDENTIFIER)) { - Description newDesc = ore.getNewClassDescription().getDescription(); - Description oldClass = ore.getCurrentClass2Learn(); +// Description newDesc = ore.getNewClassDescription().getDescription(); +// Description oldClass = ore.getCurrentClass2Learn(); +// +// List<OWLOntologyChange> changes = ore.getModifier() +// .rewriteClassDescription(newDesc, oldClass); +// ((RepairPanelDescriptor) currentPanelDescriptor) +// .getOntologyChanges().addAll(changes); - List<OWLOntologyChange> changes = ore.getModifier() - .rewriteClassDescription(newDesc, oldClass); - ((RepairPanelDescriptor) currentPanelDescriptor) - .getOntologyChanges().addAll(changes); - } if (nextPanelDescriptor instanceof WizardPanelDescriptor.FinishIdentifier) { wizard.close(Wizard.FINISH_RETURN_CODE); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ClassChoosePanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ClassChoosePanelDescriptor.java 2009-09-23 10:48:09 UTC (rev 1857) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ClassChoosePanelDescriptor.java 2009-09-23 11:26:14 UTC (rev 1858) @@ -20,7 +20,9 @@ package org.dllearner.tools.ore.ui.wizard.descriptors; +import java.util.Iterator; import java.util.Set; +import java.util.TreeSet; import java.util.concurrent.ExecutionException; import javax.swing.SwingWorker; @@ -49,7 +51,7 @@ /** * Information string for class choose panel. */ - public static final String INFORMATION = "As you can see, all atomic classes of the ontology are shown in the list above. " + public static final String INFORMATION = "Above all atomic classes which have at least one individual are listed. " + "Select one of them for which you want to learn equivalent class expressions," + " then press <Next>"; @@ -113,7 +115,7 @@ } public void refill(){ - TaskManager.getInstance().setTaskStarted("Retrieving atomic classes"); + TaskManager.getInstance().setTaskStarted("Retrieving atomic classes..."); new ClassRetrievingTask().execute(); } @@ -125,8 +127,18 @@ class ClassRetrievingTask extends SwingWorker<Set<NamedClass>, NamedClass> { @Override - public Set<NamedClass> doInBackground() { - Set<NamedClass> classes = OREManager.getInstance().getReasoner().getNamedClasses(); + public Set<NamedClass> doInBackground() { + OREManager.getInstance().makeOWAToCWA(); + Set<NamedClass> classes = new TreeSet<NamedClass>(OREManager.getInstance().getReasoner().getNamedClasses()); + classes.remove(new NamedClass("http://www.w3.org/2002/07/owl#Thing")); + Iterator<NamedClass> iter = classes.iterator(); + while(iter.hasNext()){ + NamedClass nc = iter.next(); + int instanceCount = OREManager.getInstance().getReasoner().getIndividuals(nc).size(); + if(instanceCount == 0){ + iter.remove(); + } + } return classes; } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/LearningPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/LearningPanelDescriptor.java 2009-09-23 10:48:09 UTC (rev 1857) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/LearningPanelDescriptor.java 2009-09-23 11:26:14 UTC (rev 1858) @@ -76,7 +76,12 @@ @Override public Object getNextPanelDescriptor() { - return RepairPanelDescriptor.IDENTIFIER; + EvaluatedDescriptionClass newClassDesc = OREManager.getInstance().getNewClassDescription(); + if(newClassDesc != null && newClassDesc.getAccuracy() == 1.0){ + return SavePanelDescriptor.IDENTIFIER; + } else { + return RepairPanelDescriptor.IDENTIFIER; + } } @Override Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/SavePanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/SavePanelDescriptor.java 2009-09-23 10:48:09 UTC (rev 1857) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/SavePanelDescriptor.java 2009-09-23 11:26:14 UTC (rev 1858) @@ -62,7 +62,11 @@ @Override public Object getBackPanelDescriptor() { - return "REPAIR_PANEL"; + if(OREManager.getInstance().getNewClassDescription().getAccuracy() == 1.0){ + return LearningPanelDescriptor.IDENTIFIER; + } else { + return RepairPanelDescriptor.IDENTIFIER; + } } @Override Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/UnsatisfiableExplanationPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/UnsatisfiableExplanationPanelDescriptor.java 2009-09-23 10:48:09 UTC (rev 1857) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/UnsatisfiableExplanationPanelDescriptor.java 2009-09-23 11:26:14 UTC (rev 1858) @@ -88,17 +88,10 @@ @Override public void aboutToDisplayPanel() { -// new RootDerivedTask(getWizard().getStatusBar()).execute(); getWizard().getInformationField().setText(INFORMATION); - } @Override - public void displayingPanel() { - new RootDerivedTask(getWizard().getStatusBar()).execute(); - } - - @Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("regular")) { expMan.setLaconicMode(false); @@ -136,7 +129,9 @@ } - + public void fillUnsatisfiableClassesList(){ + new RootDerivedTask(getWizard().getStatusBar()).execute(); + } @Override public void valueChanged(ListSelectionEvent e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |