From: <lor...@us...> - 2009-12-29 18:01:02
|
Revision: 1962 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1962&view=rev Author: lorenz_b Date: 2009-12-29 18:00:50 +0000 (Tue, 29 Dec 2009) Log Message: ----------- Added new constructor to Stat class. Implemented isEquivalentClass method in PelletReasoner. Started new class StatsGenerator to generate statistics from evaluation protocol files. Some small fixes. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTableModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/AutoLearnPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ManualLearnPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ManualLearnPanel.java trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/evaluation/StatsGenerator.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/father.ser Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/scripts/evaluation/test.ser trunk/src/dl-learner/org/dllearner/tools/ore/ui/ReasonerProgressUI.java Modified: trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -535,13 +535,15 @@ @Override public boolean isSuperClassOfImpl(Description superConcept, Description subConcept) { - -// System.out.println("super: " + superConcept + "; sub: " + subConcept); - return reasoner.isSubClassOf(OWLAPIDescriptionConvertVisitor.getOWLDescription(subConcept), OWLAPIDescriptionConvertVisitor.getOWLDescription(superConcept)); - + return reasoner.isSubClassOf(OWLAPIDescriptionConvertVisitor.getOWLDescription(subConcept), OWLAPIDescriptionConvertVisitor.getOWLDescription(superConcept)); } @Override + protected boolean isEquivalentClassImpl(Description class1, Description class2) { + return reasoner.isEquivalentClass(OWLAPIDescriptionConvertVisitor.getOWLDescription(class1), OWLAPIDescriptionConvertVisitor.getOWLDescription(class2)); + } + + @Override protected TreeSet<Description> getSuperClassesImpl(Description concept) { Set<Set<OWLClass>> classes = null; Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -10,6 +10,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.text.DecimalFormat; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -17,6 +18,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; +import java.util.Map.Entry; import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.ComponentInitException; @@ -25,7 +27,10 @@ import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.CELOEConfigurator; +import org.dllearner.core.owl.Axiom; +import org.dllearner.core.owl.EquivalentClassesAxiom; import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.SubClassAxiom; import org.dllearner.core.owl.Thing; import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.ClassLearningProblem; @@ -41,6 +46,7 @@ import org.semanticweb.owl.model.OWLOntologyCreationException; import org.semanticweb.owl.model.OWLOntologyManager; + public class EvaluationComputingScript { private ReasonerComponent reasoner; @@ -109,11 +115,71 @@ computeWithApproximation(); computeSuggestions(); computeGenFMeasureWithoutDefaultNegation(); - getAssertedAxioms(); +// getAssertedAxioms(); + evaluateInconsistencies(); saveResults(); } + + private void evaluateInconsistencies(){ + List<Map<NamedClass, List<EvaluatedDescriptionClass>>> superMapList = new ArrayList<Map<NamedClass,List<EvaluatedDescriptionClass>>>(); + List<Map<NamedClass, List<EvaluatedDescriptionClass>>> equivalenceMapList = new ArrayList<Map<NamedClass,List<EvaluatedDescriptionClass>>>(); + + equivalenceMapList.add(defaultEquivalenceMap); + equivalenceMapList.add(owlEquivalenceFMeasureMap); + equivalenceMapList.add(owlEquivalenceGenFMeasureMap); + equivalenceMapList.add(owlEquivalenceJaccardMap); + equivalenceMapList.add(owlEquivalencePredaccMap); + equivalenceMapList.add(owlEquivalenceStandardMap); + equivalenceMapList.add(fastEquivalenceFMeasureMap); + equivalenceMapList.add(fastEquivalenceGenFMeasureMap); + equivalenceMapList.add(fastEquivalenceJaccardMap); + equivalenceMapList.add(fastEquivalencePredaccMap); + equivalenceMapList.add(fastEquivalenceStandardMap); + + superMapList.add(defaultSuperMap); + superMapList.add(owlSuperFMeasureMap); + superMapList.add(owlSuperGenFMeasureMap); + superMapList.add(owlSuperJaccardMap); + superMapList.add(owlSuperPredaccMap); + superMapList.add(owlSuperStandardMap); + superMapList.add(fastSuperFMeasureMap); + superMapList.add(fastSuperGenFMeasureMap); + superMapList.add(fastSuperJaccardMap); + superMapList.add(fastSuperPredaccMap); + superMapList.add(fastSuperStandardMap); + + Axiom axiom; + NamedClass nc; + for(Map<NamedClass, List<EvaluatedDescriptionClass>> map : equivalenceMapList){ + for(Entry<NamedClass, List<EvaluatedDescriptionClass>> entry : map.entrySet()){ + nc = entry.getKey(); + for(EvaluatedDescriptionClass cl : entry.getValue()){ + axiom = new EquivalentClassesAxiom(nc, cl.getDescription()); + boolean followsFromKB = reasoner.isEquivalentClass(cl.getDescription(), nc); + boolean isConsistent = followsFromKB || reasoner.remainsSatisfiable(axiom); + cl.setConsistent(isConsistent); + cl.setFollowsFromKB(followsFromKB); + } + + } + } + for(Map<NamedClass, List<EvaluatedDescriptionClass>> map : superMapList){ + for(Entry<NamedClass, List<EvaluatedDescriptionClass>> entry : map.entrySet()){ + nc = entry.getKey(); + for(EvaluatedDescriptionClass cl : entry.getValue()){ + axiom = new SubClassAxiom(nc, cl.getDescription()); + boolean followsFromKB = reasoner.isSuperClassOf(cl.getDescription(), nc); + boolean isConsistent = followsFromKB || reasoner.remainsSatisfiable(axiom); + cl.setConsistent(isConsistent); + cl.setFollowsFromKB(followsFromKB); + } + + } + } + } + private void getAssertedAxioms(){ try { OWLOntologyManager man = OWLManager.createOWLOntologyManager(); @@ -146,7 +212,13 @@ private void saveResults() { OutputStream fos = null; - File file = new File("test2.ser"); + File old = new File(ontologyURI); + int index = old.getName().lastIndexOf('.'); + String fileName = "test.res"; + if (index>0&& index <= old.getName().length() - 2 ) { + fileName = old.getName().substring(0, index) + ".res"; + } + File file = new File(fileName); try { fos = new FileOutputStream(file); ObjectOutputStream o = new ObjectOutputStream(fos); @@ -233,6 +305,7 @@ for (int k = 0; k <= 3; k++) { ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); + lp.getConfigurator().setCheckConsistency(false); if (j == 0) { lp.getConfigurator().setType("equivalence"); System.out.println("Learning equivalentClass expressions"); @@ -373,6 +446,7 @@ ); ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); + lp.getConfigurator().setCheckConsistency(false); for (int j = 0; j <= 1; j++) { if (j == 0) { if(!equivalentReducedClassesSet.contains(nc)){ @@ -429,7 +503,7 @@ } cm.freeComponent(reasoner); } - cm.freeComponent(reasoner); +// cm.freeComponent(reasoner); cm.freeComponent(lp); cm.freeComponent(celoe); } @@ -459,6 +533,7 @@ + " with " + instanceCount + " instances"); ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); + lp.getConfigurator().setCheckConsistency(false); for (int i = 0; i <= 1; i++) { if (i == 0) { lp.getConfigurator().setType("equivalence"); @@ -543,7 +618,7 @@ if(args[0].startsWith("http")){ fileURL = new URL(args[0]); } else { - fileURL = new File(args[0]).toURI().toURL(); + fileURL = new File(new URL(args[0]).toURI()).toURI().toURL(); } long startTime = System.currentTimeMillis(); new EvaluationComputingScript(fileURL); Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -15,10 +15,15 @@ import java.awt.event.MouseMotionListener; import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -55,6 +60,7 @@ import org.dllearner.tools.ore.ui.GraphicalCoveragePanel; import org.dllearner.tools.ore.ui.MarkableClassesTable; import org.dllearner.tools.ore.ui.ResultTable; +import org.dllearner.tools.ore.ui.SelectableClassExpressionsTable; import org.mindswap.pellet.utils.SetUtils; import org.semanticweb.owl.model.OWLDescription; @@ -66,6 +72,8 @@ * */ private static final long serialVersionUID = -3097551929270352556L; + + private File inputFile; private RatingTablePanel tab1; private RatingTablePanel tab2; @@ -78,7 +86,11 @@ private RatingTablePanel tab9; private RatingTablePanel tab10; - private ResultTable defaultTab; + private SelectableClassExpressionsTable defaultTab; + private static String INCONSISTENCYWARNING = "<html><font color=red>" + + "Warning. Selected class expressions leads to an inconsistent ontology!" + + "</font></html>"; + private JLabel inconsistencyLabel; private JCheckBox noSuggestionCheckBox; private JCheckBox alternateSuggestionCheckBox; private ButtonGroup bg; @@ -142,12 +154,14 @@ private Map<NamedClass, Set<OWLDescription>> assertedEquivalentClasses = new HashMap<NamedClass, Set<OWLDescription>>(); private Map<NamedClass, Set<OWLDescription>> assertedSuperClasses = new HashMap<NamedClass, Set<OWLDescription>>(); - private Map<NamedClass, EvaluatedDescriptionClass> selectedEquivalenceMap = new HashMap<NamedClass, EvaluatedDescriptionClass>(); - private Map<NamedClass, EvaluatedDescriptionClass> selectedSuperMap = new HashMap<NamedClass, EvaluatedDescriptionClass>(); + + private Map<NamedClass, String> selectedEquivalenceMap = new HashMap<NamedClass, String>(); + private Map<NamedClass, String> selectedSuperMap = new HashMap<NamedClass, String>(); public EvaluationGUI(File input) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException { super(); + inputFile = input; loadResults(input); setTitle(input.getName()); createUI(); @@ -224,6 +238,15 @@ return messageTablesPanel; } + + private void showInconsistencyWarning(boolean show){ + if(show){ + inconsistencyLabel.setText(INCONSISTENCYWARNING); + } else { + inconsistencyLabel.setText(" "); + } + + } private JPanel createSingleTablePanel() { JPanel panel = new JPanel(new GridBagLayout()); @@ -232,13 +255,21 @@ c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; c.weighty = 0.0; - JPanel tableHolderPanel = new JPanel(new BorderLayout()); - defaultTab = new ResultTable(); + JPanel tableHolderPanel = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.weightx = 1.0; + defaultTab = new SelectableClassExpressionsTable(); defaultTab.getSelectionModel().addListSelectionListener(this); - tableHolderPanel.add(defaultTab); + tableHolderPanel.add(new JScrollPane(defaultTab), gbc); graphPanel = new GraphicalCoveragePanel(""); - tableHolderPanel.add(graphPanel, BorderLayout.EAST); + gbc.weightx = 0.0; + tableHolderPanel.add(graphPanel, gbc); panel.add(tableHolderPanel, c); + + inconsistencyLabel = new JLabel(); + panel.add(inconsistencyLabel, c); + inconsistencyLabel.setText(" "); c.weightx = 1.0; c.weighty = 0.0; @@ -255,7 +286,9 @@ @Override public void actionPerformed(ActionEvent e) { defaultTab.clearSelection(); + defaultTab.removeSelection(); graphPanel.clear(); + showInconsistencyWarning(false); } }); panel.add(noSuggestionCheckBox, c); @@ -272,7 +305,9 @@ @Override public void actionPerformed(ActionEvent e) { defaultTab.clearSelection(); + defaultTab.removeSelection(); graphPanel.clear(); + showInconsistencyWarning(false); } }); panel.add(alternateSuggestionCheckBox, c); @@ -280,6 +315,7 @@ bg = new ButtonGroup(); bg.add(alternateSuggestionCheckBox); bg.add(noSuggestionCheckBox); + noSuggestionCheckBox.setSelected(true); return panel; } @@ -481,6 +517,9 @@ public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("next")) { NamedClass nc = classesTable.getSelectedClass(currentClassIndex); + if(!showingMultiTables){ + traceInput(); + } if (showingMultiTables && showingEquivalentSuggestions) { if (defaultSuperMap.get(nc) != null) { showSuperSuggestions(nc); @@ -514,7 +553,7 @@ } } else if (!showingMultiTables && !showingEquivalentSuggestions) { - if (owlEquivalenceStandardMap.get(nc) != null) { + if (owlSuperStandardMap.get(nc) != null) { showMultiTables(); } else { @@ -542,17 +581,79 @@ showSingleTable(); } setFinished(); + resetSingleTablePanel(); } else if (e.getActionCommand().equals("finish")) { - + if(!showingMultiTables){ + traceInput(); + } closeDialog(); + saveInput(); } } + + private void resetSingleTablePanel(){ + bg.clearSelection(); + noSuggestionCheckBox.setSelected(true); + showInconsistencyWarning(false); + } + + private void traceInput(){ + NamedClass currentClass = classesTable.getSelectedClass(currentClassIndex); + if(alternateSuggestionCheckBox.isSelected()){ + if(showingEquivalentSuggestions){ + selectedEquivalenceMap.put(currentClass, "m"); + } else { + selectedSuperMap.put(currentClass, "m"); + } + } else if(noSuggestionCheckBox.isSelected()){ + if(showingEquivalentSuggestions){ + selectedEquivalenceMap.put(currentClass, "n"); + } else { + selectedSuperMap.put(currentClass, "n"); + } + } else { + int position = defaultTab.getSelectedPosition() - 1; + if(showingEquivalentSuggestions){ + selectedEquivalenceMap.put(currentClass, String.valueOf(position)); + } else { + selectedSuperMap.put(currentClass, String.valueOf(position)); + } + } + } + + + private void saveInput(){ + OutputStream fos = null; + int index = inputFile.getName().lastIndexOf('.'); + String fileName = "test.inp"; + if (index>0&& index <= inputFile.getName().length() - 2 ) { + fileName = inputFile.getName().substring(0, index) + ".inp"; + } + File file = new File(fileName); + try { + fos = new FileOutputStream(file); + ObjectOutputStream o = new ObjectOutputStream(fos); + + o.writeObject(selectedEquivalenceMap); + o.writeObject(selectedSuperMap); + + o.flush(); + o.close(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + fos.close(); + } catch (Exception e) { + } + } + } private void setFinished() { NamedClass nc = classesTable.getSelectedClass(currentClassIndex); - if (currentClassIndex == SetUtils.union(defaultEquivalenceMap.keySet(), defaultSuperMap.keySet()).size()) { + if (currentClassIndex == SetUtils.union(defaultEquivalenceMap.keySet(), defaultSuperMap.keySet()).size() - 1) { if (showingEquivalentSuggestions && owlEquivalenceStandardMap.get(nc) == null && defaultSuperMap.get(nc) == null || showingEquivalentSuggestions && showingMultiTables && defaultSuperMap.get(nc) == null || !showingEquivalentSuggestions @@ -567,12 +668,51 @@ @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && defaultTab.getSelectedRow() >= 0) { - graphPanel.setNewClassDescription(defaultTab.getSelectedValue()); - bg.clearSelection(); + EvaluatedDescriptionClass cl = defaultTab.getSelectedValue(); + showInconsistencyWarning(!cl.isConsistent()); + graphPanel.setNewClassDescription(cl); + if(defaultTab.getSelectedClassExpression() != null){ + bg.clearSelection(); + } + } } + + @Override + public void mouseDragged(MouseEvent e) { + + } + + @Override + public void mouseMoved(MouseEvent e) { + if (e.getSource() instanceof ResultTable) { + ResultTable result = ((ResultTable) e.getSource()); + int column = result.columnAtPoint(e.getPoint()); + int row = result.rowAtPoint(e.getPoint()); + + if (column == 0 && row >= 0) { + if (mouseOverTable != result || row != oldRow) { + mouseOverTable = result; + oldRow = row; + EvaluatedDescriptionClass ec = result.getValueAtRow(row); + graphPanel2.clear(); + graphPanel2.setNewClassDescription(ec); + setCoverageLocationRelativeTo(result); + showCoveragePanel(true); + } else { + showCoveragePanel(true); + } + } else { + showCoveragePanel(false); + } + } else { + showCoveragePanel(false); + } + + } + /** * @param args * @throws ComponentInitException @@ -582,10 +722,11 @@ * @throws IllegalAccessException * @throws InstantiationException * @throws ClassNotFoundException + * @throws URISyntaxException */ public static void main(String[] args) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException, ClassNotFoundException, InstantiationException, - IllegalAccessException, UnsupportedLookAndFeelException { + IllegalAccessException, UnsupportedLookAndFeelException, URISyntaxException { UIManager.setLookAndFeel(new PlasticLookAndFeel()); @@ -593,7 +734,7 @@ System.out.println("You need to give an file as argument."); System.exit(0); } - final File input = new File(args[0]); + final File input = new File(new URL(args[0]).toURI()); SwingUtilities.invokeLater(new Runnable() { @Override @@ -613,39 +754,7 @@ } - @Override - public void mouseDragged(MouseEvent e) { - } - - @Override - public void mouseMoved(MouseEvent e) { - if (e.getSource() instanceof ResultTable) { - ResultTable result = ((ResultTable) e.getSource()); - int column = result.columnAtPoint(e.getPoint()); - int row = result.rowAtPoint(e.getPoint()); - - if (column == 0 && row >= 0) { - if (mouseOverTable != result || row != oldRow) { - mouseOverTable = result; - oldRow = row; - EvaluatedDescriptionClass ec = result.getValueAtRow(row); - graphPanel2.clear(); - graphPanel2.setNewClassDescription(ec); - setCoverageLocationRelativeTo(result); - showCoveragePanel(true); - } else { - showCoveragePanel(true); - } - } else { - showCoveragePanel(false); - } - } else { - showCoveragePanel(false); - } - - } - class RatingTablePanel extends JPanel { /** Added: trunk/src/dl-learner/org/dllearner/scripts/evaluation/StatsGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/StatsGenerator.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/StatsGenerator.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -0,0 +1,421 @@ +package org.dllearner.scripts.evaluation; + +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.dllearner.utilities.statistics.Stat; +import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLOntologyCreationException; +import org.semanticweb.owl.model.OWLOntologyManager; + + +public class StatsGenerator { + + + private Map<NamedClass, List<EvaluatedDescriptionClass>> equivalentSuggestions; + private Map<NamedClass, List<EvaluatedDescriptionClass>> superSuggestions; + + private Map<NamedClass, String> equivalentInput; + private Map<NamedClass, String> superInput; + + private StringBuilder latex; + + //general stats + private Stat acceptedGlobalStat = new Stat(); + private Stat rejectedGlobalStat = new Stat(); + private Stat failedGlobalStat = new Stat(); + + //equivalent class stats + private Stat acceptedStat = new Stat(); + private Stat rejectedStat = new Stat(); + private Stat failedStat = new Stat(); + private Set<Stat> moreInstancesCountStats = new HashSet<Stat>(); + private Set<Stat> accStats = new HashSet<Stat>(); + private Set<Stat> accSelectedStats = new HashSet<Stat>(); + private Set<Stat> accAboveThresholdStats = new HashSet<Stat>(); + private Set<Stat> positionStats = new HashSet<Stat>(); + + //super class stats + private Stat acceptedStatSC = new Stat(); + private Stat rejectedStatSC = new Stat(); + private Stat failedStatSC = new Stat(); + private Set<Stat> moreInstancesCountStatsSC = new HashSet<Stat>(); + private Set<Stat> accStatsSC = new HashSet<Stat>(); + private Set<Stat> accSelectedStatsSC = new HashSet<Stat>(); + private Set<Stat> accAboveThresholdStatsSC = new HashSet<Stat>(); + private Set<Stat> positionStatsSC = new HashSet<Stat>(); + + private int suggestionListsCount; + private int logicalAxiomCount; + + + public StatsGenerator(File directory){ + //begin latex table with headers + beginTable(); + //for each ontology + for(File suggestionFile : directory.listFiles(new ResultFileFilter())){ + clearStats(); + loadSuggestions(suggestionFile); + loadOntology(suggestionFile); + //for each user evaluation input file + for(File inputFile : directory.listFiles(new NameFilter(suggestionFile))){ + loadUserInput(inputFile); + makeSingleStat(); + printStats(); + + } + //add row to the latex table for current ontology + addTableRow(); + } + //end latex table + endTable(); + printLatexCode(); + + + } + + private void loadOntology(File file){ + String ontologyPath = file.toURI().toString().substring(0, file.toURI().toString().lastIndexOf('.') ) + ".owl"; + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + try { + OWLOntology ont = man.loadOntologyFromPhysicalURI(URI.create(ontologyPath)); + logicalAxiomCount = ont.getLogicalAxiomCount(); + } catch (OWLOntologyCreationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void clearStats(){ + acceptedGlobalStat = new Stat(); + rejectedGlobalStat = new Stat(); + failedGlobalStat = new Stat(); + + moreInstancesCountStats.clear(); + accStats.clear(); + accSelectedStats.clear(); + accAboveThresholdStats.clear(); + positionStats.clear(); + + moreInstancesCountStatsSC.clear(); + accStatsSC.clear(); + accSelectedStatsSC.clear(); + accAboveThresholdStatsSC.clear(); + positionStatsSC.clear(); + } + + private void makeSingleStat(){ + // equivalence classes + int candidatesAboveThresholdCount = 0; + int missesCount = 0; + int foundDescriptionCount = 0; + int noSensibleDescriptionCount = 0; + int inconsistencyDetected = 0; + int moreInstancesCount = 0; + int nonPerfectCount = 0; + Stat moreInstancesCountStat = new Stat(); + Stat accStat = new Stat(); + Stat accSelectedStat = new Stat(); + Stat accAboveThresholdStat = new Stat(); + Stat positionStat = new Stat(); + + // super classes + int candidatesAboveThresholdCountSC = 0; + int missesCountSC = 0; + int foundDescriptionCountSC = 0; + int noSensibleDescriptionCountSC = 0; + int inconsistencyDetectedSC = 0; + int moreInstancesCountSC = 0; + int nonPerfectCountSC = 0; + Stat moreInstancesCountStatSC = new Stat(); + Stat accStatSC = new Stat(); + Stat accSelectedStatSC = new Stat(); + Stat accAboveThresholdStatSC = new Stat(); + Stat positionStatSC = new Stat(); + + //analysing input for equivalent class expressions + for (Entry<NamedClass, String> e : equivalentInput.entrySet()) { + NamedClass currentClass = e.getKey(); + String input = e.getValue(); + if (input.equals("m")) { + missesCount++; + } else if (input.equals("n")) { + noSensibleDescriptionCount++; + } else { + int selectedIndex = Integer.parseInt(input); + EvaluatedDescriptionClass selectedExpression = equivalentSuggestions.get(currentClass).get( + selectedIndex); + double bestAcc = equivalentSuggestions.get(currentClass).get(0).getAccuracy(); + int selectedNr = selectedIndex + 1; + boolean isConsistent = selectedExpression.isConsistent(); + Set<Individual> addInst = selectedExpression.getAdditionalInstances(); + int additionalInstances = addInst.size(); + + accSelectedStat.addNumber(selectedExpression.getAccuracy()); + positionStat.addNumber(selectedNr); + foundDescriptionCount++; + if (!isConsistent) { + inconsistencyDetected++; + } + if (additionalInstances > 0) { + moreInstancesCount++; + moreInstancesCountStat.addNumber(additionalInstances); + } + if (bestAcc < 0.9999) { + nonPerfectCount++; + } + } + } + acceptedStat.addNumber(foundDescriptionCount); + rejectedStat.addNumber(noSensibleDescriptionCount); + failedStat.addNumber(missesCount); + moreInstancesCountStats.add(moreInstancesCountStat); + accStats.add(accStat); + accSelectedStats.add(accSelectedStat); + accAboveThresholdStats.add(accSelectedStat); + positionStats.add(positionStat); + + //analysing input for super class expressions + for (Entry<NamedClass, String> e : superInput.entrySet()) { + NamedClass currentClass = e.getKey(); + if (e.getValue().equals("m")) { + missesCountSC++; + } else if (e.getValue().equals("n")) { + noSensibleDescriptionCountSC++; + } else { + int selectedIndex = Integer.parseInt(e.getValue()); + EvaluatedDescriptionClass selectedExpression = superSuggestions.get(currentClass).get(selectedIndex); + double bestAcc = superSuggestions.get(currentClass).get(0).getAccuracy(); + int selectedNr = selectedIndex + 1; + boolean isConsistent = selectedExpression.isConsistent(); + Set<Individual> addInst = selectedExpression.getAdditionalInstances(); + int additionalInstances = addInst.size(); + + accSelectedStatSC.addNumber(selectedExpression.getAccuracy()); + positionStatSC.addNumber(selectedNr); + foundDescriptionCountSC++; + if (!isConsistent) { + inconsistencyDetectedSC++; + } + if (additionalInstances > 0) { + moreInstancesCountSC++; + moreInstancesCountStatSC.addNumber(additionalInstances); + } + if (bestAcc < 0.9999) { + nonPerfectCountSC++; + } + } + } + acceptedStatSC.addNumber(foundDescriptionCountSC); + rejectedStatSC.addNumber(noSensibleDescriptionCountSC); + failedStatSC.addNumber(missesCountSC); + moreInstancesCountStatsSC.add(moreInstancesCountStatSC); + accStatsSC.add(accStatSC); + accSelectedStatsSC.add(accSelectedStatSC); + accAboveThresholdStatsSC.add(accSelectedStatSC); + positionStatsSC.add(positionStatSC); + + acceptedGlobalStat.addNumber(foundDescriptionCount + foundDescriptionCountSC); + rejectedGlobalStat.addNumber(noSensibleDescriptionCountSC + noSensibleDescriptionCount); + failedGlobalStat.addNumber(missesCountSC + missesCount); + + System.out.println("statistics for equivalence axioms:"); + System.out.println("classes above 85% threshold: " + candidatesAboveThresholdCount); + System.out.println("axioms learned succesfully: " + foundDescriptionCount); + System.out.println("axioms missed: " + missesCount); + System.out.println("class with no sensible axioms: " + noSensibleDescriptionCount); + System.out.println("inconsistencies detected: " + inconsistencyDetected); + System.out.println("additional instances found: " + moreInstancesCountStat.prettyPrint("")); + System.out.println("average accuracy overall: " + accStat.prettyPrint("")); + System.out.println("average accuracy of selected expressions: " + accSelectedStat.prettyPrint("")); + System.out.println("average accuracy of expressions above threshold: " + accAboveThresholdStat.prettyPrint("")); + System.out.println("non-perfect (not 100% accuracy) axioms selected: " + nonPerfectCount); + System.out.println("average number typed by user: " + positionStat.prettyPrint("")); + System.out.println(); + + System.out.println("statistics for super class axioms:"); + System.out.println("classes above 85% threshold: " + candidatesAboveThresholdCountSC); + System.out.println("axioms learned succesfully: " + foundDescriptionCountSC); + System.out.println("axioms missed: " + missesCountSC); + System.out.println("class with no sensible axioms: " + noSensibleDescriptionCountSC); + System.out.println("inconsistencies detected: " + inconsistencyDetectedSC); + System.out.println("additional instances found: " + moreInstancesCountStatSC.prettyPrint("")); + System.out.println("average accuracy overall: " + accStatSC.prettyPrint("")); + System.out.println("average accuracy of selected expressions: " + accSelectedStatSC.prettyPrint("")); + System.out.println("average accuracy of expressions above threshold: " + + accAboveThresholdStatSC.prettyPrint("")); + System.out.println("non-perfect (not 100% accuracy) axioms selected: " + nonPerfectCountSC); + System.out.println("average number typed by user: " + positionStatSC.prettyPrint("")); + System.out.println(); + + System.out.println("merged statistics for equivalence/superclass:"); + System.out.println("classes above 85% threshold: " + + (candidatesAboveThresholdCount + candidatesAboveThresholdCountSC)); + System.out.println("axioms learned succesfully: " + (foundDescriptionCount + foundDescriptionCountSC)); + System.out.println("axioms missed: " + (missesCount + missesCountSC)); + System.out.println("class with no sensible axioms: " + + (noSensibleDescriptionCount + noSensibleDescriptionCountSC)); + System.out.println("inconsistencies detected: " + (inconsistencyDetected + inconsistencyDetectedSC)); + System.out.println("additional instances found: " + + new Stat(moreInstancesCountStat, moreInstancesCountStatSC).prettyPrint("")); + System.out.println("average accuracy overall: " + new Stat(accStat, accStatSC).prettyPrint("")); + System.out.println("average accuracy of selected expressions: " + + new Stat(accSelectedStat, accSelectedStatSC).prettyPrint("")); + System.out.println("average accuracy of expressions above threshold: " + + new Stat(accAboveThresholdStat, accAboveThresholdStatSC).prettyPrint("")); + System.out.println("non-perfect (not 100% accuracy) axioms selected: " + (nonPerfectCount + nonPerfectCountSC)); + System.out.println("average number typed by user: " + new Stat(positionStat, positionStatSC).prettyPrint("")); + System.out.println(); + } + + + private void printStats() { + + + } + + private void printLatexCode(){ + System.out.println(latex.toString()); + } + + private void addTableRow(){ + double accept = acceptedGlobalStat.getMean() / suggestionListsCount * 100; + double reject = rejectedGlobalStat.getMean() /suggestionListsCount * 100; + double fail = failedGlobalStat.getMean() /suggestionListsCount * 100; + latex.append(logicalAxiomCount + " & " + suggestionListsCount + " & " + + accept + " & " + reject + " & " + fail + " & " + new Stat(positionStats).getMean() +"\\\\\n"); + } + + private void beginTable(){ + latex = new StringBuilder(); + latex.append("\\begin{tabular}{ c | c | c | c | c | c } \n"); + latex.append("\\rotatebox{90}{\\#logical axioms} & "); + latex.append("\\rotatebox{90}{\\#suggestions lists} & "); + latex.append("\\rotatebox{90}{accept} & "); + latex.append("\\rotatebox{90}{reject} & "); + latex.append("\\rotatebox{90}{fail} & "); + latex.append("\\rotatebox{90}{selected positions}"); + latex.append(" \\\\\n"); + latex.append("\\hline\n"); + } + + private void endTable(){ + latex.append("\\hline\n"); + latex.append("\\end{tabular}"); + } + + private void loadSuggestions(File resultFile) { + InputStream fis = null; + + try { + fis = new FileInputStream(resultFile); + ObjectInputStream o = new ObjectInputStream(fis); + for (int i = 0; i < 20; i++) { + o.readObject(); + } + equivalentSuggestions = (Map<NamedClass, List<EvaluatedDescriptionClass>>) o.readObject(); + superSuggestions = (Map<NamedClass, List<EvaluatedDescriptionClass>>) o.readObject(); + + } catch (IOException e) { + System.err.println(e); + } catch (ClassNotFoundException e) { + System.err.println(e); + } finally { + try { + fis.close(); + } catch (Exception e) { + } + } + suggestionListsCount = equivalentSuggestions.size() + superSuggestions.size(); + } + + private void loadUserInput(File input){ + InputStream fis = null; + + try { + fis = new FileInputStream(input); + ObjectInputStream o = new ObjectInputStream(fis); + + equivalentInput = (Map<NamedClass, String>) o.readObject(); + superInput = (Map<NamedClass, String>) o.readObject(); + } catch (IOException e) { + System.err.println(e); + } catch (ClassNotFoundException e) { + System.err.println(e); + } finally { + try { + fis.close(); + } catch (Exception e) { + } + } + } + + /** + * @param args + * @throws URISyntaxException + * @throws MalformedURLException + */ + public static void main(String[] args) throws MalformedURLException, URISyntaxException { + File directory = new File(new URL(args[0]).toURI()); + new StatsGenerator(directory); + } + +} + +class ResultFileFilter implements FileFilter { + + public boolean accept(File pathname) { + + if (pathname.getName().endsWith(".res")) { + return true; + } + return false; + } +} + +class InputFileFilter implements FileFilter { + + public boolean accept(File pathname) { + + if (pathname.getName().endsWith(".inp")) { + return true; + } + return false; + } +} + +class NameFilter implements FilenameFilter { + private File file; + + public NameFilter(File file){ + this.file = file; + } + + @Override + public boolean accept(File dir, String name) { + if(name.endsWith("inp")){ + if(name.substring(0, name.indexOf('.')).startsWith(file.getName().substring(0, file.getName().indexOf('.')))){ + return true; + } + } + return false; + } +} Added: trunk/src/dl-learner/org/dllearner/scripts/evaluation/father.ser =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/scripts/evaluation/father.ser ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: trunk/src/dl-learner/org/dllearner/scripts/evaluation/test.ser =================================================================== (Binary files differ) Deleted: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ReasonerProgressUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ReasonerProgressUI.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ReasonerProgressUI.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -1,265 +0,0 @@ -package org.dllearner.tools.ore.ui; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JProgressBar; - -import javax.swing.SwingUtilities; -import javax.swing.Timer; - -import org.mindswap.pellet.utils.progress.ProgressMonitor; - - - - -/** - * Author: Matthew Horridge<br> - * The University Of Manchester<br> - * Medical Informatics Group<br> - * Date: 10-Oct-2006<br><br> - * <p/> - * mat...@cs...<br> - * www.cs.man.ac.uk/~horridgm<br><br> - */ -public class ReasonerProgressUI implements ProgressMonitor { - - - private JLabel label; - - private JProgressBar progressBar; - - private JDialog window; - - private boolean cancelled; - - private Action cancelledAction; - - private String currentClass; - - private static final int CANCEL_TIMEOUT_MS = 5000; - - private Timer cancelTimeout; - - private int progress; - private int progressLength; - - public ReasonerProgressUI(JFrame frame) { - JPanel panel = new JPanel(new BorderLayout(7, 7)); - progressBar = new JProgressBar(); - panel.add(progressBar, BorderLayout.SOUTH); - panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - label = new JLabel("Classifying..."); - panel.add(label, BorderLayout.NORTH); - - window = new JDialog(frame,"Reasoner progress",true); - cancelledAction = new AbstractAction("Cancel") { - public void actionPerformed(ActionEvent e) { - setCancelled(true); - } - }; - JButton cancelledButton = new JButton(cancelledAction); - - window.setLocation(400, 400); - JPanel holderPanel = new JPanel(new BorderLayout(7, 7)); - holderPanel.add(panel, BorderLayout.NORTH); - holderPanel.add(cancelledButton, BorderLayout.EAST); - holderPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); - window.getContentPane().setLayout(new BorderLayout()); - window.getContentPane().add(holderPanel, BorderLayout.NORTH); - window.pack(); - Dimension windowSize = window.getSize(); - window.setSize(400, windowSize.height); - window.setResizable(false); - - cancelTimeout = new Timer(CANCEL_TIMEOUT_MS, new ActionListener() { - public void actionPerformed(ActionEvent event) { - } - }); - cancelTimeout.setRepeats(false); - } - - - - - public void setIndeterminate(boolean b) { - progressBar.setIndeterminate(b); - } - - - private void setCancelled(boolean b) { - cancelled = b; - if (currentClass != null) { - JOptionPane.showMessageDialog(window, - "Cancelled while classifying " + currentClass, - "Cancelled classification", - JOptionPane.INFORMATION_MESSAGE); - } - if (b){ - label.setText("Cancelling..."); - cancelTimeout.start(); - } - else{ - cancelTimeout.stop(); - } - } - - public void setProgressIndeterminate(boolean b) { - progressBar.setIndeterminate(b); - } - - public boolean isCancelled() { - return cancelled; - } - - - private void showWindow() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - window.setLocation(screenSize.width / 2 - window.getWidth() / 2, - screenSize.height / 2 - window.getHeight() / 2); - window.setVisible(true); - } - }); - } - - - private void hideWindow() { - - SwingUtilities.invokeLater(new Runnable() { - public void run() { - if (cancelled && currentClass != null) { - JOptionPane.showMessageDialog(window, - "Cancelled while classifying " + currentClass, - "Cancelled classification", - JOptionPane.INFORMATION_MESSAGE); - } - window.setVisible(false); - } - }); - } - - - @Override - public int getProgress() { - return progress; - } - - - @Override - public int getProgressPercent() { - return (int)(progress * 100.0) / progressBar.getMaximum(); - } - - - @Override - public void incrementProgress() { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - progressBar.setValue(progress++); -// double percentDone = (progress * 100.0) / progressBar.getMaximum(); -// if(percentDone / 100.0 == 0) { -// label.setText("Classifying ontology " + getProgressPercent() + " %"); -// } - } - }); - } - - - @Override - public boolean isCanceled() { - return cancelled; - } - - - @Override - public void setProgress(int progr) { - this.progress = progr; - SwingUtilities.invokeLater(new Runnable() { - public void run() { - progressBar.setValue((int) progress); - double percentDone = (progress * 100.0) / progressBar.getMaximum(); -// if(percentDone / 100.0 == 0) { -// label.setText("Classifying ontology " + ((int) percentDone) + " %"); -// } - } - }); - - } - - - @Override - public void setProgressLength(int length) { - this.progressLength = length; - SwingUtilities.invokeLater(new Runnable() { - public void run() { - progressBar.setValue(0); - progressBar.setMaximum((int) progressLength); - } - }); - - } - - - @Override - public void setProgressMessage(final String message) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - label.setText(message); - } - }); - - } - - - @Override - public void setProgressTitle(final String title) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - window.setTitle(title); - } - }); - - - } - - - @Override - public void taskFinished() { - cancelTimeout.stop(); - hideWindow(); - currentClass = null; - progress = 0; - SwingUtilities.invokeLater(new Runnable() { - public void run() { - progressBar.setValue(progress); - } - }); - - - - } - - - @Override - public void taskStarted() { -// label.setText("Classifying ontology "); - currentClass = null; - setCancelled(false); - showWindow(); - - } -} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTable.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTable.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -45,6 +45,10 @@ ((SelectableClassExpressionsTableModel)getModel()).clear(); } + public void removeSelection(){ + ((SelectableClassExpressionsTableModel)getModel()).removeSelection(); + } + public void addResults(List<EvaluatedDescriptionClass> resultList){ if(getSelectedRow() >= 0){ @@ -64,6 +68,18 @@ return ((SelectableClassExpressionsTableModel)getModel()).getSelectedValue(getSelectedRow()); } + public EvaluatedDescriptionClass getSelectedClassExpression(){ + return ((SelectableClassExpressionsTableModel)getModel()).getSelectedClassExpression(); + } + + public EvaluatedDescriptionClass getBestClassExpression(){ + return ((SelectableClassExpressionsTableModel)getModel()).getBestClassExpression(); + } + + public int getSelectedPosition(){ + return ((SelectableClassExpressionsTableModel)getModel()).getSelectedPosition(); + } + public List<EvaluatedDescriptionClass> getSelectedDescriptions(){ return ((SelectableClassExpressionsTableModel)getModel()).getSelectedDescriptions(); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTableModel.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTableModel.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -2,12 +2,14 @@ import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import javax.swing.table.AbstractTableModel; import org.dllearner.core.owl.Description; import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.protege.editor.owl.ui.view.SelectedEntityCardView; public class SelectableClassExpressionsTableModel extends AbstractTableModel { @@ -19,6 +21,7 @@ private List<EvaluatedDescriptionClass> resultList; private DecimalFormat df; private List<Boolean> selectionList; + private EvaluatedDescriptionClass selectedClassExpression; public SelectableClassExpressionsTableModel(){ super(); @@ -54,10 +57,16 @@ @Override public void setValueAt(Object value, int rowIndex, int columnIndex) { + if(!selectionList.get(rowIndex).booleanValue()){ + selectedClassExpression = resultList.get(rowIndex); + for(int i = 0; i < selectionList.size(); i++){ + selectionList.set(i, Boolean.FALSE); + } + selectionList.set(rowIndex, (Boolean)value); + + super.fireTableCellUpdated(rowIndex, columnIndex); + } - selectionList.set(rowIndex, (Boolean)value); - - super.fireTableCellUpdated(rowIndex, columnIndex); } @@ -94,6 +103,14 @@ fireTableDataChanged(); } + public void removeSelection(){ + for(int i = 0; i < selectionList.size(); i++){ + selectionList.set(i, Boolean.FALSE); + } + selectedClassExpression = null; + fireTableDataChanged(); + } + public void addResults(List<EvaluatedDescriptionClass> resultList){ this.resultList.clear(); this.selectionList.clear(); @@ -113,6 +130,18 @@ return resultList.indexOf(e); } + public EvaluatedDescriptionClass getSelectedClassExpression(){ + return selectedClassExpression; + } + + public EvaluatedDescriptionClass getBestClassExpression(){ + return resultList.get(0); + } + + public int getSelectedPosition(){ + return resultList.indexOf(selectedClassExpression) + 1; + } + public List<EvaluatedDescriptionClass> getSelectedDescriptions(){ List<EvaluatedDescriptionClass> selected = new ArrayList<EvaluatedDescriptionClass>(); for(int i = 0; i < selectionList.size(); i++){ Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/AutoLearnPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/AutoLearnPanelDescriptor.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/AutoLearnPanelDescriptor.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -262,7 +262,7 @@ private final double threshold = OREManager.getInstance().getThreshold(); @Override - public Void doInBackground() {System.out.println("Learning super class for " + OREManager.getInstance().getCurrentClass2Learn()); + public Void doInBackground() { OREManager.getInstance().setLearningType("superClass"); OREManager.getInstance().setLearningProblem(); OREManager.getInstance().setLearningAlgorithm(); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ManualLearnPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ManualLearnPanelDescriptor.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ManualLearnPanelDescriptor.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -110,11 +110,8 @@ if (!e.getValueIsAdjusting() && learnPanel.getResultTable().getSelectedRow() >= 0 && (learningTask.isDone() || learningTask.isCancelled())){ EvaluatedDescriptionClass selectedClassExpression = learnPanel.getResultTable().getSelectedValue(); -// if(!selectedClassExpression.isConsistent()){ -// learnPanel.add(new JLabel("Selected class expression may lead to an inconsistent knowledgebase.")); -// } + learnPanel.showInconsistencyWarning(!selectedClassExpression.isConsistent()); OREManager.getInstance().setNewClassDescription(selectedClassExpression); - learnPanel.updateCurrentGraphicalCoveragePanel(OREManager.getInstance().getNewClassDescription()); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ManualLearnPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ManualLearnPanel.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ManualLearnPanel.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -30,6 +30,7 @@ import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JFrame; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -57,6 +58,8 @@ private ResultTable resultTable; private JScrollPane tableScrollPane; private JPanel resultPanel; + + private JLabel inconsistencyLabel; private JButton stopButton; private JButton startButton; @@ -70,6 +73,10 @@ private JRadioButton superClassButton; private GridBagConstraints c; + + private static String INCONSISTENCYWARNING = "<html><font color=red>" + + "Warning! Adding selected class expression leads to an inconsistent ontology." + + "</font></html>"; public ManualLearnPanel() { @@ -98,6 +105,8 @@ resultPanel.setLayout(new BorderLayout()); resultPanel.add(tableScrollPane); resultPanel.setBorder(new TitledBorder("Learned class expressions")); + inconsistencyLabel = new JLabel(" "); + resultPanel.add(inconsistencyLabel, BorderLayout.SOUTH); add(resultPanel, c); } @@ -216,9 +225,18 @@ return equivalentClassButton.isSelected(); } + public void showInconsistencyWarning(boolean show){ + if(show){ + inconsistencyLabel.setText(INCONSISTENCYWARNING); + } else { + inconsistencyLabel.setText(" "); + } + } + public void reset(){ graphicPanel.clear(); resultTable.clear(); + showInconsistencyWarning(false); } public static void main(String[] args){ Modified: trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java 2009-12-29 15:39:49 UTC (rev 1961) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/Stat.java 2009-12-29 18:00:50 UTC (rev 1962) @@ -21,6 +21,7 @@ package org.dllearner.utilities.statistics; import java.text.DecimalFormat; +import java.util.Set; /** * Utility class for calculating the mean and standard deviation of a given set @@ -59,6 +60,23 @@ } /** + * Creates a new stat object by merging several stat objects. The result is the same as if + * the numbers, which have been added to each stat would have been added to this + * stat object. + * @param stat1 Statistical object 1. + * @param stat2 Statistical object 2. + */ + public Stat(Set<Stat> stats) { + for(Stat stat : stats){ + count += stat.count; + sum += stat.sum; + squareSum += stat.squareSum; + min = Math.min(min, stat.min); + max = Math.max(max, stat.max); + } + } + + /** * Add a number to this object. * * @param number This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |