From: <ku...@us...> - 2009-09-30 06:19:21
|
Revision: 1870 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1870&view=rev Author: kurzum Date: 2009-09-30 06:19:13 +0000 (Wed, 30 Sep 2009) Log Message: ----------- some minor changes and test case Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/manipulator/AddAllStringsAsClasses.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/test/JenaConstruct.java Modified: trunk/src/dl-learner/org/dllearner/kb/manipulator/AddAllStringsAsClasses.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/manipulator/AddAllStringsAsClasses.java 2009-09-29 15:59:38 UTC (rev 1869) +++ trunk/src/dl-learner/org/dllearner/kb/manipulator/AddAllStringsAsClasses.java 2009-09-30 06:19:13 UTC (rev 1870) @@ -101,6 +101,7 @@ } tmp = namespace+tmp; tmp = tmp.replaceAll("%", "_"); + tmp = "c"+tmp; keep.add(new RDFNodeTuple(new ResourceImpl(OWLVocabulary.RDF_TYPE),new ResourceImpl(tmp))); }else { Added: trunk/src/dl-learner/org/dllearner/test/JenaConstruct.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/JenaConstruct.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/test/JenaConstruct.java 2009-09-30 06:19:13 UTC (rev 1870) @@ -0,0 +1,84 @@ +package org.dllearner.test; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; + +import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLOntologyManager; + + + +/** + * this class was submitted to Jena Bug Tracker + * + */ +public class JenaConstruct { + + public static void main(String[] args) { + try{ + URL url = new URL ("http://localhost/ontowiki/model/export/?m=http://ns.softwiki.de/req/&f=rdfxml"); + getWholeOWLAPIOntology(url); + }catch (Exception e) { + e.printStackTrace(); + } + } + +public static OWLOntology getWholeOWLAPIOntology(URL url){ + OWLOntology onto = null; + try{ + File f = File.createTempFile("dllearneronto", ".rdf"); + try{ + //assemble + + //URL url = new URL (owbase+"model/export/?m="+namespace+"&f=rdfxml"); +// URLConnection u = url.openConnection(); +// String content = toString(u.getInputStream()); +// +// +// FileWriter fw = new FileWriter(f); +// fw.write(content); +// fw.close(); + URI physicalURI = url.toURI(); +// URI physicalURI = f.toURI(); + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + onto = manager.loadOntologyFromPhysicalURI(physicalURI); + System.out.println(onto.getAxiomCount()); + }catch (Exception e) { + e.printStackTrace(); + }finally{ + f.delete(); + + } + + }catch (Exception e) { + e.printStackTrace(); + } + return onto; + +} + + public static String toString(InputStream in) + throws IOException +{ + + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + + String result = ""; + String line; + while(null != (line = reader.readLine())){ + if(line.startsWith("#")){continue;} + result += line + "\n"; + } + return result; +} + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-10-01 12:05:50
|
Revision: 1871 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1871&view=rev Author: lorenz_b Date: 2009-10-01 12:05:40 +0000 (Thu, 01 Oct 2009) Log Message: ----------- continued auto learning mode Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationManager.java trunk/src/dl-learner/org/dllearner/tools/ore/explanation/CachedExplanationGenerator.java trunk/src/dl-learner/org/dllearner/tools/ore/explanation/LaconicTest.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardController.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/InconsistencyExplanationPanelDescriptor.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/AutoLearnPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassChoosePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/ore/ConcurrencyBug.java Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -254,7 +254,7 @@ // be in the search of the learning algorith, which leads to // unpredictable behaviour) Description d = ed.getDescription().clone(); - ConceptTransformation.replaceRange(d, reasoner); +// ConceptTransformation.replaceRange(d, reasoner); ed.setDescription(d); returnList.add(ed); Added: trunk/src/dl-learner/org/dllearner/tools/ore/ConcurrencyBug.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ConcurrencyBug.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ConcurrencyBug.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -0,0 +1,95 @@ +package org.dllearner.tools.ore; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Timer; +import java.util.TimerTask; + +import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.kb.OWLFile; +import org.dllearner.learningproblems.ClassLearningProblem; +import org.dllearner.reasoning.PelletReasoner; +import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.model.OWLClass; +import org.semanticweb.owl.model.OWLDataFactory; +import org.semanticweb.owl.model.OWLObjectAllRestriction; +import org.semanticweb.owl.model.OWLObjectProperty; +import org.semanticweb.owl.model.OWLObjectSomeRestriction; +import org.semanticweb.owl.model.OWLOntologyCreationException; +import org.semanticweb.owl.model.OWLOntologyManager; +import org.semanticweb.owl.model.OWLSubClassAxiom; + +public class ConcurrencyBug { + + /** + * @param args + * @throws MalformedURLException + * @throws ComponentInitException + * @throws URISyntaxException + * @throws OWLOntologyCreationException + * @throws LearningProblemUnsupportedException + */ + public static void main(String[] args) throws MalformedURLException, ComponentInitException, OWLOntologyCreationException, URISyntaxException, LearningProblemUnsupportedException { + File file = new File("examples/swore/swore.rdf"); + URL classToDescribe = new URL("http://ns.softwiki.de/req/CustomerRequirement"); + + ComponentManager cm = ComponentManager.getInstance(); + OWLFile ks = cm.knowledgeSource(OWLFile.class); + ((OWLFile)ks).getConfigurator().setUrl(file.toURI().toURL()); + ks.init(); + + PelletReasoner reasoner = cm.reasoner(PelletReasoner.class, ks); + reasoner.init(); + reasoner.loadOntologies(); + reasoner.dematerialise(); + + ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); + lp.getConfigurator().setClassToDescribe(classToDescribe); + lp.init(); + + String NS = "http://ns.softwiki.de/req/"; + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + OWLDataFactory factory = manager.getOWLDataFactory(); + OWLClass customerRequirement = factory.getOWLClass(URI.create(NS +"CustomerRequirement")); + OWLClass comment = factory.getOWLClass(URI.create(NS + "Comment")); + OWLObjectProperty idDefinedBy = factory.getOWLObjectProperty(URI.create(NS + "isDefinedBy")); + OWLObjectProperty defines = factory.getOWLObjectProperty(URI.create(NS + "defines")); + + OWLObjectSomeRestriction some = factory.getOWLObjectSomeRestriction(defines, comment); + OWLObjectAllRestriction all = factory.getOWLObjectAllRestriction(idDefinedBy, some); + OWLSubClassAxiom sub = factory.getOWLSubClassAxiom(customerRequirement, all); + +// System.out.println(reasoner.remainsSatisfiableImpl(sub)); + + final CELOE la = cm.learningAlgorithm(CELOE.class, lp, reasoner); + la.getConfigurator().setMaxExecutionTimeInSeconds(8); + la.getConfigurator().setUseNegation(false); + la.getConfigurator().setNoisePercentage(0.05); + la.getConfigurator().setMaxNrOfResults(10); + la.init(); + + Timer timer = new Timer(); + timer.schedule(new TimerTask() { + + @Override + public void run() { + if(la.isRunning()){ + System.out.println(la.getCurrentlyBestEvaluatedDescriptions(10, 0.8, true)); + } else { + cancel(); + } + + } + }, 1000, 1000); + la.start(); + + + } + +} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationManager.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ExplanationManager.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -43,7 +43,7 @@ private RootFinder rootFinder; private boolean isComputeAllExplanations = false; - private int maxExplantionCount = 1; + private int maxExplanationCount = 1; private boolean allExplanationWarningChecked = false; private Map<Explanation, List<Map<OWLAxiom, Integer>>> orderingMap; @@ -113,7 +113,7 @@ if (isComputeAllExplanations) { explanations = gen.getExplanations(entailment); } else { - explanations = gen.getExplanations(entailment, maxExplantionCount); + explanations = gen.getExplanations(entailment, maxExplanationCount); } return explanations; @@ -127,9 +127,9 @@ if (isComputeAllExplanations) { explanations = gen.getExplanations(entailment); } else { - explanations = gen.getExplanations(entailment, maxExplantionCount); + explanations = gen.getExplanations(entailment, maxExplanationCount); } - + return explanations; } @@ -244,12 +244,12 @@ } public void setMaxExplantionCount(int limit){ - maxExplantionCount = limit; + maxExplanationCount = limit; fireExplanationLimitChanged(); } public int getMaxExplantionCount(){ - return maxExplantionCount; + return maxExplanationCount; } public void addListener(ExplanationManagerListener l){ Modified: trunk/src/dl-learner/org/dllearner/tools/ore/explanation/CachedExplanationGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/explanation/CachedExplanationGenerator.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/explanation/CachedExplanationGenerator.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -69,7 +69,7 @@ @Override public Set<Explanation> getExplanations(OWLAxiom entailment){ - return getExplanations(entailment, -1); + return getExplanations(entailment, Integer.MAX_VALUE); } public int getArity(OWLAxiom axiom){ Modified: trunk/src/dl-learner/org/dllearner/tools/ore/explanation/LaconicTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/explanation/LaconicTest.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/explanation/LaconicTest.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -8,6 +8,8 @@ import org.dllearner.tools.ore.explanation.laconic.LaconicExplanationGenerator; import org.mindswap.pellet.owlapi.PelletReasonerFactory; import org.mindswap.pellet.owlapi.Reasoner; +import org.mindswap.pellet.utils.Timer; +import org.mindswap.pellet.utils.Timers; import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.inference.OWLReasoner; import org.semanticweb.owl.inference.OWLReasonerException; @@ -69,7 +71,7 @@ } public static void miniEconomyTest() { - String file = "file:examples/ore/miniEconomy.owl"; + String file = "file:examples/ore/koala.owl"; try { @@ -78,28 +80,43 @@ OWLOntology ontology = manager.loadOntologyFromPhysicalURI(URI .create(file)); - PelletReasonerFactory resonerFact = new PelletReasonerFactory(); + PelletReasonerFactory reasonerFact = new PelletReasonerFactory(); OWLDataFactory dataFactory = manager.getOWLDataFactory(); - Reasoner reasoner = resonerFact.createReasoner(manager); + Reasoner reasoner = reasonerFact.createReasoner(manager); reasoner.loadOntology(ontology); reasoner.classify(); - System.out.println(reasoner.getInconsistentClasses()); - + LaconicExplanationGenerator expGen = new LaconicExplanationGenerator( - manager, resonerFact, Collections.singleton(ontology)); + manager, reasonerFact, Collections.singleton(ontology)); +// org.semanticweb.owl.explanation.api.ExplanationGenerator<OWLAxiom> copy = org.semanticweb.owl.explanation.api. +// ExplanationManager.createLaconicExplanationGeneratorFactory(reasonerFact).createExplanationGenerator(ontology.getAxioms()); + + Set<OWLClass> unsatClasses = reasoner.getInconsistentClasses(); OWLSubClassAxiom unsatAxiom; - + Timers timers = new Timers(); for (OWLClass unsat : unsatClasses) { unsatAxiom = dataFactory.getOWLSubClassAxiom(unsat, dataFactory .getOWLNothing()); + Timer t1 = timers.createTimer("t1"); + Timer t2 =timers.createTimer("t2"); + t1.start(); Set<Explanation> explanations = expGen .getExplanations(unsatAxiom); - System.out.println(explanations); + t1.stop(); +// System.out.println(explanations); + t2.start(); +// Set<org.semanticweb.owl.explanation.api.Explanation<OWLAxiom>> expl = copy.getExplanations(unsatAxiom); + t2.stop(); +// System.out.println(expl); + + for(Timer timer : timers.getTimers()){ + System.out.println(timer.getTotal()); + } } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -22,7 +22,7 @@ public ResultTableModel(){ super(); resultList = new ArrayList<EvaluatedDescriptionClass>(); - df = new DecimalFormat("00.00%"); + df = new DecimalFormat("00%"); } public ResultTableModel(List<EvaluatedDescriptionClass> resultList){ 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-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardController.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -29,6 +29,7 @@ import org.dllearner.tools.ore.ui.wizard.descriptors.AutoLearnPanelDescriptor; import org.dllearner.tools.ore.ui.wizard.descriptors.ClassChoosePanelDescriptor; import org.dllearner.tools.ore.ui.wizard.descriptors.InconsistencyExplanationPanelDescriptor; +import org.dllearner.tools.ore.ui.wizard.descriptors.IntroductionPanelDescriptor; import org.dllearner.tools.ore.ui.wizard.descriptors.KnowledgeSourcePanelDescriptor; import org.dllearner.tools.ore.ui.wizard.descriptors.ManualLearnPanelDescriptor; import org.dllearner.tools.ore.ui.wizard.descriptors.RepairPanelDescriptor; @@ -272,25 +273,25 @@ void refreshLeftPanel(Object panelDescriptor){ - if(panelDescriptor.equals("INTRODUCTION_PANEL")){ + if(panelDescriptor.equals(IntroductionPanelDescriptor.IDENTIFIER)){ wizard.setLeftPanel(0); - } - if(panelDescriptor.equals("KNOWLEDGESOURCE_CHOOSE_PANEL")){ + } else + if(panelDescriptor.equals(KnowledgeSourcePanelDescriptor.IDENTIFIER)){ wizard.setLeftPanel(1); - } - if(panelDescriptor.equals("CLASS_CHOOSE_OWL_PANEL") || panelDescriptor.equals("CLASS_CHOOSE_SPARQL_PANEL")){ + } else + if(panelDescriptor.equals(ClassChoosePanelDescriptor.IDENTIFIER)){ wizard.setLeftPanel(3); - } - if(panelDescriptor.equals("LEARNING_PANEL")){ + } else + if(panelDescriptor.equals(ManualLearnPanelDescriptor.IDENTIFIER) || panelDescriptor.equals(AutoLearnPanelDescriptor.IDENTIFIER)){ wizard.setLeftPanel(4); - } - if(panelDescriptor.equals("REPAIR_PANEL")){ + } else + if(panelDescriptor.equals(RepairPanelDescriptor.IDENTIFIER)){ wizard.setLeftPanel(5); - } - if(panelDescriptor.equals("SAVE_PANEL")){ + } else + if(panelDescriptor.equals(SavePanelDescriptor.IDENTIFIER)){ wizard.setLeftPanel(6); - } - if(panelDescriptor.equals(UnsatisfiableExplanationPanelDescriptor.IDENTIFIER)){ + } else { + wizard.setLeftPanel(2); } 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-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/AutoLearnPanelDescriptor.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -1,5 +1,8 @@ package org.dllearner.tools.ore.ui.wizard.descriptors; +import java.awt.Cursor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -22,7 +25,7 @@ import org.dllearner.tools.ore.ui.wizard.WizardPanelDescriptor; import org.dllearner.tools.ore.ui.wizard.panels.AutoLearnPanel; -public class AutoLearnPanelDescriptor extends WizardPanelDescriptor{ +public class AutoLearnPanelDescriptor extends WizardPanelDescriptor implements ActionListener{ /** * Identification string for class choose panel. */ @@ -35,6 +38,12 @@ private AutoLearnPanel autoLearnPanel; private List<NamedClass> classes; + + private EquivalentLearningTask equivalentLearningTask; + private SuperClassLearningTask superLearningTask; + + private int currentClassIndex = 0; + /** * Constructor creates new panel and adds listener to list. @@ -43,6 +52,8 @@ autoLearnPanel = new AutoLearnPanel(); setPanelDescriptorIdentifier(IDENTIFIER); setPanelComponent(autoLearnPanel); + + autoLearnPanel.addActionListener(this); classes = new ArrayList<NamedClass>(); } @@ -63,19 +74,38 @@ } public void fillClassesTable(){ + TaskManager.getInstance().setTaskStarted("Retrieving atomic classes..."); new ClassRetrievingTask().execute(); } public void learnEquivalentClassExpressions(){ - TaskManager.getInstance().setTaskStarted("Learning equivalent class expressions..."); - new EquivalentLearningTask().execute(); + TaskManager.getInstance().getStatusBar().setMessage("Learning equivalent class expressions..."); + getWizard().getDialog().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + equivalentLearningTask = new EquivalentLearningTask(); + equivalentLearningTask.addPropertyChangeListener(TaskManager.getInstance().getStatusBar()); + equivalentLearningTask.execute(); } public void learnSubClassExpressions(){ - TaskManager.getInstance().setTaskStarted("Learning superclass expressions..."); - new SuperClassLearningTask().execute(); + TaskManager.getInstance().getStatusBar().setMessage("Learning superclass expressions..."); + TaskManager.getInstance().getStatusBar().setProgress(0); + getWizard().getDialog().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + superLearningTask = new SuperClassLearningTask(); + superLearningTask.addPropertyChangeListener(TaskManager.getInstance().getStatusBar()); + superLearningTask.execute(); } + public void learnNextClass(){ + autoLearnPanel.resetPanel(); + OREManager.getInstance().setCurrentClass2Learn(new NamedClass("http://ns.softwiki.de/req/CustomerRequirement"));//classes.get(currentClassIndex)); + learnEquivalentClassExpressions(); + currentClassIndex++; + } + + @Override + public void actionPerformed(ActionEvent e) { + learnNextClass(); + } /** * Inner class to get all atomic classes in a background thread. @@ -122,7 +152,7 @@ autoLearnPanel.fillClassesTable(result); OREManager.getInstance().setCurrentClass2Learn(classes.get(0)); TaskManager.getInstance().setTaskFinished(); - learnEquivalentClassExpressions(); + learnNextClass(); } }); } @@ -130,134 +160,118 @@ class EquivalentLearningTask extends SwingWorker<Void, List<? extends EvaluatedDescription>> { + private Timer timer; + private LearningAlgorithm la; + private final int maxNrOfResults = OREManager.getInstance().getMaxNrOfResults(); + private final double threshold = OREManager.getInstance().getThreshold(); @Override public Void doInBackground() { OREManager.getInstance().setLearningType("equivalence"); OREManager.getInstance().setLearningProblem(); OREManager.getInstance().setLearningAlgorithm(); - - final LearningAlgorithm la = OREManager.getInstance().getLa(); - Timer timer = new Timer(); + la = OREManager.getInstance().getLa(); + + timer = new Timer(); + setProgress(0); + TaskManager.getInstance().getStatusBar().setMaximumValue(OREManager.getInstance().getMaxExecutionTimeInSeconds()); timer.schedule(new TimerTask(){ + int progress = 0; + List<? extends EvaluatedDescription> result; @SuppressWarnings("unchecked") @Override public void run() { - if(!isCancelled() && la.isRunning()){ - publish(la.getCurrentlyBestEvaluatedDescriptions(OREManager.getInstance().getMaxNrOfResults(), - OREManager.getInstance().getThreshold(), true)); + if(la.isRunning()){ + progress += 1; + setProgress(progress); + result = la.getCurrentlyBestEvaluatedDescriptions(maxNrOfResults, threshold, true); + publish(result); } } - }, 1000, 2000); + }, 1000, 1000); la.start(); return null; } @Override public void done() { - SwingUtilities.invokeLater(new Runnable() { - - @SuppressWarnings("unchecked") - @Override - public void run() { - - autoLearnPanel.fillEquivalentClassExpressionsTable((List<EvaluatedDescriptionClass>)OREManager.getInstance().getLa(). - getCurrentlyBestEvaluatedDescriptions(OREManager.getInstance().getMaxNrOfResults(), OREManager.getInstance().getThreshold(), true)); - learnSubClassExpressions(); - - } - }); + timer.cancel(); + List<? extends EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions(maxNrOfResults, threshold, true); + updateList(result); + learnSubClassExpressions(); } @Override - protected void process(List<List<? extends EvaluatedDescription>> resultLists) { - + protected void process(List<List<? extends EvaluatedDescription>> resultLists) { for (List<? extends EvaluatedDescription> list : resultLists) { updateList(list); } } - private void updateList(final List<? extends EvaluatedDescription> result) { - - Runnable doUpdateList = new Runnable() { - - @SuppressWarnings("unchecked") - public void run() { - autoLearnPanel.fillEquivalentClassExpressionsTable((List<EvaluatedDescriptionClass>) result); - } - }; - SwingUtilities.invokeLater(doUpdateList); - + @SuppressWarnings("unchecked") + private void updateList(final List<? extends EvaluatedDescription> result) { + autoLearnPanel.fillEquivalentClassExpressionsTable((List<EvaluatedDescriptionClass>) result); } } class SuperClassLearningTask extends SwingWorker<Void, List<? extends EvaluatedDescription>> { + private Timer timer; + private LearningAlgorithm la; + private final int maxNrOfResults = OREManager.getInstance().getMaxNrOfResults(); + private final double threshold = OREManager.getInstance().getThreshold(); @Override public Void doInBackground() { OREManager.getInstance().setLearningType("superClass"); OREManager.getInstance().setLearningProblem(); OREManager.getInstance().setLearningAlgorithm(); - - final LearningAlgorithm la = OREManager.getInstance().getLa(); - Timer timer = new Timer(); + la = OREManager.getInstance().getLa(); + + timer = new Timer(); + setProgress(0); + TaskManager.getInstance().getStatusBar().setMaximumValue(OREManager.getInstance().getMaxExecutionTimeInSeconds()); timer.schedule(new TimerTask(){ + int progress = 0; + List<? extends EvaluatedDescription> result; @SuppressWarnings("unchecked") @Override public void run() { - if(!isCancelled() && la.isRunning()){ - publish(la.getCurrentlyBestEvaluatedDescriptions(OREManager.getInstance().getMaxNrOfResults(), - OREManager.getInstance().getThreshold(), true)); + if(la.isRunning()){ + progress += 1; + setProgress(progress); + result = la.getCurrentlyBestEvaluatedDescriptions(maxNrOfResults, threshold, true); + publish(result); } } - }, 1000, 2000); + }, 1000, 1000); la.start(); - return null; } @Override public void done() { - SwingUtilities.invokeLater(new Runnable() { - - @SuppressWarnings("unchecked") - @Override - public void run() { - - autoLearnPanel.fillSuperClassExpressionsTable((List<EvaluatedDescriptionClass>)OREManager.getInstance().getLa(). - getCurrentlyBestEvaluatedDescriptions(OREManager.getInstance().getMaxNrOfResults(), OREManager.getInstance().getThreshold(), true)); - TaskManager.getInstance().setTaskFinished(); - } - }); + timer.cancel(); + List<? extends EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions(maxNrOfResults, threshold, true); + updateList(result); + TaskManager.getInstance().setTaskFinished(); + setProgress(0); } @Override - protected void process(List<List<? extends EvaluatedDescription>> resultLists) { - + protected void process(List<List<? extends EvaluatedDescription>> resultLists) { for (List<? extends EvaluatedDescription> list : resultLists) { updateList(list); } } + @SuppressWarnings("unchecked") private void updateList(final List<? extends EvaluatedDescription> result) { - - Runnable doUpdateList = new Runnable() { - - @SuppressWarnings("unchecked") - public void run() { - autoLearnPanel.fillSuperClassExpressionsTable((List<EvaluatedDescriptionClass>) result); - } - }; - SwingUtilities.invokeLater(doUpdateList); - + autoLearnPanel.fillSuperClassExpressionsTable((List<EvaluatedDescriptionClass>) result); } } - - - } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/InconsistencyExplanationPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/InconsistencyExplanationPanelDescriptor.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/InconsistencyExplanationPanelDescriptor.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -1,13 +1,22 @@ package org.dllearner.tools.ore.ui.wizard.descriptors; +import java.awt.BorderLayout; +import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; -import javax.swing.SwingUtilities; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSpinner; import javax.swing.SwingWorker; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import org.dllearner.tools.ore.ExplanationManager; +import org.dllearner.tools.ore.ExplanationManagerListener; import org.dllearner.tools.ore.OREManager; import org.dllearner.tools.ore.RepairManager; import org.dllearner.tools.ore.RepairManagerListener; @@ -18,7 +27,7 @@ import org.mindswap.pellet.owlapi.Reasoner; import org.semanticweb.owl.model.OWLOntologyChange; -public class InconsistencyExplanationPanelDescriptor extends WizardPanelDescriptor implements ActionListener, RepairManagerListener{ +public class InconsistencyExplanationPanelDescriptor extends WizardPanelDescriptor implements ActionListener,ChangeListener, ExplanationManagerListener, RepairManagerListener{ public static final String IDENTIFIER = "INCONSISTENCY_PANEL"; public static final String INFORMATION = ""; @@ -32,14 +41,18 @@ } public void init() { - reasoner = OREManager.getInstance().getReasoner() - .getReasoner(); + reasoner = OREManager.getInstance().getReasoner().getReasoner(); + expMan = ExplanationManager.getInstance(OREManager.getInstance()); - expMan.setComputeAllExplanationsMode(true); + expMan.addListener(this); + repMan = RepairManager.getInstance(OREManager.getInstance()); repMan.addListener(this); + panel = new InconsistencyExplanationPanel(); panel.addActionListeners(this); + panel.addChangeListener(this); + setPanelComponent(panel); } @@ -79,28 +92,77 @@ showExplanations(); } - @Override - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("regular")) { - expMan.setLaconicMode(false); - } else if (e.getActionCommand().equals("laconic")) { - expMan.setLaconicMode(true); - } - } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("regular")) { + expMan.setLaconicMode(false); + } else if (e.getActionCommand().equals("laconic")) { + expMan.setLaconicMode(true); + } else if (e.getActionCommand().equals("all")){ + conditionalWarning("Computing all explanations might take a long time!", getWizard().getDialog()); + expMan.setComputeAllExplanationsMode(true); + panel.setMaxExplanationsMode(false); + } else if (e.getActionCommand().equals("max")){ + expMan.setComputeAllExplanationsMode(false); + panel.setMaxExplanationsMode(true); + } + } + @Override public void repairPlanChanged() { // TODO Auto-generated method stub } + + @Override + public void stateChanged(ChangeEvent e) { + JSpinner spinner = (JSpinner)e.getSource(); + expMan.setMaxExplantionCount(((Integer)spinner.getValue()).intValue()); + + } @Override + public void explanationLimitChanged() { + showExplanations(); + } + + @Override + public void explanationTypeChanged() { + showExplanations(); + } + + @Override public void repairPlanExecuted(List<OWLOntologyChange> changes) { showExplanations(); panel.repaint(); setNextButtonEnabled2ConsistentOntology(); } + private void conditionalWarning(final String notice, Component parent) { + class NotifyPanel extends JPanel { + /** + * + */ + private static final long serialVersionUID = -5602333953438722592L; + + public NotifyPanel() { + final JCheckBox enough = new JCheckBox("Don't show this message again", expMan.isAllExplanationWarningChecked()); + enough.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + expMan.setAllExplanationWarningChecked(); + } + }); + setLayout(new BorderLayout()); + add(new JLabel("<html><font size=+1>" + notice + "</font></html>"), BorderLayout.CENTER); + add(enough, BorderLayout.SOUTH); + } + } + if( ! expMan.isAllExplanationWarningChecked()) + JOptionPane.showMessageDialog(parent, new NotifyPanel(), "Warning", JOptionPane.WARNING_MESSAGE); + } + class ExplanationTask extends SwingWorker<Void, Void>{ @Override @@ -118,22 +180,16 @@ } private void showExplanations(){ - - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - panel.clearExplanationsPanel(); - int counter = 1; - for (Explanation explanation : expMan - .getInconsistencyExplanations()) { - panel.addExplanation(explanation, counter); - counter++; - } - panel.validate(); - + panel.clearExplanationsPanel(); + int counter = 1; + for (Explanation explanation : expMan.getInconsistencyExplanations()) { + panel.addExplanation(explanation, counter); + counter++; + if(counter > expMan.getMaxExplantionCount() && !expMan.isComputeAllExplanationsMode()){ + break; } - }); + } + panel.validate(); TaskManager.getInstance().setTaskFinished(); } 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-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/ManualLearnPanelDescriptor.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -26,9 +26,7 @@ import java.util.List; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.ExecutionException; -import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -212,12 +210,12 @@ * @author Lorenz Buehmann * */ - class LearningTask extends SwingWorker<List<? extends EvaluatedDescription>, List<? extends EvaluatedDescription>> { + class LearningTask extends SwingWorker<Void, List<? extends EvaluatedDescription>> { @SuppressWarnings("unchecked") @Override - public List<? extends EvaluatedDescription> doInBackground() { + public Void doInBackground() { OREManager.getInstance().setLearningProblem(); OREManager.getInstance().setLearningAlgorithm(); @@ -233,32 +231,27 @@ @Override public void run() {progress += 1;setProgress(progress); if(!isCancelled() && la.isRunning()){ - publish(la.getCurrentlyBestEvaluatedDescriptions(OREManager.getInstance().getMaxNrOfResults(), - OREManager.getInstance().getThreshold(), true)); + List<? extends EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions(OREManager.getInstance().getMaxNrOfResults(), + OREManager.getInstance().getThreshold(), true); + publish(result); } } }, 1000, 1000); - OREManager.getInstance().start(); + la.start(); - List<? extends EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions - (OREManager.getInstance().getMaxNrOfResults(), OREManager.getInstance().getThreshold(), true); - return result; + + return null; } @Override public void done() { timer.cancel(); - List<? extends EvaluatedDescription> result = null; - try { - result = get(); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } + + List<? extends EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions(OREManager.getInstance().getMaxNrOfResults(), + OREManager.getInstance().getThreshold(), true); updateList(result); TaskManager.getInstance().setTaskFinished(); setProgress(0); @@ -269,22 +262,14 @@ @Override protected void process(List<List<? extends EvaluatedDescription>> resultLists) { - for (List<? extends EvaluatedDescription> list : resultLists) { updateList(list); } } - private void updateList(final List<? extends EvaluatedDescription> result) { - - Runnable doUpdateList = new Runnable() { - - @SuppressWarnings("unchecked") - public void run() { - learnPanel.getResultTable().addResults((List<EvaluatedDescriptionClass>) result); - } - }; - SwingUtilities.invokeLater(doUpdateList); + @SuppressWarnings("unchecked") + private void updateList(final List<? extends EvaluatedDescription> result) { + learnPanel.getResultTable().addResults((List<EvaluatedDescriptionClass>) result); } } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -1,11 +1,17 @@ package org.dllearner.tools.ore.ui.wizard.panels; import java.awt.BorderLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionListener; import java.util.List; import java.util.Set; import javax.swing.BorderFactory; +import javax.swing.JButton; import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; @@ -36,7 +42,15 @@ private GraphicalCoveragePanel equivalentClassCoveragePanel; private GraphicalCoveragePanel superClassCoveragePanel; - + + private JLabel equivalentInconsistencyLabel; + private JLabel superInconsistencyLabel; + + private JButton skipButton; + + private final static String INCONSISTENY_WARNING = "<html><font color=red>" + + "Warning. Selected class expressions leads to an inconsistent ontology!" + + "</font></html>"; public AutoLearnPanel(){ createUI(); } @@ -68,29 +82,78 @@ equivSubSplitPane.setOneTouchExpandable(true); equivSubSplitPane.setDividerLocation(0.5); + equivSubSplitPane.setTopComponent(createEquivalentPanel()); + equivSubSplitPane.setBottomComponent(createSuperPanel()); + + addTableSelectionListeners(); + + skipButton = new JButton("Skip"); + skipButton.setActionCommand("skip"); + + resultPanel.add(equivSubSplitPane, BorderLayout.CENTER); + resultPanel.add(skipButton, BorderLayout.SOUTH); + + return resultPanel; + } + + private JComponent createEquivalentPanel(){ + GridBagConstraints c = new GridBagConstraints(); equivalentPanel = new JPanel(); + equivalentPanel.setLayout(new GridBagLayout()); + + c.weightx = 1.0; + c.weighty = 1.0; + c.fill = GridBagConstraints.BOTH; + c.gridx = 0; + c.gridy = 0; equivalentClassResultsTable = new EquivalentClassExpressionsTable(); equivalentClassResultsTable.setName("equivalent"); - equivalentPanel.add(new JScrollPane(equivalentClassResultsTable)); + equivalentPanel.add(new JScrollPane(equivalentClassResultsTable), c); + + c.weightx = 0.0; + c.weighty = 0.0; + c.gridx = 1; + c.gridy = 0; equivalentClassCoveragePanel = new GraphicalCoveragePanel(""); - equivalentPanel.add(equivalentClassCoveragePanel); + equivalentPanel.add(equivalentClassCoveragePanel, c); equivalentPanel.setBorder(BorderFactory.createTitledBorder("Equivalent class expressions")); + c.gridx = 0; + c.gridy = 1; + equivalentInconsistencyLabel = new JLabel(" "); + equivalentPanel.add(equivalentInconsistencyLabel, c); + + return equivalentPanel; + } + + private JComponent createSuperPanel(){ + GridBagConstraints c = new GridBagConstraints(); superPanel = new JPanel(); + superPanel.setLayout(new GridBagLayout()); + + c.weightx = 1.0; + c.weighty = 1.0; + c.fill = GridBagConstraints.BOTH; + c.gridx = 0; + c.gridy = 0; superClassResultsTable = new EquivalentClassExpressionsTable(); superClassResultsTable.setName("super"); - superPanel.add(new JScrollPane(superClassResultsTable)); + superPanel.add(new JScrollPane(superClassResultsTable), c); + + c.weightx = 0.0; + c.weighty = 0.0; + c.gridx = 1; + c.gridy = 0; superClassCoveragePanel = new GraphicalCoveragePanel(""); - superPanel.add(superClassCoveragePanel); + superPanel.add(superClassCoveragePanel, c); superPanel.setBorder(BorderFactory.createTitledBorder("Superclass expressions")); - addTableSelectionListeners(); + c.gridx = 0; + c.gridy = 1; + superInconsistencyLabel = new JLabel(" "); + superPanel.add(superInconsistencyLabel, c); - equivSubSplitPane.setTopComponent(equivalentPanel); - equivSubSplitPane.setBottomComponent(superPanel); - - resultPanel.add(equivSubSplitPane); - return resultPanel; + return superPanel; } public void fillClassesTable(Set<NamedClass> classes){ @@ -105,6 +168,17 @@ equivalentClassResultsTable.addResults(resultList); } + public void addActionListener(ActionListener aL){ + skipButton.addActionListener(aL); + } + + public void resetPanel(){ + equivalentClassResultsTable.clear(); + superClassResultsTable.clear(); + equivalentClassCoveragePanel.clear(); + superClassCoveragePanel.clear(); + } + private void addTableSelectionListeners(){ equivalentClassResultsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override @@ -114,7 +188,12 @@ EvaluatedDescriptionClass selectedClassExpression = equivalentClassResultsTable.getSelectedValue(); OREManager.getInstance().setNewClassDescription(selectedClassExpression); - equivalentClassCoveragePanel.setNewClassDescription(selectedClassExpression); + equivalentClassCoveragePanel.setNewClassDescription(selectedClassExpression); + if(!selectedClassExpression.isConsistent()){ + equivalentInconsistencyLabel.setText(INCONSISTENY_WARNING); + } else { + equivalentInconsistencyLabel.setText(" "); + } } } @@ -129,7 +208,12 @@ EvaluatedDescriptionClass selectedClassExpression = superClassResultsTable.getSelectedValue(); OREManager.getInstance().setNewClassDescription(selectedClassExpression); - superClassCoveragePanel.setNewClassDescription(selectedClassExpression); + superClassCoveragePanel.setNewClassDescription(selectedClassExpression); + if(!selectedClassExpression.isConsistent()){ + superInconsistencyLabel.setText(INCONSISTENY_WARNING); + } else { + superInconsistencyLabel.setText(" "); + } } } }); @@ -143,4 +227,14 @@ superClassCoveragePanel.setNewClassDescription(desc); } + public static void main(String[] args){ + JFrame frame = new JFrame(); + + + frame.add(new AutoLearnPanel()); + frame.pack(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassChoosePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassChoosePanel.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/ClassChoosePanel.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -28,6 +28,7 @@ import javax.swing.BorderFactory; import javax.swing.ButtonGroup; +import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; @@ -72,29 +73,45 @@ private void createUI(){ setLayout(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + JPanel optionsPanel = new JPanel(new GridLayout(0, 1)); + autoLearnButton = new JRadioButton("Automatic learning mode"); autoLearnButton.setActionCommand("auto"); + manualLearnButton = new JRadioButton("Manual learning mode"); manualLearnButton.setActionCommand("manual"); + ButtonGroup learningType = new ButtonGroup(); learningType.add(manualLearnButton); learningType.add(autoLearnButton); autoLearnButton.setSelected(true); optionsPanel.add(autoLearnButton); optionsPanel.add(manualLearnButton); + HelpablePanel optionsHelpPanel = new HelpablePanel(optionsPanel); optionsHelpPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); - add(optionsHelpPanel); + c.gridwidth = GridBagConstraints.REMAINDER; + add(optionsHelpPanel, c); + createAutoLearnPanel(); createManualLearnPanel(); + + Dimension size = new Dimension(500, 500); + autoLearnPanel.setPreferredSize(size); + manualLearnPanel.setPreferredSize(size); + currentPanel = autoLearnPanel; - add(currentPanel); + add(currentPanel, c); } private void createAutoLearnPanel(){ JPanel panel = new JPanel(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + + c.gridwidth = GridBagConstraints.REMAINDER; JPanel minInstancesCountPanel = new JPanel(); minInstancesCountPanel.add(new JLabel("Min. instance count per class: ")); minInstanceCountSpinner = new JSpinner(); @@ -102,9 +119,10 @@ javax.swing.SpinnerModel spinnerModel = new SpinnerNumberModel(1, 1, 500, 1); minInstanceCountSpinner.setModel(spinnerModel); minInstancesCountPanel.add(minInstanceCountSpinner); - panel.add(minInstancesCountPanel); + panel.add(minInstancesCountPanel, c); + learningOptionsPanel = new LearningOptionsPanel(); - panel.add(learningOptionsPanel); + panel.add(learningOptionsPanel, c); autoLearnPanel = panel; } @@ -187,8 +205,19 @@ OREManager.getInstance().setMaxExecutionTimeInSeconds(learningOptionsPanel.getMaxExecutionTime()); OREManager.getInstance().setMaxNrOfResults(learningOptionsPanel.getNrOfConcepts()); OREManager.getInstance().setNoisePercentage(learningOptionsPanel.getMinAccuracy()); + OREManager.getInstance().setThreshold(learningOptionsPanel.getThreshold()); OREManager.getInstance().setMinInstanceCount(((Integer)(minInstanceCountSpinner.getValue())).intValue()); } + + public static void main(String[] args){ + JFrame frame = new JFrame(); + + + frame.add(new ClassChoosePanel()); + frame.pack(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + } } \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -2,8 +2,13 @@ import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Insets; import java.awt.event.ActionListener; +import java.util.HashSet; +import java.util.Set; import javax.swing.BorderFactory; import javax.swing.Box; @@ -13,12 +18,18 @@ import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; +import javax.swing.JSpinner; import javax.swing.JSplitPane; +import javax.swing.SpinnerNumberModel; +import javax.swing.border.EtchedBorder; +import javax.swing.event.ChangeListener; import org.dllearner.tools.ore.explanation.Explanation; import org.dllearner.tools.ore.ui.ExplanationTable; import org.dllearner.tools.ore.ui.ExplanationTablePanel; +import org.dllearner.tools.ore.ui.HelpablePanel; import org.dllearner.tools.ore.ui.RepairPlanPanel; +import org.dllearner.tools.ore.ui.UnsatisfiableClassesTable; import org.semanticweb.owl.apibinding.OWLManager; public class InconsistencyExplanationPanel extends JPanel{ @@ -28,81 +39,142 @@ */ private static final long serialVersionUID = 9206626647697013786L; - private JSplitPane statsSplitPane; - private JScrollPane explanationsScrollPane; private JComponent explanationsPanel; + private JPanel buttonExplanationsPanel; - private JPanel buttonPanel; + + private ButtonGroup explanationType; private JRadioButton regularButton; private JRadioButton laconicButton; + private JRadioButton computeAllExplanationsRadioButton; + private JRadioButton computeMaxExplanationsRadioButton; + private JSpinner maxExplanationsSelector; + + + private Set<ExplanationTablePanel> explanationPanels; + private Set<ExplanationTable> explanationTables; + + public InconsistencyExplanationPanel() { + createUI(); + } + private void createUI(){ setLayout(new BorderLayout()); + add(createDebuggingPanel()); + } + + private JComponent createDebuggingPanel(){ + JSplitPane debuggingSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + debuggingSplitPane.setDividerLocation(500); + debuggingSplitPane.setOneTouchExpandable(true); - Dimension minimumSize = new Dimension(400, 400); - - + debuggingSplitPane.setTopComponent(createExplanationPanel()); + debuggingSplitPane.setBottomComponent(createRepairPanel()); + + return debuggingSplitPane; + } + + private JComponent createExplanationPanel(){ explanationsPanel = new Box(1); + + explanationPanels = new HashSet<ExplanationTablePanel>(); + explanationTables = new HashSet<ExplanationTable>(); JPanel pan = new JPanel(new BorderLayout()); pan.add(explanationsPanel, BorderLayout.NORTH); explanationsScrollPane = new JScrollPane(pan); - explanationsScrollPane.setPreferredSize(minimumSize); - explanationsScrollPane.setBorder(BorderFactory - .createLineBorder(Color.LIGHT_GRAY)); + + explanationsScrollPane.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); explanationsScrollPane.getViewport().setOpaque(false); explanationsScrollPane.getViewport().setBackground(null); explanationsScrollPane.setOpaque(false); + + buttonExplanationsPanel = new JPanel(); + buttonExplanationsPanel.setLayout(new BorderLayout()); + buttonExplanationsPanel.add(explanationsScrollPane, BorderLayout.CENTER); + JPanel holder = new JPanel(new BorderLayout()); + holder.add(createExplanationHeaderPanel(), BorderLayout.WEST); + buttonExplanationsPanel.add(holder, BorderLayout.NORTH); + + return buttonExplanationsPanel; - regularButton = new JRadioButton("regular", true); + } + + private JComponent createExplanationHeaderPanel(){ + JPanel headerPanel = new JPanel(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + + + JPanel explanationTypePanel = new JPanel(new GridLayout(0, 1)); + regularButton = new JRadioButton("Show regular explanations", true); regularButton.setActionCommand("regular"); - - laconicButton = new JRadioButton("laconic"); + regularButton.setSelected(true); + laconicButton = new JRadioButton("Show precise explanations"); laconicButton.setActionCommand("laconic"); - explanationType = new ButtonGroup(); explanationType.add(regularButton); explanationType.add(laconicButton); - buttonPanel = new JPanel(); - buttonPanel.add(regularButton); - buttonPanel.add(laconicButton); - - buttonExplanationsPanel = new JPanel(); - buttonExplanationsPanel.setLayout(new BorderLayout()); - buttonExplanationsPanel - .add(explanationsScrollPane, BorderLayout.CENTER); - buttonExplanationsPanel.add(buttonPanel, BorderLayout.NORTH); - - statsSplitPane = new JSplitPane(0); - statsSplitPane.setResizeWeight(1.0D); - statsSplitPane.setTopComponent(buttonExplanationsPanel); + explanationTypePanel.add(regularButton); + explanationTypePanel.add(laconicButton); + HelpablePanel explanationTypeHelpPanel = new HelpablePanel(explanationTypePanel); + explanationTypeHelpPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); - //repair panel - JPanel repairPanelHolder = new JPanel(); - repairPanelHolder.setOpaque(false); - repairPanelHolder.setLayout(new BorderLayout()); - repairPanelHolder.add(new JLabel("Repair plan"), BorderLayout.NORTH); - RepairPlanPanel repairPanel = new RepairPlanPanel(); - repairPanelHolder.add(repairPanel); + JPanel explanationCountPanel = new JPanel(new GridBagLayout()); - statsSplitPane.setBottomComponent(repairPanelHolder); - - statsSplitPane.setBorder(null); - statsSplitPane.setDividerLocation(500); - statsSplitPane.setOneTouchExpandable(true); - - add(statsSplitPane); + maxExplanationsSelector = new JSpinner(); + maxExplanationsSelector.setEnabled(true); + javax.swing.SpinnerModel spinnerModel = new SpinnerNumberModel(1, 1, 500, 1); + maxExplanationsSelector.setModel(spinnerModel); + maxExplanationsSelector.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); + + computeAllExplanationsRadioButton = new JRadioButton("Compute all explanations"); + computeAllExplanationsRadioButton.setActionCommand("all"); + + computeMaxExplanationsRadioButton = new JRadioButton("Limit explanation count to:"); + computeMaxExplanationsRadioButton.setActionCommand("max"); + computeMaxExplanationsRadioButton.setSelected(true); + + ButtonGroup limitButtonGroup = new ButtonGroup(); + limitButtonGroup.add(computeAllExplanationsRadioButton); + limitButtonGroup.add(computeMaxExplanationsRadioButton); + + explanationCountPanel.add(computeAllExplanationsRadioButton, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 12, 2, new Insets(0, 0, 0, 0), 0, 0)); + explanationCountPanel.add(computeMaxExplanationsRadioButton, new GridBagConstraints(0, 1, 1, 1, 0.0D, 0.0D, 12, 2, new Insets(0, 0, 0, 0), 0, 0)); + explanationCountPanel.add(maxExplanationsSelector, new GridBagConstraints(1, 1, 1, 1, 0.0D, 0.0D, 12, 2, new Insets(0, 0, 0, 0), 0, 0)); + + HelpablePanel explanationCountHelpPanel = new HelpablePanel(explanationCountPanel); + explanationCountHelpPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); + + c.fill = GridBagConstraints.VERTICAL; + + headerPanel.add(explanationTypeHelpPanel, c); + c.anchor = GridBagConstraints.LINE_END; + headerPanel.add(explanationCountHelpPanel, c); + + return headerPanel; + } + private JComponent createRepairPanel(){ + JPanel repairPanel = new JPanel(new BorderLayout()); + repairPanel.add(new JLabel("Repair plan"), BorderLayout.NORTH); + repairPanel.add(new RepairPlanPanel(), BorderLayout.CENTER); + return repairPanel; } - public void clearExplanationsPanel(){ + public void clearExplanationsPanel() { explanationsPanel.removeAll(); + explanationsPanel.validate(); } + public void setMaxExplanationsMode(boolean value){ + maxExplanationsSelector.setEnabled(value); + } + public void addExplanation(Explanation explanation, int counter){ ExplanationTable expTable = new ExplanationTable(explanation, OWLManager.createOWLOntologyManager().getOWLDataFactory().getOWLThing()); explanationsPanel.add(new ExplanationTablePanel(expTable, counter)); @@ -113,6 +185,12 @@ public void addActionListeners(ActionListener aL){ regularButton.addActionListener(aL); laconicButton.addActionListener(aL); + computeAllExplanationsRadioButton.addActionListener(aL); + computeMaxExplanationsRadioButton.addActionListener(aL); } + public void addChangeListener(ChangeListener cL){ + maxExplanationsSelector.addChangeListener(cL); + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java 2009-09-30 06:19:13 UTC (rev 1870) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java 2009-10-01 12:05:40 UTC (rev 1871) @@ -137,56 +137,11 @@ JPanel pan = new JPanel(new BorderLayout()); pan.add(explanationsPanel, BorderLayout.NORTH); explanationsScrollPane = new JScrollPane(pan); -// explanationsScrollPane.setPreferredSize(minimumSize); + explanationsScrollPane.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); explanationsScrollPane.getViewport().setOpaque(false); explanationsScrollPane.getViewport().setBackground(null); explanationsScrollPane.setOpaque(false); - -// regularButton = new JRadioButton("Show regular explanations", true); -// regularButton.setActionCommand("regular"); -// regularButton.setSelected(true); -// laconicButton = new JRadioButton("Show precise explanations"); -// laconicButton.setActionCommand("laconic"); -// -// explanationType = new ButtonGroup(); -// explanationType.add(regularButton); -// explanationType.add(laconicButton); -// -// buttonPanel = new JPanel(); -// buttonPanel.setLayout(new GridBagLayout()); -// buttonPanel.add(regularButton, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 12, 2, new Insets(0, 0, 2, 30), 0, 0)); -// buttonPanel.add(laconicButton, new GridBagConstraints(0, 1, 1, 1, 0.0D, 0.0D, 12, 2, new Insets(0, 0, 0, 30), 0, 0)); -// HelpablePanel explanationTypeHelpPanel = new HelpablePanel(buttonPanel); -// explanationTypeHelpPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); -// -// JPanel buttonPanelHolder = new JPanel(new BorderLayout()); -// buttonPanelHolder.add(explanationTypeHelpPanel, "West"); -// -// maxExplanationsSelector = new JSpinner(); -// maxExplanationsSelector.setEnabled(true); -// javax.swing.SpinnerModel spinnerModel = new SpinnerNumberModel(1, 1, 500, 1); -// maxExplanationsSelector.setModel(spinnerModel); -// maxExplanationsSelector.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); -// -// computeAllExplanationsRadioButton = new JRadioButton("Compute all explanations"); -// computeAllExplanationsRadioButton.setActionCommand("all"); -// -// computeMaxExplanationsRadioButton = new JRadioButton("Limit explanation count to:"); -// computeMaxExplanationsRadioButton.setActionCommand("MAX"); -// computeMaxExplanationsRadioButton.setSelected(true); -// -// ButtonGroup limitButtonGroup = new ButtonGroup(); -// limitButtonGroup.add(computeAllExplanationsRadioButton); -// limitButtonGroup.add(computeMaxExplanationsRadioButton); -// -//// buttonPanel.add(computeAllExplanationsRadioButton, new GridBagConstraints(1, 0, 1, 1, 0.0D, 0.0D, 12, 2, new Insets(0, 0, 0, 0), 0, 0)); -//// buttonPanel.add(computeMaxExplanationsRadioButton, new GridBagConstraints(1, 1, 1, 1, 0.0D, 0.0D, 12, 2, new Insets(0, 0, 0, 0), 0, 0)); -//// buttonPanel.add(maxExplanationsSelector, new GridBagConstraints(3, 1, 1, 1, 0.0D, 0.0D, 12, 2, new Insets(0, 0, 0, 0), 0, 0)); -// -// strikeOutBox = new JCheckBox("Strike out irrelevant parts"); -// strikeOutBox.setActionCommand("strike"); -//// buttonPanel.add(strikeOutBox, new GridBagConstraints(3, 0, 1, 1, 0.0D, 0.0D, 12, 2, new Insets(0, 0, 0, 0), 0, 0)); buttonExplanationsPanel = new JPanel(); buttonExplanationsPanel.setLayout(new BorderLayout()); @@ -231,7 +186,7 @@ computeAllExplanationsRadioButton.setActionCommand("all"); computeMaxExplanationsRadioButton = new JRadioButton("Limit explanation count to:"); - computeMaxExplanationsRadioButton.setActionCommand("MAX"); + computeMaxExplanationsRadioButton.setActionCommand("max"); computeMaxExplanationsRadioButton.setSelected(true); ButtonGroup limitButtonGroup = new ButtonGroup(); @@ -283,20 +238,20 @@ return impactRepairPanel; } - private JComponent createRepairPanel(){ - return new RepairPlanPanel(); - } +// private JComponent createRepairPanel(){ +// return new RepairPlanPanel(); +// } +// +// private JComponent createImpactPanel(){ +// ImpactTable impactTable = new ImpactTable(); +// JScrollPane impScr = new JScrollPane(impactTable); +// JPanel impactPanel = new JPanel(); +// impactPanel.setLayout(new BorderLayout()); +// impactPanel.add(new JLabel("Impact"), BorderLayout.NORTH); +// impactPanel.add(impScr); +// return impactPanel; +// } - private JComponent createImpactPanel(){ - ImpactTable impactTable = new ImpactTable(); - JScrollPane impScr = new JScrollPane(impactTable); - JPanel impactPanel = new JPanel(); - impactPanel.setLayout(new BorderLayout()); - impactPanel.add(new JLabel("Impact"), BorderLayout.NORTH); - impactPanel.add(impScr); - return impactPanel; - } - public void fillUnsatClassesTable(List<OWLClass> unsatClasses) { unsatClassesTable.addUnsatClasses(unsatClasses); unsatClassesScrollPane.validate(); @@ -306,17 +261,6 @@ explanationsPanel.removeAll(); explanationsPanel.validate(); } - - public void addExplanation(Explanation explanation, OWLClass unsat, int counter) { - ExplanationTable expTable = new ExplanationTable(explanation, unsat); - ExplanationTablePanel panel = new ExplanationTablePanel(expTable, counter); - explanationsPanel.add(panel); - explanationsPanel.add(Box.createVerticalStrut(10)); - explanationPanels.add(panel); -// explanationsPanel.add(new JSeparator()); -// explanationsPanel.add(Box.createVerticalStrut(10)); -// this.updateUI(); - } public void addExplanations(Set<Explanation> explanations, OWLClass unsat){ explanationTables.clear(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-10-03 11:29:13
|
Revision: 1876 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1876&view=rev Author: lorenz_b Date: 2009-10-03 11:29:04 +0000 (Sat, 03 Oct 2009) Log Message: ----------- continued auto learning mode Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java trunk/src/dl-learner/org/dllearner/tools/ore/ConcurrencyBug.java trunk/src/dl-learner/org/dllearner/tools/ore/OREManager.java trunk/src/dl-learner/org/dllearner/tools/ore/explanation/relevance/SyntacticRelevanceBasedExplanationGenerator.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/HelpablePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/MetricsPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairPlanPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardController.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/SavePanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/UnsatisfiableExplanationPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableTableModel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTableModel.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTableModel.java Modified: trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/core/LearningAlgorithm.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -254,6 +254,8 @@ // be in the search of the learning algorith, which leads to // unpredictable behaviour) Description d = ed.getDescription().clone(); + + //commented out because reasoner is called. leads in swing applications sometimes to exceptions // ConceptTransformation.replaceRange(d, reasoner); ed.setDescription(d); Modified: trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/reasoning/PelletReasoner.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -199,7 +199,7 @@ ontology = manager.loadOntologyFromPhysicalURI(url .toURI()); } - + owlAPIOntologies.add(ontology); // imports includes the ontology itself Set<OWLOntology> imports = manager @@ -1466,7 +1466,7 @@ public OWLOntology getOWLAPIOntologies() { - return reasoner.getLoadedOntologies().iterator().next(); + return owlAPIOntologies.get(0); } /*public void setReasonerType(String type){ Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ConcurrencyBug.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ConcurrencyBug.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ConcurrencyBug.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -2,7 +2,6 @@ import java.io.File; import java.net.MalformedURLException; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Timer; @@ -15,15 +14,7 @@ import org.dllearner.kb.OWLFile; import org.dllearner.learningproblems.ClassLearningProblem; import org.dllearner.reasoning.PelletReasoner; -import org.semanticweb.owl.apibinding.OWLManager; -import org.semanticweb.owl.model.OWLClass; -import org.semanticweb.owl.model.OWLDataFactory; -import org.semanticweb.owl.model.OWLObjectAllRestriction; -import org.semanticweb.owl.model.OWLObjectProperty; -import org.semanticweb.owl.model.OWLObjectSomeRestriction; import org.semanticweb.owl.model.OWLOntologyCreationException; -import org.semanticweb.owl.model.OWLOntologyManager; -import org.semanticweb.owl.model.OWLSubClassAxiom; public class ConcurrencyBug { @@ -53,20 +44,8 @@ lp.getConfigurator().setClassToDescribe(classToDescribe); lp.init(); - String NS = "http://ns.softwiki.de/req/"; - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - OWLDataFactory factory = manager.getOWLDataFactory(); - OWLClass customerRequirement = factory.getOWLClass(URI.create(NS +"CustomerRequirement")); - OWLClass comment = factory.getOWLClass(URI.create(NS + "Comment")); - OWLObjectProperty idDefinedBy = factory.getOWLObjectProperty(URI.create(NS + "isDefinedBy")); - OWLObjectProperty defines = factory.getOWLObjectProperty(URI.create(NS + "defines")); - OWLObjectSomeRestriction some = factory.getOWLObjectSomeRestriction(defines, comment); - OWLObjectAllRestriction all = factory.getOWLObjectAllRestriction(idDefinedBy, some); - OWLSubClassAxiom sub = factory.getOWLSubClassAxiom(customerRequirement, all); -// System.out.println(reasoner.remainsSatisfiableImpl(sub)); - final CELOE la = cm.learningAlgorithm(CELOE.class, lp, reasoner); la.getConfigurator().setMaxExecutionTimeInSeconds(8); la.getConfigurator().setUseNegation(false); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/OREManager.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/OREManager.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/OREManager.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -65,6 +65,13 @@ private int maxNrOfResults; private double threshold; private int minInstanceCount; + + public static final int AUTO_LEARN_MODE = 0; + public static final int MANUAL_LEARN_MODE = 1; + + private int learnMode = 0; + + private List<Description> newDescriptions; private List<OREManagerListener> listeners; @@ -281,6 +288,14 @@ return minInstanceCount; } + public void setLearningMode(int mode){ + learnMode = mode; + } + + public int getLearningMode(){ + return learnMode; + } + public void init(){ this.setLearningProblem(); @@ -313,6 +328,14 @@ public CELOE getLa() { return la; } + + public void setNewDescriptions(List<Description> descriptions){ + newDescriptions = descriptions; + } + + public List<Description> getNewDescriptions(){ + return newDescriptions; + } /** * Retrieves description parts that might cause inconsistency - for negative examples only. Modified: trunk/src/dl-learner/org/dllearner/tools/ore/explanation/relevance/SyntacticRelevanceBasedExplanationGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/explanation/relevance/SyntacticRelevanceBasedExplanationGenerator.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/explanation/relevance/SyntacticRelevanceBasedExplanationGenerator.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -76,7 +76,7 @@ e.printStackTrace(); } logger.addAppender( fileAppender ); - logger.setLevel(Level.OFF); + logger.setLevel(Level.DEBUG); } @@ -587,26 +587,26 @@ - Timer t1 = new Timer("pellet"); - t1.start(); - PelletExplanation exp1 = new PelletExplanation(manager, Collections.singleton(ontology)); - exp1.getUnsatisfiableExplanations(cl); - t1.stop(); - Timer t3 = new Timer("module-based"); - t3.start(); - OWLOntology module = OntologyUtils.getOntologyFromAxioms(ModularityUtils.extractModule(ontology, cl.getSignature(), ModuleType.TOP_OF_BOT)); - System.out.println(module); - PelletExplanation exp2 = new PelletExplanation(manager, Collections.singleton(module)); - System.out.println(exp2.getUnsatisfiableExplanations(cl).size()); - t3.stop(); +// Timer t1 = new Timer("pellet"); +// t1.start(); +// PelletExplanation exp1 = new PelletExplanation(manager, Collections.singleton(ontology)); +// exp1.getUnsatisfiableExplanations(cl); +// t1.stop(); +// Timer t3 = new Timer("module-based"); +// t3.start(); +// OWLOntology module = OntologyUtils.getOntologyFromAxioms(ModularityUtils.extractModule(ontology, cl.getSignature(), ModuleType.TOP_OF_BOT)); +// System.out.println(module); +// PelletExplanation exp2 = new PelletExplanation(manager, Collections.singleton(module)); +// System.out.println("Module based explanationcount: " + exp2.getUnsatisfiableExplanations(cl)); +// t3.stop(); Timer t2 = new Timer("syntactic relevance"); t2.start(); Reasoner reasoner = new PelletReasonerFactory().createReasoner(manager); - reasoner.loadOntologies(Collections.singleton(ontology)); + reasoner.loadOntologies(Collections.singleton(example)); SyntacticRelevanceBasedExplanationGenerator exp3 = new SyntacticRelevanceBasedExplanationGenerator(reasoner, manager); - System.out.println(exp3.getUnsatisfiableExplanations(cl, Strategie.All_Just_Relevance).size()); + System.out.println(exp3.getUnsatisfiableExplanations(u, Strategie.All_Just_Relevance)); System.out.print("J = {"); // for(Set<OWLAxiom> explanation : expGen.getUnsatisfiableExplanations(cl, Strategie.All_Just_Relevance)){ @@ -619,7 +619,7 @@ // } System.out.print("}"); t2.stop(); - System.out.println(t1.getTotal() +"--" + t3.getTotal() + "--" + t2.getTotal()); +// System.out.println(t1.getTotal() +"--" + t3.getTotal() + "--" + t2.getTotal()); // Set<OWLAxiom> test = new HashSet<OWLAxiom>(); // OWLClass z = factory.getOWLClass(URI.create("z")); Deleted: trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTable.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTable.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -1,66 +0,0 @@ -package org.dllearner.tools.ore.ui; - -import java.awt.Color; -import java.util.List; - -import javax.swing.ListSelectionModel; - -import org.dllearner.learningproblems.EvaluatedDescriptionClass; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.decorator.HighlighterFactory; - -public class EquivalentClassExpressionsTable extends JXTable { - - /** - * - */ - private static final long serialVersionUID = 486680925931781915L; - - private EvaluatedDescriptionClass old = null; - - public EquivalentClassExpressionsTable(){ - setBackground(Color.WHITE); - setHighlighters(HighlighterFactory.createAlternateStriping()); -// setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - setModel(new EquivalentClassExpressionsTableModel()); - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - getColumn(1).setCellRenderer(new ManchesterSyntaxTableCellRenderer()); - setColumnSizes(); - getColumn(0).setResizable(false); - getColumn(1).setResizable(false); - setGridColor(Color.LIGHT_GRAY); - } - - private void setColumnSizes(){ - getColumn(0).setMaxWidth(100); - getColumn(1).setPreferredWidth(430); - getColumn(2).setMaxWidth(30); - - } - - - - public void clear(){ - ((EquivalentClassExpressionsTableModel)getModel()).clear(); - } - - public void addResults(List<EvaluatedDescriptionClass> resultList){ - - if(getSelectedRow() >= 0){ - old = getSelectedValue(); - } - ((EquivalentClassExpressionsTableModel)getModel()).addResults(resultList); - if(old != null){ - int newRowIndex = ((EquivalentClassExpressionsTableModel)getModel()).getSelectionIndex(old); - if(newRowIndex >= 0){ - getSelectionModel().setSelectionInterval(newRowIndex, newRowIndex); - } - - } - } - - public EvaluatedDescriptionClass getSelectedValue(){ - return ((EquivalentClassExpressionsTableModel)getModel()).getSelectedValue(getSelectedRow()); - } - -} Deleted: trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTableModel.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTableModel.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -1,114 +0,0 @@ -package org.dllearner.tools.ore.ui; - -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.table.AbstractTableModel; - -import org.dllearner.core.owl.Description; -import org.dllearner.learningproblems.EvaluatedDescriptionClass; - -public class EquivalentClassExpressionsTableModel extends AbstractTableModel { - - /** - * - */ - private static final long serialVersionUID = 8582947007601430481L; - - private List<EvaluatedDescriptionClass> resultList; - private DecimalFormat df; - private List<Boolean> selectionList; - - public EquivalentClassExpressionsTableModel(){ - super(); - resultList = new ArrayList<EvaluatedDescriptionClass>(); - selectionList = new ArrayList<Boolean>(); - df = new DecimalFormat("00%"); - } - - public EquivalentClassExpressionsTableModel(List<EvaluatedDescriptionClass> resultList){ - this.resultList = resultList; - } - - @Override - public int getColumnCount() { - return 3; - } - - @Override - public int getRowCount() { - return resultList.size(); - } - - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - if(columnIndex == 0){ - return df.format(resultList.get(rowIndex).getAccuracy()); - } else if(columnIndex == 1){ - return resultList.get(rowIndex).getDescription(); - } else { - return selectionList.get(rowIndex); - } - } - - @Override - public void setValueAt(Object value, int rowIndex, int columnIndex) { - - selectionList.set(rowIndex, (Boolean)value); - - super.fireTableCellUpdated(rowIndex, columnIndex); - - } - - @Override - public Class<? extends Object> getColumnClass(int columnIndex){ - switch(columnIndex){ - case 0: return String.class; - case 1: return Description.class; - case 2: return Boolean.class; - } - return null; - } - - @Override - public String getColumnName(int column){ - switch(column){ - case 0: return "Accuracy"; - case 1: return "Class expression"; - } - return ""; - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - if(columnIndex == 2){ - return true; - } - return false; - } - - public void clear(){ - resultList.clear(); - fireTableDataChanged(); - } - - public void addResults(List<EvaluatedDescriptionClass> resultList){ - this.resultList.clear(); - this.resultList.addAll(resultList); - for(int i = 0; i < resultList.size(); i++){ - selectionList.add(i, Boolean.FALSE); - } - - fireTableRowsUpdated(0, this.resultList.size()); - } - - public EvaluatedDescriptionClass getSelectedValue(int rowIndex){ - return resultList.get(rowIndex); - } - - public int getSelectionIndex(EvaluatedDescriptionClass e){ - return resultList.indexOf(e); - } - -} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/HelpablePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/HelpablePanel.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/HelpablePanel.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -1,5 +1,7 @@ package org.dllearner.tools.ore.ui; +import java.awt.Component; import java.awt.Dimension; +import java.awt.Graphics; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; @@ -109,8 +111,24 @@ learnTypePanel.add(equivalentClassButton); learnTypePanel.add(superClassButton); HelpablePanel learnTypeHelpPanel = new HelpablePanel(learnTypePanel); - learnTypeHelpPanel.setBorder(new TitledBorder("Learning type")); - + TitledBorder border = new TitledBorder("LEarning type"){ + + /** + * + */ + private static final long serialVersionUID = 1878007899412644256L; + + @Override + public void paintBorder(Component c, Graphics g, int x, int y, + int width, int height) { + // TODO Auto-generated method stub + super.paintBorder(c, g, x, y, width, height); + } + + }; +// border.setTitleJustification(TitledBorder.ABOVE_BOTTOM); + border.setTitlePosition(TitledBorder.ABOVE_TOP); + learnTypeHelpPanel.setBorder(border); frame.add(learnTypeHelpPanel); @@ -119,4 +137,5 @@ frame.setVisible(true); } + } Added: trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableTable.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableTable.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -0,0 +1,78 @@ +package org.dllearner.tools.ore.ui; + +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.util.Set; + +import javax.swing.ImageIcon; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; + +import org.dllearner.core.owl.NamedClass; +import org.jdesktop.swingx.JXTable; + +public class MarkableTable extends JXTable { + + /** + * + */ + private static final long serialVersionUID = 4193878042914394758L; + private ImageIcon icon = new ImageIcon("src/dl-learner/org/dllearner/tools/ore/untoggled.gif"); + + public MarkableTable(){ + super(new MarkableTableModel()); + getColumn(1).setCellRenderer(new ManchesterSyntaxTableCellRenderer()); + getColumn(0).setMaxWidth(30); + setTableHeader(null); + setBorder(null); + setShowVerticalLines(false); + setShowHorizontalLines(false); + setRowSelectionAllowed(false); + setColumnSelectionAllowed(false); + setCellSelectionEnabled(false); + getColumn(0).setCellRenderer(new TableCellRenderer() { + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + if(value.equals(">")){ + return new JLabel(icon); + } else { + return new JLabel(""); + } + } + }); + } + + @Override + public String getToolTipText(MouseEvent e){ + String tip = null; + java.awt.Point p = e.getPoint(); + int rowIndex = rowAtPoint(p); + if(rowIndex != -1){ + tip = getValueAt(rowIndex, 1).toString(); + + } else { + tip = super.getToolTipText(e); + } + return tip; + } + + public void addClasses(Set<NamedClass> classes){ + ((MarkableTableModel)getModel()).addClasses(classes); + } + + public NamedClass getSelectedValue(){ + return ((MarkableTableModel)getModel()).getSelectedValue(getSelectedRow()); + } + + public void clear(){ + ((MarkableTableModel)getModel()).clear(); + } + + public void setSelectedClass(int rowIndex){ + ((MarkableTableModel)getModel()).setSelectedClass(rowIndex); + } + +} Added: trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableTableModel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableTableModel.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -0,0 +1,69 @@ +package org.dllearner.tools.ore.ui; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.swing.table.AbstractTableModel; + +import org.dllearner.core.owl.NamedClass; + +public class MarkableTableModel extends AbstractTableModel { + + /** + * + */ + private static final long serialVersionUID = 5773843275446469889L; + + private List<NamedClass> classes; + private int selectedRowIndex = 0; + + public MarkableTableModel(){ + classes = new ArrayList<NamedClass>(); + } + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public int getRowCount() { + return classes.size(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if(columnIndex == 0){ + if(rowIndex == selectedRowIndex){ + return ">"; + } else { + return ""; + } + } else { + return classes.get(rowIndex); + } + } + + public void clear(){ + classes.clear(); + fireTableDataChanged(); + } + + public void addClasses(Set<NamedClass> classes){ + this.classes.clear(); + this.classes.addAll(classes); + fireTableDataChanged(); + } + + public NamedClass getSelectedValue(int rowIndex){ + return classes.get(rowIndex); + } + + public void setSelectedClass(int rowIndex){ + int oldRowIndex = selectedRowIndex; + selectedRowIndex = rowIndex; + fireTableRowsUpdated(oldRowIndex, selectedRowIndex); + } + +} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/MetricsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/MetricsPanel.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/MetricsPanel.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -4,11 +4,7 @@ import java.awt.Color; import java.awt.Font; import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -16,9 +12,9 @@ import javax.swing.JTable; import javax.swing.border.TitledBorder; +import org.dllearner.tools.ore.OREManager; import org.protege.editor.core.PropertyUtil; import org.protege.editor.core.ProtegeProperties; -import org.semanticweb.owl.apibinding.OWLManager; import org.semanticweb.owl.metrics.DLExpressivity; import org.semanticweb.owl.metrics.OWLMetric; import org.semanticweb.owl.metrics.OWLMetricManager; @@ -26,121 +22,100 @@ import org.semanticweb.owl.metrics.ReferencedDataPropertyCount; import org.semanticweb.owl.metrics.ReferencedIndividualCount; import org.semanticweb.owl.metrics.ReferencedObjectPropertyCount; -import org.semanticweb.owl.model.OWLAxiom; import org.semanticweb.owl.model.OWLOntology; -import org.semanticweb.owl.model.OWLOntologyChangeException; -import org.semanticweb.owl.model.OWLOntologyCreationException; import org.semanticweb.owl.model.OWLOntologyManager; - /** * Author: Matthew Horridge<br> * The University Of Manchester<br> * Bio-Health Informatics Group<br> - * Date: 29-Oct-2007<br><br> + * Date: 29-Oct-2007<br> + * <br> */ public class MetricsPanel extends JPanel { - /** + /** * */ private static final long serialVersionUID = -5827197898985671614L; - private Map<String, OWLMetricManager> metricManagerMap; + private OWLOntologyManager manager; - private Map<OWLMetricManager, MetricsTableModel> tableModelMap; + private OWLMetricManager metricManager; - - private OWLOntologyManager manager; + public MetricsPanel() { +// this.manager = OWLManager.createOWLOntologyManager(); +// initialiseOWLView(); + } + protected void initialiseOWLView() { + createBasicMetrics(); + createUI(); + } - public MetricsPanel() { - this.manager = OWLManager.createOWLOntologyManager(); - try { - manager.createOntology(Collections.<OWLAxiom>emptySet()); - - } catch (OWLOntologyCreationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (OWLOntologyChangeException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - initialiseOWLView(); - } + private void createUI() { - protected void initialiseOWLView() { - metricManagerMap = new LinkedHashMap<String, OWLMetricManager>(); - tableModelMap = new HashMap<OWLMetricManager, MetricsTableModel>(); - createBasicMetrics(); - createUI(); - updateView(manager.getOntologies().iterator().next()); - for(OWLMetricManager man : metricManagerMap.values()) { - for(OWLMetric<?> m : man.getMetrics()) { - m.setImportsClosureUsed(true); - m.setOntology(manager.getOntologies().iterator().next()); - } - } - } + setLayout(new BorderLayout()); + JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); - private void createUI() { - - setLayout(new BorderLayout()); - JPanel panel = new JPanel(); - panel.setLayout(new BorderLayout()); - for (String metricsSet : metricManagerMap.keySet()) { - MetricsTableModel tableModel = new MetricsTableModel(metricManagerMap.get(metricsSet)); - tableModelMap.put(metricManagerMap.get(metricsSet), tableModel); - final JTable table = new JTable(tableModel); - table.setGridColor(Color.LIGHT_GRAY); - table.setRowHeight(table.getRowHeight() + 4); - table.setShowGrid(true); - - table.getColumnModel().getColumn(1).setMaxWidth(150); - table.getColumnModel().setColumnMargin(2); - table.setFont(getFont().deriveFont(Font.BOLD, 12.0f)); - table.setForeground(PropertyUtil.getColor(ProtegeProperties.getInstance().getProperty(ProtegeProperties.PROPERTY_COLOR_KEY), - Color.GRAY)); + MetricsTableModel tableModel = new MetricsTableModel(metricManager); - final JPanel tablePanel = new JPanel(new BorderLayout()); - - tablePanel.add(table); - tablePanel.setFont(getFont().deriveFont(Font.BOLD, 12.0f)); -// tablePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 14, 2), -// ComponentFactory.createTitledBorder(metricsSet))); - table.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); - panel.add(tablePanel); - } - JScrollPane sp = new JScrollPane(panel); - sp.setOpaque(false); - add(sp); - } + final JTable table = new JTable(tableModel); + table.setGridColor(Color.LIGHT_GRAY); + table.setRowHeight(table.getRowHeight() + 4); + table.setShowGrid(true); + table.getColumnModel().getColumn(1).setMaxWidth(150); + table.getColumnModel().setColumnMargin(2); + table.setFont(getFont().deriveFont(Font.BOLD, 12.0f)); + table.setForeground(PropertyUtil.getColor(ProtegeProperties.getInstance().getProperty( + ProtegeProperties.PROPERTY_COLOR_KEY), Color.GRAY)); + final JPanel tablePanel = new JPanel(new BorderLayout()); + tablePanel.add(table); + tablePanel.setFont(getFont().deriveFont(Font.BOLD, 12.0f)); + // tablePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, + // 2, 14, 2), + // ComponentFactory.createTitledBorder(metricsSet))); + table.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); + panel.add(tablePanel); - private void createBasicMetrics() { - List<OWLMetric> metrics = new ArrayList<OWLMetric>(); - metrics.add(new ReferencedClassCount(manager)); - metrics.add(new ReferencedObjectPropertyCount(manager)); - metrics.add(new ReferencedDataPropertyCount(manager)); - metrics.add(new ReferencedIndividualCount(manager)); - metrics.add(new DLExpressivity(manager)); - OWLMetricManager metricManager = new OWLMetricManager(metrics); - metricManagerMap.put("Metrics", metricManager); - } + JScrollPane sp = new JScrollPane(panel); + sp.setOpaque(false); + add(sp); + } - public void updateView(OWLOntology activeOntology) { - for (OWLMetricManager man : metricManagerMap.values()) { - man.setOntology(activeOntology); - } - TitledBorder border = new TitledBorder(activeOntology.getURI().toString() + " successfully loaded"); - border.setTitleFont(getFont().deriveFont(Font.BOLD, 12.0f)); - border.setTitleColor(PropertyUtil.getColor(ProtegeProperties.getInstance().getProperty(ProtegeProperties.PROPERTY_COLOR_KEY), - Color.GRAY)); - setBorder(border); - repaint(); - } - + @SuppressWarnings("unchecked") + private void createBasicMetrics() { + List<OWLMetric> metrics = new ArrayList<OWLMetric>(); + metrics.add(new ReferencedClassCount(manager)); + metrics.add(new ReferencedObjectPropertyCount(manager)); + metrics.add(new ReferencedDataPropertyCount(manager)); + metrics.add(new ReferencedIndividualCount(manager)); + metrics.add(new DLExpressivity(manager)); + metricManager = new OWLMetricManager(metrics); + + } + + public void updateView(OWLOntology activeOntology) { + removeAll(); + manager = OREManager.getInstance().getReasoner().getOWLOntologyManager(); + createBasicMetrics(); + metricManager.setOntology(activeOntology); + for (OWLMetric<?> m : metricManager.getMetrics()) { + m.setImportsClosureUsed(true); + } + createUI(); + + TitledBorder border = new TitledBorder(activeOntology.getURI().toString() + " successfully loaded"); + border.setTitleFont(getFont().deriveFont(Font.BOLD, 12.0f)); + border.setTitleColor(PropertyUtil.getColor(ProtegeProperties.getInstance().getProperty( + ProtegeProperties.PROPERTY_COLOR_KEY), Color.GRAY)); + setBorder(border); + repaint(); + } + + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairPlanPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairPlanPanel.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/RepairPlanPanel.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -27,7 +27,7 @@ this.repMan = RepairManager.getInstance(OREManager.getInstance()); setLayout(new BorderLayout()); - add(new JLabel("Axioms"), BorderLayout.NORTH); + add(new JLabel("Repair plan"), BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new FlowLayout(2)); add(buttonPanel, "South"); undoButton = new JButton(new AbstractAction("Undo") { Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTable.java (from rev 1869, trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTable.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTable.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTable.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -0,0 +1,71 @@ +package org.dllearner.tools.ore.ui; + +import java.awt.Color; +import java.util.List; + +import javax.swing.ListSelectionModel; + +import org.dllearner.core.owl.Description; +import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.HighlighterFactory; + +public class SelectableClassExpressionsTable extends JXTable { + + /** + * + */ + private static final long serialVersionUID = 486680925931781915L; + + private EvaluatedDescriptionClass old = null; + + public SelectableClassExpressionsTable(){ + setBackground(Color.WHITE); + setHighlighters(HighlighterFactory.createAlternateStriping()); +// setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + setModel(new SelectableClassExpressionsTableModel()); + setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + getColumn(1).setCellRenderer(new ManchesterSyntaxTableCellRenderer()); + setColumnSizes(); + getColumn(0).setResizable(false); + getColumn(1).setResizable(false); + setGridColor(Color.LIGHT_GRAY); + } + + private void setColumnSizes(){ + getColumn(0).setMaxWidth(95); +// getColumn(1).setPreferredWidth(430); + getColumn(2).setMaxWidth(30); + + } + + + + public void clear(){ + ((SelectableClassExpressionsTableModel)getModel()).clear(); + } + + public void addResults(List<EvaluatedDescriptionClass> resultList){ + + if(getSelectedRow() >= 0){ + old = getSelectedValue(); + } + ((SelectableClassExpressionsTableModel)getModel()).addResults(resultList); + if(old != null){ + int newRowIndex = ((SelectableClassExpressionsTableModel)getModel()).getSelectionIndex(old); + if(newRowIndex >= 0){ + getSelectionModel().setSelectionInterval(newRowIndex, newRowIndex); + } + + } + } + + public EvaluatedDescriptionClass getSelectedValue(){ + return ((SelectableClassExpressionsTableModel)getModel()).getSelectedValue(getSelectedRow()); + } + + public List<Description> getSelecetdDescriptions(){ + return ((SelectableClassExpressionsTableModel)getModel()).getSelectedDescriptions(); + } + +} Copied: trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTableModel.java (from rev 1869, trunk/src/dl-learner/org/dllearner/tools/ore/ui/EquivalentClassExpressionsTableModel.java) =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTableModel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/SelectableClassExpressionsTableModel.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -0,0 +1,125 @@ +package org.dllearner.tools.ore.ui; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.table.AbstractTableModel; + +import org.dllearner.core.owl.Description; +import org.dllearner.learningproblems.EvaluatedDescriptionClass; + +public class SelectableClassExpressionsTableModel extends AbstractTableModel { + + /** + * + */ + private static final long serialVersionUID = 8582947007601430481L; + + private List<EvaluatedDescriptionClass> resultList; + private DecimalFormat df; + private List<Boolean> selectionList; + + public SelectableClassExpressionsTableModel(){ + super(); + resultList = new ArrayList<EvaluatedDescriptionClass>(); + selectionList = new ArrayList<Boolean>(); + df = new DecimalFormat("00%"); + } + + public SelectableClassExpressionsTableModel(List<EvaluatedDescriptionClass> resultList){ + this.resultList = resultList; + } + + @Override + public int getColumnCount() { + return 3; + } + + @Override + public int getRowCount() { + return resultList.size(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if(columnIndex == 0){ + return df.format(resultList.get(rowIndex).getAccuracy()); + } else if(columnIndex == 1){ + return resultList.get(rowIndex).getDescription(); + } else { + return selectionList.get(rowIndex); + } + } + + @Override + public void setValueAt(Object value, int rowIndex, int columnIndex) { + + selectionList.set(rowIndex, (Boolean)value); + + super.fireTableCellUpdated(rowIndex, columnIndex); + + } + + @Override + public Class<? extends Object> getColumnClass(int columnIndex){ + switch(columnIndex){ + case 0: return String.class; + case 1: return Description.class; + case 2: return Boolean.class; + } + return null; + } + + @Override + public String getColumnName(int column){ + switch(column){ + case 0: return "Accuracy"; + case 1: return "Class expression"; + } + return ""; + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + if(columnIndex == 2){ + return true; + } + return false; + } + + public void clear(){ + resultList.clear(); + fireTableDataChanged(); + } + + public void addResults(List<EvaluatedDescriptionClass> resultList){ + this.resultList.clear(); + this.resultList.addAll(resultList); + for(int i = 0; i < resultList.size(); i++){ + selectionList.add(i, Boolean.FALSE); + } + + fireTableRowsUpdated(0, this.resultList.size()); + } + + public EvaluatedDescriptionClass getSelectedValue(int rowIndex){ + return resultList.get(rowIndex); + } + + public int getSelectionIndex(EvaluatedDescriptionClass e){ + return resultList.indexOf(e); + } + + public List<Description> getSelectedDescriptions(){ + List<Description> selected = new ArrayList<Description>(); + for(int i = 0; i < selectionList.size(); i++){ + if(selectionList.get(i).equals(Boolean.TRUE)){ + selected.add(resultList.get(i).getDescription()); + } + } + + return selected; + } + +} 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-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/WizardController.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -162,6 +162,10 @@ classChoose.resetPanel(); } else if(nextPanelDescriptor.equals(AutoLearnPanelDescriptor.IDENTIFIER)){ ((ClassChoosePanelDescriptor)currentPanelDescriptor).setAutoLearningOptions(); + AutoLearnPanelDescriptor learnDescriptor = ((AutoLearnPanelDescriptor) model + .getPanelHashMap().get(nextPanelDescriptor)); + learnDescriptor.resetPanel(); + learnDescriptor.fillClassesTable(); } // else if(currentPanelDescriptor.getPanelDescriptorIdentifier().equals(LearningPanelDescriptor.IDENTIFIER)){ // if(OREManager.getInstance().getNewClassDescription().getAccuracy() == 1.0){ 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-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/AutoLearnPanelDescriptor.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -18,6 +18,7 @@ import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.NamedClass; import org.dllearner.learningproblems.EvaluatedDescriptionClass; import org.dllearner.tools.ore.OREManager; @@ -42,6 +43,8 @@ private EquivalentLearningTask equivalentLearningTask; private SuperClassLearningTask superLearningTask; + private SwingWorker<Void, List<? extends EvaluatedDescription>> currentLearningTask; + private int currentClassIndex = 0; @@ -59,7 +62,13 @@ @Override public Object getNextPanelDescriptor() { - return RepairPanelDescriptor.IDENTIFIER; + if(getSelectedDescriptions().isEmpty()){ + return SavePanelDescriptor.IDENTIFIER; + } else { + OREManager.getInstance().setNewDescriptions(getSelectedDescriptions()); + return RepairPanelDescriptor.IDENTIFIER; + } + } @Override @@ -70,10 +79,9 @@ @Override public void aboutToDisplayPanel() { getWizard().getInformationField().setText(INFORMATION); - fillClassesTable(); } - public void fillClassesTable(){ + public void fillClassesTable(){ TaskManager.getInstance().setTaskStarted("Retrieving atomic classes..."); new ClassRetrievingTask().execute(); } @@ -97,11 +105,23 @@ public void learnNextClass(){ autoLearnPanel.resetPanel(); - OREManager.getInstance().setCurrentClass2Learn(new NamedClass("http://ns.softwiki.de/req/CustomerRequirement"));//classes.get(currentClassIndex)); + autoLearnPanel.setSelectedClass(currentClassIndex); + OREManager.getInstance().setCurrentClass2Learn(classes.get(currentClassIndex)); learnEquivalentClassExpressions(); currentClassIndex++; } + public List<Description> getSelectedDescriptions(){ + return autoLearnPanel.getSelectedDescriptions(); + } + + public void resetPanel(){ + currentClassIndex = 0; + autoLearnPanel.resetPanel(); + autoLearnPanel.clearClassesTable(); + + } + @Override public void actionPerformed(ActionEvent e) { learnNextClass(); @@ -148,6 +168,7 @@ // TODO Auto-generated catch block e.printStackTrace(); } + classes.clear(); classes.addAll(result); autoLearnPanel.fillClassesTable(result); OREManager.getInstance().setCurrentClass2Learn(classes.get(0)); @@ -199,19 +220,22 @@ public void done() { timer.cancel(); List<? extends EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions(maxNrOfResults, threshold, true); - updateList(result); + updateResultTable(result); + if(result.isEmpty()){ + EvaluatedDescriptionClass best = (EvaluatedDescriptionClass)la.getCurrentlyBestEvaluatedDescription(); + } learnSubClassExpressions(); } @Override protected void process(List<List<? extends EvaluatedDescription>> resultLists) { for (List<? extends EvaluatedDescription> list : resultLists) { - updateList(list); + updateResultTable(list); } } @SuppressWarnings("unchecked") - private void updateList(final List<? extends EvaluatedDescription> result) { + private void updateResultTable(final List<? extends EvaluatedDescription> result) { autoLearnPanel.fillEquivalentClassExpressionsTable((List<EvaluatedDescriptionClass>) result); } } @@ -257,7 +281,7 @@ public void done() { timer.cancel(); List<? extends EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions(maxNrOfResults, threshold, true); - updateList(result); + updateResultTable(result); TaskManager.getInstance().setTaskFinished(); setProgress(0); } @@ -265,12 +289,12 @@ @Override protected void process(List<List<? extends EvaluatedDescription>> resultLists) { for (List<? extends EvaluatedDescription> list : resultLists) { - updateList(list); + updateResultTable(list); } } @SuppressWarnings("unchecked") - private void updateList(final List<? extends EvaluatedDescription> result) { + private void updateResultTable(final List<? extends EvaluatedDescription> result) { autoLearnPanel.fillSuperClassExpressionsTable((List<EvaluatedDescriptionClass>) result); } } 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-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/SavePanelDescriptor.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -62,11 +62,16 @@ @Override public Object getBackPanelDescriptor() { - if(OREManager.getInstance().getNewClassDescription().getAccuracy() == 1.0){ - return ManualLearnPanelDescriptor.IDENTIFIER; - } else { - return RepairPanelDescriptor.IDENTIFIER; - } + + if(OREManager.getInstance().getLearningMode() == OREManager.MANUAL_LEARN_MODE){ + if(OREManager.getInstance().getNewClassDescription().getAccuracy() == 1.0){ + return ManualLearnPanelDescriptor.IDENTIFIER; + } else { + return RepairPanelDescriptor.IDENTIFIER; + } + } else { + return AutoLearnPanelDescriptor.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-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/descriptors/UnsatisfiableExplanationPanelDescriptor.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -227,45 +227,40 @@ } - class RootDerivedTask extends SwingWorker<Void, Void>{ + class RootDerivedTask extends SwingWorker<Void, Void> { - @Override - public Void doInBackground() { - - expMan.getRootUnsatisfiableClasses(); - expMan.getDerivedClasses(); - return null; - } + @Override + public Void doInBackground() { - @Override - public void done() { - TaskManager.getInstance().setTaskFinished(); - if(!isCancelled()){ - fillUnsatClassesTable(); - } - + expMan.getRootUnsatisfiableClasses(); + expMan.getDerivedClasses(); + return null; + } + + @Override + public void done() { + TaskManager.getInstance().setTaskFinished(); + if (!isCancelled()) { + fillUnsatClassesTable(); } - - private void fillUnsatClassesTable(){ - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - List<OWLClass> unsatClasses = new ArrayList<OWLClass>(); - - Set<OWLClass> rootClasses = new TreeSet<OWLClass>(expMan - .getRootUnsatisfiableClasses()); - unsatClasses.addAll(rootClasses); - - Set<OWLClass> derivedClasses = new TreeSet<OWLClass>(expMan - .getDerivedClasses()); - unsatClasses.addAll(derivedClasses); - - panel.fillUnsatClassesTable(unsatClasses); - panel.getUnsatTable().clearSelection(); - } - }); - } - } + } + private void fillUnsatClassesTable() { + + List<OWLClass> unsatClasses = new ArrayList<OWLClass>(); + + Set<OWLClass> rootClasses = new TreeSet<OWLClass>(expMan + .getRootUnsatisfiableClasses()); + unsatClasses.addAll(rootClasses); + + Set<OWLClass> derivedClasses = new TreeSet<OWLClass>(expMan + .getDerivedClasses()); + unsatClasses.addAll(derivedClasses); + + panel.fillUnsatClassesTable(unsatClasses); + panel.getUnsatTable().clearSelection(); + + } + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/AutoLearnPanel.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -4,6 +4,7 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionListener; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -15,15 +16,16 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; +import javax.swing.border.MatteBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.NamedClass; import org.dllearner.learningproblems.EvaluatedDescriptionClass; -import org.dllearner.tools.ore.OREManager; -import org.dllearner.tools.ore.ui.ClassesTable; -import org.dllearner.tools.ore.ui.EquivalentClassExpressionsTable; import org.dllearner.tools.ore.ui.GraphicalCoveragePanel; +import org.dllearner.tools.ore.ui.MarkableTable; +import org.dllearner.tools.ore.ui.SelectableClassExpressionsTable; public class AutoLearnPanel extends JPanel { @@ -32,13 +34,13 @@ */ private static final long serialVersionUID = -5204979906041331328L; - private ClassesTable classesTable; - +// private ClassesTable classesTable; + private MarkableTable classesTable; private JPanel superPanel; private JPanel equivalentPanel; - private EquivalentClassExpressionsTable equivalentClassResultsTable; - private EquivalentClassExpressionsTable superClassResultsTable; + private SelectableClassExpressionsTable equivalentClassResultsTable; + private SelectableClassExpressionsTable superClassResultsTable; private GraphicalCoveragePanel equivalentClassCoveragePanel; private GraphicalCoveragePanel superClassCoveragePanel; @@ -48,7 +50,7 @@ private JButton skipButton; - private final static String INCONSISTENY_WARNING = "<html><font color=red>" + + private final static String INCONSISTENCY_WARNING = "<html><font color=red>" + "Warning. Selected class expressions leads to an inconsistent ontology!" + "</font></html>"; public AutoLearnPanel(){ @@ -69,10 +71,10 @@ } private JComponent createClassesPanel(){ - classesTable = new ClassesTable(); + classesTable = new MarkableTable(); classesTable.setBorder(null); - classesTable.setEnabled(false); JScrollPane classesScroll = new JScrollPane(classesTable); + classesScroll.setBorder(new MatteBorder(null)); return classesScroll; } @@ -106,7 +108,7 @@ c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; - equivalentClassResultsTable = new EquivalentClassExpressionsTable(); + equivalentClassResultsTable = new SelectableClassExpressionsTable(); equivalentClassResultsTable.setName("equivalent"); equivalentPanel.add(new JScrollPane(equivalentClassResultsTable), c); @@ -136,7 +138,7 @@ c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; - superClassResultsTable = new EquivalentClassExpressionsTable(); + superClassResultsTable = new SelectableClassExpressionsTable(); superClassResultsTable.setName("super"); superPanel.add(new JScrollPane(superClassResultsTable), c); @@ -177,8 +179,21 @@ superClassResultsTable.clear(); equivalentClassCoveragePanel.clear(); superClassCoveragePanel.clear(); + validate(); + repaint(); } + public void clearClassesTable(){ + classesTable.clear(); + } + + public List<Description> getSelectedDescriptions(){ + List<Description> selected = new ArrayList<Description>(); + selected.addAll(equivalentClassResultsTable.getSelecetdDescriptions()); + selected.addAll(superClassResultsTable.getSelecetdDescriptions()); + return selected; + } + private void addTableSelectionListeners(){ equivalentClassResultsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override @@ -187,10 +202,10 @@ if (!e.getValueIsAdjusting() && equivalentClassResultsTable.getSelectedRow() >= 0){ EvaluatedDescriptionClass selectedClassExpression = equivalentClassResultsTable.getSelectedValue(); - OREManager.getInstance().setNewClassDescription(selectedClassExpression); + equivalentClassCoveragePanel.setNewClassDescription(selectedClassExpression); if(!selectedClassExpression.isConsistent()){ - equivalentInconsistencyLabel.setText(INCONSISTENY_WARNING); + equivalentInconsistencyLabel.setText(INCONSISTENCY_WARNING); } else { equivalentInconsistencyLabel.setText(" "); } @@ -207,10 +222,10 @@ if (!e.getValueIsAdjusting() && superClassResultsTable.getSelectedRow() >= 0){ EvaluatedDescriptionClass selectedClassExpression = superClassResultsTable.getSelectedValue(); - OREManager.getInstance().setNewClassDescription(selectedClassExpression); + superClassCoveragePanel.setNewClassDescription(selectedClassExpression); if(!selectedClassExpression.isConsistent()){ - superInconsistencyLabel.setText(INCONSISTENY_WARNING); + superInconsistencyLabel.setText(INCONSISTENCY_WARNING); } else { superInconsistencyLabel.setText(" "); } @@ -227,6 +242,10 @@ superClassCoveragePanel.setNewClassDescription(desc); } + public void setSelectedClass(int rowIndex){ + classesTable.setSelectedClass(rowIndex); + } + public static void main(String[] args){ JFrame frame = new JFrame(); @@ -236,5 +255,6 @@ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/InconsistencyExplanationPanel.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -7,14 +7,11 @@ import java.awt.GridLayout; import java.awt.Insets; import java.awt.event.ActionListener; -import java.util.HashSet; -import java.util.Set; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.ButtonGroup; import javax.swing.JComponent; -import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JScrollPane; @@ -29,7 +26,6 @@ import org.dllearner.tools.ore.ui.ExplanationTablePanel; import org.dllearner.tools.ore.ui.HelpablePanel; import org.dllearner.tools.ore.ui.RepairPlanPanel; -import org.dllearner.tools.ore.ui.UnsatisfiableClassesTable; import org.semanticweb.owl.apibinding.OWLManager; public class InconsistencyExplanationPanel extends JPanel{ @@ -52,11 +48,6 @@ private JRadioButton computeMaxExplanationsRadioButton; private JSpinner maxExplanationsSelector; - - private Set<ExplanationTablePanel> explanationPanels; - private Set<ExplanationTable> explanationTables; - - public InconsistencyExplanationPanel() { createUI(); @@ -80,9 +71,6 @@ private JComponent createExplanationPanel(){ explanationsPanel = new Box(1); - - explanationPanels = new HashSet<ExplanationTablePanel>(); - explanationTables = new HashSet<ExplanationTable>(); JPanel pan = new JPanel(new BorderLayout()); pan.add(explanationsPanel, BorderLayout.NORTH); @@ -161,7 +149,6 @@ private JComponent createRepairPanel(){ JPanel repairPanel = new JPanel(new BorderLayout()); - repairPanel.add(new JLabel("Repair plan"), BorderLayout.NORTH); repairPanel.add(new RepairPlanPanel(), BorderLayout.CENTER); return repairPanel; } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java 2009-10-02 16:29:11 UTC (rev 1875) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/wizard/panels/UnsatisfiableExplanationPanel.java 2009-10-03 11:29:04 UTC (rev 1876) @@ -216,7 +216,6 @@ private JComponent createImpactRepairPanel(){ JPanel impactRepairPanel = new JPanel(); impactRepairPanel.setLayout(new BorderLayout()); - impactRepairPanel.add(new JLabel("Repair plan"), BorderLayout.NORTH); JSplitPane impRepSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); impRepSplit.setOneTouchExpandable(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2009-10-05 10:20:21
|
Revision: 1878 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1878&view=rev Author: kurzum Date: 2009-10-05 10:20:13 +0000 (Mon, 05 Oct 2009) Log Message: ----------- fix for Invalid URIs cause the learn-Algorithm to break on Extraction - ID: 2872207 invalid Classes or values of Objectproperties are ignored, a warning is issued Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Info.java trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java Modified: trunk/src/dl-learner/org/dllearner/Info.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Info.java 2009-10-04 11:54:44 UTC (rev 1877) +++ trunk/src/dl-learner/org/dllearner/Info.java 2009-10-05 10:20:13 UTC (rev 1878) @@ -1,8 +1,8 @@ - // File is updated automatically when a new version is created - package org.dllearner; +// File is updated automatically when a new version is created +package org.dllearner; - public class Info { - public static final String build = "2009-09-23"; - } - \ No newline at end of file +public class Info { + public static final String build = "2009-09-30"; +} + \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2009-10-04 11:54:44 UTC (rev 1877) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/InstanceNode.java 2009-10-05 10:20:13 UTC (rev 1878) @@ -19,6 +19,7 @@ */ package org.dllearner.kb.extraction; +import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.SortedSet; @@ -82,11 +83,20 @@ return newNodes; } + /** + * estimates the type of the retrieved tuple + * @param tuple + * @return + */ public Node processTuple( RDFNodeTuple tuple) { + try { + + //Literal nodes if(tuple.b.isLiteral()) { datatypeProperties.add(new DatatypePropertyNode(tuple.a.toString(), this, new LiteralNode(tuple.b) )); return null; + //Blank nodes }else if(tuple.b.isAnon()){ @SuppressWarnings("unused") RDFBlankNode n = (RDFBlankNode) tuple.b; @@ -101,11 +111,27 @@ // basically : if p is rdf:type then o is a class // else it is an instance + // Class Node }else if (tuple.a.toString().equals(OWLVocabulary.RDF_TYPE)) { + try{ + URI.create(tuple.b.toString()); + }catch (Exception e) { + logger.warn("uri "+tuple.b.toString()+" is not a valid uri for a class, ignoring"); + return null; + } + ClassNode tmp = new ClassNode(tuple.b.toString()); classes.add(tmp); return tmp; + // instance node } else { + + try{ + URI.create(tuple.b.toString()); + }catch (Exception e) { + logger.warn("uri "+tuple.b.toString()+" for objectproperty: "+tuple.a.toString() +" is not valid, ignoring"); + return null; + } InstanceNode tmp = new InstanceNode(tuple.b.toString()); objectProperties.add(new ObjectPropertyNode(tuple.a.toString(), this, tmp)); return tmp; Modified: trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java 2009-10-04 11:54:44 UTC (rev 1877) +++ trunk/src/dl-learner/org/dllearner/kb/extraction/Node.java 2009-10-05 10:20:13 UTC (rev 1878) @@ -95,6 +95,7 @@ return uri; } + public URI getURI() { return URI.create(uri); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-10-05 11:09:30
|
Revision: 1879 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1879&view=rev Author: jenslehmann Date: 2009-10-05 11:09:22 +0000 (Mon, 05 Oct 2009) Log Message: ----------- working nested cross validation script Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/NestedCrossValidation.java trunk/src/dl-learner/org/dllearner/utilities/datastructures/Datastructures.java Modified: trunk/src/dl-learner/org/dllearner/scripts/NestedCrossValidation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/NestedCrossValidation.java 2009-10-05 10:20:13 UTC (rev 1878) +++ trunk/src/dl-learner/org/dllearner/scripts/NestedCrossValidation.java 2009-10-05 11:09:22 UTC (rev 1879) @@ -24,11 +24,14 @@ import java.io.IOException; import java.text.DecimalFormat; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.Set; import java.util.TreeSet; +import java.util.Map.Entry; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; @@ -45,7 +48,9 @@ import org.dllearner.learningproblems.PosNegLP; import org.dllearner.parser.ParseException; import org.dllearner.utilities.Helper; +import org.dllearner.utilities.datastructures.Datastructures; import org.dllearner.utilities.datastructures.TrainTestList; +import org.dllearner.utilities.statistics.Stat; import joptsimple.OptionParser; import joptsimple.OptionSet; @@ -80,6 +85,10 @@ * * Currently, only learning from positive and negative examples is supported. * + * Currently, the script can only optimise towards classification accuracy. + * (Can be extended to handle optimising F measure or other combinations of + * precision, recall, accuracy.) + * * @author Jens Lehmann * */ @@ -129,6 +138,7 @@ String[] rangeSplit = range.split("-"); int rangeStart = new Integer(rangeSplit[0]); int rangeEnd = new Integer(rangeSplit[1]); + boolean verbose = options.has("v"); // create logger (a simple logger which outputs // its messages to the console) @@ -141,7 +151,8 @@ // disable OWL API info output java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.WARNING); - new NestedCrossValidation(confFile, outerFolds, innerFolds, parameter, rangeStart, rangeEnd); + System.out.println("Warning: The script is not well tested yet. (No known bugs, but needs more testing.)"); + new NestedCrossValidation(confFile, outerFolds, innerFolds, parameter, rangeStart, rangeEnd, verbose); // an option is missing => print help screen and message } else { @@ -151,7 +162,7 @@ } - public NestedCrossValidation(File confFile, int outerFolds, int innerFolds, String parameter, int startValue, int endValue) throws FileNotFoundException, ComponentInitException, ParseException { + public NestedCrossValidation(File confFile, int outerFolds, int innerFolds, String parameter, int startValue, int endValue, boolean verbose) throws FileNotFoundException, ComponentInitException, ParseException { DecimalFormat df = new DecimalFormat(); ComponentManager cm = ComponentManager.getInstance(); @@ -170,18 +181,30 @@ LinkedList<Individual> negExamples = new LinkedList<Individual>(((PosNegLP)lp).getNegativeExamples()); Collections.shuffle(negExamples, new Random(2)); + ReasonerComponent rc = start.getReasonerComponent(); + String baseURI = rc.getBaseURI(); + List<TrainTestList> posLists = getFolds(posExamples, outerFolds); List<TrainTestList> negLists = getFolds(negExamples, outerFolds); + // overall statistics + Stat accOverall = new Stat(); + Stat fOverall = new Stat(); + Stat recallOverall = new Stat(); + Stat precisionOverall = new Stat(); + for(int currOuterFold=0; currOuterFold<outerFolds; currOuterFold++) { - System.out.println("Start processing outer fold " + currOuterFold); + System.out.println("Outer fold " + currOuterFold); TrainTestList posList = posLists.get(currOuterFold); TrainTestList negList = negLists.get(currOuterFold); + // measure relevant criterion (accuracy, F-measure) over different parameter values + Map<Integer,Stat> paraStats = new HashMap<Integer,Stat>(); + for(int currParaValue=startValue; currParaValue<=endValue; currParaValue++) { - System.out.println(" Start Processing parameter value " + currParaValue); + System.out.println(" Parameter value " + currParaValue + ":"); // split train folds again (computation of inner folds for each parameter // value is redundant, but not a big problem) List<Individual> trainPosList = posList.getTrainList(); @@ -189,101 +212,156 @@ List<Individual> trainNegList = negList.getTrainList(); List<TrainTestList> innerNegLists = getFolds(trainNegList, innerFolds); + // measure relevant criterion for parameter (by default accuracy, + // can also be F measure) + Stat paraCriterionStat = new Stat(); + for(int currInnerFold=0; currInnerFold<innerFolds; currInnerFold++) { - System.out.println(" Inner fold " + currInnerFold + " ... "); + System.out.println(" Inner fold " + currInnerFold + ":"); // get positive & negative examples for training run - List<Individual> posEx = innerPosLists.get(currInnerFold).getTrainList(); - List<Individual> negEx = innerNegLists.get(currInnerFold).getTrainList(); + Set<Individual> posEx = new TreeSet<Individual>(innerPosLists.get(currInnerFold).getTrainList()); + Set<Individual> negEx = new TreeSet<Individual>(innerNegLists.get(currInnerFold).getTrainList()); // read conf file and exchange options for pos/neg examples // and parameter to optimise start = new Start(confFile); - lp = start.getLearningProblem(); - cm.applyConfigEntry(lp, "positiveExamples", posEx); - cm.applyConfigEntry(lp, "negativeExamples", negEx); - LearningAlgorithm la = start.getLearningAlgorithm(); - cm.applyConfigEntry(la, parameter, (double)currParaValue); + LearningProblem lpIn = start.getLearningProblem(); + cm.applyConfigEntry(lpIn, "positiveExamples", Datastructures.individualSetToStringSet(posEx)); + cm.applyConfigEntry(lpIn, "negativeExamples", Datastructures.individualSetToStringSet(negEx)); + LearningAlgorithm laIn = start.getLearningAlgorithm(); + cm.applyConfigEntry(laIn, parameter, (double)currParaValue); - lp.init(); - la.init(); - la.start(); + lpIn.init(); + laIn.init(); + laIn.start(); // evaluate learned expression - Description concept = la.getCurrentlyBestDescription(); + Description concept = laIn.getCurrentlyBestDescription(); TreeSet<Individual> posTest = new TreeSet<Individual>(innerPosLists.get(currInnerFold).getTestList()); TreeSet<Individual> negTest = new TreeSet<Individual>(innerNegLists.get(currInnerFold).getTestList()); ReasonerComponent rs = start.getReasonerComponent(); + // true positive Set<Individual> posCorrect = rs.hasType(concept, posTest); + // false negative Set<Individual> posError = Helper.difference(posTest, posCorrect); + // false positive Set<Individual> negError = rs.hasType(concept, negTest); + // true negative Set<Individual> negCorrect = Helper.difference(negTest, negError); + +// double posErrorRate = 100*(posError.size()/posTest.size()); +// double negErrorRate = 100*(negError.size()/posTest.size()); -// System.out.println("test set errors pos: " + tmp2); -// System.out.println("test set errors neg: " + tmp3); - double accuracy = 100*((double)(posCorrect.size()+negCorrect.size())/(posTest.size()+negTest.size())); + double precision = 100 * (double) posCorrect.size() / (posCorrect.size() + negError.size()); + double recall = 100 * (double) posCorrect.size() / (posCorrect.size() + posError.size()); + double fmeasure = 2 * (precision * recall) / (precision + recall); - System.out.println(" accuracy: " + df.format(accuracy)); + paraCriterionStat.addNumber(accuracy); + System.out.println(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); + System.out.println(" accuracy: " + df.format(accuracy) + "%"); + System.out.println(" precision: " + df.format(precision) + "%"); + System.out.println(" recall: " + df.format(recall) + "%"); + System.out.println(" F measure: " + df.format(fmeasure) + "%"); + + if(verbose) { + System.out.println(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); + System.out.println(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); + } + // free memory rs.releaseKB(); cm.freeAllComponents(); } + paraStats.put(currParaValue, paraCriterionStat); + } - } - - /* - - // calculate splits using CV class - int[] splitsPos = CrossValidation.calculateSplits(posExamples.size(), outerFolds); - int[] splitsNeg = CrossValidation.calculateSplits(negExamples.size(), outerFolds); - - // the training and test sets used later on -// List<List<Individual>> trainingSetsPos = new LinkedList<List<Individual>>(); -// List<List<Individual>> trainingSetsNeg = new LinkedList<List<Individual>>(); -// List<List<Individual>> testSetsPos = new LinkedList<List<Individual>>(); -// List<List<Individual>> testSetsNeg = new LinkedList<List<Individual>>(); - - // calculating training and test sets for outer folds - for(int i=0; i<outerFolds; i++) { + // decide for the best parameter + System.out.println(" Summary over parameter values:"); + int bestPara = startValue; + double bestValue = Double.NEGATIVE_INFINITY; + for(Entry<Integer,Stat> entry : paraStats.entrySet()) { + int para = entry.getKey(); + Stat stat = entry.getValue(); + System.out.println(" value " + para + ": " + stat.prettyPrint("%")); + if(stat.getMean() > bestValue) { + bestPara = para; + bestValue = stat.getMean(); + } + } + System.out.println(" selected " + bestPara + " as best parameter value (criterion value " + df.format(bestValue) + "%)"); + System.out.println(" Learn on Outer fold:"); + // start a learning process with this parameter and evaluate it on the outer fold + start = new Start(confFile); + LearningProblem lpOut = start.getLearningProblem(); + cm.applyConfigEntry(lpOut, "positiveExamples", Datastructures.individualListToStringSet(posLists.get(currOuterFold).getTrainList())); + cm.applyConfigEntry(lpOut, "negativeExamples", Datastructures.individualListToStringSet(negLists.get(currOuterFold).getTrainList())); + LearningAlgorithm laOut = start.getLearningAlgorithm(); + cm.applyConfigEntry(laOut, parameter, (double)bestPara); + lpOut.init(); + laOut.init(); + laOut.start(); - // sets for positive examples - int posFromIndex = (i==0) ? 0 : splitsPos[i-1]; - int posToIndex = splitsPos[i]; - List<Individual> testPos = posExamples.subList(posFromIndex, posToIndex); - List<Individual> trainPos = new LinkedList<Individual>(posExamples); - trainPos.removeAll(testPos); - - // sets for negative examples - int negFromIndex = (i==0) ? 0 : splitsNeg[i-1]; - int negToIndex = splitsNeg[i]; - List<Individual> testNeg = posExamples.subList(negFromIndex, negToIndex); - List<Individual> trainNeg = new LinkedList<Individual>(negExamples); - trainNeg.removeAll(testNeg); - - // split train folds - int[] innerSplitPos = CrossValidation.calculateSplits(trainPos.size(), innerFolds); - int[] innerSplitNeg = CrossValidation.calculateSplits(trainNeg.size(), innerFolds); + // evaluate learned expression + Description concept = laOut.getCurrentlyBestDescription(); - for(int j=0; j<innerFolds; j++) { - - } + TreeSet<Individual> posTest = new TreeSet<Individual>(posLists.get(currOuterFold).getTestList()); + TreeSet<Individual> negTest = new TreeSet<Individual>(negLists.get(currOuterFold).getTestList()); - // add to list of folds -// trainingSetsPos.add(trainPos); -// trainingSetsNeg.add(trainNeg); -// testSetsPos.add(testPos); -// testSetsNeg.add(testNeg); - } + ReasonerComponent rs = start.getReasonerComponent(); + // true positive + Set<Individual> posCorrect = rs.hasType(concept, posTest); + // false negative + Set<Individual> posError = Helper.difference(posTest, posCorrect); + // false positive + Set<Individual> negError = rs.hasType(concept, negTest); + // true negative + Set<Individual> negCorrect = Helper.difference(negTest, negError); + + double accuracy = 100*((double)(posCorrect.size()+negCorrect.size())/(posTest.size()+negTest.size())); + double precision = 100 * (double) posCorrect.size() / (posCorrect.size() + negError.size()); + double recall = 100 * (double) posCorrect.size() / (posCorrect.size() + posError.size()); + double fmeasure = 2 * (precision * recall) / (precision + recall); + + System.out.println(" hypothesis: " + concept.toManchesterSyntaxString(baseURI, null)); + System.out.println(" accuracy: " + df.format(accuracy) + "%"); + System.out.println(" precision: " + df.format(precision) + "%"); + System.out.println(" recall: " + df.format(recall) + "%"); + System.out.println(" F measure: " + df.format(fmeasure) + "%"); + + if(verbose) { + System.out.println(" false positives (neg. examples classified as pos.): " + formatIndividualSet(posError, baseURI)); + System.out.println(" false negatives (pos. examples classified as neg.): " + formatIndividualSet(negError, baseURI)); + } + + // update overall statistics + accOverall.addNumber(accuracy); + fOverall.addNumber(fmeasure); + recallOverall.addNumber(recall); + precisionOverall.addNumber(precision); + + // free memory + rs.releaseKB(); + cm.freeAllComponents(); + } - */ + // overall statistics + System.out.println(); + System.out.println("*******************"); + System.out.println("* Overall Results *"); + System.out.println("*******************"); + System.out.println("accuracy: " + accOverall.prettyPrint("%")); + System.out.println("F measure: " + fOverall.prettyPrint("%")); + System.out.println("precision: " + precisionOverall.prettyPrint("%")); + System.out.println("recall: " + recallOverall.prettyPrint("%")); } @@ -302,4 +380,17 @@ } return ret; } + + private static String formatIndividualSet(Set<Individual> inds, String baseURI) { + String ret = ""; + int i=0; + for(Individual ind : inds) { + ret += ind.toManchesterSyntaxString(baseURI, null) + " "; + i++; + if(i==20) { + break; + } + } + return ret; + } } Modified: trunk/src/dl-learner/org/dllearner/utilities/datastructures/Datastructures.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/datastructures/Datastructures.java 2009-10-05 10:20:13 UTC (rev 1878) +++ trunk/src/dl-learner/org/dllearner/utilities/datastructures/Datastructures.java 2009-10-05 11:09:22 UTC (rev 1879) @@ -21,6 +21,7 @@ import java.util.Arrays; import java.util.Iterator; +import java.util.List; import java.util.Set; import java.util.TreeSet; @@ -107,4 +108,12 @@ } return ret; } + + public static Set<String> individualListToStringSet(List<Individual> individuals) { + Set<String> ret = new TreeSet<String>(); + for(Individual ind : individuals) { + ret.add(ind.toString()); + } + return ret; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-11-16 22:10:01
|
Revision: 1913 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1913&view=rev Author: jenslehmann Date: 2009-11-16 22:09:55 +0000 (Mon, 16 Nov 2009) Log Message: ----------- implemented CELOE single suggestion mode for learning problems with >1000 examples (i.e. all evaluations should be approximated for performance reasons) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-11-15 13:55:34 UTC (rev 1912) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-11-16 22:09:55 UTC (rev 1913) @@ -21,6 +21,7 @@ import java.text.DecimalFormat; import java.util.Collection; +import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -36,6 +37,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.CELOEConfigurator; +import org.dllearner.core.options.BooleanConfigOption; import org.dllearner.core.options.CommonConfigOptions; import org.dllearner.core.options.ConfigOption; import org.dllearner.core.owl.ClassHierarchy; @@ -95,6 +97,12 @@ private EvaluatedDescriptionSet bestEvaluatedDescriptions; + // if true, then each solution is evaluated exactly instead of approximately + // private boolean exactBestDescriptionEvaluation = false; + private boolean singleSuggestionMode; + private Description bestDescription; + private double bestAccuracy = Double.MIN_VALUE; + private NamedClass classToDescribe; // examples are either 1.) instances of the class to describe 2.) positive examples // 3.) union of pos.+neg. examples depending on the learning problem at hand @@ -154,6 +162,7 @@ options.add(CommonConfigOptions.getNoisePercentage()); options.add(CommonConfigOptions.getMaxDepth(7)); options.add(CommonConfigOptions.maxNrOfResults(10)); + options.add(new BooleanConfigOption("singleSuggestionMode", "Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.", false)); return options; } @@ -172,6 +181,8 @@ startClass = Thing.instance; + singleSuggestionMode = configurator.getSingleSuggestionMode(); + // create refinement operator operator = new RhoDRDown(reasoner, classHierarchy, startClass, configurator); baseURI = reasoner.getBaseURI(); @@ -246,7 +257,7 @@ int loop = 0; while (!terminationCriteriaSatisfied()) { - if(bestEvaluatedDescriptions.getBest().getAccuracy() > highestAccuracy) { + if(!singleSuggestionMode && bestEvaluatedDescriptions.getBest().getAccuracy() > highestAccuracy) { highestAccuracy = bestEvaluatedDescriptions.getBest().getAccuracy(); logger.info("more accurate (" + dfPercent.format(highestAccuracy) + ") class expression found: " + descriptionToString(bestEvaluatedDescriptions.getBest().getDescription())); } @@ -260,6 +271,11 @@ TreeSet<Description> refinements = refineNode(nextNode); mon.stop(); +// System.out.println("next node: " + nextNode); +// for(Description refinement : refinements) { +// System.out.println("refinement: " + refinement); +// } + while(refinements.size() != 0) { // pick element from set Description refinement = refinements.pollFirst(); @@ -269,24 +285,30 @@ // (this also avoids duplicate node children) if(length > horizExp && refinement.getDepth() <= maxDepth) { +// System.out.println("potentially adding " + refinement + " to search tree as child of " + nextNode + " " + new Date()); Monitor mon2 = MonitorFactory.start("addNode"); addNode(refinement, nextNode); mon2.stop(); - +// System.out.println("addNode finished" + " " + new Date()); } } updateMinMaxHorizExp(nextNode); +// System.out.println(loop); loop++; } - + if (stop) { logger.info("Algorithm stopped ("+expressionTests+" descriptions tested).\n"); } else { logger.info("Algorithm terminated successfully ("+expressionTests+" descriptions tested).\n"); } + + if(singleSuggestionMode) { + bestEvaluatedDescriptions.add(bestDescription, bestAccuracy, learningProblem); + } // print solution(s) logger.info("solutions:\n" + getSolutionString()); @@ -343,8 +365,10 @@ return false; } +// System.out.println("Test " + new Date()); // quality of description (return if too weak) double accuracy = learningProblem.getAccuracyOrTooWeak(description, noise); +// System.out.println("Test2 " + new Date()); expressionTests++; // System.out.println(description + " " + accuracy); if(accuracy == -1) { @@ -361,7 +385,19 @@ } nodes.add(node); +// System.out.println("Test3 " + new Date()); + // in some cases (e.g. mutation) fully evaluating even a single description is too expensive + // due to the high number of examples -- so we just stick to the approximate accuracy + if(singleSuggestionMode) { + if(accuracy > bestAccuracy) { + bestAccuracy = accuracy; + bestDescription = description; + logger.info("more accurate (" + dfPercent.format(bestAccuracy) + ") class expression found: " + descriptionToString(bestDescription)); + } + return true; + } + // maybe add to best descriptions (method keeps set size fixed); // we need to make sure that this does not get called more often than // necessary since rewriting is expensive @@ -374,6 +410,7 @@ (accuracy >= accThreshold && description.getLength() < worst.getDescriptionLength())); } +// System.out.println("Test4 " + new Date()); if(isCandidate) { Description niceDescription = rewriteNode(node); ConceptTransformation.transformToOrderedForm(niceDescription, descriptionComparator); @@ -383,18 +420,20 @@ // a subdescription of this one unless accuracy is different boolean shorterDescriptionExists = false; for(EvaluatedDescription ed : bestEvaluatedDescriptions.getSet()) { - if(ed.getAccuracy()==accuracy && ConceptTransformation.isSubdescription(niceDescription, ed.getDescription())) { + if(Math.abs(ed.getAccuracy()-accuracy) <= 0.00001 && ConceptTransformation.isSubdescription(niceDescription, ed.getDescription())) { shorterDescriptionExists = true; break; } } if(!shorterDescriptionExists) { - bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); + bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); } } +// System.out.println("Test5 " + new Date()); +// System.out.println("best evaluated descriptions size: " + bestEvaluatedDescriptions.size() + " worst: " + bestEvaluatedDescriptions.getWorst()); return true; } Modified: trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2009-11-15 13:55:34 UTC (rev 1912) +++ trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2009-11-16 22:09:55 UTC (rev 1913) @@ -174,6 +174,15 @@ public int getMaxNrOfResults() { return (Integer) ComponentManager.getInstance().getConfigOptionValue(cELOE, "maxNrOfResults") ; } +/** +* singleSuggestionMode Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.. +* mandatory: false| reinit necessary: true +* default value: false +* @return boolean +**/ +public boolean getSingleSuggestionMode() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "singleSuggestionMode") ; +} /** * @param useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm. @@ -292,6 +301,15 @@ ComponentManager.getInstance().applyConfigEntry(cELOE, "maxNrOfResults", maxNrOfResults); reinitNecessary = true; } +/** +* @param singleSuggestionMode Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.. +* mandatory: false| reinit necessary: true +* default value: false +**/ +public void setSingleSuggestionMode(boolean singleSuggestionMode) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "singleSuggestionMode", singleSuggestionMode); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java 2009-11-15 13:55:34 UTC (rev 1912) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PelletReasonerConfigurator.java 2009-11-16 22:09:55 UTC (rev 1913) @@ -21,7 +21,6 @@ package org.dllearner.core.configurators; import java.util.Set; - import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; import org.dllearner.reasoning.PelletReasoner; @@ -73,7 +72,6 @@ reinitNecessary = true; } - /** * true, if this component needs reinitializsation. * @return boolean Modified: trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java 2009-11-15 13:55:34 UTC (rev 1912) +++ trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java 2009-11-16 22:09:55 UTC (rev 1913) @@ -63,6 +63,9 @@ private static boolean generatePosExampleClass = true; // set to true if accessing PostreSQL and false for MySQL private static boolean pgSQL = true; + // generate fragment => limits the number of individuals in the ontology + // to speed up learning +// private static boolean onlyFragment = true; public static void main(String[] args) throws ClassNotFoundException, BackingStoreException, SQLException { @@ -233,6 +236,10 @@ kb.addAxiom(new DatatypePropertyDomainAxiom(reliabilityDeltagProp, mutationClass)); kb.addAxiom(new DatatypePropertyRangeAxiom(reliabilityDeltagProp, Datatype.DOUBLE)); + if(generatePosExampleClass) { + kb.addAxiom(new SubClassAxiom(deleteriousMutationClass, mutationClass)); + } + // select data (restricted to pos/neg examples for efficiency) Statement stmt = conn.createStatement(); ResultSet rs = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-11-23 14:35:30
|
Revision: 1914 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1914&view=rev Author: jenslehmann Date: 2009-11-23 14:35:21 +0000 (Mon, 23 Nov 2009) Log Message: ----------- added ability to optimise towards F-measure in class learning problems Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-11-16 22:09:55 UTC (rev 1913) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-11-23 14:35:21 UTC (rev 1914) @@ -81,6 +81,15 @@ public boolean getUseApproximations() { return (Boolean) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "useApproximations") ; } +/** +* accuracyMethod Specifies, which method/function to use for computing accuracy.. +* mandatory: false| reinit necessary: true +* default value: standard +* @return String +**/ +public String getAccuracyMethod() { +return (String) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "accuracyMethod") ; +} /** * @param classToDescribe class of which a description should be learned. @@ -108,6 +117,15 @@ ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "useApproximations", useApproximations); reinitNecessary = true; } +/** +* @param accuracyMethod Specifies, which method/function to use for computing accuracy.. +* mandatory: false| reinit necessary: true +* default value: standard +**/ +public void setAccuracyMethod(String accuracyMethod) { +ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "accuracyMethod", accuracyMethod); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-11-16 22:09:55 UTC (rev 1913) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-11-23 14:35:21 UTC (rev 1914) @@ -51,6 +51,10 @@ */ public class ClassLearningProblem extends LearningProblem { + // TODO: naming needs to be cleaned up for consistency: + // coverage => recall + // protusion => precision + private NamedClass classToDescribe; private List<Individual> classInstances; private boolean equivalence = true; @@ -59,6 +63,7 @@ private static final double approx = 0.05; private boolean useApproximations; + private boolean useFMeasure; // factor for higher weight on coverage (needed for subclass learning) private double coverageFactor; @@ -86,6 +91,9 @@ options.add(type); BooleanConfigOption approx = new BooleanConfigOption("useApproximations", "whether to use stochastic approximations for computing accuracy", true); options.add(approx); + StringConfigOption accMethod = new StringConfigOption("accuracyMethod", "Specifies, which method/function to use for computing accuracy.","standard"); // or domain/range of a property. + accMethod.setAllowedValues(new String[] {"standard", "fmeasure", "predacc"}); + options.add(accMethod); return options; } @@ -97,6 +105,7 @@ public void init() throws ComponentInitException { classToDescribe = new NamedClass(configurator.getClassToDescribe().toString()); useApproximations = configurator.getUseApproximations(); + useFMeasure = configurator.getAccuracyMethod().equals("fmeasure"); if(!reasoner.getNamedClasses().contains(classToDescribe)) { throw new ComponentInitException("The class \"" + configurator.getClassToDescribe() + "\" does not exist. Make sure you spelled it correctly."); @@ -173,7 +182,8 @@ // we check whether the axiom already follows from the knowledge base boolean followsFromKB = reasoner.isSuperClassOf(description, classToDescribe); - return new ClassScore(coveredInstances, coverage, additionalInstances, protusion, getAccuracy(coverage, protusion), isConsistent, followsFromKB); + double acc = useFMeasure ? getFMeasure(coverage, protusion) : getAccuracy(coverage, protusion); + return new ClassScore(coveredInstances, coverage, additionalInstances, protusion, acc, isConsistent, followsFromKB); } public boolean isEquivalenceProblem() { @@ -210,11 +220,19 @@ @Override public double getAccuracyOrTooWeak(Description description, double noise) { - if(useApproximations) { - return getAccuracyOrTooWeakApprox(description, noise); - } else { - return getAccuracyOrTooWeakExact(description, noise); - } +// if(useFMeasure) { +// if(useApproximations) { +// return getFMeasureOrTooWeakApprox(description, noise); +// } else { +// return getFMeasureOrTooWeakExact(description, noise); +// } +// } else { + if(useApproximations) { + return getAccuracyOrTooWeakApprox(description, noise); + } else { + return getAccuracyOrTooWeakExact(description, noise); + } +// } } // instead of using the standard operation, we use optimisation @@ -278,7 +296,7 @@ } } - double coverage = instancesCovered/(double)classInstances.size(); + double recall = instancesCovered/(double)classInstances.size(); // MonitorFactory.add("estimatedA","count", estimatedA ? 1 : 0); // MonitorFactory.add("aInstances","count", total); @@ -318,7 +336,7 @@ size = getAccuracy(upperBorderA, upperEstimateA/(double)(upperEstimateA+lowerEstimate)) - getAccuracy(lowerBorderA, lowerEstimateA/(double)(lowerEstimateA+upperEstimate)); } else { // size = 1/(coverageFactor+1) * (coverageFactor * coverage + Math.sqrt(instancesCovered/(instancesCovered+lowerEstimate)) + Math.sqrt(instancesCovered/(instancesCovered+upperEstimate))); - size = getAccuracy(coverage, instancesCovered/(double)(instancesCovered+lowerEstimate)) - getAccuracy(coverage, instancesCovered/(double)(instancesCovered+upperEstimate)); + size = getAccuracy(recall, instancesCovered/(double)(instancesCovered+lowerEstimate)) - getAccuracy(recall, instancesCovered/(double)(instancesCovered+upperEstimate)); } if(size < 0.1) { @@ -336,20 +354,26 @@ // since we measured/estimated accuracy only on instances outside A (superClassInstances // does not include instances of A), we need to add it in the denominator - double protusion = instancesCovered/(double)(instancesDescription+instancesCovered); + double precision = instancesCovered/(double)(instancesDescription+instancesCovered); if(instancesCovered + instancesDescription == 0) { - protusion = 0; + precision = 0; } // MonitorFactory.add("estimatedB","count", estimatedB ? 1 : 0); // MonitorFactory.add("bInstances","count", testsPerformed); - return getAccuracy(coverage, protusion); + // debug code to compare the two measures +// System.out.println("recall: " + recall); +// System.out.println("precision: " + precision); +// System.out.println("F-measure: " + getFMeasure(recall, precision)); +// System.out.println("standard acc: " + getAccuracy(recall, precision)); + +// return getAccuracy(recall, precision); + return useFMeasure ? getFMeasure(recall, precision) : getAccuracy(recall, precision); } public double getAccuracyOrTooWeakExact(Description description, double noise) { - // overhang int additionalInstances = 0; for(Individual ind : superClassInstances) { if(reasoner.hasType(description, ind)) { @@ -357,7 +381,6 @@ } } - // coverage int coveredInstances = 0; for(Individual ind : classInstances) { if(reasoner.hasType(description, ind)) { @@ -365,16 +388,15 @@ } } - double coverage = coveredInstances/(double)classInstances.size(); + double recall = coveredInstances/(double)classInstances.size(); - if(coverage < 1 - noise) { + if(recall < 1 - noise) { return -1; } -// double protusion = additionalInstances == 0 ? 0 : coveredInstances/(double)(coveredInstances+additionalInstances); - double protusion = (additionalInstances + coveredInstances == 0) ? 0 : coveredInstances / (double) (coveredInstances + additionalInstances); + double precision = (additionalInstances + coveredInstances == 0) ? 0 : coveredInstances / (double) (coveredInstances + additionalInstances); - return getAccuracy(coverage, protusion); + return useFMeasure ? getFMeasure(recall, precision) : getAccuracy(recall, precision); } // @Deprecated @@ -389,12 +411,77 @@ // } // } + // please note that getting recall and precision wastes some computational + // resource, because both methods need to compute the covered instances + public double getRecall(Description description) { + int coveredInstances = 0; + for(Individual ind : classInstances) { + if(reasoner.hasType(description, ind)) { + coveredInstances++; + } + } + return coveredInstances/(double)classInstances.size(); + } + + public double getPrecision(Description description) { + + int additionalInstances = 0; + for(Individual ind : superClassInstances) { + if(reasoner.hasType(description, ind)) { + additionalInstances++; + } + } + + int coveredInstances = 0; + for(Individual ind : classInstances) { + if(reasoner.hasType(description, ind)) { + coveredInstances++; + } + } + + return (additionalInstances + coveredInstances == 0) ? 0 : coveredInstances / (double) (coveredInstances + additionalInstances); + } + + public double getPredictiveAccuracy() { + return 0; + } + + // see http://sunsite.informatik.rwth-aachen.de/Publications/CEUR-WS/Vol-426/swap2008_submission_14.pdf + // for all methods below (currently dummies) + public double getMatchRate() { + return 0; + } + + public double getOmissionError() { + return 0; + } + + public double getInductionRate() { + return 0; + } + + public double getComissionError() { + return 0; + } + + public double getGeneralisedRecall() { + return 0; + } + + public double getGeneralisedPrecision() { + return 0; + } + // computes accuracy from coverage and protusion (changing this function may // make it necessary to change the appoximation too) private double getAccuracy(double coverage, double protusion) { return (coverageFactor * coverage + Math.sqrt(protusion)) / (coverageFactor + 1); } + private double getFMeasure(double recall, double precision) { + return 2 * precision * recall / (precision + recall); + } + // see paper: expression used in confidence interval estimation private static double p3(double p1, int total) { return 1.96 * Math.sqrt(p1*(1-p1)/(total+4)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-11-24 07:14:35
|
Revision: 1916 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1916&view=rev Author: jenslehmann Date: 2009-11-24 07:14:29 +0000 (Tue, 24 Nov 2009) Log Message: ----------- introduced parameter for controlling approximate coverage test + minor improvements Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-11-23 20:57:15 UTC (rev 1915) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-11-24 07:14:29 UTC (rev 1916) @@ -301,9 +301,9 @@ } if (stop) { - logger.info("Algorithm stopped ("+expressionTests+" descriptions tested).\n"); + logger.info("Algorithm stopped ("+expressionTests+" descriptions tested). " + nodes.size() + " nodes in the search tree.\n"); } else { - logger.info("Algorithm terminated successfully ("+expressionTests+" descriptions tested).\n"); + logger.info("Algorithm terminated successfully ("+expressionTests+" descriptions tested). " + nodes.size() + " nodes in the search tree.\n"); } if(singleSuggestionMode) { Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-11-23 20:57:15 UTC (rev 1915) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-11-24 07:14:29 UTC (rev 1916) @@ -82,6 +82,15 @@ return (Boolean) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "useApproximations") ; } /** +* approxAccuracy accuracy of the approximation (only for expert use). +* mandatory: false| reinit necessary: true +* default value: 0.05 +* @return double +**/ +public double getApproxAccuracy() { +return (Double) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "approxAccuracy") ; +} +/** * accuracyMethod Specifies, which method/function to use for computing accuracy.. * mandatory: false| reinit necessary: true * default value: standard @@ -118,6 +127,15 @@ reinitNecessary = true; } /** +* @param approxAccuracy accuracy of the approximation (only for expert use). +* mandatory: false| reinit necessary: true +* default value: 0.05 +**/ +public void setApproxAccuracy(double approxAccuracy) { +ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "approxAccuracy", approxAccuracy); +reinitNecessary = true; +} +/** * @param accuracyMethod Specifies, which method/function to use for computing accuracy.. * mandatory: false| reinit necessary: true * default value: standard Modified: trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java =================================================================== --- trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java 2009-11-23 20:57:15 UTC (rev 1915) +++ trunk/src/dl-learner/org/dllearner/examples/MonogenicDiseases.java 2009-11-24 07:14:29 UTC (rev 1916) @@ -408,6 +408,23 @@ } } + // conf example: + +// import("mutation.owl"); +// +// reasoner = fastInstanceChecker; +// +// problem = classLearning; +// classLearning.classToDescribe = "http://dl-learner.org/mutation#DeletoriousMutation"; +// classLearning.accuracyMethod = "fmeasure"; +// classLearning.approxAccuracy = 0.03; +// +// algorithm = celoe; +// celoe.maxExecutionTimeInSeconds = 10; +// celoe.noisePercentage = 10; +// celoe.maxNrOfResults = 1; +// celoe.singleSuggestionMode = true; + // writing conf file Files.clearFile(confFile); String confHeader = "import(\"" + owlFile.getName() + "\");\n\n"; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-11-23 20:57:15 UTC (rev 1915) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-11-24 07:14:29 UTC (rev 1916) @@ -33,6 +33,7 @@ import org.dllearner.core.configurators.ClassLearningProblemConfigurator; import org.dllearner.core.options.BooleanConfigOption; import org.dllearner.core.options.ConfigOption; +import org.dllearner.core.options.DoubleConfigOption; import org.dllearner.core.options.StringConfigOption; import org.dllearner.core.options.URLConfigOption; import org.dllearner.core.owl.Axiom; @@ -60,7 +61,7 @@ private boolean equivalence = true; private ClassLearningProblemConfigurator configurator; // approximation of accuracy +- 0.05 % - private static final double approx = 0.05; + private double approx = 0.05; private boolean useApproximations; private boolean useFMeasure; @@ -91,6 +92,8 @@ options.add(type); BooleanConfigOption approx = new BooleanConfigOption("useApproximations", "whether to use stochastic approximations for computing accuracy", true); options.add(approx); + DoubleConfigOption approxAccuracy = new DoubleConfigOption("approxAccuracy", "accuracy of the approximation (only for expert use)", 0.05); + options.add(approxAccuracy); StringConfigOption accMethod = new StringConfigOption("accuracyMethod", "Specifies, which method/function to use for computing accuracy.","standard"); // or domain/range of a property. accMethod.setAllowedValues(new String[] {"standard", "fmeasure", "predacc"}); options.add(accMethod); @@ -106,6 +109,7 @@ classToDescribe = new NamedClass(configurator.getClassToDescribe().toString()); useApproximations = configurator.getUseApproximations(); useFMeasure = configurator.getAccuracyMethod().equals("fmeasure"); + approx = configurator.getApproxAccuracy(); if(!reasoner.getNamedClasses().contains(classToDescribe)) { throw new ComponentInitException("The class \"" + configurator.getClassToDescribe() + "\" does not exist. Make sure you spelled it correctly."); @@ -333,10 +337,10 @@ double size; if(estimatedA) { // size = 1/(coverageFactor+1) * (coverageFactor * (upperBorderA-lowerBorderA) + Math.sqrt(upperEstimateA/(upperEstimateA+lowerEstimate)) + Math.sqrt(lowerEstimateA/(lowerEstimateA+upperEstimate))); - size = getAccuracy(upperBorderA, upperEstimateA/(double)(upperEstimateA+lowerEstimate)) - getAccuracy(lowerBorderA, lowerEstimateA/(double)(lowerEstimateA+upperEstimate)); + size = useFMeasure ? getFMeasure(upperBorderA, upperEstimateA/(double)(upperEstimateA+lowerEstimate)) - getFMeasure(lowerBorderA, lowerEstimateA/(double)(lowerEstimateA+upperEstimate)) : getAccuracy(upperBorderA, upperEstimateA/(double)(upperEstimateA+lowerEstimate)) - getAccuracy(lowerBorderA, lowerEstimateA/(double)(lowerEstimateA+upperEstimate)); } else { // size = 1/(coverageFactor+1) * (coverageFactor * coverage + Math.sqrt(instancesCovered/(instancesCovered+lowerEstimate)) + Math.sqrt(instancesCovered/(instancesCovered+upperEstimate))); - size = getAccuracy(recall, instancesCovered/(double)(instancesCovered+lowerEstimate)) - getAccuracy(recall, instancesCovered/(double)(instancesCovered+upperEstimate)); + size = useFMeasure ? getFMeasure(recall, instancesCovered/(double)(instancesCovered+lowerEstimate)) - getFMeasure(recall, instancesCovered/(double)(instancesCovered+upperEstimate)) : getAccuracy(recall, instancesCovered/(double)(instancesCovered+lowerEstimate)) - getAccuracy(recall, instancesCovered/(double)(instancesCovered+upperEstimate)); } if(size < 0.1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-11-24 15:28:40
|
Revision: 1918 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1918&view=rev Author: jenslehmann Date: 2009-11-24 15:28:33 +0000 (Tue, 24 Nov 2009) Log Message: ----------- preliminary approximation support for pos/neg problems Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java 2009-11-24 08:48:27 UTC (rev 1917) +++ trunk/src/dl-learner/org/dllearner/core/configurators/PosNegLPStandardConfigurator.java 2009-11-24 15:28:33 UTC (rev 1918) @@ -103,6 +103,33 @@ public String getUseMultiInstanceChecks() { return (String) ComponentManager.getInstance().getConfigOptionValue(posNegLPStandard, "useMultiInstanceChecks") ; } +/** +* useApproximations whether to use stochastic approximations for computing accuracy. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getUseApproximations() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(posNegLPStandard, "useApproximations") ; +} +/** +* approxAccuracy accuracy of the approximation (only for expert use). +* mandatory: false| reinit necessary: true +* default value: 0.05 +* @return double +**/ +public double getApproxAccuracy() { +return (Double) ComponentManager.getInstance().getConfigOptionValue(posNegLPStandard, "approxAccuracy") ; +} +/** +* accuracyMethod Specifies, which method/function to use for computing accuracy.. +* mandatory: false| reinit necessary: true +* default value: standard +* @return String +**/ +public String getAccuracyMethod() { +return (String) ComponentManager.getInstance().getConfigOptionValue(posNegLPStandard, "accuracyMethod") ; +} /** * @param positiveExamples positive examples. @@ -147,6 +174,33 @@ ComponentManager.getInstance().applyConfigEntry(posNegLPStandard, "useMultiInstanceChecks", useMultiInstanceChecks); reinitNecessary = true; } +/** +* @param useApproximations whether to use stochastic approximations for computing accuracy. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setUseApproximations(boolean useApproximations) { +ComponentManager.getInstance().applyConfigEntry(posNegLPStandard, "useApproximations", useApproximations); +reinitNecessary = true; +} +/** +* @param approxAccuracy accuracy of the approximation (only for expert use). +* mandatory: false| reinit necessary: true +* default value: 0.05 +**/ +public void setApproxAccuracy(double approxAccuracy) { +ComponentManager.getInstance().applyConfigEntry(posNegLPStandard, "approxAccuracy", approxAccuracy); +reinitNecessary = true; +} +/** +* @param accuracyMethod Specifies, which method/function to use for computing accuracy.. +* mandatory: false| reinit necessary: true +* default value: standard +**/ +public void setAccuracyMethod(String accuracyMethod) { +ComponentManager.getInstance().applyConfigEntry(posNegLPStandard, "accuracyMethod", accuracyMethod); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-11-24 08:48:27 UTC (rev 1917) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-11-24 15:28:33 UTC (rev 1918) @@ -487,7 +487,7 @@ } // see paper: expression used in confidence interval estimation - private static double p3(double p1, int total) { + public static double p3(double p1, int total) { return 1.96 * Math.sqrt(p1*(1-p1)/(total+4)); } @@ -498,7 +498,7 @@ // } // see paper: p' - private static double p1(int success, int total) { + public static double p1(int success, int total) { return (success+2)/(double)(total+4); } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java 2009-11-24 08:48:27 UTC (rev 1917) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLPStandard.java 2009-11-24 15:28:33 UTC (rev 1918) @@ -20,6 +20,7 @@ package org.dllearner.learningproblems; import java.util.Collection; +import java.util.LinkedList; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -27,7 +28,10 @@ import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.configurators.PosNegLPStandardConfigurator; +import org.dllearner.core.options.BooleanConfigOption; import org.dllearner.core.options.ConfigOption; +import org.dllearner.core.options.DoubleConfigOption; +import org.dllearner.core.options.StringConfigOption; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.utilities.Helper; @@ -49,6 +53,13 @@ private PosNegLPStandardConfigurator configurator; + // approximation and F-measure + // (taken from class learning => super class instances corresponds to negative examples + // and class instances to positive examples) + private double approx = 0.05; + private boolean useApproximations; + private boolean useFMeasure; + @Override public PosNegLPStandardConfigurator getConfigurator() { return configurator; @@ -66,6 +77,19 @@ this.configurator = new PosNegLPStandardConfigurator(this); } + public void init() { + super.init(); + useApproximations = configurator.getUseApproximations(); + useFMeasure = configurator.getAccuracyMethod().equals("fmeasure"); + + if((!useApproximations && useFMeasure) || (useApproximations && !useFMeasure)) { + System.err.println("Currently F measure can only be used in combination with approximated reasoning."); + System.exit(0); + } + + approx = configurator.getApproxAccuracy(); + } + /* * (non-Javadoc) * @@ -75,9 +99,16 @@ return "pos neg learning problem"; } - public static Collection<ConfigOption<?>> createConfigOptions() { - return PosNegLP.createConfigOptions(); + Collection<ConfigOption<?>> options = new LinkedList<ConfigOption<?>>(PosNegLP.createConfigOptions()); + BooleanConfigOption approx = new BooleanConfigOption("useApproximations", "whether to use stochastic approximations for computing accuracy", false); + options.add(approx); + DoubleConfigOption approxAccuracy = new DoubleConfigOption("approxAccuracy", "accuracy of the approximation (only for expert use)", 0.05); + options.add(approxAccuracy); + StringConfigOption accMethod = new StringConfigOption("accuracyMethod", "Specifies, which method/function to use for computing accuracy.","predacc"); // or domain/range of a property. + accMethod.setAllowedValues(new String[] {"fmeasure", "predacc"}); + options.add(accMethod); + return options; } /** @@ -253,11 +284,23 @@ return coveredPos + negativeExamples.size() - coveredNeg / (double) allExamples.size(); } + @Override + public double getAccuracyOrTooWeak(Description description, double noise) { + if(useApproximations) { + if(useFMeasure) { + return getFMeasureOrTooWeakApprox(description, noise); + } else { + throw new Error("approximating pred. acc not implemented"); + } + } else { + return getAccuracyOrTooWeakExact(description, noise); + } + } + /* (non-Javadoc) * @see org.dllearner.core.LearningProblem#getAccuracyOrTooWeak(org.dllearner.core.owl.Description, double) */ - @Override - public double getAccuracyOrTooWeak(Description description, double noise) { + public double getAccuracyOrTooWeakExact(Description description, double noise) { int maxNotCovered = (int) Math.ceil(noise*positiveExamples.size()); @@ -281,6 +324,124 @@ return positiveExamples.size() - notCoveredPos + notCoveredNeg / (double) allExamples.size(); } + // instead of using the standard operation, we use optimisation + // and approximation here + public double getFMeasureOrTooWeakApprox(Description description, double noise) { + // we abort when there are too many uncovered positives + int maxNotCovered = (int) Math.ceil(noise*positiveExamples.size()); + int instancesCovered = 0; + int instancesNotCovered = 0; + int total = 0; + boolean estimatedA = false; + + double lowerBorderA = 0; + int lowerEstimateA = 0; + double upperBorderA = 1; + int upperEstimateA = positiveExamples.size(); + + for(Individual ind : positiveExamples) { + if(reasoner.hasType(description, ind)) { + instancesCovered++; + } else { + instancesNotCovered ++; + if(instancesNotCovered > maxNotCovered) { + return -1; + } + } + + // approximation step (starting after 10 tests) + total = instancesCovered + instancesNotCovered; + if(total > 10) { + // compute confidence interval + double p1 = ClassLearningProblem.p1(instancesCovered, total); + double p2 = ClassLearningProblem.p3(p1, total); + lowerBorderA = Math.max(0, p1 - p2); + upperBorderA = Math.min(1, p1 + p2); + double size = upperBorderA - lowerBorderA; + // if the interval has a size smaller than 10%, we can be confident + if(size < 2 * approx) { + // we have to distinguish the cases that the accuracy limit is + // below, within, or above the limit and that the mean is below + // or above the limit + double mean = instancesCovered/(double)total; + + // if the mean is greater than the required minimum, we can accept; + // we also accept if the interval is small and close to the minimum + // (worst case is to accept a few inaccurate descriptions) + if(mean > 1-noise || (upperBorderA > mean && size < 0.03)) { + instancesCovered = (int) (instancesCovered/(double)total * positiveExamples.size()); + upperEstimateA = (int) (upperBorderA * positiveExamples.size()); + lowerEstimateA = (int) (lowerBorderA * positiveExamples.size()); + estimatedA = true; + break; + } + + // reject only if the upper border is far away (we are very + // certain not to lose a potential solution) + if(upperBorderA + 0.1 < 1-noise) { + return -1; + } + } + } + } + + double recall = instancesCovered/(double)positiveExamples.size(); + +// MonitorFactory.add("estimatedA","count", estimatedA ? 1 : 0); +// MonitorFactory.add("aInstances","count", total); + + // we know that a definition candidate is always subclass of the + // intersection of all super classes, so we test only the relevant instances + // (leads to undesired effects for descriptions not following this rule, + // but improves performance a lot); + // for learning a superclass of a defined class, similar observations apply; + + + int testsPerformed = 0; + int instancesDescription = 0; +// boolean estimatedB = false; + + for(Individual ind : negativeExamples) { + + if(reasoner.hasType(description, ind)) { + instancesDescription++; + } + + testsPerformed++; + + if(testsPerformed > 10) { + + // compute confidence interval + double p1 = ClassLearningProblem.p1(instancesDescription, testsPerformed); + double p2 = ClassLearningProblem.p3(p1, testsPerformed); + double lowerBorder = Math.max(0, p1 - p2); + double upperBorder = Math.min(1, p1 + p2); + int lowerEstimate = (int) (lowerBorder * negativeExamples.size()); + int upperEstimate = (int) (upperBorder * negativeExamples.size()); + + double size; + if(estimatedA) { + size = getFMeasure(upperBorderA, upperEstimateA/(double)(upperEstimateA+lowerEstimate)) - getFMeasure(lowerBorderA, lowerEstimateA/(double)(lowerEstimateA+upperEstimate)); + } else { + size = getFMeasure(recall, instancesCovered/(double)(instancesCovered+lowerEstimate)) - getFMeasure(recall, instancesCovered/(double)(instancesCovered+upperEstimate)); + } + + if(size < 0.1) { + instancesDescription = (int) (instancesDescription/(double)testsPerformed * negativeExamples.size()); + break; + } + } + } + + double precision = instancesCovered/(double)(instancesDescription+instancesCovered); + if(instancesCovered + instancesDescription == 0) { + precision = 0; + } + + return getFMeasure(recall, precision); + } + + /* (non-Javadoc) * @see org.dllearner.core.LearningProblem#evaluate(org.dllearner.core.owl.Description) */ @@ -290,4 +451,8 @@ return new EvaluatedDescriptionPosNeg(description, score); } + private double getFMeasure(double recall, double precision) { + return 2 * precision * recall / (precision + recall); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-12-08 21:48:07
|
Revision: 1929 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1929&view=rev Author: jenslehmann Date: 2009-12-08 21:47:58 +0000 (Tue, 08 Dec 2009) Log Message: ----------- operator test added Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2009-12-02 08:56:36 UTC (rev 1928) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/ELLearningAlgorithm.java 2009-12-08 21:47:58 UTC (rev 1929) @@ -159,8 +159,11 @@ // convert tree to standard description Description description = descriptionTree.transformToDescription(); + +// double accuracy = getLearningProblem().getAccuracyOrTooWeak(description, 0); int negCovers = getLearningProblem().coveredNegativeExamplesOrTooWeak(description); if(negCovers == -1) { +// if(accuracy == -1) { node.setTooWeak(); } else { node.setCoveredNegatives(negCovers); @@ -200,6 +203,7 @@ private boolean stoppingCriteriaSatisfied() { // in some cases, there could be no candidate left ... if(candidates.isEmpty()) { +// System.out.println("EMPTY"); return true; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java 2009-12-02 08:56:36 UTC (rev 1928) +++ trunk/src/dl-learner/org/dllearner/algorithms/el/StableHeuristic.java 2009-12-08 21:47:58 UTC (rev 1929) @@ -19,6 +19,7 @@ */ package org.dllearner.algorithms.el; + /** * A stable comparator for search tree nodes. Stable means that the order * of nodes will not change during the run of the learning algorithm. In @@ -30,10 +31,30 @@ */ public class StableHeuristic implements ELHeuristic { + private ELDescriptionTreeComparator cmp = new ELDescriptionTreeComparator(); + @Override public int compare(SearchTreeNode o1, SearchTreeNode o2) { - // TODO Auto-generated method stub - return 0; + + double diff = o2.getCoveredNegatives() - o1.getCoveredNegatives(); + + if(diff>0) { + return 1; + } else if(diff<0) { + return -1; + } else { + + double sizeDiff = o2.getDescriptionTree().size - o1.getDescriptionTree().size; + + if(sizeDiff == 0) { + return cmp.compare(o1.getDescriptionTree(), o2.getDescriptionTree()); + } else if(sizeDiff>0) { + return 1; + } else { + return -1; + } + + } } } Modified: trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2009-12-02 08:56:36 UTC (rev 1928) +++ trunk/src/dl-learner/org/dllearner/test/junit/RefinementOperatorTests.java 2009-12-08 21:47:58 UTC (rev 1929) @@ -42,6 +42,8 @@ import org.dllearner.parser.KBParser; import org.dllearner.parser.ParseException; import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.refinementoperators.ELDown2; +import org.dllearner.refinementoperators.RefinementOperator; import org.dllearner.refinementoperators.RhoDRDown; import org.dllearner.test.junit.TestOntologies.TestOntology; import org.dllearner.utilities.Helper; @@ -174,6 +176,19 @@ assertTrue(results.size()==desiredResultSize); } + @Test + public void rhoDRDownTest4() throws ParseException, LearningProblemUnsupportedException { + ReasonerComponent rs = TestOntologies.getTestOntology(TestOntology.RHO1); + RefinementOperator operator = new RhoDRDown(rs); + Description concept = KBParser.parseConcept("(car AND EXISTS hasOwner.person)"); +// Description concept = Thing.instance; + Set<Description> refinements = operator.refine(concept, 6); + for(Description refinement : refinements) { + System.out.println(refinement); + } + } + + private String uri(String name) { return "\""+baseURI+name+"\""; } Modified: trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java =================================================================== --- trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-12-02 08:56:36 UTC (rev 1928) +++ trunk/src/dl-learner/org/dllearner/test/junit/TestOntologies.java 2009-12-08 21:47:58 UTC (rev 1929) @@ -42,7 +42,7 @@ */ public final class TestOntologies { - public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE_NO_DR_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES, FATHER_OE, CARCINOGENESIS, EPC_OE, KRK_ZERO_ONE, DBPEDIA_OWL, TRAINS_OWL }; + public enum TestOntology { EMPTY, SIMPLE, SIMPLE_NO_DR, SIMPLE_NO_DISJOINT, SIMPLE_NO_DR_DISJOINT, SIMPLE2, SIMPLE3, R1SUBR2, DATA1, FIVE_ROLES, FATHER_OE, CARCINOGENESIS, EPC_OE, KRK_ZERO_ONE, DBPEDIA_OWL, TRAINS_OWL, RHO1 }; public static ReasonerComponent getTestOntology(TestOntology ont) { String kbString = ""; @@ -110,6 +110,15 @@ kbString += "r3(a,b).\n"; kbString += "r4(a,b).\n"; kbString += "r5(a,b).\n"; + } else if(ont.equals(TestOntology.RHO1)) { + kbString += "suv SUB car.\n"; + kbString += "limo SUB car.\n"; + kbString += "man SUB person.\n"; + kbString += "woman SUB person.\n"; + kbString += "(person AND car) = BOTTOM.\n"; + kbString += "OPDOMAIN(hasOwner) = car.\n"; + kbString += "OPRANGE(hasOwner) = person.\n"; + kbString += "hasOwner(opel123,person123).\n"; } else if(ont.equals(TestOntology.FATHER_OE)) { owlFile = "examples/family/father_oe.owl"; } else if(ont.equals(TestOntology.CARCINOGENESIS)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-12-17 15:18:25
|
Revision: 1932 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1932&view=rev Author: jenslehmann Date: 2009-12-17 15:18:17 +0000 (Thu, 17 Dec 2009) Log Message: ----------- option instanceBasedDisjoints in CELOE and OCEL Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLComponent2.java trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-12-15 22:17:07 UTC (rev 1931) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-12-17 15:18:17 UTC (rev 1932) @@ -164,6 +164,7 @@ options.add(CommonConfigOptions.getMaxDepth(7)); options.add(CommonConfigOptions.maxNrOfResults(10)); options.add(new BooleanConfigOption("singleSuggestionMode", "Use this if you are interested in only one suggestion and your learning problem has many (more than 1000) examples.", false)); + options.add(CommonConfigOptions.getInstanceBasedDisjoints()); return options; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2009-12-15 22:17:07 UTC (rev 1931) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement/ROLearner.java 2009-12-17 15:18:17 UTC (rev 1932) @@ -239,6 +239,7 @@ options.add(CommonConfigOptions.minExecutionTimeInSeconds()); options.add(CommonConfigOptions.guaranteeXgoodDescriptions()); options.add(CommonConfigOptions.getLogLevel()); + options.add(CommonConfigOptions.getInstanceBasedDisjoints()); return options; } Modified: trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLComponent2.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLComponent2.java 2009-12-15 22:17:07 UTC (rev 1931) +++ trunk/src/dl-learner/org/dllearner/algorithms/refinement2/ROLComponent2.java 2009-12-17 15:18:17 UTC (rev 1932) @@ -214,6 +214,7 @@ options.add(new DoubleConfigOption("startNodeBonus", "You can use this to give a heuristic bonus on the start node (= initially broader exploration of search space).",0.0)); options.add(new IntegerConfigOption("negationPenalty", "Penalty on negations (TODO: better explanation).", 0)); options.add(CommonConfigOptions.getExpansionPenaltyFactor(0.02)); + options.add(CommonConfigOptions.getInstanceBasedDisjoints()); return options; } Modified: trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2009-12-15 22:17:07 UTC (rev 1931) +++ trunk/src/dl-learner/org/dllearner/core/configurators/CELOEConfigurator.java 2009-12-17 15:18:17 UTC (rev 1932) @@ -183,6 +183,15 @@ public boolean getSingleSuggestionMode() { return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "singleSuggestionMode") ; } +/** +* instanceBasedDisjoints Specifies whether to use real disjointness checks or instance based ones (no common instances) in the refinement operator.. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getInstanceBasedDisjoints() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(cELOE, "instanceBasedDisjoints") ; +} /** * @param useAllConstructor specifies whether the universal concept constructor is used in the learning algorithm. @@ -310,6 +319,15 @@ ComponentManager.getInstance().applyConfigEntry(cELOE, "singleSuggestionMode", singleSuggestionMode); reinitNecessary = true; } +/** +* @param instanceBasedDisjoints Specifies whether to use real disjointness checks or instance based ones (no common instances) in the refinement operator.. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setInstanceBasedDisjoints(boolean instanceBasedDisjoints) { +ComponentManager.getInstance().applyConfigEntry(cELOE, "instanceBasedDisjoints", instanceBasedDisjoints); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java 2009-12-15 22:17:07 UTC (rev 1931) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLComponent2Configurator.java 2009-12-17 15:18:17 UTC (rev 1932) @@ -413,6 +413,15 @@ public double getExpansionPenaltyFactor() { return (Double) ComponentManager.getInstance().getConfigOptionValue(rOLComponent2, "expansionPenaltyFactor") ; } +/** +* instanceBasedDisjoints Specifies whether to use real disjointness checks or instance based ones (no common instances) in the refinement operator.. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getInstanceBasedDisjoints() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(rOLComponent2, "instanceBasedDisjoints") ; +} /** * @param writeSearchTree specifies whether to write a search tree. @@ -765,6 +774,15 @@ ComponentManager.getInstance().applyConfigEntry(rOLComponent2, "expansionPenaltyFactor", expansionPenaltyFactor); reinitNecessary = true; } +/** +* @param instanceBasedDisjoints Specifies whether to use real disjointness checks or instance based ones (no common instances) in the refinement operator.. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setInstanceBasedDisjoints(boolean instanceBasedDisjoints) { +ComponentManager.getInstance().applyConfigEntry(rOLComponent2, "instanceBasedDisjoints", instanceBasedDisjoints); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2009-12-15 22:17:07 UTC (rev 1931) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ROLearnerConfigurator.java 2009-12-17 15:18:17 UTC (rev 1932) @@ -287,6 +287,15 @@ public String getLogLevel() { return (String) ComponentManager.getInstance().getConfigOptionValue(rOLearner, "logLevel") ; } +/** +* instanceBasedDisjoints Specifies whether to use real disjointness checks or instance based ones (no common instances) in the refinement operator.. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getInstanceBasedDisjoints() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(rOLearner, "instanceBasedDisjoints") ; +} /** * @param writeSearchTree specifies whether to write a search tree. @@ -513,6 +522,15 @@ ComponentManager.getInstance().applyConfigEntry(rOLearner, "logLevel", logLevel); reinitNecessary = true; } +/** +* @param instanceBasedDisjoints Specifies whether to use real disjointness checks or instance based ones (no common instances) in the refinement operator.. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setInstanceBasedDisjoints(boolean instanceBasedDisjoints) { +ComponentManager.getInstance().applyConfigEntry(rOLearner, "instanceBasedDisjoints", instanceBasedDisjoints); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java 2009-12-15 22:17:07 UTC (rev 1931) +++ trunk/src/dl-learner/org/dllearner/core/configurators/RefinementOperatorConfigurator.java 2009-12-17 15:18:17 UTC (rev 1932) @@ -39,6 +39,8 @@ // below are optional parameters (neutral return values choosen) + public abstract boolean getInstanceBasedDisjoints(); + public boolean getUseHasValueConstructor() { return false; } Modified: trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java =================================================================== --- trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2009-12-15 22:17:07 UTC (rev 1931) +++ trunk/src/dl-learner/org/dllearner/refinementoperators/RhoDRDown.java 2009-12-17 15:18:17 UTC (rev 1932) @@ -228,6 +228,7 @@ this.useBooleanDatatypes = useBooleanDatatypes; this.useDoubleDatatypes = useDoubleDatatypes; useStringDatatypes = configurator.getUseStringDatatypes(); + instanceBasedDisjoints = configurator.getInstanceBasedDisjoints(); if(startClass != null) { this.startClass = startClass; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-12-19 17:24:52
|
Revision: 1935 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1935&view=rev Author: lorenz_b Date: 2009-12-19 17:24:43 +0000 (Sat, 19 Dec 2009) Log Message: ----------- Started evaluation script with GUI. Made all necessary classes serializable - therefore superclasses now implementing the interface Serializable, and relevant classes got a SID. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java trunk/src/dl-learner/org/dllearner/core/Score.java trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Description.java trunk/src/dl-learner/org/dllearner/core/owl/Individual.java trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java trunk/src/dl-learner/org/dllearner/core/owl/InverseObjectPropertyAxiom.java trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java trunk/src/dl-learner/org/dllearner/core/owl/Negation.java trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyInverse.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java trunk/src/dl-learner/org/dllearner/core/owl/Thing.java trunk/src/dl-learner/org/dllearner/core/owl/Union.java trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableClassesTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/SparqlExtractOptionsPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatsTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/rendering/ManchesterSyntaxTableCellRenderer.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java Modified: trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/EvaluatedDescription.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -19,6 +19,7 @@ */ package org.dllearner.core; +import java.io.Serializable; import java.text.DecimalFormat; import org.dllearner.core.owl.Description; @@ -36,8 +37,12 @@ * @author Jens Lehmann * */ -public class EvaluatedDescription { +public class EvaluatedDescription implements Serializable{ + /** + * + */ + private static final long serialVersionUID = 1106431570510815033L; protected Description description; protected Score score; Modified: trunk/src/dl-learner/org/dllearner/core/Score.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/Score.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/Score.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -19,6 +19,8 @@ */ package org.dllearner.core; +import java.io.Serializable; + /** * The score class is used to store how well a class description did * on a learning problem. Depending on the learning problem at hand, @@ -30,9 +32,14 @@ * @author Jens Lehmann * */ -public abstract class Score { +public abstract class Score implements Serializable{ /** + * + */ + private static final long serialVersionUID = -6479328496461875019L; + + /** * This method returns a value, which indicates how accurate a * class description solves a learning problem. * Modified: trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/BooleanValueRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -30,6 +30,10 @@ */ public class BooleanValueRestriction extends DatatypeValueRestriction { + /** + * + */ + private static final long serialVersionUID = 1653555689466334140L; private boolean booleanValue; /** Modified: trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/CardinalityRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -25,6 +25,10 @@ */ public abstract class CardinalityRestriction extends Restriction { + /** + * + */ + private static final long serialVersionUID = -2405514686030313790L; int cardinality; PropertyRange propertyRange; Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeCardinalityRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeCardinalityRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -25,6 +25,11 @@ */ public abstract class DatatypeCardinalityRestriction extends CardinalityRestriction { + /** + * + */ + private static final long serialVersionUID = 5027383671603031229L; + public DatatypeCardinalityRestriction(DatatypeProperty datatypeProperty, DataRange dataRange, int cardinality) { super(datatypeProperty, dataRange, cardinality); Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeExactCardinalityRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -28,6 +28,11 @@ public class DatatypeExactCardinalityRestriction extends DatatypeCardinalityRestriction { /** + * + */ + private static final long serialVersionUID = -6125552354406848242L; + + /** * @param datatypeProperty * @param dataRange * @param cardinality Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMaxCardinalityRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -28,6 +28,11 @@ public class DatatypeMaxCardinalityRestriction extends DatatypeCardinalityRestriction { /** + * + */ + private static final long serialVersionUID = -6593396982074419677L; + + /** * @param datatypeProperty * @param dataRange * @param cardinality Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeMinCardinalityRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -28,6 +28,11 @@ public class DatatypeMinCardinalityRestriction extends DatatypeCardinalityRestriction { /** + * + */ + private static final long serialVersionUID = 7192239562553467873L; + + /** * @param datatypeProperty * @param dataRange * @param cardinality Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeQuantorRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -30,6 +30,11 @@ public abstract class DatatypeQuantorRestriction extends QuantorRestriction { /** + * + */ + private static final long serialVersionUID = 7230621629431369625L; + + /** * Creates a <code>DatatypeQuantorRestriction</code> along the * given property. * @param datatypeProperty The datatype property along which this restriction acts. Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeSomeRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -32,6 +32,10 @@ */ public class DatatypeSomeRestriction extends DatatypeQuantorRestriction { + /** + * + */ + private static final long serialVersionUID = -9190086621306032225L; DataRange dataRange; /** Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeValueRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -31,6 +31,11 @@ */ public abstract class DatatypeValueRestriction extends ValueRestriction { + /** + * + */ + private static final long serialVersionUID = 3263813180892609631L; + public DatatypeValueRestriction(DatatypeProperty restrictedPropertyExpression, Constant value) { super(restrictedPropertyExpression, value); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Description.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Description.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/Description.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -19,6 +19,7 @@ */ package org.dllearner.core.owl; +import java.io.Serializable; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -29,9 +30,13 @@ * @author Jens Lehmann * */ -public abstract class Description implements Cloneable, PropertyRange, KBElement { +public abstract class Description implements Cloneable, PropertyRange, KBElement, Serializable { - protected Description parent = null; + /** + * + */ + private static final long serialVersionUID = -3439073654652166607L; + protected Description parent = null; protected List<Description> children = new LinkedList<Description>(); public abstract int getArity(); Modified: trunk/src/dl-learner/org/dllearner/core/owl/Individual.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Individual.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/Individual.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -19,6 +19,7 @@ */ package org.dllearner.core.owl; +import java.io.Serializable; import java.net.URI; import java.util.Map; @@ -30,8 +31,12 @@ * @author Jens Lehmann * */ -public class Individual implements Entity, NamedKBElement, Comparable<Individual> { +public class Individual implements Entity, NamedKBElement, Comparable<Individual>, Serializable { + /** + * + */ + private static final long serialVersionUID = 1831526393296388784L; private String name; public String getName() { Modified: trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/Intersection.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -5,6 +5,11 @@ public class Intersection extends Description { + /** + * + */ + private static final long serialVersionUID = 296837418292087387L; + public Intersection() { } Modified: trunk/src/dl-learner/org/dllearner/core/owl/InverseObjectPropertyAxiom.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/InverseObjectPropertyAxiom.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/InverseObjectPropertyAxiom.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -2,8 +2,6 @@ import java.util.Map; -import org.dllearner.utilities.Helper; - public class InverseObjectPropertyAxiom extends PropertyAxiom { private ObjectProperty inverseRole; Modified: trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/NamedClass.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -19,6 +19,7 @@ */ package org.dllearner.core.owl; +import java.io.Serializable; import java.net.URI; import java.util.Map; @@ -31,9 +32,13 @@ * @author Jens Lehmann * */ -public class NamedClass extends Description implements Entity, NamedKBElement, Comparable<NamedClass> { +public class NamedClass extends Description implements Entity, NamedKBElement, Comparable<NamedClass>, Serializable { - private String name; + /** + * + */ + private static final long serialVersionUID = -2316344469212256752L; + private String name; public NamedClass(String name) { this.name = name; Modified: trunk/src/dl-learner/org/dllearner/core/owl/Negation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Negation.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/Negation.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -14,6 +14,11 @@ } */ + /** + * + */ + private static final long serialVersionUID = -3007095278542800128L; + public Negation(Description c) { addChild(c); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/Nothing.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -29,6 +29,10 @@ */ public class Nothing extends Description { + /** + * + */ + private static final long serialVersionUID = -3053885252153066318L; public static final Nothing instance = new Nothing(); public String toString(String baseURI, Map<String,String> prefixes) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectAllRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -30,6 +30,11 @@ */ public class ObjectAllRestriction extends ObjectQuantorRestriction { + /** + * + */ + private static final long serialVersionUID = -882418755852820088L; + public ObjectAllRestriction(ObjectPropertyExpression role, Description c) { super(role, c); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectCardinalityRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -2,6 +2,10 @@ public abstract class ObjectCardinalityRestriction extends CardinalityRestriction { + /** + * + */ + private static final long serialVersionUID = 4891273304140021612L; protected ObjectPropertyExpression role; protected int number; Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectExactCardinalityRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -27,6 +27,11 @@ */ public class ObjectExactCardinalityRestriction extends ObjectCardinalityRestriction { + /** + * + */ + private static final long serialVersionUID = -5472599301526939702L; + public ObjectExactCardinalityRestriction(int number, ObjectPropertyExpression role, Description c) { super(number,role,c); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectMaxCardinalityRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -4,6 +4,11 @@ public class ObjectMaxCardinalityRestriction extends ObjectCardinalityRestriction { + /** + * + */ + private static final long serialVersionUID = -674570964821143091L; + public ObjectMaxCardinalityRestriction(int number, ObjectPropertyExpression role, Description c) { super(number,role,c); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectMinCardinalityRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -4,6 +4,11 @@ public class ObjectMinCardinalityRestriction extends ObjectCardinalityRestriction { + /** + * + */ + private static final long serialVersionUID = -7729018670336927250L; + public ObjectMinCardinalityRestriction(int number, ObjectPropertyExpression role, Description c) { super(number,role,c); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectProperty.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -31,8 +31,13 @@ * @author Jens Lehmann * */ -public class ObjectProperty extends ObjectPropertyExpression implements Property, Comparable<ObjectProperty> { +public class ObjectProperty extends ObjectPropertyExpression implements Property, Comparable<ObjectProperty>{ + /** + * + */ + private static final long serialVersionUID = -3343070247923446690L; + public ObjectProperty(String name) { super(name); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyExpression.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -19,6 +19,8 @@ */ package org.dllearner.core.owl; +import java.io.Serializable; + /** * An object property expression is an object property construct, which * can be used in axioms, e.g. complex class descriptions. It can be @@ -27,8 +29,12 @@ * @author Jens Lehmann * */ -public abstract class ObjectPropertyExpression implements PropertyExpression { +public abstract class ObjectPropertyExpression implements PropertyExpression, Serializable { + /** + * + */ + private static final long serialVersionUID = -5590591991241290070L; protected String name; public ObjectPropertyExpression(String name) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyInverse.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyInverse.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectPropertyInverse.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -38,6 +38,11 @@ */ public class ObjectPropertyInverse extends ObjectPropertyExpression { + /** + * + */ + private static final long serialVersionUID = -5416117104822700896L; + public ObjectPropertyInverse(String name) { super(name); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectQuantorRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -26,6 +26,11 @@ */ public abstract class ObjectQuantorRestriction extends QuantorRestriction { + /** + * + */ + private static final long serialVersionUID = -5482730659805823042L; + public ObjectQuantorRestriction(ObjectPropertyExpression role, Description c) { super(role); addChild(c); Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectSomeRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -29,7 +29,12 @@ */ public class ObjectSomeRestriction extends ObjectQuantorRestriction { - public ObjectSomeRestriction(ObjectPropertyExpression role, Description c) { + /** + * + */ + private static final long serialVersionUID = 858960420513908151L; + + public ObjectSomeRestriction(ObjectPropertyExpression role, Description c) { super(role,c); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ObjectValueRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -31,6 +31,11 @@ public class ObjectValueRestriction extends ValueRestriction { /** + * + */ + private static final long serialVersionUID = 2437223709767096950L; + + /** * @param property */ public ObjectValueRestriction(Property property, Individual value) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/QuantorRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -25,6 +25,11 @@ */ public abstract class QuantorRestriction extends Restriction { + /** + * + */ + private static final long serialVersionUID = 5803592323249030865L; + public QuantorRestriction(PropertyExpression restrictedPropertyExpression) { super(restrictedPropertyExpression); } Modified: trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/Restriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -27,6 +27,10 @@ */ public abstract class Restriction extends Description { + /** + * + */ + private static final long serialVersionUID = 932723843389518050L; protected PropertyExpression restrictedPropertyExpression; public Restriction(PropertyExpression restrictedPropertyExpression) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/Thing.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Thing.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/Thing.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -36,6 +36,10 @@ */ public class Thing extends Description { + /** + * + */ + private static final long serialVersionUID = -880276915058868775L; public static final Thing instance = new Thing(); public String toString(String baseURI, Map<String,String> prefixes) { Modified: trunk/src/dl-learner/org/dllearner/core/owl/Union.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Union.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/Union.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -5,6 +5,11 @@ public class Union extends Description { + /** + * + */ + private static final long serialVersionUID = -4475957631228826618L; + public Union() { } Modified: trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/core/owl/ValueRestriction.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -27,6 +27,10 @@ */ public abstract class ValueRestriction extends Restriction { + /** + * + */ + private static final long serialVersionUID = -4597259716399359860L; protected KBElement value; public ValueRestriction(PropertyExpression propertyExpression, KBElement value) { Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -19,6 +19,7 @@ */ package org.dllearner.learningproblems; +import java.io.Serializable; import java.util.Set; import org.dllearner.core.Score; @@ -30,8 +31,12 @@ * @author Jens Lehmann * */ -public class ClassScore extends Score { +public class ClassScore extends Score implements Serializable{ + /** + * + */ + private static final long serialVersionUID = 2003326044901308157L; private Set<Individual> coveredInstances; private Set<Individual> additionalInstances; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -19,6 +19,7 @@ */ package org.dllearner.learningproblems; +import java.io.Serializable; import java.util.Set; import org.dllearner.core.EvaluatedDescription; @@ -37,8 +38,12 @@ * @author Jens Lehmann * */ -public class EvaluatedDescriptionClass extends EvaluatedDescription { +public class EvaluatedDescriptionClass extends EvaluatedDescription implements Serializable{ + /** + * + */ + private static final long serialVersionUID = -5907640793141522431L; private ClassScore classScore; /** Added: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -0,0 +1,331 @@ +package org.dllearner.scripts.evaluation; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +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.URL; +import java.text.DecimalFormat; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSeparator; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.LearningProblemUnsupportedException; +import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.configurators.CELOEConfigurator; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.Thing; +import org.dllearner.kb.OWLFile; +import org.dllearner.learningproblems.ClassLearningProblem; +import org.dllearner.learningproblems.EvaluatedDescriptionClass; +import org.dllearner.reasoning.FastInstanceChecker; +import org.dllearner.tools.ore.ui.MarkableClassesTable; +import org.dllearner.tools.ore.ui.SelectableClassExpressionsTable; + +public class EvaluationGUI extends JFrame implements ActionListener{ + + + + /** + * + */ + private static final long serialVersionUID = -3097551929270352556L; + + private SelectableClassExpressionsTable tab1; + private MarkableClassesTable classesTable; + + private ReasonerComponent reasoner; + + private int classesCount = 0; + private int currentClassIndex = 0; + + private static double minAccuracy = 0.85; + + private static double noisePercent = 5.0; + + private static int minInstanceCount = 3; + + private static int algorithmRuntimeInSeconds = 10; + + private static DecimalFormat df = new DecimalFormat(); + + // for performance measurements and development + private static boolean autoMode = false; + private static boolean useFastInstanceChecker = true; + private static boolean useApproximations = true; + private static boolean computeApproxDiff = false; + + private Map<NamedClass, List<EvaluatedDescriptionClass>> namedClass2EquivalenceSuggestionsMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); + private Map<NamedClass, List<EvaluatedDescriptionClass>> namedClass2SuperSuggestionsMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); + + public EvaluationGUI(URL fileURL) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException{ + super(); + loadOntology(fileURL); + computeLearningResults(); + serializeResults(); + deserializeResults(); + createUI(); + pack(); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setVisible(true); + } + + private void createUI(){ + + setLayout(new BorderLayout()); + + classesTable = new MarkableClassesTable(); + classesTable.addClasses(new TreeSet<NamedClass>(namedClass2EquivalenceSuggestionsMap.keySet())); + JScrollPane classesScroll = new JScrollPane(classesTable); + add(classesScroll, BorderLayout.WEST); + + JScrollPane suggestionsScroll = new JScrollPane(createTablesPanel()); + add(suggestionsScroll, BorderLayout.CENTER); + + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new BorderLayout()); + JSeparator separator = new JSeparator(); + buttonPanel.add(separator, BorderLayout.NORTH); + Box buttonBox = new Box(BoxLayout.X_AXIS); + JButton nextButton = new JButton("Next"); + nextButton.setActionCommand("next"); + nextButton.addActionListener(this); + buttonBox.add(nextButton); + buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST); + add(buttonPanel, BorderLayout.SOUTH); + + } + + private JPanel createTablesPanel(){ + JPanel tablesHolder = new JPanel(); + tablesHolder.setLayout(new GridLayout(5, 2)); + tab1 = new SelectableClassExpressionsTable(); + + + + tablesHolder.add(tab1); + return tablesHolder; + } + + private void showNextClassSuggestions(){ + NamedClass nc = classesTable.getSelectedClass(currentClassIndex); + tab1.addResults(namedClass2EquivalenceSuggestionsMap.get(nc)); + } + + private void loadOntology(URL fileURL) throws ComponentInitException{ + ComponentManager cm = ComponentManager.getInstance(); + + + + // load OWL in reasoner + OWLFile ks = cm.knowledgeSource(OWLFile.class); + ks.getConfigurator().setUrl(fileURL); + ks.init(); + + reasoner = null; + reasoner = cm.reasoner(FastInstanceChecker.class, ks); + reasoner.init(); + + System.out.println("Loaded ontology " + fileURL + "."); + } + + + + private void computeLearningResults() throws ComponentInitException, LearningProblemUnsupportedException, MalformedURLException{ + ComponentManager cm = ComponentManager.getInstance(); + + String baseURI = reasoner.getBaseURI(); + Map<String, String> prefixes = reasoner.getPrefixes(); + + // loop through all classes + Set<NamedClass> classes = new TreeSet<NamedClass>(reasoner.getNamedClasses()); + classes.remove(new NamedClass("http://www.w3.org/2002/07/owl#Thing")); + // reduce number of classes for testing purposes +// shrinkSet(classes, 20); + for (NamedClass nc : classes) { + // check whether the class has sufficient instances + int instanceCount = reasoner.getIndividuals(nc).size(); + if (instanceCount < minInstanceCount) { + System.out.println("class " + nc.toManchesterSyntaxString(baseURI, prefixes) + + " has only " + instanceCount + " instances (minimum: " + minInstanceCount + + ") - skipping"); + } else { + System.out.println("\nlearning axioms for class " + + nc.toManchesterSyntaxString(baseURI, prefixes) + " with " + instanceCount + + " instances"); + + + TreeSet<EvaluatedDescriptionClass> suggestions; + // i=0 is equivalence and i=1 is super class + for (int i = 0; i <= 1; i++) { + // learn equivalence axiom + ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, + reasoner); + lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); + if (i == 0) { + System.out + .println("generating suggestions for equivalent class (please wait " + + algorithmRuntimeInSeconds + " seconds)"); + lp.getConfigurator().setType("equivalence"); + } else { + System.out.println("suggestions for super class (please wait " + + algorithmRuntimeInSeconds + " seconds)"); + lp.getConfigurator().setType("superClass"); + } + lp.getConfigurator().setUseApproximations(useApproximations); + lp.init(); + + CELOE celoe = cm.learningAlgorithm(CELOE.class, lp, reasoner); + CELOEConfigurator cf = celoe.getConfigurator(); + cf.setUseNegation(false); + cf.setValueFrequencyThreshold(3); + cf.setMaxExecutionTimeInSeconds(algorithmRuntimeInSeconds); + cf.setNoisePercentage(noisePercent); + cf.setMaxNrOfResults(10); + celoe.init(); + + celoe.start(); + // test whether a solution above the threshold was found + EvaluatedDescription best = celoe.getCurrentlyBestEvaluatedDescription(); + double bestAcc = best.getAccuracy(); + + if (bestAcc < minAccuracy || (best.getDescription() instanceof Thing)) { + System.out + .println("The algorithm did not find a suggestion with an accuracy above the threshold of " + + (100 * minAccuracy) + + "% or the best description is not appropriate. (The best one was \"" + + best.getDescription().toManchesterSyntaxString(baseURI, + prefixes) + + "\" with an accuracy of " + + df.format(bestAcc) + ".) - skipping"); + } else { + + + + suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe + .getCurrentlyBestEvaluatedDescriptions(); + List<EvaluatedDescriptionClass> suggestionsList = new LinkedList<EvaluatedDescriptionClass>( + suggestions.descendingSet()); + if(i == 0){ + namedClass2EquivalenceSuggestionsMap.put(nc, suggestionsList); + } else { + namedClass2SuperSuggestionsMap.put(nc, suggestionsList); + } + + } + } + } + } + + + } + + private void serializeResults() { + OutputStream fos = null; + File file = new File("test.ser"); + try { + fos = new FileOutputStream(file); + ObjectOutputStream o = new ObjectOutputStream(fos); + o.writeObject(namedClass2EquivalenceSuggestionsMap); + o.writeObject(namedClass2SuperSuggestionsMap); + o.flush(); + } catch (IOException e) { + System.err.println(e); + } finally { + try { + fos.close(); + } catch (Exception e) { + } + } + } + + private void deserializeResults() { + InputStream fis = null; + + try { + fis = new FileInputStream("test.ser"); + ObjectInputStream o = new ObjectInputStream(fis); + namedClass2EquivalenceSuggestionsMap = (HashMap<NamedClass, List<EvaluatedDescriptionClass>>) o + .readObject(); + namedClass2SuperSuggestionsMap = (HashMap<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) { + } + } + } + + @Override + public void actionPerformed(ActionEvent e) { + if(e.getActionCommand().equals("next")){ + classesTable.setSelectedClass(currentClassIndex++); + showNextClassSuggestions(); + } + + } + + /** + * @param args + * @throws ComponentInitException + * @throws MalformedURLException + * @throws LearningProblemUnsupportedException + * @throws UnsupportedLookAndFeelException + * @throws IllegalAccessException + * @throws InstantiationException + * @throws ClassNotFoundException + */ + public static void main(String[] args) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { +// Logger.getRootLogger().setLevel(Level.WARN); + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + + if (args.length == 0) { + System.out.println("You need to give an OWL file as argument."); + System.exit(0); + } + URL fileURL = null; + if(args[0].startsWith("http")){ + fileURL = new URL(args[0]); + } else { + fileURL = new File(args[0]).toURI().toURL(); + } + new EvaluationGUI(fileURL); + + } + + + +} Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableClassesTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableClassesTable.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/MarkableClassesTable.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -64,8 +64,8 @@ ((MarkableClassesTableModel)getModel()).addClasses(classes); } - public NamedClass getSelectedValue(){ - return ((MarkableClassesTableModel)getModel()).getSelectedValue(getSelectedRow()); + public NamedClass getSelectedClass(int rowIndex){ + return ((MarkableClassesTableModel)getModel()).getSelectedValue(rowIndex); } public void clear(){ Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/SparqlExtractOptionsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/SparqlExtractOptionsPanel.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/SparqlExtractOptionsPanel.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -177,7 +177,7 @@ breakSuperClassRetrievalAfterSpinner.setValue(1000); useCacheCheckBox.setSelected(true); useImprovedSparqlTupelAquisitorCheckBox.setSelected(false); - dissolveBlankNodesCheckBox.setSelected(true); + dissolveBlankNodesCheckBox.setSelected(false); getPropertyInformationCheckBox.setSelected(false); closeAfterRecursionCheckBox.setSelected(true); getAllSuperClassesCheckBox.setSelected(true); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatsTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatsTable.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/StatsTable.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -5,7 +5,6 @@ import javax.swing.ListSelectionModel; -import org.dllearner.tools.ore.ui.rendering.ManchesterSyntaxTableCellRenderer; import org.jdesktop.swingx.JXTable; import org.semanticweb.owl.model.OWLOntologyChange; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/rendering/ManchesterSyntaxTableCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/rendering/ManchesterSyntaxTableCellRenderer.java 2009-12-19 10:54:30 UTC (rev 1934) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/rendering/ManchesterSyntaxTableCellRenderer.java 2009-12-19 17:24:43 UTC (rev 1935) @@ -34,7 +34,7 @@ } @Override - protected void setValue(Object value) {System.out.println(value); + protected void setValue(Object value) { if(value instanceof Description){ OWLDescription desc = OWLAPIDescriptionConvertVisitor.getOWLDescription((Description)value); render(desc); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-12-21 20:17:04
|
Revision: 1947 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1947&view=rev Author: lorenz_b Date: 2009-12-21 20:16:58 +0000 (Mon, 21 Dec 2009) Log Message: ----------- Added mouse over coveragepanel - still experimental with exceptions sometimes. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTable.java trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-21 19:00:48 UTC (rev 1946) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-21 20:16:58 UTC (rev 1947) @@ -7,6 +7,8 @@ import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionListener; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -28,6 +30,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSeparator; +import javax.swing.JWindow; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -44,7 +47,7 @@ import org.dllearner.tools.ore.ui.ResultTable; import org.dllearner.tools.ore.ui.SelectableClassExpressionsTable; -public class EvaluationGUI extends JFrame implements ActionListener, ListSelectionListener{ +public class EvaluationGUI extends JFrame implements ActionListener, ListSelectionListener, MouseMotionListener{ @@ -67,11 +70,14 @@ private SelectableClassExpressionsTable defaultTab; private GraphicalCoveragePanel graphPanel; + private GraphicalCoveragePanel graphPanel2; private MarkableClassesTable classesTable; private JButton nextFinishButton; private JLabel messageLabel; + private JWindow coverageWindow; + private JPanel cardPanel; private CardLayout cardLayout; @@ -125,6 +131,7 @@ loadResults(input); setTitle(input.getName()); createUI(); + createCoverageWindow(); classesTable.setSelectedClass(currentClassIndex); showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); cardLayout.last(cardPanel); @@ -196,24 +203,34 @@ JPanel tablesHolderPanel = new JPanel(); tablesHolderPanel.setLayout(new GridLayout(5, 2, 5, 5)); tab1 = new ResultTable(); + tab1.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab1)); tab2 = new ResultTable(); + tab2.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab2)); tab3 = new ResultTable(); + tab3.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab3)); tab4 = new ResultTable(); + tab4.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab4)); tab5 = new ResultTable(); + tab5.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab5)); tab6 = new ResultTable(); + tab6.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab6)); tab7 = new ResultTable(); + tab7.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab7)); tab8 = new ResultTable(); + tab8.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab8)); tab9 = new ResultTable(); + tab9.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab9)); tab10 = new ResultTable(); + tab10.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab10)); return tablesHolderPanel; @@ -280,6 +297,14 @@ showingEquivalentSuggestions = false; } + + private void createCoverageWindow(){ + coverageWindow = new JWindow(this); + graphPanel2 = new GraphicalCoveragePanel(""); + coverageWindow.add(graphPanel2); + coverageWindow.pack(); + coverageWindow.setLocationRelativeTo(classesTable); + } @SuppressWarnings("unchecked") private void loadResults(File input) { @@ -335,6 +360,11 @@ dispose(); } + + private void showCoveragePanel(boolean visible){ + coverageWindow.setVisible(visible); + } + @Override public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("next")){ @@ -372,6 +402,9 @@ } } + + + /** * @param args @@ -414,8 +447,29 @@ } - + @Override + public void mouseDragged(MouseEvent e) { + // TODO Auto-generated method stub + + } - + @Override + public void mouseMoved(MouseEvent e) { + ResultTable result = ((ResultTable)e.getSource()); + int column = result.columnAtPoint(e.getPoint()); + int row = result.rowAtPoint(e.getPoint()); + EvaluatedDescriptionClass ec = result.getValueAtRow(row); + if(column == 0){ + graphPanel2.clear(); + graphPanel2.setNewClassDescription(ec); + showCoveragePanel(true); + + } else { + showCoveragePanel(false); + } + + } + + } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTable.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTable.java 2009-12-21 19:00:48 UTC (rev 1946) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTable.java 2009-12-21 20:16:58 UTC (rev 1947) @@ -69,4 +69,9 @@ public EvaluatedDescriptionClass getSelectedValue(){ return ((ResultTableModel)getModel()).getSelectedValue(getSelectedRow()); } + + public EvaluatedDescriptionClass getValueAtRow(int rowIndex){ + return ((ResultTableModel)getModel()).getValueAtRow(rowIndex); + + } } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java 2009-12-21 19:00:48 UTC (rev 1946) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/ResultTableModel.java 2009-12-21 20:16:58 UTC (rev 1947) @@ -86,5 +86,9 @@ public int getSelectionIndex(EvaluatedDescriptionClass e){ return resultList.indexOf(e); } + + public EvaluatedDescriptionClass getValueAtRow(int rowIndex){ + return resultList.get(rowIndex); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-12-21 22:29:47
|
Revision: 1948 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1948&view=rev Author: lorenz_b Date: 2009-12-21 22:29:38 +0000 (Mon, 21 Dec 2009) Log Message: ----------- Fixed bug. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/Info.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java Modified: trunk/src/dl-learner/org/dllearner/Info.java =================================================================== --- trunk/src/dl-learner/org/dllearner/Info.java 2009-12-21 20:16:58 UTC (rev 1947) +++ trunk/src/dl-learner/org/dllearner/Info.java 2009-12-21 22:29:38 UTC (rev 1948) @@ -1,8 +1,8 @@ -// File is updated automatically when a new version is created -package org.dllearner; + // File is updated automatically when a new version is created + package org.dllearner; -public class Info { - public static final String build = "2009-09-30"; -} - \ No newline at end of file + public class Info { + public static final String build = "2009-12-14"; + } + \ No newline at end of file Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-21 20:16:58 UTC (rev 1947) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-21 22:29:38 UTC (rev 1948) @@ -202,6 +202,7 @@ private JPanel createMultiTablesPanel(){ JPanel tablesHolderPanel = new JPanel(); tablesHolderPanel.setLayout(new GridLayout(5, 2, 5, 5)); + tablesHolderPanel.addMouseMotionListener(this); tab1 = new ResultTable(); tab1.addMouseMotionListener(this); tablesHolderPanel.add(createSelectablePanel(tab1)); @@ -455,19 +456,25 @@ @Override public void mouseMoved(MouseEvent e) { - ResultTable result = ((ResultTable)e.getSource()); - int column = result.columnAtPoint(e.getPoint()); - int row = result.rowAtPoint(e.getPoint()); - EvaluatedDescriptionClass ec = result.getValueAtRow(row); - if(column == 0){ - graphPanel2.clear(); - graphPanel2.setNewClassDescription(ec); - showCoveragePanel(true); + 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 && row <= 9){ + EvaluatedDescriptionClass ec = result.getValueAtRow(row); + graphPanel2.clear(); + graphPanel2.setNewClassDescription(ec); + showCoveragePanel(true); + + } else { + showCoveragePanel(false); + } } else { showCoveragePanel(false); } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-12-22 10:47:44
|
Revision: 1949 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1949&view=rev Author: lorenz_b Date: 2009-12-22 10:47:34 +0000 (Tue, 22 Dec 2009) Log Message: ----------- Some improvements in evaluation GUI. Modified Paths: -------------- 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/GraphicalCoveragePanel.java Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-21 22:29:38 UTC (rev 1948) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-22 10:47:34 UTC (rev 1949) @@ -93,6 +93,7 @@ public EvaluationComputingScript(URL fileURL) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException{ loadOntology(fileURL); computeSuggestions(); + computeGenFMeasureWithoutDefaultNegation(); computeWithApproximation(); saveResults(); } @@ -195,7 +196,7 @@ lp.getConfigurator().setType("superClass"); System.out.println("Learning superClass expressions"); } - for(int k = 0; k <= 4; k++){ + for(int k = 0; k <= 3; k++){ if(k == 0){ lp.getConfigurator().setAccuracyMethod("standard"); System.out.println("Using accuracy method: standard"); @@ -312,8 +313,118 @@ } cm.freeComponent(reasoner); } + cm.freeComponent(reasoner); + cm.freeComponent(lp); + cm.freeComponent(celoe); } + private void computeGenFMeasureWithoutDefaultNegation() throws ComponentInitException, MalformedURLException, + LearningProblemUnsupportedException { + ComponentManager cm = ComponentManager.getInstance(); + TreeSet<EvaluatedDescriptionClass> suggestions; + for (int i = 0; i <= 1; i++) { + if (i == 0) { + reasoner = null; + reasoner = cm.reasoner(OWLAPIReasoner.class, ks); + System.out.println("using OWLAPI-Reasoner"); + } else { + reasoner = null; + reasoner = cm.reasoner(FastInstanceChecker.class, ks); + ((FastInstanceChecker) reasoner).getConfigurator().setDefaultNegation(false); + System.out.println("using FastInstanceChecker"); + } + + reasoner.init(); + baseURI = reasoner.getBaseURI(); + prefixes = reasoner.getPrefixes(); + + // loop through all classes + Set<NamedClass> classes = new TreeSet<NamedClass>(reasoner.getNamedClasses()); + classes.remove(new NamedClass("http://www.w3.org/2002/07/owl#Thing")); + // reduce number of classes for testing purposes + // shrinkSet(classes, 20); + for (NamedClass nc : classes) { + // check whether the class has sufficient instances + int instanceCount = reasoner.getIndividuals(nc).size(); + if (instanceCount < minInstanceCount) { + System.out.println("class " + nc.toManchesterSyntaxString(baseURI, prefixes) + " has only " + + instanceCount + " instances (minimum: " + minInstanceCount + ") - skipping"); + } else { + System.out.println("\nlearning axioms for class " + nc.toManchesterSyntaxString(baseURI, prefixes) + + " with " + instanceCount + " instances"); + ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); + lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); + for (int j = 0; j <= 1; j++) { + if (j == 0) { + lp.getConfigurator().setType("equivalence"); + System.out.println("Learning equivalentClass expressions"); + } else { + lp.getConfigurator().setType("superClass"); + System.out.println("Learning superClass expressions"); + } + lp.getConfigurator().setAccuracyMethod("generalised_fmeasure"); + System.out.println("Using accuracy method: Generalised F-Measure"); + lp.getConfigurator().setUseApproximations(useApproximations); + lp.init(); + CELOE celoe = cm.learningAlgorithm(CELOE.class, lp, reasoner); + CELOEConfigurator cf = celoe.getConfigurator(); + cf.setUseNegation(false); + cf.setValueFrequencyThreshold(3); + cf.setMaxExecutionTimeInSeconds(algorithmRuntimeInSeconds); + cf.setNoisePercentage(noisePercent); + cf.setMaxNrOfResults(10); + celoe.init(); + + celoe.start(); + + // test whether a solution above the threshold was found + EvaluatedDescription best = celoe.getCurrentlyBestEvaluatedDescription(); + double bestAcc = best.getAccuracy(); + + if (bestAcc < minAccuracy || (best.getDescription() instanceof Thing)) { + System.out + .println("The algorithm did not find a suggestion with an accuracy above the threshold of " + + (100 * minAccuracy) + + "% or the best description is not appropriate. (The best one was \"" + + best.getDescription().toManchesterSyntaxString(baseURI, prefixes) + + "\" with an accuracy of " + df.format(bestAcc) + ".) - skipping"); + suggestions = new TreeSet<EvaluatedDescriptionClass>(); + } else { + + suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe + .getCurrentlyBestEvaluatedDescriptions(); + } + List<EvaluatedDescriptionClass> suggestionsList = new LinkedList<EvaluatedDescriptionClass>( + suggestions.descendingSet()); + + if (i == 0) { + if (j == 0) { + owlEquivalenceGenFMeasureMap.put(nc, suggestionsList); + } else { + owlSuperGenFMeasureMap.put(nc, suggestionsList); + } + + } else { + if (j == 0) { + fastEquivalenceGenFMeasureMap.put(nc, suggestionsList); + } else { + fastSuperGenFMeasureMap.put(nc, suggestionsList); + } + + } + + } + cm.freeComponent(celoe); + cm.freeComponent(lp); + } + } + cm.freeComponent(reasoner); + } + cm.freeComponent(reasoner); + cm.freeComponent(lp); + cm.freeComponent(celoe); + } + private void computeWithApproximation() throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException { ComponentManager cm = ComponentManager.getInstance(); TreeSet<EvaluatedDescriptionClass> suggestions; @@ -390,7 +501,7 @@ } } - + cm.freeAllComponents(); } /** Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-21 22:29:38 UTC (rev 1948) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-22 10:47:34 UTC (rev 1949) @@ -3,8 +3,10 @@ import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; +import java.awt.Component; import java.awt.GridLayout; import java.awt.Insets; +import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -23,11 +25,13 @@ import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JRadioButton; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JWindow; @@ -90,7 +94,7 @@ private int currentClassIndex = 0; private boolean showingEquivalentSuggestions = false; - private boolean showingMultiTables = true; + private boolean showingMultiTables = false; private Map<NamedClass, List<EvaluatedDescriptionClass>> fastEquivalenceStandardMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); @@ -133,8 +137,10 @@ createUI(); createCoverageWindow(); classesTable.setSelectedClass(currentClassIndex); + graphPanel.setConcept(classesTable.getSelectedClass(currentClassIndex)); + graphPanel2.setConcept(classesTable.getSelectedClass(currentClassIndex)); showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); - cardLayout.last(cardPanel); + cardLayout.first(cardPanel); pack(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setExtendedState(JFrame.MAXIMIZED_BOTH); @@ -148,6 +154,7 @@ classesTable = new MarkableClassesTable(); classesTable.addClasses(new TreeSet<NamedClass>(owlEquivalenceStandardMap.keySet())); JScrollPane classesScroll = new JScrollPane(classesTable); + classesTable.addMouseMotionListener(this); add(classesScroll, BorderLayout.WEST); JScrollPane suggestionsScroll = new JScrollPane(createMainPanel()); @@ -165,6 +172,8 @@ buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST); add(buttonPanel, BorderLayout.SOUTH); + addMouseMotionListener(this); + } private JPanel createMainPanel(){ @@ -172,6 +181,7 @@ messageTablesPanel.setLayout(new BorderLayout()); messageLabel = new JLabel(); + messageLabel.addMouseMotionListener(this); messageTablesPanel.add(messageLabel, BorderLayout.NORTH); cardPanel = new JPanel(); @@ -242,8 +252,8 @@ panel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); JCheckBox box = new JCheckBox(); panel.add(table, BorderLayout.CENTER); - panel.add(box, BorderLayout.EAST); - +// panel.add(box, BorderLayout.EAST); + panel.add(new RatingPanel(), BorderLayout.EAST); return panel; } @@ -304,7 +314,7 @@ graphPanel2 = new GraphicalCoveragePanel(""); coverageWindow.add(graphPanel2); coverageWindow.pack(); - coverageWindow.setLocationRelativeTo(classesTable); +// coverageWindow.setLocationRelativeTo(classesTable); } @SuppressWarnings("unchecked") @@ -366,17 +376,30 @@ coverageWindow.setVisible(visible); } + private void setCoverageLocationRelativeTo(Component component){ + Component parent = component.getParent(); + Point componentLocation = component.getLocationOnScreen(); + Point p; + if(componentLocation.getX() < parent.getSize().width/2){ + p = new Point((int)(componentLocation.getX() + parent.getSize().width/2 + coverageWindow.getSize().getWidth()/2),componentLocation.y); + } else { + p = new Point((int)(componentLocation.getX() - parent.getSize().width/2 - coverageWindow.getSize().getWidth()/2),componentLocation.y); + } + + coverageWindow.setLocation(p); + } + @Override public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("next")){ NamedClass nc = classesTable.getSelectedClass(currentClassIndex); if(showingMultiTables && showingEquivalentSuggestions){ + showSuperSuggestions(nc); showSingleTable(); } else if(!showingMultiTables && showingEquivalentSuggestions){ - showSuperSuggestions(nc); showMultiTables(); - } else if(showingMultiTables && !showingEquivalentSuggestions){ - showSingleTable(); + } else if(!showingMultiTables && !showingEquivalentSuggestions){ + showMultiTables(); if(currentClassIndex + 1 >= owlEquivalenceStandardMap.keySet().size()){ nextFinishButton.setText("Finish"); nextFinishButton.setActionCommand("finish"); @@ -385,8 +408,10 @@ currentClassIndex++; classesTable.setSelectedClass(currentClassIndex); + graphPanel.setConcept(classesTable.getSelectedClass(currentClassIndex)); + showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); - showMultiTables(); + showSingleTable(); } } else if(e.getActionCommand().equals("finish")){ @@ -465,6 +490,7 @@ EvaluatedDescriptionClass ec = result.getValueAtRow(row); graphPanel2.clear(); graphPanel2.setNewClassDescription(ec); + setCoverageLocationRelativeTo(result); showCoveragePanel(true); } else { @@ -476,7 +502,59 @@ } + + class RatingPanel extends JPanel{ + + /** + * + */ + private static final long serialVersionUID = -111227945780885551L; + private JRadioButton rb1 = new JRadioButton("1"); + private JRadioButton rb2 = new JRadioButton("2");; + private JRadioButton rb3 = new JRadioButton("3");; + private JRadioButton rb4 = new JRadioButton("4");; + private JRadioButton rb5 = new JRadioButton("5");; + private ButtonGroup bg; + public RatingPanel(){ + setLayout(new GridLayout(5,1)); + bg = new ButtonGroup(); + add(rb5); + add(rb4); + add(rb3); + add(rb2); + add(rb1); + bg.add(rb1); + bg.add(rb2); + bg.add(rb3); + bg.add(rb4); + bg.add(rb5); + rb1.setSelected(true); + } + + public int getSelectedValue(){ + if(rb1.isSelected()){ + return 1; + } else if(rb2.isSelected()){ + return 2; + } else if(rb3.isSelected()){ + return 3; + } else if(rb4.isSelected()){ + return 4; + } else { + return 5; + } + } + + public void clearSelection(){ + rb1.setSelected(true); + } + + } + + } + + Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java 2009-12-21 22:29:38 UTC (rev 1948) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java 2009-12-22 10:47:34 UTC (rev 1949) @@ -35,6 +35,7 @@ import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.owl.Individual; +import org.dllearner.core.owl.NamedClass; import org.dllearner.learningproblems.EvaluatedDescriptionClass; import org.dllearner.tools.ore.OREManager; import org.dllearner.tools.ore.ui.rendering.ManchesterSyntaxRenderer; @@ -68,6 +69,8 @@ private EvaluatedDescription eval; + private NamedClass concept; + private String conceptNew; private final Vector<IndividualPoint> posCovIndVector; private final Vector<IndividualPoint> posNotCovIndVector; @@ -92,6 +95,9 @@ private final Color darkGreen; private final Color darkRed; // private int notCoveredInd; + + private String coverageString = ""; + private String coversAdditionalString = ""; /** @@ -110,7 +116,7 @@ public GraphicalCoveragePanel( String concept) { - this.setPreferredSize(new Dimension(540, 260)); + this.setPreferredSize(new Dimension(640, 260)); // this.repaint(); darkGreen = new Color(0, 100, 0); @@ -142,9 +148,12 @@ AlphaComposite ac = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.5f); g2D.setColor(Color.BLACK); - if(OREManager.getInstance().getCurrentClass2Learn() != null){ - g2D.drawString(ManchesterSyntaxRenderer.renderSimple(OREManager.getInstance().getCurrentClass2Learn()) + if(concept == null && OREManager.getInstance().getCurrentClass2Learn() != null){ + g2D.drawString(ManchesterSyntaxRenderer.renderSimple(OREManager.getInstance().getCurrentClass2Learn()) , 320, 10); + } else if(concept!= null){ + g2D.drawString(concept.getName(), 320, 10); + } // g2D.setColor(Color.ORANGE); // g2D.fillOval(310, 20, 9, 9); @@ -189,6 +198,13 @@ p = p + 20; g2D.drawString("(potential problem)", 320, p); + p = p +20; + g2D.drawString(coverageString , 320, p); + p = p +20; + g2D.drawString(coversAdditionalString , 320, p); + + + g2D.setColor(Color.YELLOW); g2D.fill(oldConcept); g2D.fillOval(310, 0, 9, 9); @@ -469,17 +485,30 @@ } // computeGraphics(); computeIndividualPoints(); - + int coveredInstanceCount = ((EvaluatedDescriptionClass) eval).getCoveredInstances().size(); + int instanceCount = coveredInstanceCount + ((EvaluatedDescriptionClass) eval).getNotCoveredInstances().size(); + int coverage = (int)(((EvaluatedDescriptionClass) eval).getCoverage() * 100); + int additionalCount = ((EvaluatedDescriptionClass) eval).getAdditionalInstances().size(); + coverageString = "Covers " + coveredInstanceCount + " of " + instanceCount + + "(" + coverage + "%) of all instances"; + coversAdditionalString = "Covers " + additionalCount + " additional instances"; getParent().repaint(); } + public void setConcept(NamedClass nc){ + concept = nc; + getParent().repaint(); + } + public void clear(){ newConcept = new Ellipse2D.Double(0, 0, 0, 0); posCovIndVector.clear(); posNotCovIndVector.clear(); additionalIndividuals.clear(); points.clear(); + coverageString = ""; + coversAdditionalString = ""; getParent().repaint(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-12-22 19:02:31
|
Revision: 1950 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1950&view=rev Author: lorenz_b Date: 2009-12-22 19:02:23 +0000 (Tue, 22 Dec 2009) Log Message: ----------- Continued evaluation stuff. Modified Paths: -------------- 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/GraphicalCoveragePanel.java Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-22 10:47:34 UTC (rev 1949) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-22 19:02:23 UTC (rev 1950) @@ -9,6 +9,7 @@ import java.net.URL; import java.text.DecimalFormat; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -48,6 +49,8 @@ private static int minInstanceCount = 3; private static int algorithmRuntimeInSeconds = 10; + + private static int allListsComputingCount = 5; private static DecimalFormat df = new DecimalFormat(); @@ -57,7 +60,9 @@ private static boolean useApproximations = false; private static boolean computeApproxDiff = false; + private Set<NamedClass> reducedClassesSet; + private Map<NamedClass, List<EvaluatedDescriptionClass>> fastEquivalenceStandardMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); private Map<NamedClass, List<EvaluatedDescriptionClass>> fastEquivalenceFMeasureMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); private Map<NamedClass, List<EvaluatedDescriptionClass>> fastEquivalencePredaccMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); @@ -92,9 +97,9 @@ public EvaluationComputingScript(URL fileURL) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException{ loadOntology(fileURL); + computeWithApproximation(); computeSuggestions(); computeGenFMeasureWithoutDefaultNegation(); - computeWithApproximation(); saveResults(); } @@ -111,7 +116,7 @@ private void saveResults() { OutputStream fos = null; - File file = new File("test.ser"); + File file = new File("test2.ser"); try { fos = new FileOutputStream(file); ObjectOutputStream o = new ObjectOutputStream(fos); @@ -154,7 +159,8 @@ } } - private void computeSuggestions() throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException { + private void computeSuggestions() throws ComponentInitException, MalformedURLException, + LearningProblemUnsupportedException { ComponentManager cm = ComponentManager.getInstance(); TreeSet<EvaluatedDescriptionClass> suggestions; for (int i = 0; i <= 1; i++) { @@ -173,11 +179,7 @@ prefixes = reasoner.getPrefixes(); // loop through all classes - Set<NamedClass> classes = new TreeSet<NamedClass>(reasoner.getNamedClasses()); - classes.remove(new NamedClass("http://www.w3.org/2002/07/owl#Thing")); - // reduce number of classes for testing purposes - // shrinkSet(classes, 20); - for (NamedClass nc : classes) { + for (NamedClass nc : reducedClassesSet) { // check whether the class has sufficient instances int instanceCount = reasoner.getIndividuals(nc).size(); if (instanceCount < minInstanceCount) { @@ -188,129 +190,129 @@ + " with " + instanceCount + " instances"); ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); - for(int j = 0; j <= 1; j++){ - if(j == 0){ + for (int j = 0; j <= 1; j++) { + if (j == 0) { lp.getConfigurator().setType("equivalence"); System.out.println("Learning equivalentClass expressions"); } else { lp.getConfigurator().setType("superClass"); System.out.println("Learning superClass expressions"); } - for(int k = 0; k <= 3; k++){ - if(k == 0){ - lp.getConfigurator().setAccuracyMethod("standard"); - System.out.println("Using accuracy method: standard"); - } else if(k == 1){ - lp.getConfigurator().setAccuracyMethod("fmeasure"); - System.out.println("Using accuracy method: F-Measure"); - } else if(k == 2){ - lp.getConfigurator().setAccuracyMethod("pred_acc"); - System.out.println("Using accuracy method: Predictive accuracy"); - } else if(k == 3){ - lp.getConfigurator().setAccuracyMethod("jaccard"); - System.out.println("Using accuracy method: Jaccard"); - } else{ - lp.getConfigurator().setAccuracyMethod("generalised_fmeasure"); - System.out.println("Using accuracy method: Generalised F-Measure"); - } - lp.getConfigurator().setUseApproximations(useApproximations); - lp.init(); - CELOE celoe = cm.learningAlgorithm(CELOE.class, lp, reasoner); - CELOEConfigurator cf = celoe.getConfigurator(); - cf.setUseNegation(false); - cf.setValueFrequencyThreshold(3); - cf.setMaxExecutionTimeInSeconds(algorithmRuntimeInSeconds); - cf.setNoisePercentage(noisePercent); - cf.setMaxNrOfResults(10); - celoe.init(); + for (int k = 0; k <= 3; k++) { + if (k == 0) { + lp.getConfigurator().setAccuracyMethod("standard"); + System.out.println("Using accuracy method: standard"); + } else if (k == 1) { + lp.getConfigurator().setAccuracyMethod("fmeasure"); + System.out.println("Using accuracy method: F-Measure"); + } else if (k == 2) { + lp.getConfigurator().setAccuracyMethod("pred_acc"); + System.out.println("Using accuracy method: Predictive accuracy"); + } else if (k == 3) { + lp.getConfigurator().setAccuracyMethod("jaccard"); + System.out.println("Using accuracy method: Jaccard"); + } else { + lp.getConfigurator().setAccuracyMethod("generalised_fmeasure"); + System.out.println("Using accuracy method: Generalised F-Measure"); + } + lp.getConfigurator().setUseApproximations(useApproximations); + lp.init(); + CELOE celoe = cm.learningAlgorithm(CELOE.class, lp, reasoner); + CELOEConfigurator cf = celoe.getConfigurator(); + cf.setUseNegation(false); + cf.setValueFrequencyThreshold(3); + cf.setMaxExecutionTimeInSeconds(algorithmRuntimeInSeconds); + cf.setNoisePercentage(noisePercent); + cf.setMaxNrOfResults(10); + celoe.init(); - celoe.start(); - - - // test whether a solution above the threshold was found - EvaluatedDescription best = celoe.getCurrentlyBestEvaluatedDescription(); - double bestAcc = best.getAccuracy(); - - if (bestAcc < minAccuracy || (best.getDescription() instanceof Thing)) { - System.out - .println("The algorithm did not find a suggestion with an accuracy above the threshold of " - + (100 * minAccuracy) - + "% or the best description is not appropriate. (The best one was \"" - + best.getDescription().toManchesterSyntaxString(baseURI, - prefixes) - + "\" with an accuracy of " - + df.format(bestAcc) + ".) - skipping"); - suggestions = new TreeSet<EvaluatedDescriptionClass>(); - } else { + celoe.start(); + // test whether a solution above the threshold + // was found + EvaluatedDescription best = celoe.getCurrentlyBestEvaluatedDescription(); + double bestAcc = best.getAccuracy(); - suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe - .getCurrentlyBestEvaluatedDescriptions(); +// if (bestAcc < minAccuracy || (best.getDescription() instanceof Thing)) { +// System.out +// .println("The algorithm did not find a suggestion with an accuracy above the threshold of " +// + (100 * minAccuracy) +// + "% or the best description is not appropriate. (The best one was \"" +// + best.getDescription().toManchesterSyntaxString(baseURI, prefixes) +// + "\" with an accuracy of " + df.format(bestAcc) + ".) - skipping"); +// suggestions = new TreeSet<EvaluatedDescriptionClass>(); +// } else { +// +// suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe +// .getCurrentlyBestEvaluatedDescriptions(); +// } + suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe + .getCurrentlyBestEvaluatedDescriptions(); + List<EvaluatedDescriptionClass> suggestionsList = new LinkedList<EvaluatedDescriptionClass>( + suggestions.descendingSet()); + + if (i == 0) { + if (j == 0) { + if (k == 0) { + owlEquivalenceStandardMap.put(nc, suggestionsList); + } else if (k == 1) { + owlEquivalenceFMeasureMap.put(nc, suggestionsList); + } else if (k == 2) { + owlEquivalencePredaccMap.put(nc, suggestionsList); + } else if (k == 3) { + owlEquivalenceJaccardMap.put(nc, suggestionsList); + } else { + owlEquivalenceGenFMeasureMap.put(nc, suggestionsList); + } + } else { + if (k == 0) { + owlSuperStandardMap.put(nc, suggestionsList); + } else if (k == 1) { + owlSuperFMeasureMap.put(nc, suggestionsList); + } else if (k == 2) { + owlSuperPredaccMap.put(nc, suggestionsList); + } else if (k == 3) { + owlSuperJaccardMap.put(nc, suggestionsList); + } else { + owlSuperGenFMeasureMap.put(nc, suggestionsList); + } } - List<EvaluatedDescriptionClass> suggestionsList = new LinkedList<EvaluatedDescriptionClass>( - suggestions.descendingSet()); - - if(i == 0){ - if(j == 0){ - if(k == 0){ - owlEquivalenceStandardMap.put(nc, suggestionsList); - } else if( k == 1){ - owlEquivalenceFMeasureMap.put(nc, suggestionsList); - } else if(k == 2){ - owlEquivalencePredaccMap.put(nc, suggestionsList); - } else if(k == 3){ - owlEquivalenceJaccardMap.put(nc, suggestionsList); - } else { - owlEquivalenceGenFMeasureMap.put(nc, suggestionsList); - } - } else { - if(k == 0){ - owlSuperStandardMap.put(nc, suggestionsList); - } else if( k == 1){ - owlSuperFMeasureMap.put(nc, suggestionsList); - } else if(k == 2){ - owlSuperPredaccMap.put(nc, suggestionsList); - } else if(k == 3){ - owlSuperJaccardMap.put(nc, suggestionsList); - } else { - owlSuperGenFMeasureMap.put(nc, suggestionsList); - } - } + } else { + if (j == 0) { + if (k == 0) { + fastEquivalenceStandardMap.put(nc, suggestionsList); + } else if (k == 1) { + fastEquivalenceFMeasureMap.put(nc, suggestionsList); + } else if (k == 2) { + fastEquivalencePredaccMap.put(nc, suggestionsList); + } else if (k == 3) { + fastEquivalenceJaccardMap.put(nc, suggestionsList); } else { - if(j == 0){ - if(k == 0){ - fastEquivalenceStandardMap.put(nc, suggestionsList); - } else if( k == 1){ - fastEquivalenceFMeasureMap.put(nc, suggestionsList); - } else if(k == 2){ - fastEquivalencePredaccMap.put(nc, suggestionsList); - } else if(k == 3){ - fastEquivalenceJaccardMap.put(nc, suggestionsList); - } else { - fastEquivalenceGenFMeasureMap.put(nc, suggestionsList); - } - } else { - if(k == 0){ - fastSuperStandardMap.put(nc, suggestionsList); - } else if( k == 1){ - fastSuperFMeasureMap.put(nc, suggestionsList); - } else if(k == 2){ - fastSuperPredaccMap.put(nc, suggestionsList); - } else if(k == 3){ - fastSuperJaccardMap.put(nc, suggestionsList); - } else { - fastSuperGenFMeasureMap.put(nc, suggestionsList); - } - } + fastEquivalenceGenFMeasureMap.put(nc, suggestionsList); } -// } + } else { + if (k == 0) { + fastSuperStandardMap.put(nc, suggestionsList); + } else if (k == 1) { + fastSuperFMeasureMap.put(nc, suggestionsList); + } else if (k == 2) { + fastSuperPredaccMap.put(nc, suggestionsList); + } else if (k == 3) { + fastSuperJaccardMap.put(nc, suggestionsList); + } else { + fastSuperGenFMeasureMap.put(nc, suggestionsList); + } + } + } + // } cm.freeComponent(celoe); -// cm.freeComponent(lp); + // cm.freeComponent(lp); } } } cm.freeComponent(lp); } + cm.freeComponent(reasoner); } cm.freeComponent(reasoner); @@ -318,6 +320,13 @@ cm.freeComponent(celoe); } + /** + * Computing results for accuracy method 'Generalised F-Measure'. This is done separate because + * for FastInstanceChecker option useDefaultNegation is set to 'false'. + * @throws ComponentInitException + * @throws MalformedURLException + * @throws LearningProblemUnsupportedException + */ private void computeGenFMeasureWithoutDefaultNegation() throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException { ComponentManager cm = ComponentManager.getInstance(); @@ -338,12 +347,7 @@ baseURI = reasoner.getBaseURI(); prefixes = reasoner.getPrefixes(); - // loop through all classes - Set<NamedClass> classes = new TreeSet<NamedClass>(reasoner.getNamedClasses()); - classes.remove(new NamedClass("http://www.w3.org/2002/07/owl#Thing")); - // reduce number of classes for testing purposes - // shrinkSet(classes, 20); - for (NamedClass nc : classes) { + for (NamedClass nc : reducedClassesSet) { // check whether the class has sufficient instances int instanceCount = reasoner.getIndividuals(nc).size(); if (instanceCount < minInstanceCount) { @@ -381,19 +385,21 @@ EvaluatedDescription best = celoe.getCurrentlyBestEvaluatedDescription(); double bestAcc = best.getAccuracy(); - if (bestAcc < minAccuracy || (best.getDescription() instanceof Thing)) { - System.out - .println("The algorithm did not find a suggestion with an accuracy above the threshold of " - + (100 * minAccuracy) - + "% or the best description is not appropriate. (The best one was \"" - + best.getDescription().toManchesterSyntaxString(baseURI, prefixes) - + "\" with an accuracy of " + df.format(bestAcc) + ".) - skipping"); - suggestions = new TreeSet<EvaluatedDescriptionClass>(); - } else { - - suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe - .getCurrentlyBestEvaluatedDescriptions(); - } +// if (bestAcc < minAccuracy || (best.getDescription() instanceof Thing)) { +// System.out +// .println("The algorithm did not find a suggestion with an accuracy above the threshold of " +// + (100 * minAccuracy) +// + "% or the best description is not appropriate. (The best one was \"" +// + best.getDescription().toManchesterSyntaxString(baseURI, prefixes) +// + "\" with an accuracy of " + df.format(bestAcc) + ".) - skipping"); +// suggestions = new TreeSet<EvaluatedDescriptionClass>(); +// } else { +// +// suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe +// .getCurrentlyBestEvaluatedDescriptions(); +// } + suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe + .getCurrentlyBestEvaluatedDescriptions(); List<EvaluatedDescriptionClass> suggestionsList = new LinkedList<EvaluatedDescriptionClass>( suggestions.descendingSet()); @@ -501,9 +507,22 @@ } } - cm.freeAllComponents(); + reducedClassesSet = getShrinkedSet(defaultEquivalenceMap.keySet(), allListsComputingCount); + } + private Set<NamedClass> getShrinkedSet(Set<NamedClass> set, int count){ + Set<NamedClass> reducedSet = new HashSet<NamedClass>(); + int i = count; + for(NamedClass nc : set){ + if(i % count == 0){ + reducedSet.add(nc); + } + i++; + } + return reducedSet; + + } /** * @param args * @throws MalformedURLException Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-22 10:47:34 UTC (rev 1949) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-22 19:02:23 UTC (rev 1950) @@ -34,6 +34,7 @@ import javax.swing.JRadioButton; import javax.swing.JScrollPane; import javax.swing.JSeparator; +import javax.swing.JTextField; import javax.swing.JWindow; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -60,16 +61,16 @@ */ private static final long serialVersionUID = -3097551929270352556L; - private ResultTable tab1; - private ResultTable tab2; - private ResultTable tab3; - private ResultTable tab4; - private ResultTable tab5; - private ResultTable tab6; - private ResultTable tab7; - private ResultTable tab8; - private ResultTable tab9; - private ResultTable tab10; + private RatingTablePanel tab1; + private RatingTablePanel tab2; + private RatingTablePanel tab3; + private RatingTablePanel tab4; + private RatingTablePanel tab5; + private RatingTablePanel tab6; + private RatingTablePanel tab7; + private RatingTablePanel tab8; + private RatingTablePanel tab9; + private RatingTablePanel tab10; private SelectableClassExpressionsTable defaultTab; @@ -152,7 +153,7 @@ setLayout(new BorderLayout()); classesTable = new MarkableClassesTable(); - classesTable.addClasses(new TreeSet<NamedClass>(owlEquivalenceStandardMap.keySet())); + classesTable.addClasses(new TreeSet<NamedClass>(defaultEquivalenceMap.keySet())); JScrollPane classesScroll = new JScrollPane(classesTable); classesTable.addMouseMotionListener(this); add(classesScroll, BorderLayout.WEST); @@ -197,6 +198,8 @@ } private JPanel createSingleTablePanel(){ + JPanel panel = new JPanel(new GridLayout(3,1)); + JPanel tableHolderPanel = new JPanel(new BorderLayout()); defaultTab = new SelectableClassExpressionsTable(); defaultTab.getSelectionModel().addListSelectionListener(this); @@ -205,44 +208,53 @@ graphPanel = new GraphicalCoveragePanel(""); tableHolderPanel.add(graphPanel, BorderLayout.EAST); + JPanel noSuggestionPanel = new JPanel(); + noSuggestionPanel.add(new JCheckBox("There is no appropriate suggestion for this class in your opinion.")); - return tableHolderPanel; + JPanel alternateSuggestionPanel = new JPanel(); + alternateSuggestionPanel.add(new JTextField("There is an appropriate suggestion in your opinion, but the algorithm did not suggest it.")); + + panel.add(tableHolderPanel); + panel.add(noSuggestionPanel); + panel.add(alternateSuggestionPanel); + + return panel; } private JPanel createMultiTablesPanel(){ JPanel tablesHolderPanel = new JPanel(); tablesHolderPanel.setLayout(new GridLayout(5, 2, 5, 5)); tablesHolderPanel.addMouseMotionListener(this); - tab1 = new ResultTable(); + tab1 = new RatingTablePanel(); tab1.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab1)); - tab2 = new ResultTable(); + tablesHolderPanel.add(tab1); + tab2 = new RatingTablePanel(); tab2.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab2)); - tab3 = new ResultTable(); + tablesHolderPanel.add(tab2); + tab3 = new RatingTablePanel(); tab3.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab3)); - tab4 = new ResultTable(); + tablesHolderPanel.add(tab3); + tab4 = new RatingTablePanel(); tab4.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab4)); - tab5 = new ResultTable(); + tablesHolderPanel.add(tab4); + tab5 = new RatingTablePanel(); tab5.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab5)); - tab6 = new ResultTable(); + tablesHolderPanel.add(tab5); + tab6 = new RatingTablePanel(); tab6.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab6)); - tab7 = new ResultTable(); + tablesHolderPanel.add(tab6); + tab7 = new RatingTablePanel(); tab7.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab7)); - tab8 = new ResultTable(); + tablesHolderPanel.add(tab7); + tab8 = new RatingTablePanel(); tab8.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab8)); - tab9 = new ResultTable(); + tablesHolderPanel.add(tab8); + tab9 = new RatingTablePanel(); tab9.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab9)); - tab10 = new ResultTable(); + tablesHolderPanel.add(tab9); + tab10 = new RatingTablePanel(); tab10.addMouseMotionListener(this); - tablesHolderPanel.add(createSelectablePanel(tab10)); + tablesHolderPanel.add(tab10); return tablesHolderPanel; } @@ -272,17 +284,20 @@ private void showEquivalentSuggestions(NamedClass nc){ messageLabel.setText(EQUIVALENTCLASSTEXT); - tab1.addResults(owlEquivalenceStandardMap.get(nc)); - tab2.addResults(owlEquivalenceFMeasureMap.get(nc)); - tab3.addResults(owlEquivalencePredaccMap.get(nc)); - tab4.addResults(owlEquivalenceJaccardMap.get(nc)); - tab5.addResults(owlEquivalenceGenFMeasureMap.get(nc)); + if(owlEquivalenceStandardMap.get(nc) != null){ + tab1.addResults(owlEquivalenceStandardMap.get(nc)); + tab2.addResults(owlEquivalenceFMeasureMap.get(nc)); + tab3.addResults(owlEquivalencePredaccMap.get(nc)); + tab4.addResults(owlEquivalenceJaccardMap.get(nc)); + tab5.addResults(owlEquivalenceGenFMeasureMap.get(nc)); + + tab6.addResults(fastEquivalenceStandardMap.get(nc)); + tab7.addResults(fastEquivalenceFMeasureMap.get(nc)); + tab8.addResults(fastEquivalencePredaccMap.get(nc)); + tab9.addResults(fastEquivalenceJaccardMap.get(nc)); + tab10.addResults(fastEquivalenceGenFMeasureMap.get(nc)); + } - tab6.addResults(fastEquivalenceStandardMap.get(nc)); - tab7.addResults(fastEquivalenceFMeasureMap.get(nc)); - tab8.addResults(fastEquivalencePredaccMap.get(nc)); - tab9.addResults(fastEquivalenceJaccardMap.get(nc)); - tab10.addResults(fastEquivalenceGenFMeasureMap.get(nc)); defaultTab.addResults(defaultEquivalenceMap.get(nc)); @@ -292,17 +307,20 @@ private void showSuperSuggestions(NamedClass nc){ messageLabel.setText(SUPERCLASSTEXT); - tab1.addResults(owlSuperStandardMap.get(nc)); - tab2.addResults(owlSuperFMeasureMap.get(nc)); - tab3.addResults(owlSuperPredaccMap.get(nc)); - tab4.addResults(owlSuperJaccardMap.get(nc)); - tab5.addResults(owlSuperGenFMeasureMap.get(nc)); + if(owlSuperStandardMap.get(nc) != null){ + tab1.addResults(owlSuperStandardMap.get(nc)); + tab2.addResults(owlSuperFMeasureMap.get(nc)); + tab3.addResults(owlSuperPredaccMap.get(nc)); + tab4.addResults(owlSuperJaccardMap.get(nc)); + tab5.addResults(owlSuperGenFMeasureMap.get(nc)); + + tab6.addResults(fastSuperStandardMap.get(nc)); + tab7.addResults(fastSuperFMeasureMap.get(nc)); + tab8.addResults(fastSuperPredaccMap.get(nc)); + tab9.addResults(fastSuperJaccardMap.get(nc)); + tab10.addResults(fastSuperGenFMeasureMap.get(nc)); + } - tab6.addResults(fastSuperStandardMap.get(nc)); - tab7.addResults(fastSuperFMeasureMap.get(nc)); - tab8.addResults(fastSuperPredaccMap.get(nc)); - tab9.addResults(fastSuperJaccardMap.get(nc)); - tab10.addResults(fastSuperGenFMeasureMap.get(nc)); defaultTab.addResults(defaultSuperMap.get(nc)); @@ -397,13 +415,35 @@ showSuperSuggestions(nc); showSingleTable(); } else if(!showingMultiTables && showingEquivalentSuggestions){ - showMultiTables(); + if(owlEquivalenceStandardMap.get(nc) != null){ + showMultiTables(); + } else { + showSuperSuggestions(nc); + showSingleTable(); + if(currentClassIndex + 1 >= defaultEquivalenceMap.keySet().size()){ + nextFinishButton.setText("Finish"); + nextFinishButton.setActionCommand("finish"); + } + } + } else if(!showingMultiTables && !showingEquivalentSuggestions){ - showMultiTables(); - if(currentClassIndex + 1 >= owlEquivalenceStandardMap.keySet().size()){ - nextFinishButton.setText("Finish"); - nextFinishButton.setActionCommand("finish"); + if(owlEquivalenceStandardMap.get(nc) != null){ + showMultiTables(); + if(currentClassIndex + 1 >= defaultEquivalenceMap.keySet().size()){ + nextFinishButton.setText("Finish"); + nextFinishButton.setActionCommand("finish"); + } + } else { + + currentClassIndex++; + classesTable.setSelectedClass(currentClassIndex); + graphPanel.setConcept(classesTable.getSelectedClass(currentClassIndex)); + + showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); + showSingleTable(); } + + } else { currentClassIndex++; @@ -503,6 +543,44 @@ } + class RatingTablePanel extends JPanel{ + + /** + * + */ + private static final long serialVersionUID = 7408917327199664584L; + private ResultTable table; + private RatingPanel rating; + + public RatingTablePanel(){ + setLayout(new BorderLayout()); + setBorder(BorderFactory.createLineBorder(Color.BLACK)); + table = new ResultTable(); + add(table, BorderLayout.CENTER); + rating = new RatingPanel(); + add(rating, BorderLayout.EAST); + + } + + public void addResults(List<EvaluatedDescriptionClass> resultList){ + table.addResults(resultList); + } + + public void reset(){ + rating.clearSelection(); + } + + public int getRatingValue(){ + return rating.getSelectedValue(); + } + + public void addMouseMotionListener(MouseMotionListener mL){ + rating.addMouseMotionListener(mL); + table.addMouseMotionListener(mL); + } + + } + class RatingPanel extends JPanel{ /** Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java 2009-12-22 10:47:34 UTC (rev 1949) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java 2009-12-22 19:02:23 UTC (rev 1950) @@ -490,8 +490,8 @@ int coverage = (int)(((EvaluatedDescriptionClass) eval).getCoverage() * 100); int additionalCount = ((EvaluatedDescriptionClass) eval).getAdditionalInstances().size(); coverageString = "Covers " + coveredInstanceCount + " of " + instanceCount + - "(" + coverage + "%) of all instances"; - coversAdditionalString = "Covers " + additionalCount + " additional instances"; + "(" + coverage + " %) of all instances."; + coversAdditionalString = "Covers " + additionalCount + " additional instances."; getParent().repaint(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2009-12-27 16:31:39
|
Revision: 1954 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1954&view=rev Author: lorenz_b Date: 2009-12-27 16:31:29 +0000 (Sun, 27 Dec 2009) Log Message: ----------- Small changes in evaluation script. Fixed some bugs in evaluation GUI. Added 2 serialized examples. Checking execution time in score computation in class ClassLearningProblem. Made DatatypeProperty serializable. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.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/scripts/evaluation/test.ser trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/scripts/evaluation/test2.ser Modified: trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2009-12-22 20:17:48 UTC (rev 1953) +++ trunk/src/dl-learner/org/dllearner/core/owl/DatatypeProperty.java 2009-12-27 16:31:29 UTC (rev 1954) @@ -19,6 +19,7 @@ */ package org.dllearner.core.owl; +import java.io.Serializable; import java.net.URI; import java.util.Map; @@ -28,8 +29,12 @@ * @author Jens Lehmann * */ -public class DatatypeProperty implements Comparable<DatatypeProperty>, Property, NamedKBElement { +public class DatatypeProperty implements Comparable<DatatypeProperty>, Property, NamedKBElement, Serializable { + /** + * + */ + private static final long serialVersionUID = 8452865438915671952L; protected String name; public DatatypeProperty(String name) { Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-22 20:17:48 UTC (rev 1953) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-27 16:31:29 UTC (rev 1954) @@ -37,7 +37,6 @@ import org.dllearner.core.options.StringConfigOption; import org.dllearner.core.options.URLConfigOption; import org.dllearner.core.owl.Axiom; -import org.dllearner.core.owl.ClassAssertionAxiom; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.EquivalentClassesAxiom; import org.dllearner.core.owl.Individual; @@ -54,6 +53,9 @@ * */ public class ClassLearningProblem extends LearningProblem { + + private long nanoStartTime; + private static int maxExecutionTimeInSeconds = 20; // TODO: naming needs to be cleaned up for consistency: // coverage => recall @@ -441,6 +443,8 @@ public double getAccuracyOrTooWeakExact(Description description, double noise) { + nanoStartTime = System.nanoTime(); + if(heuristic.equals(HeuristicType.JACCARD)) { // computing R(C) restricted to relevant instances @@ -449,6 +453,9 @@ if(reasoner.hasType(description, ind)) { additionalInstancesSet.add(ind); } + if(terminationTimeExpired()){ + return 0; + } } // computing R(A) @@ -457,6 +464,9 @@ if(reasoner.hasType(description, ind)) { coveredInstancesSet.add(ind); } + if(terminationTimeExpired()){ + return 0; + } } // for Jaccard: covered instances is the intersection of the sets @@ -472,6 +482,9 @@ if(reasoner.hasType(description, ind)) { additionalInstances++; } + if(terminationTimeExpired()){ + return 0; + } } // computing R(A) @@ -480,6 +493,9 @@ if(reasoner.hasType(description, ind)) { coveredInstances++; } + if(terminationTimeExpired()){ + return 0; + } } double recall = coveredInstances/(double)classInstances.size(); @@ -517,6 +533,9 @@ } else if(reasoner.hasType(descriptionNeg, ind)) { icNeg.add(ind); } + if(terminationTimeExpired()){ + return 0; + } } // semantic precision @@ -542,6 +561,10 @@ throw new Error("ClassLearningProblem error: not implemented"); } + private boolean terminationTimeExpired(){ + return ((System.nanoTime() - nanoStartTime) >= (maxExecutionTimeInSeconds*1000000000l)); + } + // @Deprecated // public double getAccuracyOrTooWeakStandard(Description description, double minAccuracy) { // // since we have to perform a retrieval operation anyway, we cannot easily Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-22 20:17:48 UTC (rev 1953) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-27 16:31:29 UTC (rev 1954) @@ -6,6 +6,8 @@ import java.io.ObjectOutputStream; import java.io.OutputStream; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.text.DecimalFormat; import java.util.HashMap; @@ -30,12 +32,19 @@ import org.dllearner.learningproblems.EvaluatedDescriptionClass; import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.OWLAPIReasoner; +import org.mindswap.pellet.utils.SetUtils; +import org.semanticweb.owl.apibinding.OWLManager; +import org.semanticweb.owl.model.OWLClass; +import org.semanticweb.owl.model.OWLDataFactory; +import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.OWLOntology; +import org.semanticweb.owl.model.OWLOntologyCreationException; +import org.semanticweb.owl.model.OWLOntologyManager; public class EvaluationComputingScript { private ReasonerComponent reasoner; private OWLFile ks; - private ComponentManager cm = ComponentManager.getInstance(); private CELOE celoe; private ClassLearningProblem lp; @@ -54,15 +63,14 @@ private static DecimalFormat df = new DecimalFormat(); - // for performance measurements and development - private static boolean autoMode = false; - private static boolean useFastInstanceChecker = true; private static boolean useApproximations = false; - private static boolean computeApproxDiff = false; - private Set<NamedClass> reducedClassesSet; + private Set<NamedClass> equivalentReducedClassesSet; + private Set<NamedClass> superReducedClassesSet; + private URI ontologyURI; + private Map<NamedClass, List<EvaluatedDescriptionClass>> fastEquivalenceStandardMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); private Map<NamedClass, List<EvaluatedDescriptionClass>> fastEquivalenceFMeasureMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); private Map<NamedClass, List<EvaluatedDescriptionClass>> fastEquivalencePredaccMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); @@ -92,18 +100,40 @@ private Map<NamedClass, List<EvaluatedDescriptionClass>> defaultEquivalenceMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); private Map<NamedClass, List<EvaluatedDescriptionClass>> defaultSuperMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); + private Map<NamedClass, Set<OWLDescription>> assertedEquivalentClasses = new HashMap<NamedClass, Set<OWLDescription>>(); + private Map<NamedClass, Set<OWLDescription>> assertedSuperClasses = new HashMap<NamedClass, Set<OWLDescription>>(); - - public EvaluationComputingScript(URL fileURL) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException{ + public EvaluationComputingScript(URL fileURL) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException, URISyntaxException{ loadOntology(fileURL); computeWithApproximation(); computeSuggestions(); computeGenFMeasureWithoutDefaultNegation(); + getAssertedAxioms(); saveResults(); + } - private void loadOntology(URL fileURL) throws ComponentInitException{ + private void getAssertedAxioms(){ + try { + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + OWLDataFactory fac = man.getOWLDataFactory(); + OWLOntology ont = man.loadOntology(ontologyURI); + OWLClass cl; + for(NamedClass nc : SetUtils.union(defaultEquivalenceMap.keySet(), defaultSuperMap.keySet())){ + cl = fac.getOWLClass(URI.create(nc.getName())); + assertedEquivalentClasses.put(nc, cl.getEquivalentClasses(ont)); + assertedSuperClasses.put(nc, cl.getSuperClasses(ont)); + } + } catch (OWLOntologyCreationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void loadOntology(URL fileURL) throws ComponentInitException, URISyntaxException{ + ontologyURI = fileURL.toURI(); ComponentManager cm = ComponentManager.getInstance(); // initialize KnowledgeSource @@ -148,6 +178,12 @@ o.writeObject(defaultEquivalenceMap); o.writeObject(defaultSuperMap); + o.writeObject(baseURI); + o.writeObject(prefixes); + + o.writeObject(assertedEquivalentClasses); + o.writeObject(assertedSuperClasses); + o.flush(); } catch (IOException e) { System.err.println(e); @@ -179,26 +215,31 @@ prefixes = reasoner.getPrefixes(); // loop through all classes - for (NamedClass nc : reducedClassesSet) { - // check whether the class has sufficient instances - int instanceCount = reasoner.getIndividuals(nc).size(); - if (instanceCount < minInstanceCount) { - System.out.println("class " + nc.toManchesterSyntaxString(baseURI, prefixes) + " has only " - + instanceCount + " instances (minimum: " + minInstanceCount + ") - skipping"); - } else { + for (NamedClass nc : SetUtils.union(equivalentReducedClassesSet, superReducedClassesSet)) { System.out.println("\nlearning axioms for class " + nc.toManchesterSyntaxString(baseURI, prefixes) - + " with " + instanceCount + " instances"); - ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); - lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); + ); +// ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); +// lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); for (int j = 0; j <= 1; j++) { if (j == 0) { - lp.getConfigurator().setType("equivalence"); - System.out.println("Learning equivalentClass expressions"); + if(!equivalentReducedClassesSet.contains(nc)){ + continue; + } } else { - lp.getConfigurator().setType("superClass"); - System.out.println("Learning superClass expressions"); + if(!superReducedClassesSet.contains(nc)){ + continue; + } } for (int k = 0; k <= 3; k++) { + ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); + lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); + if (j == 0) { + lp.getConfigurator().setType("equivalence"); + System.out.println("Learning equivalentClass expressions"); + } else { + lp.getConfigurator().setType("superClass"); + System.out.println("Learning superClass expressions"); + } if (k == 0) { lp.getConfigurator().setAccuracyMethod("standard"); System.out.println("Using accuracy method: standard"); @@ -227,25 +268,6 @@ celoe.init(); celoe.start(); - - // test whether a solution above the threshold - // was found - EvaluatedDescription best = celoe.getCurrentlyBestEvaluatedDescription(); - double bestAcc = best.getAccuracy(); - -// if (bestAcc < minAccuracy || (best.getDescription() instanceof Thing)) { -// System.out -// .println("The algorithm did not find a suggestion with an accuracy above the threshold of " -// + (100 * minAccuracy) -// + "% or the best description is not appropriate. (The best one was \"" -// + best.getDescription().toManchesterSyntaxString(baseURI, prefixes) -// + "\" with an accuracy of " + df.format(bestAcc) + ".) - skipping"); -// suggestions = new TreeSet<EvaluatedDescriptionClass>(); -// } else { -// -// suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe -// .getCurrentlyBestEvaluatedDescriptions(); -// } suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe .getCurrentlyBestEvaluatedDescriptions(); List<EvaluatedDescriptionClass> suggestionsList = new LinkedList<EvaluatedDescriptionClass>( @@ -306,11 +328,9 @@ } // } cm.freeComponent(celoe); - // cm.freeComponent(lp); + cm.freeComponent(lp); } } - } - cm.freeComponent(lp); } cm.freeComponent(reasoner); @@ -320,6 +340,7 @@ cm.freeComponent(celoe); } + /** * Computing results for accuracy method 'Generalised F-Measure'. This is done separate because * for FastInstanceChecker option useDefaultNegation is set to 'false'. @@ -347,22 +368,22 @@ baseURI = reasoner.getBaseURI(); prefixes = reasoner.getPrefixes(); - for (NamedClass nc : reducedClassesSet) { - // check whether the class has sufficient instances - int instanceCount = reasoner.getIndividuals(nc).size(); - if (instanceCount < minInstanceCount) { - System.out.println("class " + nc.toManchesterSyntaxString(baseURI, prefixes) + " has only " - + instanceCount + " instances (minimum: " + minInstanceCount + ") - skipping"); - } else { + for (NamedClass nc : SetUtils.union(equivalentReducedClassesSet, superReducedClassesSet)) { System.out.println("\nlearning axioms for class " + nc.toManchesterSyntaxString(baseURI, prefixes) - + " with " + instanceCount + " instances"); + ); ClassLearningProblem lp = cm.learningProblem(ClassLearningProblem.class, reasoner); lp.getConfigurator().setClassToDescribe(nc.getURI().toURL()); for (int j = 0; j <= 1; j++) { if (j == 0) { + if(!equivalentReducedClassesSet.contains(nc)){ + continue; + } lp.getConfigurator().setType("equivalence"); System.out.println("Learning equivalentClass expressions"); } else { + if(!superReducedClassesSet.contains(nc)){ + continue; + } lp.getConfigurator().setType("superClass"); System.out.println("Learning superClass expressions"); } @@ -381,23 +402,6 @@ celoe.start(); - // test whether a solution above the threshold was found - EvaluatedDescription best = celoe.getCurrentlyBestEvaluatedDescription(); - double bestAcc = best.getAccuracy(); - -// if (bestAcc < minAccuracy || (best.getDescription() instanceof Thing)) { -// System.out -// .println("The algorithm did not find a suggestion with an accuracy above the threshold of " -// + (100 * minAccuracy) -// + "% or the best description is not appropriate. (The best one was \"" -// + best.getDescription().toManchesterSyntaxString(baseURI, prefixes) -// + "\" with an accuracy of " + df.format(bestAcc) + ".) - skipping"); -// suggestions = new TreeSet<EvaluatedDescriptionClass>(); -// } else { -// -// suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe -// .getCurrentlyBestEvaluatedDescriptions(); -// } suggestions = (TreeSet<EvaluatedDescriptionClass>) celoe .getCurrentlyBestEvaluatedDescriptions(); List<EvaluatedDescriptionClass> suggestionsList = new LinkedList<EvaluatedDescriptionClass>( @@ -422,7 +426,6 @@ } cm.freeComponent(celoe); cm.freeComponent(lp); - } } cm.freeComponent(reasoner); } @@ -507,13 +510,13 @@ } } - reducedClassesSet = getShrinkedSet(defaultEquivalenceMap.keySet(), allListsComputingCount); - + equivalentReducedClassesSet = getShrinkedSet(defaultEquivalenceMap.keySet(), allListsComputingCount); + superReducedClassesSet = getShrinkedSet(defaultSuperMap.keySet(), allListsComputingCount); } private Set<NamedClass> getShrinkedSet(Set<NamedClass> set, int count){ Set<NamedClass> reducedSet = new HashSet<NamedClass>(); - int i = count; + int i = 0; for(NamedClass nc : set){ if(i % count == 0){ reducedSet.add(nc); @@ -528,8 +531,9 @@ * @throws MalformedURLException * @throws LearningProblemUnsupportedException * @throws ComponentInitException + * @throws URISyntaxException */ - public static void main(String[] args) throws MalformedURLException, ComponentInitException, LearningProblemUnsupportedException { + public static void main(String[] args) throws MalformedURLException, ComponentInitException, LearningProblemUnsupportedException, URISyntaxException { // Logger.getRootLogger().setLevel(Level.WARN); if (args.length == 0) { System.out.println("You need to give an OWL file as argument."); @@ -541,8 +545,9 @@ } else { fileURL = new File(args[0]).toURI().toURL(); } - + long startTime = System.currentTimeMillis(); new EvaluationComputingScript(fileURL); + System.out.println("Overall computing time: " + (System.currentTimeMillis() - startTime)/1000 +" s"); } } Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-22 20:17:48 UTC (rev 1953) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-27 16:31:29 UTC (rev 1954) @@ -20,13 +20,13 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeSet; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; -import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -53,6 +53,8 @@ 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; public class EvaluationGUI extends JFrame implements ActionListener, ListSelectionListener, MouseMotionListener{ @@ -88,6 +90,9 @@ private JPanel cardPanel; private CardLayout cardLayout; + private ResultTable mouseOverTable; + private int oldRow; + private static String SUPERCLASSTEXT = "Showing suggestions for super class"; private static String EQUIVALENTCLASSTEXT = "Showing suggestions for equivalent class"; @@ -129,6 +134,12 @@ private Map<NamedClass, List<EvaluatedDescriptionClass>> defaultEquivalenceMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); private Map<NamedClass, List<EvaluatedDescriptionClass>> defaultSuperMap = new HashMap<NamedClass, List<EvaluatedDescriptionClass>>(); + private String baseURI; + private Map<String, String> prefixes; + + 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>(); @@ -140,9 +151,16 @@ createUI(); createCoverageWindow(); classesTable.setSelectedClass(currentClassIndex); + graphPanel.initManchesterSyntax(baseURI, prefixes); + graphPanel2.initManchesterSyntax(baseURI, prefixes); graphPanel.setConcept(classesTable.getSelectedClass(currentClassIndex)); graphPanel2.setConcept(classesTable.getSelectedClass(currentClassIndex)); - showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); + if(classesTable.getSelectedClass(currentClassIndex) != null){ + showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); + } else { + showSuperSuggestions(classesTable.getSelectedClass(currentClassIndex)); + } + cardLayout.last(cardPanel); pack(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -153,9 +171,10 @@ private void createUI(){ setLayout(new BorderLayout()); - + System.out.println(assertedEquivalentClasses); + System.out.println(assertedSuperClasses); classesTable = new MarkableClassesTable(); - classesTable.addClasses(new TreeSet<NamedClass>(defaultEquivalenceMap.keySet())); + classesTable.addClasses(new TreeSet<NamedClass>(SetUtils.union(defaultEquivalenceMap.keySet(), defaultSuperMap.keySet()))); JScrollPane classesScroll = new JScrollPane(classesTable); classesTable.addMouseMotionListener(this); add(classesScroll, BorderLayout.WEST); @@ -262,16 +281,6 @@ return tablesHolderPanel; } - private JPanel createSelectablePanel(ResultTable table){ - JPanel panel = new JPanel(new BorderLayout()); - panel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); - JCheckBox box = new JCheckBox(); - panel.add(table, BorderLayout.CENTER); -// panel.add(box, BorderLayout.EAST); - panel.add(new RatingPanel(), BorderLayout.EAST); - return panel; - } - private void showSingleTable(){ defaultTab.clearSelection(); graphPanel.clear(); @@ -288,6 +297,8 @@ messageLabel.setText(EQUIVALENTCLASSTEXT); if(owlEquivalenceStandardMap.get(nc) != null){ + + tab1.addResults(owlEquivalenceStandardMap.get(nc)); tab2.addResults(owlEquivalenceFMeasureMap.get(nc)); tab3.addResults(owlEquivalencePredaccMap.get(nc)); @@ -300,9 +311,9 @@ tab9.addResults(fastEquivalenceJaccardMap.get(nc)); tab10.addResults(fastEquivalenceGenFMeasureMap.get(nc)); } + defaultTab.addResults(defaultEquivalenceMap.get(nc)); - defaultTab.addResults(defaultEquivalenceMap.get(nc)); showingEquivalentSuggestions = true; } @@ -311,6 +322,7 @@ messageLabel.setText(SUPERCLASSTEXT); if(owlSuperStandardMap.get(nc) != null){ + tab1.addResults(owlSuperStandardMap.get(nc)); tab2.addResults(owlSuperFMeasureMap.get(nc)); tab3.addResults(owlSuperPredaccMap.get(nc)); @@ -324,9 +336,9 @@ tab10.addResults(fastSuperGenFMeasureMap.get(nc)); } - defaultTab.addResults(defaultSuperMap.get(nc)); + showingEquivalentSuggestions = false; } @@ -373,6 +385,12 @@ defaultEquivalenceMap = (HashMap<NamedClass, List<EvaluatedDescriptionClass>>) o.readObject(); defaultSuperMap = (HashMap<NamedClass, List<EvaluatedDescriptionClass>>) o.readObject(); + baseURI = (String)o.readObject(); + prefixes = (Map<String, String>)o.readObject(); + + assertedEquivalentClasses = (Map<NamedClass, Set<OWLDescription>>) o.readObject(); + assertedSuperClasses = (Map<NamedClass, Set<OWLDescription>>) o.readObject(); + } catch (IOException e) { @@ -393,8 +411,17 @@ } - private void showCoveragePanel(boolean visible){ - coverageWindow.setVisible(visible); + private void showCoveragePanel(boolean show){ + final boolean visible = show; + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + coverageWindow.setVisible(visible); + + } + }); + } private void setCoverageLocationRelativeTo(Component component){ @@ -415,34 +442,53 @@ if(e.getActionCommand().equals("next")){ NamedClass nc = classesTable.getSelectedClass(currentClassIndex); if(showingMultiTables && showingEquivalentSuggestions){ - showSuperSuggestions(nc); - showSingleTable(); + if(defaultSuperMap.get(nc) != null){ + showSuperSuggestions(nc); + showSingleTable(); + } else { + currentClassIndex++; + classesTable.setSelectedClass(currentClassIndex); + graphPanel.setConcept(classesTable.getSelectedClass(currentClassIndex)); + + showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); + showSingleTable(); + } + } else if(!showingMultiTables && showingEquivalentSuggestions){ if(owlEquivalenceStandardMap.get(nc) != null){ showMultiTables(); - } else { + } else if(defaultSuperMap.get(nc) != null){ showSuperSuggestions(nc); showSingleTable(); if(currentClassIndex + 1 >= defaultEquivalenceMap.keySet().size()){ nextFinishButton.setText("Finish"); nextFinishButton.setActionCommand("finish"); } + } else { + currentClassIndex++; + classesTable.setSelectedClass(currentClassIndex); + graphPanel.setConcept(classesTable.getSelectedClass(currentClassIndex)); + + showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); + showSingleTable(); } } else if(!showingMultiTables && !showingEquivalentSuggestions){ if(owlEquivalenceStandardMap.get(nc) != null){ showMultiTables(); - if(currentClassIndex + 1 >= defaultEquivalenceMap.keySet().size()){ - nextFinishButton.setText("Finish"); - nextFinishButton.setActionCommand("finish"); - } + } else { currentClassIndex++; classesTable.setSelectedClass(currentClassIndex); - graphPanel.setConcept(classesTable.getSelectedClass(currentClassIndex)); + NamedClass newNc = classesTable.getSelectedClass(currentClassIndex); + graphPanel.setConcept(newNc); + if(defaultEquivalenceMap.get(newNc) != null){ + showEquivalentSuggestions(newNc); + } else { + showSuperSuggestions(newNc); + } - showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); showSingleTable(); } @@ -456,6 +502,7 @@ showEquivalentSuggestions(classesTable.getSelectedClass(currentClassIndex)); showSingleTable(); } + setFinished(); } else if(e.getActionCommand().equals("finish")){ @@ -464,6 +511,22 @@ } + private void setFinished(){ + NamedClass nc = classesTable.getSelectedClass(currentClassIndex); + if(currentClassIndex == SetUtils.union(defaultEquivalenceMap.keySet(),defaultSuperMap.keySet()).size()){ + if(showingEquivalentSuggestions && owlEquivalenceStandardMap.get(nc) == null && defaultSuperMap.get(nc) == null || + showingEquivalentSuggestions && showingMultiTables && defaultSuperMap.get(nc) == null|| + !showingEquivalentSuggestions && owlSuperStandardMap.get(nc) == null || + !showingEquivalentSuggestions && showingMultiTables){ + nextFinishButton.setText("Finish"); + nextFinishButton.setActionCommand("finish"); + } + + + + } + } + @Override public void valueChanged(ListSelectionEvent e) { if(!e.getValueIsAdjusting() && defaultTab.getSelectedRow() >= 0){ @@ -529,13 +592,18 @@ int column = result.columnAtPoint(e.getPoint()); int row = result.rowAtPoint(e.getPoint()); - if(column == 0 && row >=0 && row <= 9){ - EvaluatedDescriptionClass ec = result.getValueAtRow(row); - graphPanel2.clear(); - graphPanel2.setNewClassDescription(ec); - setCoverageLocationRelativeTo(result); - showCoveragePanel(true); - + 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); } Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/test.ser =================================================================== (Binary files differ) Added: trunk/src/dl-learner/org/dllearner/scripts/evaluation/test2.ser =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/scripts/evaluation/test2.ser ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java 2009-12-22 20:17:48 UTC (rev 1953) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ui/GraphicalCoveragePanel.java 2009-12-27 16:31:29 UTC (rev 1954) @@ -27,6 +27,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.awt.geom.Ellipse2D; +import java.util.Map; import java.util.Random; import java.util.Set; import java.util.Vector; @@ -71,6 +72,9 @@ private NamedClass concept; + private String baseURI; + private Map<String, String> prefixes; + private String conceptNew; private final Vector<IndividualPoint> posCovIndVector; private final Vector<IndividualPoint> posNotCovIndVector; @@ -138,10 +142,16 @@ // this.computeIndividualPoints(); } + + public void initManchesterSyntax(String baseURI, Map<String, String> prefixes){ + this.baseURI = baseURI; + this.prefixes = prefixes; + } @Override protected void paintComponent(Graphics g) { - + g.clearRect(0, 0, 400, 400); + g.clearRect(320, 130, 320, 50); Graphics2D g2D; g2D = (Graphics2D) g; // Composite original = g2D.getComposite(); @@ -152,7 +162,7 @@ g2D.drawString(ManchesterSyntaxRenderer.renderSimple(OREManager.getInstance().getCurrentClass2Learn()) , 320, 10); } else if(concept!= null){ - g2D.drawString(concept.getName(), 320, 10); + g2D.drawString(concept.toManchesterSyntaxString(baseURI, prefixes), 320, 10); } // g2D.setColor(Color.ORANGE); @@ -383,6 +393,8 @@ // } // getParent().repaint(); } + + @SuppressWarnings(value = { "unused" }) private void renderPlus() { if (eval != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-12-28 11:43:04
|
Revision: 1957 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1957&view=rev Author: jenslehmann Date: 2009-12-28 11:42:54 +0000 (Mon, 28 Dec 2009) Log Message: ----------- Introduced option to turn off convenience consistency checks in class learning problems (they are often useful, but can be time consuming.) Use "classLearning.checkConsistency = false;" to turn the checks off (they are turned on by default). Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java Modified: trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-12-28 07:59:52 UTC (rev 1956) +++ trunk/src/dl-learner/org/dllearner/core/configurators/ClassLearningProblemConfigurator.java 2009-12-28 11:42:54 UTC (rev 1957) @@ -99,6 +99,15 @@ public String getAccuracyMethod() { return (String) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "accuracyMethod") ; } +/** +* checkConsistency Specify whether to check consistency for solution candidates. This is convenient for user interfaces, but can be performance intensive.. +* mandatory: false| reinit necessary: true +* default value: true +* @return boolean +**/ +public boolean getCheckConsistency() { +return (Boolean) ComponentManager.getInstance().getConfigOptionValue(classLearningProblem, "checkConsistency") ; +} /** * @param classToDescribe class of which a description should be learned. @@ -144,6 +153,15 @@ ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "accuracyMethod", accuracyMethod); reinitNecessary = true; } +/** +* @param checkConsistency Specify whether to check consistency for solution candidates. This is convenient for user interfaces, but can be performance intensive.. +* mandatory: false| reinit necessary: true +* default value: true +**/ +public void setCheckConsistency(boolean checkConsistency) { +ComponentManager.getInstance().applyConfigEntry(classLearningProblem, "checkConsistency", checkConsistency); +reinitNecessary = true; +} /** * true, if this component needs reinitializsation. Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-28 07:59:52 UTC (rev 1956) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-28 11:42:54 UTC (rev 1957) @@ -112,6 +112,8 @@ StringConfigOption accMethod = new StringConfigOption("accuracyMethod", "Specifies, which method/function to use for computing accuracy.","standard"); // or domain/range of a property. accMethod.setAllowedValues(new String[] {"standard", "fmeasure", "pred_acc", "generalised_fmeasure", "jaccard"}); options.add(accMethod); + BooleanConfigOption consistency = new BooleanConfigOption("checkConsistency", "Specify whether to check consistency for solution candidates. This is convenient for user interfaces, but can be performance intensive.", true); + options.add(consistency); return options; } @@ -229,13 +231,6 @@ // for each description with less than 100% coverage, we check whether it is // leads to an inconsistent knowledge base - // workaround due to a bug (see http://sourceforge.net/tracker/?func=detail&aid=2866610&group_id=203619&atid=986319) -// boolean isConsistent = coverage >= 0.999999 || isConsistent(description); - boolean isConsistent = isConsistent(description); - - // we check whether the axiom already follows from the knowledge base - boolean followsFromKB = reasoner.isSuperClassOf(description, classToDescribe); - double acc = 0; if(heuristic.equals(HeuristicType.FMEASURE)) { acc = getFMeasure(coverage, protusion); @@ -246,8 +241,23 @@ // move accuracy computation here if possible acc = getAccuracyOrTooWeakExact(description, 1); } -// double acc = useFMeasure ? getFMeasure(coverage, protusion) : getAccuracy(coverage, protusion); - return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), coverage, additionalInstances, protusion, acc, isConsistent, followsFromKB); + + if(configurator.getCheckConsistency()) { + + // we check whether the axiom already follows from the knowledge base + boolean followsFromKB = reasoner.isSuperClassOf(description, classToDescribe); + + // workaround due to a bug (see http://sourceforge.net/tracker/?func=detail&aid=2866610&group_id=203619&atid=986319) +// boolean isConsistent = coverage >= 0.999999 || isConsistent(description); + // (if the axiom follows, then the knowledge base remains consistent) + boolean isConsistent = followsFromKB || isConsistent(description); + +// double acc = useFMeasure ? getFMeasure(coverage, protusion) : getAccuracy(coverage, protusion); + return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), coverage, additionalInstances, protusion, acc, isConsistent, followsFromKB); + + } else { + return new ClassScore(coveredInstances, Helper.difference(classInstancesSet, coveredInstances), coverage, additionalInstances, protusion, acc); + } } public boolean isEquivalenceProblem() { Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-12-28 07:59:52 UTC (rev 1956) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassScore.java 2009-12-28 11:42:54 UTC (rev 1957) @@ -49,13 +49,17 @@ private boolean isConsistent; private boolean followsFromKB; - public ClassScore(Set<Individual> coveredInstances, Set<Individual> notCoveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy, boolean isConsistent, boolean followsFromKB) { + public ClassScore(Set<Individual> coveredInstances, Set<Individual> notCoveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy) { this.coveredInstances = coveredInstances; this.notCoveredInstances = notCoveredInstances; this.additionalInstances = additionalInstances; this.coverage = coverage; this.addition = protusion; this.accuracy = accuracy; + } + + public ClassScore(Set<Individual> coveredInstances, Set<Individual> notCoveredInstances, double coverage, Set<Individual> additionalInstances, double protusion, double accuracy, boolean isConsistent, boolean followsFromKB) { + this(coveredInstances, notCoveredInstances, coverage, additionalInstances, protusion, accuracy); this.isConsistent = isConsistent; this.followsFromKB = followsFromKB; } @@ -107,6 +111,14 @@ return additionalInstances; } + public void setConsistent(boolean isConsistent) { + this.isConsistent = isConsistent; + } + + public void setFollowsFromKB(boolean followsFromKB) { + this.followsFromKB = followsFromKB; + } + /** * @return the isConsistent */ Modified: trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java 2009-12-28 07:59:52 UTC (rev 1956) +++ trunk/src/dl-learner/org/dllearner/learningproblems/EvaluatedDescriptionClass.java 2009-12-28 11:42:54 UTC (rev 1957) @@ -115,6 +115,14 @@ return classScore.followsFromKB(); } + public void setConsistent(boolean isConsistent) { + classScore.setConsistent(isConsistent); + } + + public void setFollowsFromKB(boolean followsFromKB) { + classScore.setFollowsFromKB(followsFromKB); + } + /** * This convenience method can be used to store and exchange evaluated * descriptions by transforming them to a JSON string. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-12-29 10:05:24
|
Revision: 1959 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1959&view=rev Author: jenslehmann Date: 2009-12-29 10:05:16 +0000 (Tue, 29 Dec 2009) Log Message: ----------- included check for equivalence of classes in reasoner interface Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java Modified: trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2009-12-28 13:15:27 UTC (rev 1958) +++ trunk/src/dl-learner/org/dllearner/core/ReasonerComponent.java 2009-12-29 10:05:16 UTC (rev 1959) @@ -243,6 +243,26 @@ } @Override + public final boolean isEquivalentClass(Description class1, Description class2) { + reasoningStartTimeTmp = System.nanoTime(); + boolean result = false; + try { + result = isEquivalentClassImpl(class1, class2); + } catch (ReasoningMethodUnsupportedException e) { + handleExceptions(e); + } + nrOfSubsumptionChecks+=2; + reasoningDurationTmp = System.nanoTime() - reasoningStartTimeTmp; + subsumptionReasoningTimeNs += reasoningDurationTmp; + overallReasoningTimeNs += reasoningDurationTmp; + return result; + } + + protected boolean isEquivalentClassImpl(Description class1, Description class2) throws ReasoningMethodUnsupportedException { + return isSuperClassOfImpl(class1,class2) && isSuperClassOfImpl(class2,class1); + } + + @Override public final Set<Description> isSuperClassOf(Set<Description> superConcepts, Description subConcept) { reasoningStartTimeTmp = System.nanoTime(); Modified: trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java 2009-12-28 13:15:27 UTC (rev 1958) +++ trunk/src/dl-learner/org/dllearner/core/SchemaReasoner.java 2009-12-29 10:05:16 UTC (rev 1959) @@ -86,6 +86,14 @@ public boolean isSuperClassOf(Description superClass, Description subClass); /** + * Checks whether <code>class1</code> is equivalent to <code>class2</code>. + * @param class1 The first class. + * @param class2 The second class2. + * @return Whether <code>class1</code> is equivalent to <code>class2</code>. + */ + public boolean isEquivalentClass(Description class1, Description class2); + + /** * Checks which of <code>superClasses</code> are super classes of <code>subClass</code> * @param superClasses A set of (supposed) super classes. * @param subClasses The (supposed) sub class. Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-28 13:15:27 UTC (rev 1958) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-29 10:05:16 UTC (rev 1959) @@ -245,8 +245,10 @@ if(configurator.getCheckConsistency()) { // we check whether the axiom already follows from the knowledge base - boolean followsFromKB = reasoner.isSuperClassOf(description, classToDescribe); +// boolean followsFromKB = reasoner.isSuperClassOf(description, classToDescribe); + boolean followsFromKB = equivalence ? reasoner.isEquivalentClass(description, classToDescribe) : reasoner.isSuperClassOf(description, classToDescribe); + // workaround due to a bug (see http://sourceforge.net/tracker/?func=detail&aid=2866610&group_id=203619&atid=986319) // boolean isConsistent = coverage >= 0.999999 || isConsistent(description); // (if the axiom follows, then the knowledge base remains consistent) Modified: trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-12-28 13:15:27 UTC (rev 1958) +++ trunk/src/dl-learner/org/dllearner/reasoning/OWLAPIReasoner.java 2009-12-29 10:05:16 UTC (rev 1959) @@ -508,6 +508,16 @@ } @Override + public boolean isEquivalentClassImpl(Description class1, Description class2) { + try { + return reasoner.isEquivalentClass(OWLAPIDescriptionConvertVisitor.getOWLDescription(class1), OWLAPIDescriptionConvertVisitor.getOWLDescription(class2)); + } catch (OWLReasonerException e) { + e.printStackTrace(); + throw new Error("Equivalent Classes Reasoning Error in OWL API."); + } + } + + @Override protected TreeSet<Description> getSuperClassesImpl(Description concept) { Set<Set<OWLClass>> classes = null; try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-12-29 15:24:41
|
Revision: 1960 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1960&view=rev Author: jenslehmann Date: 2009-12-29 15:24:35 +0000 (Tue, 29 Dec 2009) Log Message: ----------- noise parameter included in all five heuristics Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-12-29 10:05:16 UTC (rev 1959) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-12-29 15:24:35 UTC (rev 1960) @@ -434,6 +434,7 @@ } if(!shorterDescriptionExists) { +// System.out.println(niceDescription + " acc " + accuracy); bestEvaluatedDescriptions.add(niceDescription, accuracy, learningProblem); } Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-29 10:05:16 UTC (rev 1959) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-29 15:24:35 UTC (rev 1960) @@ -27,6 +27,8 @@ import java.util.Set; import java.util.TreeSet; +import org.apache.log4j.Logger; +import org.dllearner.algorithms.celoe.CELOE; import org.dllearner.core.ComponentInitException; import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; @@ -54,6 +56,7 @@ */ public class ClassLearningProblem extends LearningProblem { + private static Logger logger = Logger.getLogger(ClassLearningProblem.class); private long nanoStartTime; private static int maxExecutionTimeInSeconds = 20; @@ -352,10 +355,15 @@ // or above the limit double mean = instancesCovered/(double)total; + // we can estimate the best possible concept to reach with downward refinement + // by setting precision to 1 and recall = mean stays as it is + double optimumEstimate = heuristic.equals(HeuristicType.FMEASURE) ? ((1+Math.sqrt(coverageFactor))*mean)/(Math.sqrt(coverageFactor)+1) : (coverageFactor*mean+1)/(double)(coverageFactor+1); + // if the mean is greater than the required minimum, we can accept; // we also accept if the interval is small and close to the minimum // (worst case is to accept a few inaccurate descriptions) - if(mean > 1-noise || (upperBorderA > mean && size < 0.03)) { + if(optimumEstimate > 1-noise-0.03) { +// || (upperBorderA > mean && size < 0.03)) { instancesCovered = (int) (instancesCovered/(double)total * classInstances.size()); upperEstimateA = (int) (upperBorderA * classInstances.size()); lowerEstimateA = (int) (lowerBorderA * classInstances.size()); @@ -365,7 +373,9 @@ // reject only if the upper border is far away (we are very // certain not to lose a potential solution) - if(upperBorderA + 0.1 < 1-noise) { +// if(upperBorderA + 0.1 < 1-noise) { + double optimumEstimateUpperBorder = heuristic.equals(HeuristicType.FMEASURE) ? ((1+Math.sqrt(coverageFactor))*(upperBorderA+0.1))/(Math.sqrt(coverageFactor)+1) : (coverageFactor*(upperBorderA+0.1)+1)/(double)(coverageFactor+1); + if(optimumEstimateUpperBorder < 1 - noise) { return -1; } } @@ -448,38 +458,44 @@ return heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(recall, precision) : getAccuracy(recall, precision); } - ////// - // TODO: Adaption to super class learning case needs to be made for each heuristic! - // TODO: noise parameter is not used by some heuristics - ////// - + + // exact computation for 5 heuristics; each one adapted to super class learning; + // each one takes the noise parameter into account public double getAccuracyOrTooWeakExact(Description description, double noise) { nanoStartTime = System.nanoTime(); if(heuristic.equals(HeuristicType.JACCARD)) { - // computing R(C) restricted to relevant instances - TreeSet<Individual> additionalInstancesSet = new TreeSet<Individual>(); - for(Individual ind : superClassInstances) { + // computing R(A) + TreeSet<Individual> coveredInstancesSet = new TreeSet<Individual>(); + for(Individual ind : classInstances) { if(reasoner.hasType(description, ind)) { - additionalInstancesSet.add(ind); + coveredInstancesSet.add(ind); } if(terminationTimeExpired()){ return 0; } + } + + // if even the optimal case (no additional instances covered) is not sufficient, + // the concept is too weak + if(coveredInstancesSet.size() / (double) classInstances.size() <= 1 - noise) { + return -1; } - - // computing R(A) - TreeSet<Individual> coveredInstancesSet = new TreeSet<Individual>(); - for(Individual ind : classInstances) { + + // computing R(C) restricted to relevant instances + TreeSet<Individual> additionalInstancesSet = new TreeSet<Individual>(); + for(Individual ind : superClassInstances) { if(reasoner.hasType(description, ind)) { - coveredInstancesSet.add(ind); + additionalInstancesSet.add(ind); } if(terminationTimeExpired()){ return 0; } - } + } + + // TODO: easier computation |R(A) \cap R(C)| / |R(A) \cup R(C)| // for Jaccard: covered instances is the intersection of the sets // R(A) and R(C); @@ -512,19 +528,36 @@ double recall = coveredInstances/(double)classInstances.size(); - if(recall < 1 - noise) { - return -1; - } + // noise computation is incorrect +// if(recall < 1 - noise) { +// return -1; +// } double precision = (additionalInstances + coveredInstances == 0) ? 0 : coveredInstances / (double) (coveredInstances + additionalInstances); + if(heuristic.equals(HeuristicType.OWN)) { - return getAccuracy(recall, precision); + // best reachable concept has same recall and precision 1: + // 1/t+1 * (t*r + 1) + if((coverageFactor*recall+1)/(double)(coverageFactor+1) <(1-noise)) { + return -1; + } else { + return getAccuracy(recall, precision); + } } else if(heuristic.equals(HeuristicType.FMEASURE)) { - return getFMeasure(recall, precision); + // best reachable concept has same recall and precision 1: + if(((1+Math.sqrt(coverageFactor))*recall)/(Math.sqrt(coverageFactor)+1)<1-noise) { + return -1; + } else { + return getFMeasure(recall, precision); + } } else if(heuristic.equals(HeuristicType.PRED_ACC)) { - // correctly classified divided by all examples - return (coverageFactor * coveredInstances + superClassInstances.size() - additionalInstances) / (double) (coverageFactor * classInstances.size() + superClassInstances.size()); + if((coverageFactor * coveredInstances + superClassInstances.size()) / (double) (coverageFactor * classInstances.size() + superClassInstances.size()) < 1 -noise) { + return -1; + } else { + // correctly classified divided by all examples + return (coverageFactor * coveredInstances + superClassInstances.size() - additionalInstances) / (double) (coverageFactor * classInstances.size() + superClassInstances.size()); + } } // return heuristic.equals(HeuristicType.FMEASURE) ? getFMeasure(recall, precision) : getAccuracy(recall, precision); @@ -552,7 +585,8 @@ // semantic precision // first compute I_C \cap Cn(DC) - // => TODO: we ignore Cn for now, because it is not clear how to implement it + // it seems that in our setting, we can ignore Cn, because the examples (class instances) + // are already part of the background knowledge Set<Individual> tmp1Pos = Helper.intersection(icPos, classInstancesSet); Set<Individual> tmp1Neg = Helper.intersection(icNeg, negatedClassInstances); int tmp1Size = tmp1Pos.size() + tmp1Neg.size(); @@ -567,6 +601,11 @@ // System.out.println(prec); // System.out.println(rec); + // too weak: see F-measure above + if(((1+Math.sqrt(coverageFactor))*rec)/(Math.sqrt(coverageFactor)+1)<1-noise) { + return -1; + } + return getFMeasure(rec,prec); } @@ -574,7 +613,11 @@ } private boolean terminationTimeExpired(){ - return ((System.nanoTime() - nanoStartTime) >= (maxExecutionTimeInSeconds*1000000000l)); + boolean val = ((System.nanoTime() - nanoStartTime) >= (maxExecutionTimeInSeconds*1000000000l)); + if(val) { + logger.warn("Description test aborted, because it took longer than " + maxExecutionTimeInSeconds + " seconds."); + } + return val; } // @Deprecated This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-12-29 15:39:57
|
Revision: 1961 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1961&view=rev Author: jenslehmann Date: 2009-12-29 15:39:49 +0000 (Tue, 29 Dec 2009) Log Message: ----------- rewrote max. 0 cardinality restrictions to make them easier to read for humans Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/core/owl/Negation.java trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-12-29 15:24:35 UTC (rev 1960) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-12-29 15:39:49 UTC (rev 1961) @@ -533,7 +533,7 @@ // check whether the node is a potential solution candidate private Description rewriteNode(OENode node) { Description description = node.getDescription(); - // minimize description (expensive!) + // minimize description (expensive!) - also performes some human friendly rewrites Description niceDescription = minimizer.minimizeClone(description); // replace \exists r.\top with \exists r.range(r) which is easier to read for humans ConceptTransformation.replaceRange(niceDescription, reasoner); Modified: trunk/src/dl-learner/org/dllearner/core/owl/Negation.java =================================================================== --- trunk/src/dl-learner/org/dllearner/core/owl/Negation.java 2009-12-29 15:24:35 UTC (rev 1960) +++ trunk/src/dl-learner/org/dllearner/core/owl/Negation.java 2009-12-29 15:39:49 UTC (rev 1961) @@ -58,6 +58,6 @@ */ @Override public String toManchesterSyntaxString(String baseURI, Map<String, String> prefixes) { - return "(not " +children.get(0).toString(baseURI, prefixes) + ")"; + return "(not " +children.get(0).toManchesterSyntaxString(baseURI, prefixes) + ")"; } } Modified: trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java 2009-12-29 15:24:35 UTC (rev 1960) +++ trunk/src/dl-learner/org/dllearner/utilities/owl/DescriptionMinimizer.java 2009-12-29 15:39:49 UTC (rev 1961) @@ -128,6 +128,11 @@ if(description.getChild(0) instanceof Nothing) { return Thing.instance; } + // we rewrite <= 0 r C to \neg \exists r C - easier to read for humans + if(((ObjectMaxCardinalityRestriction)description).getCardinality() == 0) { + ObjectProperty p = (ObjectProperty)((ObjectMaxCardinalityRestriction)description).getRole(); + return new Negation(new ObjectSomeRestriction(p, description.getChild(0))); + } return description; } else if(description instanceof ObjectMinCardinalityRestriction) { // >= 0 r.C \equiv \top This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <lor...@us...> - 2009-12-29 20:43:56
|
Revision: 1965 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1965&view=rev Author: lorenz_b Date: 2009-12-29 20:43:47 +0000 (Tue, 29 Dec 2009) Log Message: ----------- Added input tracing for rating tables. Added Fleiss' Kappa as a statistical measure for assessing the reliability of agreement between a fixed number of raters when assigning categorical ratings to a number of items or classifying items. Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/StatsGenerator.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/utilities/statistics/FleissKappa.java Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-29 20:03:55 UTC (rev 1964) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationGUI.java 2009-12-29 20:43:47 UTC (rev 1965) @@ -24,6 +24,7 @@ import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -157,6 +158,9 @@ private Map<NamedClass, String> selectedEquivalenceMap = new HashMap<NamedClass, String>(); private Map<NamedClass, String> selectedSuperMap = new HashMap<NamedClass, String>(); + + private Map<NamedClass, List<Integer>> equivalentClassListRating = new HashMap<NamedClass, List<Integer>>(); + private Map<NamedClass, List<Integer>> superClassListRating = new HashMap<NamedClass, List<Integer>>(); public EvaluationGUI(File input) throws ComponentInitException, MalformedURLException, LearningProblemUnsupportedException { @@ -515,10 +519,12 @@ @Override public void actionPerformed(ActionEvent e) { + traceInput(); if (e.getActionCommand().equals("next")) { + NamedClass nc = classesTable.getSelectedClass(currentClassIndex); if(!showingMultiTables){ - traceInput(); + } if (showingMultiTables && showingEquivalentSuggestions) { if (defaultSuperMap.get(nc) != null) { @@ -584,9 +590,6 @@ resetSingleTablePanel(); } else if (e.getActionCommand().equals("finish")) { - if(!showingMultiTables){ - traceInput(); - } closeDialog(); saveInput(); } @@ -601,24 +604,43 @@ private void traceInput(){ NamedClass currentClass = classesTable.getSelectedClass(currentClassIndex); - if(alternateSuggestionCheckBox.isSelected()){ - if(showingEquivalentSuggestions){ - selectedEquivalenceMap.put(currentClass, "m"); + if (!showingMultiTables) { + 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 { - selectedSuperMap.put(currentClass, "m"); + int position = defaultTab.getSelectedPosition() - 1; + if (showingEquivalentSuggestions) { + selectedEquivalenceMap.put(currentClass, String.valueOf(position)); + } else { + selectedSuperMap.put(currentClass, String.valueOf(position)); + } } - } else if(noSuggestionCheckBox.isSelected()){ - if(showingEquivalentSuggestions){ - selectedEquivalenceMap.put(currentClass, "n"); - } else { - selectedSuperMap.put(currentClass, "n"); - } } else { - int position = defaultTab.getSelectedPosition() - 1; + List<Integer> ratingList = new ArrayList<Integer>(); + ratingList.add(tab1.getRatingValue()); + ratingList.add(tab2.getRatingValue()); + ratingList.add(tab3.getRatingValue()); + ratingList.add(tab4.getRatingValue()); + ratingList.add(tab5.getRatingValue()); + ratingList.add(tab6.getRatingValue()); + ratingList.add(tab7.getRatingValue()); + ratingList.add(tab8.getRatingValue()); + ratingList.add(tab9.getRatingValue()); + ratingList.add(tab10.getRatingValue()); if(showingEquivalentSuggestions){ - selectedEquivalenceMap.put(currentClass, String.valueOf(position)); + equivalentClassListRating.put(currentClass, ratingList); } else { - selectedSuperMap.put(currentClass, String.valueOf(position)); + superClassListRating.put(currentClass, ratingList); } } } @@ -639,6 +661,9 @@ o.writeObject(selectedEquivalenceMap); o.writeObject(selectedSuperMap); + o.writeObject(equivalentClassListRating); + o.writeObject(superClassListRating); + o.flush(); o.close(); } catch (IOException e) { Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/StatsGenerator.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/StatsGenerator.java 2009-12-29 20:03:55 UTC (rev 1964) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/StatsGenerator.java 2009-12-29 20:43:47 UTC (rev 1965) @@ -381,6 +381,7 @@ equivalentInput = (Map<NamedClass, String>) o.readObject(); superInput = (Map<NamedClass, String>) o.readObject(); + } catch (IOException e) { System.err.println(e); } catch (ClassNotFoundException e) { Added: trunk/src/dl-learner/org/dllearner/utilities/statistics/FleissKappa.java =================================================================== --- trunk/src/dl-learner/org/dllearner/utilities/statistics/FleissKappa.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/utilities/statistics/FleissKappa.java 2009-12-29 20:43:47 UTC (rev 1965) @@ -0,0 +1,152 @@ +package org.dllearner.utilities.statistics; + +import java.util.Arrays; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; + +/** + * Computes the Fleiss' Kappa value as described in (Fleiss, 1971). + * Fleiss' Kappa is a statistical measure for assessing the reliability of agreement between + * a fixed number of raters when assigning categorical ratings to a number of items or classifying items. + */ +public class FleissKappa +{ + private static Logger logger = Logger.getLogger(FleissKappa.class); + + /** + * Example from Wikipedia article + */ + public static void main(String[] args) + { + Logger.getRootLogger().setLevel(Level.DEBUG); + short[][] mat = new short[][] + { + {0,0,0,0,14}, + {0,2,6,4,2}, + {0,0,3,5,6}, + {0,3,9,2,0}, + {2,2,8,1,1}, + {7,7,0,0,0}, + {3,2,6,3,0}, + {2,5,3,2,2}, + {6,5,2,1,0}, + {0,2,2,3,7} + } ; + + float kappa = computeKappa(mat) ; + System.out.println(getInterpretation(kappa)); + } + + /** + * Computes the Kappa value + * @param n Number of rating per subjects (number of human raters) + * @param mat Matrix[subjects][categories] + * @return The Kappa value + */ + public static float computeKappa(short[][] mat) { + final int n = checkEachLineCount(mat); + final int N = mat.length; + final int k = mat[0].length; + + logger.debug(n + " raters."); + logger.debug(N + " subjects."); + logger.debug(k + " categories."); + + // Computing columns p[] + float[] p = new float[k]; + for (int j = 0; j < k; j++) { + p[j] = 0; + for (int i = 0; i < N; i++) { + p[j] += mat[i][j]; + } + p[j] /= N * n; + } + logger.debug("p = " + Arrays.toString(p)); + + // Computing rows P[] + float[] P = new float[N]; + for (int i = 0; i < N; i++) { + P[i] = 0; + for (int j = 0; j < k; j++) { + P[i] += mat[i][j] * mat[i][j]; + } + P[i] = (P[i] - n) / (n * (n - 1)); + } + logger.debug("P = " + Arrays.toString(P)); + + // Computing Pbar + float Pbar = 0; + for (float Pi : P) { + Pbar += Pi; + } + Pbar /= N; + logger.debug("Pbar = " + Pbar); + + // Computing PbarE + float PbarE = 0; + for (float pj : p) { + PbarE += pj * pj; + } + logger.debug("PbarE = " + PbarE); + + final float kappa = (Pbar - PbarE) / (1 - PbarE); + logger.debug("kappa = " + kappa); + + return kappa; + } + + /** + * Assert that each line has a constant number of ratings + * @param mat The matrix checked + * @return The number of ratings + * @throws IllegalArgumentException If lines contain different number of ratings + */ + private static int checkEachLineCount(short[][] mat) { + int n = 0; + boolean firstLine = true; + + for (short[] line : mat) { + int count = 0; + for (short cell : line) { + count += cell; + } + if (firstLine) { + n = count; + firstLine = false; + } + if (n != count) { + throw new IllegalArgumentException("Line count != " + n + " (n value)."); + } + } + return n; + } + + /** + * Landis and Koch (1977) gave the following table for interpreting κ values. This table is + * however by no means universally accepted; They supplied no evidence to support it, basing it + * instead on personal opinion. It has been noted that these guidelines may be more harmful than + * helpful, as the number of categories and subjects will affect the magnitude of the value. + * The kappa will be higher when there are fewer categories. (Wikipedia) + * @param kappa The Kappa value + */ + public static String getInterpretation(float kappa){ + String interpretation = ""; + if(kappa < 0){ + interpretation = "Poor agreement"; + } else if(0 <= kappa && kappa <= 0.2 ){ + interpretation = "Slight agreement"; + } else if(0.2 < kappa && kappa <= 0.4 ){ + interpretation = "Fair agreement"; + } else if(0.4 <= kappa && kappa <= 0.6 ){ + interpretation = "Moderate agreement"; + } else if(0.6 <= kappa && kappa <= 0.8 ){ + interpretation = "Substantial agreement"; + } else if(0.8 <= kappa && kappa <= 1 ){ + interpretation = "Almost perfect agreement"; + } + + return interpretation; + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-12-29 21:57:35
|
Revision: 1967 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1967&view=rev Author: jenslehmann Date: 2009-12-29 21:57:27 +0000 (Tue, 29 Dec 2009) Log Message: ----------- changed interpretation of noise parameter for generalised F-measure (standard one does not work) Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-12-29 21:43:40 UTC (rev 1966) +++ trunk/src/dl-learner/org/dllearner/algorithms/celoe/CELOE.java 2009-12-29 21:57:27 UTC (rev 1967) @@ -361,6 +361,8 @@ // returns true if node was added and false otherwise private boolean addNode(Description description, OENode parentNode) { +// System.out.println(description); + // redundancy check (return if redundant) boolean nonRedundant = descriptions.add(description); if(!nonRedundant) { @@ -377,6 +379,7 @@ double accuracy = learningProblem.getAccuracyOrTooWeak(description, noise); // System.out.println("Test2 " + new Date()); expressionTests++; +// System.out.println("acc: " + accuracy); // System.out.println(description + " " + accuracy); if(accuracy == -1) { return false; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-29 21:43:40 UTC (rev 1966) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-29 21:57:27 UTC (rev 1967) @@ -598,11 +598,24 @@ double rec = tmp1Size / (double) (classInstances.size() + negatedClassInstances.size()); // System.out.println(description); + +// System.out.println("I_C pos: " + icPos); +// System.out.println("I_C neg: " + icNeg); +// System.out.println("class instances: " + classInstances); +// System.out.println("negated class instances: " + negatedClassInstances); + // System.out.println(prec); // System.out.println(rec); +// System.out.println(coverageFactor); // too weak: see F-measure above - if(((1+Math.sqrt(coverageFactor))*rec)/(Math.sqrt(coverageFactor)+1)<1-noise) { + // => does not work for generalised F-measure, because even very general + // concepts do not have a recall of 1 +// if(((1+Math.sqrt(coverageFactor))*rec)/(Math.sqrt(coverageFactor)+1)<1-noise) { +// return -1; +// } + // we only return too weak if there is no recall + if(rec <= 0.01) { return -1; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2009-12-31 09:18:34
|
Revision: 1972 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1972&view=rev Author: jenslehmann Date: 2009-12-31 09:18:21 +0000 (Thu, 31 Dec 2009) Log Message: ----------- adapted parameters Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java Modified: trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-31 09:12:22 UTC (rev 1971) +++ trunk/src/dl-learner/org/dllearner/learningproblems/ClassLearningProblem.java 2009-12-31 09:18:21 UTC (rev 1972) @@ -58,7 +58,7 @@ private static Logger logger = Logger.getLogger(ClassLearningProblem.class); private long nanoStartTime; - private static int maxExecutionTimeInSeconds = 20; + private static int maxExecutionTimeInSeconds = 10; // TODO: naming needs to be cleaned up for consistency: // coverage => recall Modified: trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java =================================================================== --- trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-31 09:12:22 UTC (rev 1971) +++ trunk/src/dl-learner/org/dllearner/scripts/evaluation/EvaluationComputingScript.java 2009-12-31 09:18:21 UTC (rev 1972) @@ -61,7 +61,7 @@ private static double noisePercent = 5.0; - private static int minInstanceCount = 3; + private static int minInstanceCount = 5; private static int algorithmRuntimeInSeconds = 10; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |