From: <hee...@us...> - 2008-08-14 12:07:47
|
Revision: 1070 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1070&view=rev Author: heeroyuy Date: 2008-08-14 12:07:43 +0000 (Thu, 14 Aug 2008) Log Message: ----------- -added feature to get more details on the selected concept when doubleclick it -small change in detail panel -java doc Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-08-14 09:50:45 UTC (rev 1069) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-08-14 12:07:43 UTC (rev 1070) @@ -1,92 +1,120 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.tools.protege; +import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.awt.event.ActionEvent; -import java.awt.event.ItemEvent; -import java.awt.event.MouseEvent; +import java.util.Iterator; + +import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.event.ListSelectionEvent; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.owl.Description; +import org.protege.editor.owl.OWLEditorKit; /** + * This class processes input from the user. + * @author Christian Koetteritzsch * - * @author Heero Yuy - * */ -public class ActionHandler implements ActionListener, ItemListener, MouseListener, ListSelectionListener{ - /** - * This is the DLLearnerModel. - */ +public class ActionHandler implements ActionListener, ItemListener, + MouseListener, ListSelectionListener { + + // This is the DLLearnerModel. + private DLLearnerModel model; - /** - * This is the id that checks if the equivalent class or subclass button is - * pressed in protege - */ + private OWLEditorKit editorKit; + + // This is the id that checks if the equivalent class or subclass button is + // pressed in protege private String id; - /** - * this is a boolean that checked if the advanced button was pressed or not. - */ + // this is a boolean that checked if the advanced button was pressed or not. private boolean toggled; - /** - * This is the Tread of the DL-Learner - */ + // This is the Tread of the DL-Learner private Thread dlLearner; - /** - * This is the view of the DL-Learner tab. - */ + private EvaluatedDescription evaluatedDescription; + // This is the view of the DL-Learner tab. private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; + private int counter; + private EvaluatedDescription oldEvaluatedDescription; /** - * This is the constructor for the action handler - * @param a ActionHandler - * @param m DLLearnerModel - * @param view DLlearner tab - * @param i id if it is a subclass oran equivalent class + * This is the constructor for the action handler. + * + * @param a + * ActionHandler + * @param m + * DLLearnerModel + * @param view + * DLlearner tab + * @param i + * id if it is a subclass or an equivalent class + * @param editor OWLEditorKit */ - public ActionHandler(ActionHandler a,DLLearnerModel m,OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view ,String i) - { - this.view = view; - this.id=i; + public ActionHandler(ActionHandler a, DLLearnerModel m, + OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view, + String i, OWLEditorKit editor) { + this.editorKit = editor; + this.view = view; + this.id = i; + counter = 0; this.model = m; toggled = false; - - + } + /** - * + * When a Button is pressed this method select the right. + * @param z ActionEvent */ - public void actionPerformed(ActionEvent z){ - - if(z.getActionCommand().equals("Suggest "+id)) - { - if(model.getAlreadyLearned()==true) - { + public void actionPerformed(ActionEvent z) { + + if (z.getActionCommand().equals("Suggest " + id)) { + if (model.getAlreadyLearned()) { model.unsetListModel(); } - if(view.getPosAndNegSelectPanel().getPosAndNegSelectPanel().getComponentCount()<=2) - { - view.renderErrorMessage("Could not start learning. No Examples where available"); + if (view.getPosAndNegSelectPanel().getPosAndNegSelectPanel() + .getComponentCount() <= 2) { + view + .renderErrorMessage("Could not start learning. No Examples where available"); + } else { + model.setKnowledgeSource(); + model.setReasoner(); + model.setPositiveAndNegativeExamples(); + model.setLearningProblem(); + model.setLearningAlgorithm(); + this.dlLearner = new Thread(model); + dlLearner.start(); + view.getRunButton().setEnabled(false); + view.getCancelButton().setEnabled(true); + view.renderErrorMessage("Learning started"); + view.getPosAndNegSelectPanel().unsetCheckBoxes(); } - else{ - model.setKnowledgeSource(); - model.setReasoner(); - model.setPositiveAndNegativeExamples(); - model.setLearningProblem(); - model.setLearningAlgorithm(); - this.dlLearner = new Thread(model); - dlLearner.start(); - view.getRunButton().setEnabled(false); - view.getCancelButton().setEnabled(true); - view.renderErrorMessage("Learning started"); - view.getPosAndNegSelectPanel().unsetCheckBoxes(); - } } - - if(z.getActionCommand().equals("Cancel")) - { + + if (z.getActionCommand().equals("Cancel")) { view.getRunButton().setEnabled(true); view.getCancelButton().setEnabled(false); String error = "Learning aborted"; @@ -95,96 +123,89 @@ model.getLearningAlgorithm().stop(); model.setErrorMessage(error); } - - if(z.getActionCommand().equals("ADD")) - { - model.changeDLLearnerDescriptionsToOWLDescriptions((Description)view.getSuggestClassPanel().getSuggestList().getSelectedValue()); - String message ="Concept added"; + + if (z.getActionCommand().equals("ADD")) { + if (evaluatedDescription != null) { + model + .changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription + .getDescription()); + } else { + model + .changeDLLearnerDescriptionsToOWLDescriptions((Description) view + .getSuggestClassPanel().getSuggestList() + .getSelectedValue()); + } + String message = "Concept added"; view.renderErrorMessage(message); } - - if(z.getActionCommand().equals("?")) - { - if(z.getSource().toString().contains("PosHelpButton")) - { - String hilfe="A Instance that follows from the classdescription.\nPer Default all that belongs to the class."; - view.getPosAndNegSelectPanel().renderHelpMessage(hilfe); + + if (z.getActionCommand().equals("?")) { + if (z.getSource().toString().contains("PosHelpButton")) { + String help = "A Instance that follows from the classdescription.\nPer Default all that belongs to the class."; + view.getPosAndNegSelectPanel().renderHelpMessage(help); } - - if(z.getSource().toString().contains("NegHelpButton")) - { - String hilfe="A Instance tht doesn't follow from the classdescription."; - view.getPosAndNegSelectPanel().renderHelpMessage(hilfe); + + if (z.getSource().toString().contains("NegHelpButton")) { + String help = "A Instance tht doesn't follow from the classdescription."; + view.getPosAndNegSelectPanel().renderHelpMessage(help); } - - + } - if(z.getActionCommand().equals("")) - { - if(!toggled==true) - { - toggled=true; + if (z.getActionCommand().equals("")) { + if (!toggled) { + toggled = true; view.setIconToggled(toggled); view.setExamplePanelVisible(toggled); - } - else - { - toggled=false; + } else { + toggled = false; view.setIconToggled(toggled); view.setExamplePanelVisible(toggled); } } - if(z.getActionCommand().equals("Why")) - { - view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel((Description)view.getSuggestClassPanel().getSuggestList().getSelectedValue()); + if (z.getActionCommand().equals("Why")) { + view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel( + evaluatedDescription); } } - - /** + + /** * - * @return + * @return id StringID if it is a Subclass or an equivalent class. */ - public String getID() - { + public String getID() { return id; } + + /** - * + * select/deselect the Check boxes. + * @param i ItemEvent */ - public void itemStateChanged(ItemEvent i) - { - if(i.getItem().toString().contains("Positive")) - { - for(int j = 0;j < model.getPosVector().size(); j++) - { - if(i.getItem().toString().contains(model.getPosVector().get(j).getText().toString())) - { - if(!model.getPosVector().get(j).isSelected()) - { + public void itemStateChanged(ItemEvent i) { + if (i.getItem().toString().contains("Positive")) { + for (int j = 0; j < model.getPosVector().size(); j++) { + if (i.getItem().toString().contains( + model.getPosVector().get(j).getText().toString())) { + if (!model.getPosVector().get(j).isSelected()) { model.getPosVector().get(j).setSelected(true); break; } - if(model.getPosVector().get(j).isSelected()) - { + if (model.getPosVector().get(j).isSelected()) { model.getPosVector().get(j).setSelected(false); break; } } } } - if(i.getItem().toString().contains("Negative")) - { - for(int j = 0;j < model.getNegVector().size(); j++) - { - if(i.getItem().toString().contains(model.getNegVector().get(j).getText().toString())) - { - if(!model.getNegVector().get(j).isSelected()) - { + if (i.getItem().toString().contains("Negative")) { + for (int j = 0; j < model.getNegVector().size(); j++) { + if (i.getItem().toString().contains( + model.getNegVector().get(j).getText().toString())) { + if (!model.getNegVector().get(j).isSelected()) { model.getNegVector().get(j).setSelected(true); break; } - if(model.getNegVector().get(j).isSelected()) - { + if (model.getNegVector().get(j).isSelected()) { model.getNegVector().get(j).setSelected(false); break; } @@ -193,61 +214,101 @@ } } - public void valueChanged(ListSelectionEvent e) - { - - } /** - * + * Nothing happens here. + * @param e ListSelectionEvent */ - public void mouseReleased(MouseEvent m) - { - + public void valueChanged(ListSelectionEvent e) { + } + /** - * + * Nothing happens here. + * @param m MouseEvent */ - public void mouseEntered(MouseEvent m) - { - + public void mouseReleased(MouseEvent m) { + } + + /** + * Nothing happens here. + * @param m MouseEvent + */ + public void mouseEntered(MouseEvent m) { + + } + /** - * + * Choses the right EvaluatedDescription object after a concept is chosen in the list. + * @param m MouseEvent */ - public void mouseClicked(MouseEvent m) - { - + public void mouseClicked(MouseEvent m) { + EvaluatedDescription eDescription = null; + oldEvaluatedDescription = evaluatedDescription; + String desc = view.getSuggestClassPanel().getSuggestList() + .getSelectedValue().toString(); + if (model.getEvaluatedDescriptionList() != null) { + for (Iterator<EvaluatedDescription> i = model + .getEvaluatedDescriptionList().iterator(); i.hasNext();) { + eDescription = i.next(); + if (desc.equals(eDescription.getDescription() + .toManchesterSyntaxString( + editorKit.getOWLModelManager() + .getActiveOntology().getURI() + + "#", null))) { + evaluatedDescription = eDescription; + break; + } + + } + } + System.out.println("old: " + oldEvaluatedDescription); + if (oldEvaluatedDescription != null) { + + if (oldEvaluatedDescription != evaluatedDescription) { + counter = 0; + } + counter++; + } else { + counter++; + } + if (counter == 2) { + counter = 0; + view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel( + evaluatedDescription); + } + System.out.println("Counter: " + counter); } + /** - * + * Nothing happens here. + * @param m MouseEvent */ - public void mouseExited(MouseEvent m) - { - + public void mouseExited(MouseEvent m) { + } + /** - * + * Sets the ADD button enable after a concept is chosen. + * @param m MouseEvent */ - public void mousePressed(MouseEvent m) - { - if(!view.getAddButton().isEnabled()) - { + public void mousePressed(MouseEvent m) { + if (!view.getAddButton().isEnabled()) { view.getAddButton().setEnabled(true); } } /** - * + * Destroys the Thread after the Pluigin is closed. */ - public void destroyDLLearnerThread() - { - dlLearner =null; + public void destroyDLLearnerThread() { + dlLearner = null; } + /** - * + * Resets the toggled Button after the plugin is closed. */ - public void resetToggled() - { + public void resetToggled() { toggled = false; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java 2008-08-14 09:50:45 UTC (rev 1069) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java 2008-08-14 12:07:43 UTC (rev 1070) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.tools.protege; import org.protege.editor.owl.ui.frame.AbstractOWLFrame; @@ -7,15 +26,32 @@ import org.semanticweb.owl.model.OWLClass; import org.protege.editor.owl.OWLEditorKit; -public class ButtonList extends AbstractOWLFrame<OWLClass>{ - - public ButtonList(OWLEditorKit editorKit) - { +/** + * This class manages the list of the lists for equivalent classes and so on. + * This is necessary to implement the dllearner plugin in the + * OWLClassDescriptionEditor. + * + * @author Christian Koetteritzsch + * + */ +public class ButtonList extends AbstractOWLFrame<OWLClass> { + /** + * Construktor of the Buttonlist. + * + * @param editorKit EditorKit from Protege + */ + public ButtonList(OWLEditorKit editorKit) { super(editorKit.getOWLModelManager().getOWLOntologyManager()); - addSection(new OWLEquivalentClassesAxiomFrameSection(editorKit, this)); - addSection(new OWLSubClassAxiomFrameSection(editorKit, this)); - addSection(new InheritedAnonymousClassesFrameSection(editorKit, this)); - addSection(new OWLClassAssertionAxiomIndividualSection(editorKit, this)); - addSection(new OWLDisjointClassesAxiomFrameSection(editorKit, this)); + // own OWLEquivalentClassesAxiomFrameSection to add the dllearner plugin + // to the + // OWLClassDescritpionEditor + addSection(new OWLEquivalentClassesAxiomFrameSection(editorKit, this)); + // own OWLEquivalentClassesAxiomFrameSection to add the dllearner plugin + // to the + // OWLClassDescritpionEditor + addSection(new OWLSubClassAxiomFrameSection(editorKit, this)); + addSection(new InheritedAnonymousClassesFrameSection(editorKit, this)); + addSection(new OWLClassAssertionAxiomIndividualSection(editorKit, this)); + addSection(new OWLDisjointClassesAxiomFrameSection(editorKit, this)); } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-08-14 09:50:45 UTC (rev 1069) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-08-14 12:07:43 UTC (rev 1070) @@ -1,197 +1,232 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + package org.dllearner.tools.protege; +import java.net.URI; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import java.util.Set; +import java.util.SortedSet; import java.util.TreeSet; -import java.util.List; import java.util.Vector; -import java.util.HashSet; -import java.util.Iterator; -import java.util.SortedSet; import javax.swing.DefaultListModel; import javax.swing.JCheckBox; -import org.dllearner.algorithms.refinement.ROLearner; import org.dllearner.algorithms.SimpleSuggestionLearningAlgorithm; - -import org.dllearner.core.owl.Description; +import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.ComponentManager; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; -import org.dllearner.core.ComponentManager; -import org.dllearner.core.ComponentInitException; import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.core.ReasoningService; - +import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; - import org.dllearner.kb.OWLAPIOntology; - +import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; -import org.dllearner.learningproblems.PosNegDefinitionLP; - import org.dllearner.reasoning.OWLAPIDescriptionConvertVisitor; import org.dllearner.reasoning.OWLAPIReasoner; - +import org.jdesktop.swingx.JXTaskPane; import org.protege.editor.owl.OWLEditorKit; import org.protege.editor.owl.ui.frame.OWLFrame; - import org.semanticweb.owl.apibinding.OWLManager; -import org.semanticweb.owl.model.OWLClass; -import org.semanticweb.owl.model.OWLOntologyChangeException; import org.semanticweb.owl.model.AddAxiom; import org.semanticweb.owl.model.OWLAxiom; +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.OWLOntologyChangeException; import org.semanticweb.owl.model.OWLOntologyManager; -import org.semanticweb.owl.model.OWLDescription; +/** + * This Class provides the necessary methods to learn Concepts from the + * DL-Learner. + * + * @author Christian Koetteritzsch + * + */ +public class DLLearnerModel implements Runnable { + // The Sting is for components that are available in the DL-Learner + private String[] componenten = { "org.dllearner.kb.OWLFile", + "org.dllearner.reasoning.OWLAPIReasoner", + "org.dllearner.reasoning.DIGReasoner", + "org.dllearner.reasoning.FastRetrievalReasoner", + "org.dllearner.learningproblems.PosNegInclusionLP", + "org.dllearner.learningproblems.PosNegDefinitionLP", + "org.dllearner.algorithms.RandomGuesser", + "org.dllearner.algorithms.BruteForceLearner", + "org.dllearner.algorithms.refinement.ROLearner", + "org.dllearner.algorithms.refexamples.ExampleBasedROLComponent", + "org.dllearner.algorithms.gp.GP" }; + // This Vector stores the check boxes for the view. -/**2 - * This Class provides the necessary methods to learn Concepts from the DL-Learner. - * @author Heero Yuy - * - */ -public class DLLearnerModel implements Runnable{ - /** - * The Sting is for components that are available in the DL-Learner - */ - private String[] componenten={"org.dllearner.kb.OWLFile","org.dllearner.reasoning.OWLAPIReasoner", - "org.dllearner.reasoning.DIGReasoner","org.dllearner.reasoning.FastRetrievalReasoner","org.dllearner.learningproblems.PosNegInclusionLP" - ,"org.dllearner.learningproblems.PosNegDefinitionLP","org.dllearner.algorithms.RandomGuesser","org.dllearner.algorithms.BruteForceLearner","org.dllearner.algorithms.refinement.ROLearner","org.dllearner.algorithms.refexamples.ExampleBasedROLComponent","org.dllearner.algorithms.gp.GP"}; - /** - * This Vector stores the check boxes for the view. - */ private Vector<JCheckBox> positiv; - /** - * This Vector stores the negative Examples. - */ + + // This Vector stores the negative Examples. + private Vector<JCheckBox> negativ; - /** - * - */ + + // Component Manager that manages the components of the DL-Learner + private ComponentManager cm; - /** - * - */ + + // The Reasoning Service for the Reasoner + private ReasoningService rs; - /** - * - */ + + // The Knowledge source for the reasoner + private KnowledgeSource source; - /** - * - */ + + // The View of the DL-Learner Plugin + private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; - /** - * This is the count of Concepts which you get after learning - */ - private static final int anzahl = 6; - /** - * - */ + + // This is the count of Concepts which you get after learning + + private static final int ANZAHL = 6; + + // A Array of Concepts which the DL-Learner suggested + private Description[] description; - /** - * - */ + + // The Learning problem that is used to learn new concepts + private LearningProblem lp; - /** - * This boolean is - */ - private boolean alreadyLearned=false; - /** - * - */ + + // This boolean is for clearing the suggest Panel + + private boolean alreadyLearned = false; + + // The Ontology which is currently used + private OWLOntology ontology; - /** - * This is the learning algorithm - */ + + // This is the learning algorithm + private LearningAlgorithm la = null; - /** - * - */ + + // Necessary to get the currently loaded Ontology + private OWLEditorKit editor; - /** - * - */ - private OWLFrame<OWLClass> aktuell; - /** - * - */ + + // Necessary to get the BaseUri of the currently loaded Ontology + + private OWLFrame<OWLClass> current; + + // The Reasoner which is used to learn + private OWLAPIReasoner reasoner; - /** - * - */ - private Set<OWLDescription> OWLDescription; - /** - * This set stores the positive examples. - */ + + // A Set of Descriptions in OWL Syntax which the DL-Learner suggested + + private Set<OWLDescription> owlDescription; + + // This set stores the positive examples. + private Set<String> positiveExamples; - /** - * This set stores the negative examples that doesn't belong to the concept. - */ + + // This set stores the negative examples that doesn't belong to the concept. + private Set<String> negativeExamples; - /** - * - */ + + // The most fitting Description in OWL Syntax which the DL-Learner suggested + private OWLDescription desc; - /** - * - */ + + // String to distinguish between Equivalent classes and sub classes + private String id; - /** - * - */ + + // The new Concept which is learned by the DL-Learner + private OWLDescription newConceptOWLAPI; - /** - * - */ + + // The old concept that is chosen in Protege + private OWLDescription oldConceptOWLAPI; - /** - * - */ + + // A Set of Descriptions in OWL Syntax which the DL-Learner suggested + private Set<OWLDescription> ds; - /** - * - */ + + // The model for the suggested Descriptions + private DefaultListModel suggestModel; - /** - * - */ + + // The Individuals of the Ontology + private Set<Individual> individual; - /** - * - */ + + // This is a simple learning algorithm to get the first concepts before + // learning + private SimpleSuggestionLearningAlgorithm test; - /** - * - */ + + // The error message which is rendered when an error occured + private String error; - /** - * - */ + + // This is the new axiom which will be added to the Ontology + private OWLAxiom axiomOWLAPI; - + + // This is necessary to get the details of the suggested concept + + private JXTaskPane detailPane; + + // This is a List of evaluated descriptions to get more information of the + // suggested concept private List<EvaluatedDescription> evalDescription; + /** - * This is the constructor for DL-Learner model + * This is the constructor for DL-Learner model. + * * @param editorKit + * Editor Kit to get the currently loaded Ontology * @param h - * @param id String if it learns a subclass or a superclass. - * @param view current view of the DL-Learner tab + * OWLFrame(OWLClass) to get the base uri of the Ontology + * @param id + * String if it learns a subclass or a superclass. + * @param view + * current view of the DL-Learner tab */ - public DLLearnerModel(OWLEditorKit editorKit, OWLFrame<OWLClass> h,String id,OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view) - { - editor=editorKit; - aktuell=h; - this.id=id; - this.view=view; - OWLDescription = new HashSet<OWLDescription>(); + public DLLearnerModel(OWLEditorKit editorKit, OWLFrame<OWLClass> h, + String id, + OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view) { + editor = editorKit; + current = h; + this.id = id; + this.view = view; + owlDescription = new HashSet<OWLDescription>(); positiv = new Vector<JCheckBox>(); negativ = new Vector<JCheckBox>(); test = new SimpleSuggestionLearningAlgorithm(); @@ -199,522 +234,560 @@ cm = ComponentManager.getInstance(); ds = new HashSet<OWLDescription>(); suggestModel = new DefaultListModel(); - + detailPane = new JXTaskPane(); + detailPane.setTitle("Details"); + } - + /** - * This method initializes the SimpleSuggestionLearningAlgorithm and adds the - * suggestions to the suggest panel model. + * This method initializes the SimpleSuggestionLearningAlgorithm and adds + * the suggestions to the suggest panel model. */ - public void initReasoner() - { + public void initReasoner() { alreadyLearned = false; setKnowledgeSource(); setReasoner(); - SortedSet<Individual> pos=rs.getIndividuals(); - Set<Description> desc = test.getSimpleSuggestions(rs, pos); + SortedSet<Individual> pos = rs.getIndividuals(); + Set<Description> descri = test.getSimpleSuggestions(rs, pos); int i = 0; - for(Iterator<Description> j = desc.iterator();j.hasNext();) - { - suggestModel.add(i,j.next()); + for (Iterator<Description> j = descri.iterator(); j.hasNext();) { + suggestModel.add(i, j.next()); } + // suggestModel.add(0,test.getCurrentlyBestEvaluatedDescription(). + // getDescription + // ().toManchesterSyntaxString(editor.getOWLModelManager(). + // getActiveOntology().getURI().toString()+"#", null)); } - + /** - * This method adds the solutions from the DL-Learner to the - * model for the + * This method adds the solutions from the DL-Learner to the List Model. */ - private void addToListModel() - { - evalDescription = la.getCurrentlyBestEvaluatedDescriptions(anzahl); - System.out.println("Size: "+la.getCurrentlyBestDescriptions().size()); - for(int j = 0;j<la.getCurrentlyBestEvaluatedDescriptions(anzahl).size();j++) - { - suggestModel.add(j,la.getCurrentlyBestEvaluatedDescriptions(anzahl).get(j).getDescription()); + private void addToListModel() { + evalDescription = la.getCurrentlyBestEvaluatedDescriptions(ANZAHL); + for (int j = 0; j < la.getCurrentlyBestEvaluatedDescriptions(ANZAHL).size(); j++) { + suggestModel.add(j, la + .getCurrentlyBestEvaluatedDescriptions(ANZAHL).get(j) + .getDescription().toManchesterSyntaxString( + editor.getOWLModelManager().getActiveOntology() + .getURI().toString() + + "#", null)); } } - + /** - * This method checks which positive and negative examples are checked - * and puts the checked examples into a tree set. + * This method checks which positive and negative examples are checked and + * puts the checked examples into a tree set. */ - public void setPositiveAndNegativeExamples() - { + public void setPositiveAndNegativeExamples() { positiveExamples = new TreeSet<String>(); negativeExamples = new TreeSet<String>(); - for(int i=0;i<positiv.size();i++) - { - if(positiv.get(i).isSelected()) - { + for (int i = 0; i < positiv.size(); i++) { + if (positiv.get(i).isSelected()) { positiveExamples.add(positiv.get(i).getText()); } - - if(negativ.get(i).isSelected()) - { + + if (negativ.get(i).isSelected()) { negativeExamples.add(negativ.get(i).getText()); } } } - + /** * This method returns the data for the suggest panel. + * * @return Model for the suggest panel. */ - public DefaultListModel getSuggestList() - { + public DefaultListModel getSuggestList() { return suggestModel; } - + /** * This method returns an array of descriptions learned by the DL-Learner. + * * @return Array of descriptions learned by the DL-Learner. */ - public Description[] getDescriptions() - { + public Description[] getDescriptions() { return description; } - public List<EvaluatedDescription> getEvaluatedDescriptionList() - { + + /** + * This Method returns a List of evaluated descriptions suggested by the + * DL-Learner. + * + * @return list of evaluated descriptions + */ + public List<EvaluatedDescription> getEvaluatedDescriptionList() { return evalDescription; } + /** - * This method sets the knowledge source for the learning process. - * Only OWLAPIOntology will be available. + * This method sets the knowledge source for the learning process. Only + * OWLAPIOntology will be available. */ - public void setKnowledgeSource() - { - this.source = new OWLAPIOntology(editor.getOWLModelManager().getActiveOntology()); + public void setKnowledgeSource() { + this.source = new OWLAPIOntology(editor.getOWLModelManager() + .getActiveOntology()); } - + /** - * This method sets the reasoner and the reasoning service - * Only OWLAPIReasoner is available. + * This method sets the reasoner and the reasoning service Only + * OWLAPIReasoner is available. */ - public void setReasoner() - { - this.reasoner =cm.reasoner(OWLAPIReasoner.class,source); + public void setReasoner() { + this.reasoner = cm.reasoner(OWLAPIReasoner.class, source); try { reasoner.init(); } catch (ComponentInitException e) { // TODO Auto-generated catch block + System.out.println("fehler!!!!!!!!!"); e.printStackTrace(); } rs = cm.reasoningService(reasoner); } - + /** * This method sets the Learning problem for the learning process. - * PosNegDefinitonLp for equivalent classes and - * PosNegInclusionLP for super classes. + * PosNegDefinitonLp for equivalent classes and PosNegInclusionLP for super + * classes. */ - public void setLearningProblem() - { - if(id.equals("Equivalent classes")) - { + public void setLearningProblem() { + if (id.equals("Equivalent classes")) { + // sets the learning problem to PosNegDefinitionLP when the + // dllearner should suggest an equivalent class lp = cm.learningProblem(PosNegDefinitionLP.class, rs); } - if(id.equals("Superclasses")) - { + if (id.equals("Superclasses")) { + // sets the learning problem to PosNegInclusionLP when the dllearner + // should suggest a subclass lp = cm.learningProblem(PosNegInclusionLP.class, rs); } - + // adds the positive examples cm.applyConfigEntry(lp, "positiveExamples", positiveExamples); + // adds the neagtive examples cm.applyConfigEntry(lp, "negativeExamples", negativeExamples); - try{ - lp.init(); - } - catch(ComponentInitException e) - { + try { + lp.init(); + } catch (ComponentInitException e) { e.printStackTrace(); } } - + /** * This method sets the learning algorithm for the learning process. */ - public void setLearningAlgorithm() - { + public void setLearningAlgorithm() { try { - this.la = cm.learningAlgorithm(ROLearner.class, lp, rs); + // sets the learning algorithm to ROlearner + this.la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, + rs); } catch (LearningProblemUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } cm.applyConfigEntry(la, "numberOfTrees", 100); cm.applyConfigEntry(la, "maxDepth", 5); - try{ + try { + // initializes the learning algorithm la.init(); - } - catch(ComponentInitException e){ - e.printStackTrace(); - } - alreadyLearned = true; + } catch (ComponentInitException e) { + e.printStackTrace(); + } + alreadyLearned = true; } /** * This method starts the learning process. */ - public void run() - { + public void run() { error = "Learning succesful"; // start the algorithm and print the best concept found la.start(); - description = new Description[la.getCurrentlyBestEvaluatedDescriptions(anzahl).size()]; + description = new Description[la.getCurrentlyBestEvaluatedDescriptions( + ANZAHL).size()]; addToListModel(); - System.out.println(la.getCurrentlyBestEvaluatedDescriptions()); + // renders the errormessage view.renderErrorMessage(error); + // reenables the run button view.getRunButton().setEnabled(true); + // disables the cancel button view.getCancelButton().setEnabled(false); view.getSuggestClassPanel().setSuggestList(suggestModel); } - + /** - * This method returns the Concepts from the DL-Learner. - * @return Array of learned Concepts. + * This method returns the Concepts from the DL-Learner. + * + * @return Array of learned Concepts. */ - public Description[] getSolutions() - { + public Description[] getSolutions() { return description; } - + /** * This method returns the check boxes for the positive examples. + * * @return Vector of check boxes for positive examples */ - public Vector<JCheckBox> getPosVector() - { + public Vector<JCheckBox> getPosVector() { return positiv; } - + /** * This method returns the check boxes for the negative examples. + * * @return Vector of check boxes for negative examples */ - public Vector<JCheckBox> getNegVector() - { + public Vector<JCheckBox> getNegVector() { return negativ; } - + /** * This method gets an error message and storess it. - * @param error error message + * + * @param err + * error message */ - public void setErrorMessage(String error) - { - this.error = error; + public void setErrorMessage(String err) { + this.error = err; } - + /** - * This method sets the check boxes for the positive check boxes checked - * if the individuals matches the concept that is chosen in protege. + * This method sets the check boxes for the positive check boxes checked if + * the individuals matches the concept that is chosen in protege. */ - public void setPosVector() - { + public void setPosVector() { setPositiveConcept(); - for(Iterator<Individual> j = rs.getIndividuals().iterator(); j.hasNext();) - { + for (Iterator<Individual> j = rs.getIndividuals().iterator(); j + .hasNext();) { String ind = j.next().toString(); - if(setPositivExamplesChecked(ind)) - { - JCheckBox box = new JCheckBox(ind.toString(),true); + // checks if individual belongs to the selected concept + if (setPositivExamplesChecked(ind)) { + // when yes then it sets the positive example checked + JCheckBox box = new JCheckBox(ind.toString(), true); box.setName("Positive"); positiv.add(box); - - } - else - { - JCheckBox box = new JCheckBox(ind.toString(),false); + // and ne genative examples unchecked + JCheckBox box2 = new JCheckBox(ind.toString(), false); + box.setName("Negative"); + negativ.add(box2); + + } else { + // When no it unchecks the positive example + JCheckBox box = new JCheckBox(ind.toString(), false); box.setName("Positive"); positiv.add(box); + // and checks the negative example + JCheckBox box2 = new JCheckBox(ind.toString(), true); + box.setName("Negative"); + negativ.add(box2); } - JCheckBox box = new JCheckBox(ind.toString(),false); - box.setName("Negative"); - negativ.add(box); } } /** * This method resets the Concepts that are learned. */ - public void unsetNewConcepts() - { - while(OWLDescription.iterator().hasNext()) - { - OWLDescription.remove(OWLDescription.iterator().next()); + public void unsetNewConcepts() { + while (owlDescription.iterator().hasNext()) { + owlDescription.remove(owlDescription.iterator().next()); } } - + /** - * This method sets the individuals that belong to the concept which is chosen in protege. + * This method sets the individuals that belong to the concept which is + * chosen in protege. */ - public void setPositiveConcept() - { + public void setPositiveConcept() { SortedSet<Individual> individuals = null; - if(!aktuell.getRootObject().toString().equals("Thing")) - { - for(Iterator<NamedClass> i = rs.getNamedClasses().iterator(); i.hasNext();) - { - if(individuals==null) - { + // checks if selected concept is thing when yes then it selects all + // individuals + if (!current.getRootObject().toString().equals("Thing")) { + + for (Iterator<NamedClass> i = rs.getNamedClasses().iterator(); i + .hasNext();) { + // if individuals is null + if (individuals == null) { NamedClass concept = i.next(); - if(concept.toString().endsWith("#"+aktuell.getRootObject().toString())) - { - if(rs.retrieval(concept)!=null) - { + // checks if the concept is the selected concept in protege + if (concept.toString().endsWith( + "#" + current.getRootObject().toString())) { + // if individuals is not null it gets all individuals of + // the concept + if (rs.retrieval(concept) != null) { individual = rs.retrieval(concept); break; - } + } } } } - } - else - { + } else { individual = rs.getIndividuals(); } } - + /** - * This method gets an Individual and checks if this individual belongs to the concept - * chosen in protege. - * @param indi Individual to check if it belongs to the chosen concept + * This method gets an Individual and checks if this individual belongs to + * the concept chosen in protege. + * + * @param indi + * Individual to check if it belongs to the chosen concept * @return is Individual belongs to the concept which is chosen in protege. */ - public boolean setPositivExamplesChecked(String indi) - { - boolean isChecked = false; - if(individual != null) - { - if(individual.toString().contains(indi)) - { - isChecked = true; - } + public boolean setPositivExamplesChecked(String indi) { + boolean isChecked = false; + // checks if individuals are not empty + if (individual != null) { + // checks if the delivered individual belongs to the individuals of + // the selected concept + if (individual.toString().contains(indi)) { + isChecked = true; } - return isChecked; - + } + return isChecked; + } /** - * This method resets the vectors where the check boxes for positive and negative Examples - * are stored. It is called when the DL-Learner View is closed. + * This method resets the vectors where the check boxes for positive and + * negative Examples are stored. It is called when the DL-Learner View is + * closed. */ - public void clearVector() - { + public void clearVector() { positiv.removeAllElements(); negativ.removeAllElements(); } - + /** * This method gets an array of concepts from the DL-Learner and stores it * in the description array. - * @param list Array of concepts from DL-Learner + * + * @param list + * Array of concepts from DL-Learner */ - public void setDescriptionList(Description[] list) - { - description=list; + public void setDescriptionList(Description[] list) { + description = list; } - + /** - * This method returns the current learning algorithm that is used to learn new concepts. + * This method returns the current learning algorithm that is used to learn + * new concepts. + * * @return Learning algorithm that is used for learning concepts. */ - public LearningAlgorithm getLearningAlgorithm() - { + public LearningAlgorithm getLearningAlgorithm() { return la; } - + /** - * This method gets an integer to return the positive examples check box on that position. - * @param i integer for the position in the vector + * This method gets an integer to return the positive examples check box on + * that position. + * + * @param i + * integer for the position in the vector * @return Positive examples check box on position i. */ - public JCheckBox getPositivJCheckBox(int i) - { + public JCheckBox getPositivJCheckBox(int i) { return positiv.get(i); } - + /** - * This method gets an integer to return the negative examples check box on that position. - * @param i integer for the position in the vector + * This method gets an integer to return the negative examples check box on + * that position. + * + * @param i + * integer for the position in the vector * @return Negative examples check box on position i. */ - public JCheckBox getNegativJCheckBox(int i) - { + public JCheckBox getNegativJCheckBox(int i) { return negativ.get(i); } - + /** - * This method resets the array of concepts from the DL_Learner. - * It is called after the DL-Learner tab is closed. + * This method resets the array of concepts from the DL_Learner. It is + * called after the DL-Learner tab is closed. */ - public void resetSuggestionList() - { - for(int i=0;i<description.length;i++) - { - description[i]=null; + public void resetSuggestionList() { + for (int i = 0; i < description.length; i++) { + description[i] = null; } } - + /** - * This method unchecks the checkboxes that are checked after the process - * of learning. + * This method unchecks the checkboxes that are checked after the process of + * learning. */ - public void unsetJCheckBoxen() - { - for(int j=0;j<positiv.size();j++) - { - if(positiv.get(j).isSelected()) - { - JCheckBox i = positiv.get(j); - i.setSelected(false); - positiv.set(j, i); - } - if(negativ.get(j).isSelected()) - { - JCheckBox i = negativ.get(j); - i.setSelected(false); - negativ.set(j, i); - } - } + public void unsetJCheckBoxen() { + for (int j = 0; j < positiv.size(); j++) { + // unselect all check poxes of the positive examples + if (positiv.get(j).isSelected()) { + JCheckBox i = positiv.get(j); + i.setSelected(false); + positiv.set(j, i); + } + // unselect all check boxes of the negative examples + if (negativ.get(j).isSelected()) { + JCheckBox i = negativ.get(j); + i.setSelected(false); + negativ.set(j, i); + } + } } /** - * This method resets the model for the suggest panel. - * It is called befor the DL-Learner learns the second time or when the - * DL-Learner tab is closed. + * This method resets the model for the suggest panel. It is called befor + * the DL-Learner learns the second time or when the DL-Learner tab is + * closed. */ - public void unsetListModel() - { - if(suggestModel!=null) - { + public void unsetListModel() { + if (suggestModel != null) { suggestModel.removeAllElements(); } } /** - * This method gets a description from the DL-Learner and adds is to the model from the suggest panel. - * @param desc Description from the DL-Learner + * This method gets a description from the DL-Learner and adds is to the + * model from the suggest panel. + * + * @param descript + * Description from the DL-Learner */ - public void setSuggestModel(Description desc) - { - suggestModel.add(0, desc); + public void setSuggestModel(Description descript) { + suggestModel.add(0, descript); } - + /** * This method returns the current OWLOntology that is loaded in protege. + * * @return current ontology */ - public OWLOntology getOWLOntology() - { + public OWLOntology getOWLOntology() { return ontology; } - + /** * This method returns a set of concepts that are learned by the DL-Learner. - * They are already converted into the OWLDescription format. + * They are already converted into the OWLDescription format. + * * @return Set of learned concepts in OWLDescription format */ - public Set<OWLDescription> getNewOWLDescription() - { - return OWLDescription; + public Set<OWLDescription> getNewOWLDescription() { + return owlDescription; } - + /** - * This method returns the old concept which is chosen in protege in OWLDescription format. + * This method returns the old concept which is chosen in protege in + * OWLDescription format. + * * @return Old Concept in OWLDescription format. */ - public OWLDescription getOldConceptOWLAPI() - { + public OWLDescription getOldConceptOWLAPI() { return oldConceptOWLAPI; } - + /** - * This method returns the currently learned description in OWLDescription format. + * This method returns the currently learned description in OWLDescription + * format. + * * @return currently used description in OWLDescription format */ - public OWLDescription getSolution() - { + public OWLDescription getSolution() { return desc; } - + /** * This method gets a description learned by the DL-Learner an converts it * to the OWLDescription format. - * @param desc Description learned by the DL-Learner + * + * @param desc + * Description learned by the DL-Learner */ - public void setNewConceptOWLAPI(Description desc) - { - newConceptOWLAPI = OWLAPIDescriptionConvertVisitor.getOWLDescription(desc); + private void setNewConceptOWLAPI(Description des) { + // converts DL-Learner description into an OWL API Description + newConceptOWLAPI = OWLAPIDescriptionConvertVisitor + .getOWLDescription(des); ds.add(newConceptOWLAPI); - OWLDescription.add(newConceptOWLAPI); + owlDescription.add(newConceptOWLAPI); this.desc = newConceptOWLAPI; } - + /** * This method gets the old concept from checking the positive examples. */ - public void setOldConceptOWLAPI() - { - SortedSet<Individual> indi=rs.getIndividuals(); - for(Iterator<Individual> i = indi.iterator(); i.hasNext();) - { + private void setOldConceptOWLAPI() { + // gets all individuals + SortedSet<Individual> indi = rs.getIndividuals(); + // Iterator of Individuals + for (Iterator<Individual> i = indi.iterator(); i.hasNext();) { Individual indi2 = i.next(); - if(positiveExamples.toString().contains(indi2.toString())) - { - Set<NamedClass> concept=reasoner.getConcepts(indi2); - for(Iterator<NamedClass> k = concept.iterator();k.hasNext();) - { - OWLDescription oldConceptOWLAPI = OWLAPIDescriptionConvertVisitor.getOWLDescription(k.next()); - ds.add(oldConceptOWLAPI); + // checks if the current individual belongs to positive examples + if (positiveExamples != null) { + if (positiveExamples.toString().contains(indi2.toString())) { + // if yes then get the concepts of this individuals + Set<NamedClass> concept = reasoner.getConcepts(indi2); + // adds all concepts to old concept OWLAPI + for (Iterator<NamedClass> k = concept.iterator(); k + .hasNext();) { + OWLDescription oldOWLAPI = OWLAPIDescriptionConvertVisitor + .getOWLDescription(k.next()); + ds.add(oldOWLAPI); + } + } - } } } - + /** - * This method stores the new concept learned by the DL-Learner in the Ontology. - * @param desc Description learn by the DL-Learner + * This method stores the new concept learned by the DL-Learner in the + * Ontology. + * + * @param descript + * Description learn by the DL-Learner */ - public void changeDLLearnerDescriptionsToOWLDescriptions(Description desc) - { - setNewConceptOWLAPI(desc); + public void changeDLLearnerDescriptionsToOWLDescriptions(Description descript) { + setNewConceptOWLAPI(descript); setOldConceptOWLAPI(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - + OWLDataFactory factory = manager.getOWLDataFactory(); - - axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); - - OWLOntology ontology = editor.getOWLModelManager().getActiveOntology(); - AddAxiom axiom = new AddAxiom(ontology, axiomOWLAPI); - System.out.println("axiom: "+axiomOWLAPI); + if (id.equals("Equivalent classes")) { + axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); + } else { + axiomOWLAPI = factory.getOWLSubClassAxiom(oldConceptOWLAPI, + newConceptOWLAPI); + } + OWLOntology onto = editor.getOWLModelManager().getActiveOntology(); + AddAxiom axiom = new AddAxiom(onto, axiomOWLAPI); try { + // adds the new concept to the ontology manager.applyChange(axiom); } catch (OWLOntologyChangeException e) { // TODO Auto-generated catch block e.printStackTrace(); - } - } - + + } + /** * This method returns the currently used reasoning service. + * * @return current reasoning service */ - public ReasoningService getReasoningService() - { + public ReasoningService getReasoningService() { return rs; } - + /** - * This method gets the status if the DL-Learner has already learned. - * It is only for reseting the suggest panel. + * This method gets the status if the DL-Learner has already learned. It is + * only for reseting the suggest panel. + * * @return boolean if the learner has already learned */ - public boolean getAlreadyLearned() - { + public boolean getAlreadyLearned() { return alreadyLearned; - } - -} \ No newline at end of file + } + + public URI getURI() { + return editor.getOWLModelManager().getActiveOntology().getURI(); + } +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2008-08-14 09:50:45 UTC (rev 1069) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/MANIFEST.MF 2008-08-14 12:07:43 UTC (rev 1070) @@ -1,12 +1,12 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: Hallo Welt +Bundle-Name: DL-Learner Plugin Bundle-SymbolicName: org.dllearner.tools.protege;singleton:=true Bundle-Category: protege Bundle-Description: blablabla Bundle-Vendor: blablabla Bundle-DocURL: blablabla -Bundle-ClassPath: .,lib/junit-4.4.jar,lib/pellet/pellet.jar,lib/pellet/aterm-java-1.6.jar,lib/jena/json.jar,lib/pellet/relaxngDatatype.jar,lib/pellet/xsdlib.jar,lib/jena/commons-logging-1.1.jar +Bundle-ClassPath: .,lib/junit-4.4.jar,lib/jamon-2.7.jar,lib/pellet/pellet.jar,lib/pellet/aterm-java-1.6.jar,lib/jena/json.jar,lib/pellet/relaxngDatatype.jar,lib/pellet/xsdlib.jar,lib/jena/commons-logging-1.1.1.jar,lib/ore-tool/swingx-0.9.2.jar Import-Package: org.osgi.framework,org.apache.log4j Export-Package: lib Bundle-Version: 1.0.0 Modified: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml 2008-08-14 09:50:45 UTC (rev 1069) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml 2008-08-14 12:07:43 UTC (rev 1070) @@ -2,7 +2,7 @@ <plugin> <extension id="org.dllearner.tools.protege.ProtegePlugin" point="org.protege.editor.core.application.ViewComponent"> - <label value="Hallo Welt"/> + <label value="DL-Learner Plugin"/> <class value="org.dllearner.tools.protege.ProtegePlugin"/> <headerColor value="@org.protege.classcolor"/> <category value="@org.protege.classcategory"/> Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-08-14 09:50:45 UTC (rev 1069) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-08-14 12:07:43 UTC (rev 1070) @@ -1,161 +1,209 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.tools.protege; +import java.awt.GridLayout; +import java.awt.Color; + import java.util.Iterator; -import java.util.List; +import javax.swing.JDialog; +import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JLabel; +import javax.swing.JScrollPane; import javax.swing.JTextArea; -import javax.swing.JScrollPane; -import javax.swing.JDialog; import javax.swing.WindowConstants; -import java.awt.GridLayout; - import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; -public class MoreDetailForSuggestedConceptsPanel extends JPanel{ +/** + * This class shows more details of the suggested concepts. It shows the positive and negative examples + * that are covered and that are not covered by the suggested concepts. It also shows the accuracya of the + * selected concept. + * @author Christian Koetteritzsch + * + */ +public class MoreDetailForSuggestedConceptsPanel extends JPanel { private static final long serialVersionUID = 785272797932584581L; - + + // Model of the dllearner + private DLLearnerModel model; + // Textarea to render the accuracy of the concept + private JTextArea accuracy; - private JPanel accuracyPanel; + // Label for the positive examples that are covered by the concept + private JLabel coveredPositiveExamples; + + // Label for the negative examples that are covered by the concept + private JLabel coveredNegativeExamples; + + // Label for the positive examples that are not covered by the concept + private JLabel notCoveredPositiveExamples; + + // Label for the negative examples that are not covered by the concept + private JLabel notCoveredNegativeExamples; + + // Pop up panel for the informations of the selected concept + private JDialog detailPopup; + + // Panel where the informations of the selected panel are rendered + private JPanel examplePanel; + + // Text area that shows the covered positive examples + private JTextArea posCoveredText; + + // Text area that shows the positive examples that are not covered by the selected concept + private JTextArea posNotCoveredText; + + // Text area that shows the covered negative examples + private JTextArea negCoveredText; + + // Text area that shows the negative examples that are not covered by the selected concept + private JTextArea negNotCoveredText; + + // Text area that shows the accurcy of the selected concept + private JTextArea accuracyText; + + // Scroll pane if scroll bar is necessary to show all covered examples + private JScrollPane detailScroll; - private JPanel detailPanel; - - public MoreDetailForSuggestedConceptsPanel(DLLearnerModel model) - { + // Evaluated description of the selected concept + + private EvaluatedDescription eval; + private final Color colorRed = Color.red; + private final Color colorGreen = Color.green; + /** + * This is the constructor for the Panel. + * @param model DLLearnerModel + */ + public MoreDetailForSuggestedConceptsPanel(DLLearnerModel model) { this.model = model; } - - public JDialog getMoreDialog() - { + /** + * This method returns the Detail Panel. + * @return DetailPanel + */ + public JDialog getMoreDialog() { return detailPopup; } - public JScrollPane getDetailScrollPane() - { - return detailScroll; - } - private EvaluatedDescription getSelectedConcept(Description eval) - { - List<EvaluatedDescription> evalDesc = model.getEvaluatedDescriptionList(); - EvaluatedDescription eDesc = null; - - for(Iterator<EvaluatedDescription> i = evalDesc.iterator(); i.hasNext();) - { - if(eDesc==null) - { - EvaluatedDescription e = i.next(); - System.out.println("Description: "+e.getDescription()); - System.out.println("Description2: "+eval); - if(e.getDescription().toString().equals(eval.toString())) - { - eDesc = e; - } - - } - } - return eDesc; - } - - public void renderDetailPanel(Description desc) - { - EvaluatedDescription eval = getSelectedConcept(desc); - System.out.println("Eval: "+eval); - accuracyPanel = new JPanel(new GridLayout(0,2)); + + /** + * This method renders the output for the detail panel. + * @param desc selected description + */ + public void renderDetailPanel(EvaluatedDescription desc) { + eval = desc; accuracy = new JTextArea("Accuracy:"); accuracy.setEditable(false); - accuracyPanel.add(accuracy); posCoveredText = new JTextArea(); + posCoveredText.setForeground(colorGreen); + //sets covered positive examples text area not editable posCoveredText.setEditable(false); posNotCoveredText = new JTextArea(); + posNotCoveredText.setForeground(colorRed); + //sets not covered positive examples text area not editable posNotCoveredText.setEditable(false); negCoveredText = new JTextArea(); + negCoveredText.se... [truncated message content] |
From: <hee...@us...> - 2008-09-09 07:34:31
|
Revision: 1180 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1180&view=rev Author: heeroyuy Date: 2008-09-09 07:34:25 +0000 (Tue, 09 Sep 2008) Log Message: ----------- warnings fixed Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -786,7 +786,10 @@ public boolean getAlreadyLearned() { return alreadyLearned; } - + /** + * This Method returns the URI of the currently loaded Ontology. + * @return URI Ontology URI + */ public URI getURI() { return editor.getOWLModelManager().getActiveOntology().getURI(); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -91,7 +91,13 @@ handleVerifyEditorContents(); } }; - + /** + * Konstruktor of the Class Description Editor with integrated DL-Learner Tab. + * @param editorKit OWLEditorKit + * @param description OWLDescription + * @param frame OWLFrame + * @param label String + */ public OWLClassDescriptionEditorWithDLLearnerTab(OWLEditorKit editorKit, OWLDescription description, OWLFrame<OWLClass> frame, String label) { this.editorKit = editorKit; @@ -160,7 +166,10 @@ } return validated; } - + /** + * Returns Editor Component. + * @return JComponent + */ public JComponent getInlineEditorComponent() { // Same as general editor component return editingComponent; @@ -174,7 +183,9 @@ public JComponent getEditorComponent() { return editingComponent; } - + /** + * Removes everything after closing the Class Description Editor. + */ public void clear() { dllearner.unsetEverything(); dllearner.makeView(); @@ -182,7 +193,10 @@ // initialDescription = null; editor.setText(""); } - + /** + * returns the edited Components. + * @return Set of OWLDescriptions + */ public Set<OWLDescription> getEditedObjects() { if (tabbedPane.getSelectedComponent() == classSelectorPanel) { return new HashSet<OWLDescription>(classSelectorPanel @@ -216,7 +230,9 @@ return null; } } - + /** + * Removes everything after protege is closed. + */ public void dispose() { if (classSelectorPanel != null) { classSelectorPanel.dispose(); @@ -232,14 +248,22 @@ private OWLDataFactory getDataFactory() { return editorKit.getOWLModelManager().getOWLDataFactory(); } - + /** + * Adds a Status Changed Listener to all components of the + * class description editor. + * @param listener InputVerificationStatusChangedListener + */ public void addStatusChangedListener( InputVerificationStatusChangedListener listener) { listeners.add(listener); editor.addStatusChangedListener(listener); listener.verifiedStatusChanged(isValidated()); } - + /** + * Removes the Status Changed Listener from all components of the + * class description editor. + * @param listener InputVerificationStatusChangedListener + */ public void removeStatusChangedListener( InputVerificationStatusChangedListener listener) { listeners.remove(listener); @@ -563,7 +587,11 @@ } } - + /** + * This is the class for the object restriktion creator panel. + * + * + */ private class ObjectRestrictionCreatorPanel extends JPanel { @@ -703,7 +731,11 @@ classSelectorPanel.dispose(); } } - + /** + * This is the abstract class of the restriction creator. + * + * + */ private abstract class RestrictionCreator { private String name; @@ -719,7 +751,11 @@ abstract void createRestrictions(Set<OWLObjectProperty> properties, Set<OWLDescription> fillers, Set<OWLDescription> result); } - + /** + * This is the abstract class for the cardinality restriction creator. + * + * + */ private abstract class CardinalityRestrictionCreator extends RestrictionCreator { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -59,7 +59,11 @@ private boolean inferredEquivalentClasses = true; private OWLFrame<OWLClass> frame; - + /** + * Constructor of the OWLEquivalentClassesAxiomFrameSection. + * @param editorKit OWLEditorKit + * @param frame OWLFrame + */ public OWLEquivalentClassesAxiomFrameSection(OWLEditorKit editorKit, OWLFrame<OWLClass> frame) { super(editorKit, LABEL, frame); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -56,7 +56,11 @@ private Set<OWLDescription> added = new HashSet<OWLDescription>(); private OWLFrame<OWLClass> frame; - + /** + * Constructor of the OWLSubClassesAxiomFrameSection. + * @param editorKit OWLEditorKit + * @param frame OWLFrame + */ public OWLSubClassAxiomFrameSection(OWLEditorKit editorKit, OWLFrame<OWLClass> frame) { super(editorKit, LABEL, frame); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -67,4 +67,4 @@ public void disposeView() { list.dispose(); } -} \ No newline at end of file +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-09-08 17:59:49 UTC (rev 1179) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-09-09 07:34:25 UTC (rev 1180) @@ -2,7 +2,7 @@ * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. - * + * * DL-Learner is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -99,9 +99,5 @@ public void addSuggestPanelMouseListener(ActionHandler action) { descriptions.addMouseListener(action); - } - - - - -} \ No newline at end of file + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-09-17 02:00:07
|
Revision: 1225 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1225&view=rev Author: heeroyuy Date: 2008-09-17 08:59:58 +0000 (Wed, 17 Sep 2008) Log Message: ----------- some warnings fixed Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-09-17 08:15:45 UTC (rev 1224) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-09-17 08:59:58 UTC (rev 1225) @@ -253,8 +253,7 @@ eDescription = i.next(); if (desc.equals(eDescription.getDescription() .toManchesterSyntaxString( - editorKit.getOWLModelManager() - .getActiveOntology().getURI() + editorKit.getModelManager().getActiveOntology().getURI() + "#", null))) { evaluatedDescription = eDescription; break; Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java 2008-09-17 08:15:45 UTC (rev 1224) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ButtonList.java 2008-09-17 08:59:58 UTC (rev 1225) @@ -41,7 +41,7 @@ * @param editorKit EditorKit from Protege */ public ButtonList(OWLEditorKit editorKit) { - super(editorKit.getOWLModelManager().getOWLOntologyManager()); + super(editorKit.getModelManager().getOWLOntologyManager()); // own OWLEquivalentClassesAxiomFrameSection to add the dllearner plugin // to the // OWLClassDescritpionEditor Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-09-17 08:15:45 UTC (rev 1224) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-09-17 08:59:58 UTC (rev 1225) @@ -113,8 +113,8 @@ // This is the count of Concepts which you get after learning // TODO make those configurable via user interface - private static final int nrOfDisplayedDescriptions = 6; - private static final double minAccuracy = 0.8; + private static final int NR_OF_DISPLAYED_DESCRIPTIONS = 6; + private static final double MIN_ACCURACY = 0.8; // A Array of Concepts which the DL-Learner suggested @@ -265,11 +265,11 @@ * This method adds the solutions from the DL-Learner to the List Model. */ private void addToListModel() { - evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(nrOfDisplayedDescriptions, minAccuracy, true); + evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(NR_OF_DISPLAYED_DESCRIPTIONS, MIN_ACCURACY, true); for (int j = 0; j < evalDescriptions.size(); j++) { suggestModel.add(j, evalDescriptions.get(j) .getDescription().toManchesterSyntaxString( - editor.getOWLModelManager().getActiveOntology() + editor.getModelManager().getActiveOntology() .getURI().toString() + "#", null)); } @@ -326,7 +326,7 @@ * OWLAPIOntology will be available. */ public void setKnowledgeSource() { - this.source = new OWLAPIOntology(editor.getOWLModelManager() + this.source = new OWLAPIOntology(editor.getModelManager() .getActiveOntology()); } @@ -404,7 +404,7 @@ // start the algorithm and print the best concept found la.start(); description = new Description[la.getCurrentlyBestEvaluatedDescriptions( - nrOfDisplayedDescriptions).size()]; + NR_OF_DISPLAYED_DESCRIPTIONS).size()]; addToListModel(); // renders the errormessage view.renderErrorMessage(error); @@ -757,7 +757,7 @@ axiomOWLAPI = factory.getOWLSubClassAxiom(oldConceptOWLAPI, newConceptOWLAPI); } - OWLOntology onto = editor.getOWLModelManager().getActiveOntology(); + OWLOntology onto = editor.getModelManager().getActiveOntology(); AddAxiom axiom = new AddAxiom(onto, axiomOWLAPI); try { // adds the new concept to the ontology @@ -792,6 +792,6 @@ * @return URI Ontology URI */ public URI getURI() { - return editor.getOWLModelManager().getActiveOntology().getURI(); + return editor.getModelManager().getActiveOntology().getURI(); } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-09-17 08:15:45 UTC (rev 1224) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-09-17 08:59:58 UTC (rev 1225) @@ -25,7 +25,7 @@ import org.protege.editor.owl.OWLEditorKit; import org.protege.editor.owl.ui.frame.AbstractOWLFrameSectionRowObjectEditor; import org.protege.editor.owl.ui.clsdescriptioneditor.ExpressionEditor; -import org.protege.editor.owl.ui.clsdescriptioneditor.OWLDescriptionChecker; +//import org.protege.editor.owl.ui.clsdescriptioneditor.OWLDescriptionChecker; import org.protege.editor.owl.ui.selector.OWLClassSelectorPanel; import org.protege.editor.owl.ui.selector.OWLObjectPropertySelectorPanel; import org.semanticweb.owl.model.OWLDataFactory; @@ -67,7 +67,7 @@ private OWLEditorKit editorKit; - private OWLDescriptionChecker checker; + //private OWLDescriptionChecker checker; private ExpressionEditor<OWLDescription> editor; @@ -219,7 +219,7 @@ try { if (editor.isWellFormed()) { String expression = editor.getText(); - return editorKit.getOWLModelManager().getOWLDescriptionParser() + return editorKit.getModelManager().getOWLDescriptionParser() .createOWLDescription(expression); } if (!dllearner.getSollutions().isEmpty()) { @@ -230,6 +230,7 @@ } catch (OWLException e) { return null; } + } /** * Removes everything after protege is closed. @@ -247,7 +248,7 @@ } private OWLDataFactory getDataFactory() { - return editorKit.getOWLModelManager().getOWLDataFactory(); + return editorKit.getModelManager().getOWLDataFactory(); } /** * Adds a Status Changed Listener to all components of the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-10-07 10:10:12
|
Revision: 1346 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1346&view=rev Author: heeroyuy Date: 2008-10-07 10:05:51 +0000 (Tue, 07 Oct 2008) Log Message: ----------- -some gui changes -add options to chose maxEcecutionTime, maxNrOfResults and minAccuracy Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-06 16:46:14 UTC (rev 1345) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-07 10:05:51 UTC (rev 1346) @@ -27,6 +27,8 @@ import java.awt.event.MouseListener; import java.util.Iterator; +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -40,7 +42,7 @@ * */ public class ActionHandler implements ActionListener, ItemListener, - MouseListener, ListSelectionListener { + MouseListener, ListSelectionListener, ListDataListener { // This is the DLLearnerModel. @@ -91,6 +93,11 @@ */ public void actionPerformed(ActionEvent z) { + + if(z.getActionCommand().equals("comboBoxChanged")) { + view.getPosAndNegSelectPanel().setOptionSpinner(); + } + if (z.getActionCommand().equals("Suggest " + id)) { if (model.getAlreadyLearned()) { model.unsetListModel(); @@ -108,22 +115,11 @@ this.dlLearner = new Thread(model); dlLearner.start(); view.getRunButton().setEnabled(false); - view.getCancelButton().setEnabled(true); view.renderErrorMessage("Learning started"); view.getPosAndNegSelectPanel().unsetCheckBoxes(); } } - if (z.getActionCommand().equals("Cancel")) { - view.getRunButton().setEnabled(true); - view.getCancelButton().setEnabled(false); - String error = "Learning aborted"; - view.renderErrorMessage(error); - dlLearner.interrupt(); - model.getLearningAlgorithm().stop(); - model.setErrorMessage(error); - } - if (z.getActionCommand().equals("ADD")) { if (evaluatedDescription != null) { model @@ -311,4 +307,22 @@ toggled = false; } + @Override + public void contentsChanged(ListDataEvent listEvent) { + System.out.println(listEvent); + + } + + @Override + public void intervalAdded(ListDataEvent listEvent) { + // TODO Auto-generated method stub + + } + + @Override + public void intervalRemoved(ListDataEvent listEvent) { + // TODO Auto-generated method stub + + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-10-06 16:46:14 UTC (rev 1345) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-10-07 10:05:51 UTC (rev 1346) @@ -112,9 +112,6 @@ // This is the count of Concepts which you get after learning - // TODO make those configurable via user interface - private static final int NR_OF_DISPLAYED_DESCRIPTIONS = 6; - private static final double MIN_ACCURACY = 0.8; // A Array of Concepts which the DL-Learner suggested @@ -265,7 +262,7 @@ * This method adds the solutions from the DL-Learner to the List Model. */ private void addToListModel() { - evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(NR_OF_DISPLAYED_DESCRIPTIONS, MIN_ACCURACY, true); + evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getMaxNrOfResultsModelData(), view.getPosAndNegSelectPanel().getMinAccuracyModelData(), true); for (int j = 0; j < evalDescriptions.size(); j++) { suggestModel.add(j, evalDescriptions.get(j) .getDescription().toManchesterSyntaxString( @@ -387,6 +384,7 @@ } cm.applyConfigEntry(la, "numberOfTrees", 100); cm.applyConfigEntry(la, "maxDepth", 5); + cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getMaxExecutionModelData()); try { // initializes the learning algorithm la.init(); @@ -404,14 +402,13 @@ // start the algorithm and print the best concept found la.start(); description = new Description[la.getCurrentlyBestEvaluatedDescriptions( - NR_OF_DISPLAYED_DESCRIPTIONS).size()]; + view.getPosAndNegSelectPanel().getMaxNrOfResultsModelData()).size()]; addToListModel(); // renders the errormessage view.renderErrorMessage(error); // reenables the run button view.getRunButton().setEnabled(true); // disables the cancel button - view.getCancelButton().setEnabled(false); view.getSuggestClassPanel().setSuggestList(suggestModel); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-06 16:46:14 UTC (rev 1345) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-07 10:05:51 UTC (rev 1346) @@ -305,10 +305,6 @@ private final Color colorRed = Color.red; - // Cancel button to abort the learning algorithm - - private JButton cancel; - // This is the text area for the error message when an error occurred private JTextArea errorMessage; @@ -338,7 +334,7 @@ private ImageIcon icon; // Picture of the advanced button when it is toggled - + private JPanel addButtonPanel; private ImageIcon toggledIcon; private JTextArea hint; // This is the Panel for more details of the suggested concept @@ -366,9 +362,8 @@ advanced = new JToggleButton(icon); advanced.setVisible(true); run = new JButton("Suggest " + label); - cancel = new JButton("Cancel"); accept = new JButton("ADD"); - // why = new JButton("Why"); + addButtonPanel = new JPanel(new BorderLayout()); sugPanel.addSuggestPanelMouseListener(action); errorMessage = new JTextArea(); errorMessage.setEditable(false); @@ -384,7 +379,6 @@ posPanel = new PosAndNegSelectPanel(model, action); addAcceptButtonListener(this.action); addRunButtonListener(this.action); - addCancelButtonListener(this.action); addAdvancedButtonListener(this.action); } @@ -410,32 +404,31 @@ advanced.setIcon(icon); model.clearVector(); model.unsetListModel(); - model.initReasoner(); + //model.initReasoner(); model.setPosVector(); - posPanel.setJCheckBoxen(); - cancel.setEnabled(false); + posPanel.setJCheckBoxes(); accept.setEnabled(false); action.resetToggled(); + addButtonPanel.add("North", accept); sugPanel.setSuggestList(model.getSuggestList()); sugPanel = sugPanel.updateSuggestClassList(); advanced.setSelected(false); - sugPanel.setBounds(10, 40, 490, 110); + sugPanel.setBounds(10, 35, 490, 110); adv.setBounds(40, 200, 200, 20); + addButtonPanel.setBounds(510, 40, 80, 110); run.setBounds(10, 0, 200, 30); advanced.setBounds(10, 200, 20, 20); sugPanel.setVisible(true); posPanel.setVisible(false); posPanel.setBounds(10, 230, 490, 250); - cancel.setBounds(260, 0, 200, 30); accept.setBounds(510, 40, 80, 110); hint.setBounds(10, 150, 490, 20); errorMessage.setBounds(10, 170, 490, 20); learner.add(run); learner.add(adv); learner.add(advanced); - learner.add(cancel); learner.add(sugPanel); - learner.add(accept); + learner.add(addButtonPanel); learner.add(hint); learner.add(errorMessage); learner.add(posPanel); @@ -542,14 +535,6 @@ } /** - * This method returns the cancel button. - * @return JButton - */ - public JButton getCancelButton() { - return cancel; - } - - /** * Destroys the view after the plugin is closed. */ public void dispose() { @@ -565,14 +550,6 @@ } /** - * Adds Actionlistener to the cancel button. - * @param a ActionListener - */ - public void addCancelButtonListener(ActionListener a) { - cancel.addActionListener(a); - } - - /** * Adds Actionlistener to the add button. * @param a ActionListener */ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-10-06 16:46:14 UTC (rev 1345) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-10-07 10:05:51 UTC (rev 1346) @@ -25,11 +25,14 @@ import java.awt.GridLayout; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JSpinner; import javax.swing.JTextArea; +import javax.swing.SpinnerNumberModel; import javax.swing.WindowConstants; /** @@ -94,6 +97,14 @@ // This is the frame that pops up when the help button is pressed. private JDialog assistPanel; + private JComboBox optionBox; + private JPanel optionBoxPanel; + private JPanel spinnerPanel; + private SpinnerNumberModel minAccuracyModel; + private SpinnerNumberModel maxNrOfResultsModel; + private SpinnerNumberModel maxExecutionModel; + private JSpinner optionSpinner; + private ActionHandler action; private final Color colorBlack = Color.black; /** @@ -101,21 +112,37 @@ * * @param model * DLLearnerModel - * @param action + * @param act * ActionHandler */ - public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler action) { + public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act) { super(); pos = new JLabel("Positive Examples"); neg = new JLabel("Negative Examples"); + optionBoxPanel = new JPanel(new GridLayout(0, 1)); + spinnerPanel = new JPanel(new GridLayout(0, 1)); + action = act; + minAccuracyModel = new SpinnerNumberModel(0.8, 0.0 , 1.0, 0.05); + maxNrOfResultsModel = new SpinnerNumberModel(5.0, 1.0 , 20.0, 1.0); + maxExecutionModel = new SpinnerNumberModel(10.0, 1.0 , 60.0, 1.0); + optionBox = new JComboBox(); + optionSpinner = new JSpinner(); + optionSpinner.setModel(minAccuracyModel); + optionBox.addItem("min. Accuracy"); + optionBox.addItem("max. Nr. of Results"); + optionBox.addItem("max. Executiontime"); + optionBoxPanel.add(optionBox); + spinnerPanel.add(optionSpinner); + setComboBoxListener(); + spinnerPanel.setSize(50, 20); // help button for positive examples helpForPosExamples = new JButton("?"); helpForPosExamples.setSize(10, 10); // help button for negative examples helpForNegExamples = new JButton("?"); helpForNegExamples.setSize(10, 10); - posLabelPanel = new JPanel(); - negLabelPanel = new JPanel(); + posLabelPanel = new JPanel(new GridLayout(0, 1)); + negLabelPanel = new JPanel(new GridLayout(0, 1)); // panel for the positive check boxes with flow layout posLabelPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); // panel for the negative check boxes with flow layout @@ -137,6 +164,7 @@ model.clearVector(); model.unsetListModel(); model.initReasoner(); + model.setPosVector(); posAndNegPanel = new JPanel(new GridLayout(0, 1)); posAndNegPanel.add(posAndNegSelectPanel); @@ -153,7 +181,9 @@ * This method adds the check boxes, the labels and the help buttons for * positive and negative examples. */ - public void setJCheckBoxen() { + public void setJCheckBoxes() { + posAndNegSelectPanel.add(optionBoxPanel); + posAndNegSelectPanel.add(spinnerPanel); posAndNegSelectPanel.add(posLabelPanel); posAndNegSelectPanel.add(negLabelPanel); // adds check boxes for all examples of the ontology @@ -165,8 +195,60 @@ } } - + /** + * This Methode returns the min Accuracy that the concepts must have. + * @return min accuracy + */ + public float getMinAccuracyModelData() { + float minAccuracy = Float.valueOf(minAccuracyModel.getValue().toString()).floatValue(); + return minAccuracy; + } + + /** + * This Methode returns the max nr. of results selected in the option Panel. + * @return Max Nr. of Results + */ + public int getMaxNrOfResultsModelData() { + float maxNrOfRes = Float.valueOf(maxNrOfResultsModel.getValue().toString()).floatValue(); + int maxNrOfResults = Math.round(maxNrOfRes); + return maxNrOfResults; + } + + /** + * This Methode returns the max execution time selected in the Panel. + * @return Max Execution Time in seconds + */ + public int getMaxExecutionModelData() { + float maxExe = Float.valueOf(maxExecutionModel.getValue().toString()).floatValue(); + int maxExecution = Math.round(maxExe); + return maxExecution; + } + + /** + * This method adds the ActionListener to the Option Combo Box. + */ + private void setComboBoxListener() { + optionBox.addActionListener(action); + } + /** + * This Methode sets the right Spinner for the selected Option. + */ + public void setOptionSpinner() { + if(optionBox.getSelectedItem().equals("min. Accuracy")) { + optionSpinner.setModel(minAccuracyModel); + } + + if(optionBox.getSelectedItem().equals("max. Nr. of Results")) { + optionSpinner.setModel(maxNrOfResultsModel); + } + + if(optionBox.getSelectedItem().equals("max. Executiontime")) { + optionSpinner.setModel(maxExecutionModel); + } + + } + /** * This method removes the Check boxes, the labels and the help buttons * after the DL-Learner tab is closed. */ @@ -177,16 +259,16 @@ /** * This method adds the item listener for every check box. * - * @param action + * @param act * ActionHandler */ - public void addListeners(ActionHandler action) { + public void addListeners(ActionHandler act) { // adds the listener for the checkboxes for (int i = 0; i < model.getPosVector().size(); i++) { // listener for the check boxes of the positive examples - model.getPositivJCheckBox(i).addItemListener(action); + model.getPositivJCheckBox(i).addItemListener(act); // listener for the check boxes of the negative examples - model.getNegativJCheckBox(i).addItemListener(action); + model.getNegativJCheckBox(i).addItemListener(act); } } @@ -223,7 +305,7 @@ assistPanel = new JDialog(); // no writing in the help panel is allowed help.setEditable(false); - assistPanel.setName("Hilfe"); + assistPanel.setName("help"); assistPanel.setSize(300, 100); // window will be disposed if the x or the ok button is pressed assistPanel.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-10-06 16:46:14 UTC (rev 1345) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-10-07 10:05:51 UTC (rev 1346) @@ -19,6 +19,7 @@ */ package org.dllearner.tools.protege; +import java.awt.Color; import java.awt.Dimension; import javax.swing.*; @@ -82,6 +83,7 @@ * @param desc List model of descriptions made by the DL-Learner */ public void setSuggestList(DefaultListModel desc) { + descriptions.setForeground(Color.GREEN); descriptions.setModel(desc); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-10-15 09:11:31
|
Revision: 1376 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1376&view=rev Author: heeroyuy Date: 2008-10-15 09:10:58 +0000 (Wed, 15 Oct 2008) Log Message: ----------- -add double click listener -add name of the concept to the detail panel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-13 15:56:08 UTC (rev 1375) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-15 09:10:58 UTC (rev 1376) @@ -93,7 +93,7 @@ */ public void actionPerformed(ActionEvent z) { - + System.out.println("Doppelklick?: "+ z); if(z.getActionCommand().equals("comboBoxChanged")) { view.getPosAndNegSelectPanel().setOptionSpinner(); } @@ -257,22 +257,10 @@ } } - System.out.println("old: " + oldEvaluatedDescription); - if (oldEvaluatedDescription != null) { - - if (oldEvaluatedDescription != evaluatedDescription) { - counter = 0; - } - counter++; - } else { - counter++; - } - if (counter == 2) { - counter = 0; + if(m.getClickCount()==2) { view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel( evaluatedDescription); } - System.out.println("Counter: " + counter); } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-10-13 15:56:08 UTC (rev 1375) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-10-15 09:10:58 UTC (rev 1376) @@ -103,6 +103,8 @@ private EvaluatedDescription eval; private final Color colorRed = Color.red; + private JTextArea concept; + private JTextArea conceptText; private final Color colorGreen = Color.green; /** * This is the constructor for the Panel. @@ -126,8 +128,11 @@ */ public void renderDetailPanel(EvaluatedDescription desc) { eval = desc; + accuracy = new JTextArea("Accuracy:"); accuracy.setEditable(false); + conceptText = new JTextArea(); + conceptText.setEditable(false); posCoveredText = new JTextArea(); posCoveredText.setForeground(colorGreen); //sets covered positive examples text area not editable @@ -151,6 +156,8 @@ examplePanel = new JPanel(new GridLayout(0, 2)); //this method adds the informations for the selected concept to the panel setInformation(); + concept = new JTextArea("Concept:"); + concept.setEditable(false); coveredPositiveExamples = new JLabel("Covered Positive Examples:"); coveredPositiveExamples.setForeground(colorGreen); notCoveredPositiveExamples = new JLabel("Not Covered Positive Examples"); @@ -167,6 +174,8 @@ detailPopup.setResizable(false); detailScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); //adds all information to the example panel + examplePanel.add(concept); + examplePanel.add(conceptText); examplePanel.add(accuracy); examplePanel.add(accuracyText); examplePanel.add(coveredPositiveExamples); @@ -186,6 +195,7 @@ private void setInformation() { if(eval!=null) { //sets the accuracy of the selected concept + conceptText.append(eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#",null)); double acc = (eval.getAccuracy())*100; accuracyText.append(String.valueOf(acc)+"%"); //sets the positive examples that are covered Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-13 15:56:08 UTC (rev 1375) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-15 09:10:58 UTC (rev 1376) @@ -373,7 +373,7 @@ learner.setPreferredSize(new Dimension(600, 520)); accept.setPreferredSize(new Dimension(290, 50)); advanced.setName("Advanced"); - posPanel = new PosAndNegSelectPanel(model, action); + posPanel = new PosAndNegSelectPanel(model, action, this); addAcceptButtonListener(this.action); addRunButtonListener(this.action); addAdvancedButtonListener(this.action); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-10-13 15:56:08 UTC (rev 1375) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-10-15 09:10:58 UTC (rev 1376) @@ -105,6 +105,7 @@ private SpinnerNumberModel maxExecutionModel; private JSpinner optionSpinner; private ActionHandler action; + private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; private final Color colorBlack = Color.black; /** @@ -115,9 +116,10 @@ * @param act * ActionHandler */ - public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act) { + public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView window) { super(); pos = new JLabel("Positive Examples"); + view = window; neg = new JLabel("Negative Examples"); optionBoxPanel = new JPanel(new GridLayout(0, 1)); spinnerPanel = new JPanel(new GridLayout(0, 1)); @@ -317,6 +319,7 @@ scrollHelp.setViewportView(help); scrollHelp.setBounds(0, 0, 300, 100); assistPanel.add(scrollHelp); + assistPanel.setLocationRelativeTo(view); } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-10-13 15:56:08 UTC (rev 1375) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-10-15 09:10:58 UTC (rev 1376) @@ -95,11 +95,13 @@ } /** - * this method adds the suggest list to the Mouse Listener. + * This method adds the suggest list to the Mouse Listener. * @param action ActionHandler */ public void addSuggestPanelMouseListener(ActionHandler action) { descriptions.addMouseListener(action); - } + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-10-15 10:12:21
|
Revision: 1377 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1377&view=rev Author: heeroyuy Date: 2008-10-15 10:12:15 +0000 (Wed, 15 Oct 2008) Log Message: ----------- -new images for the advanced button -put helpmessages on a JOptionPane instead of an new JPanel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/arrow.gif trunk/src/dl-learner/org/dllearner/tools/protege/arrow2.gif Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/protege/pfeil.gif trunk/src/dl-learner/org/dllearner/tools/protege/pfeil2.gif Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-15 09:10:58 UTC (rev 1376) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-15 10:12:15 UTC (rev 1377) @@ -59,8 +59,6 @@ private EvaluatedDescription evaluatedDescription; // This is the view of the DL-Learner tab. private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; - private int counter; - private EvaluatedDescription oldEvaluatedDescription; /** * This is the constructor for the action handler. @@ -81,7 +79,6 @@ this.editorKit = editor; this.view = view; this.id = i; - counter = 0; this.model = m; toggled = false; @@ -92,8 +89,6 @@ * @param z ActionEvent */ public void actionPerformed(ActionEvent z) { - - System.out.println("Doppelklick?: "+ z); if(z.getActionCommand().equals("comboBoxChanged")) { view.getPosAndNegSelectPanel().setOptionSpinner(); } @@ -240,7 +235,6 @@ */ public void mouseClicked(MouseEvent m) { EvaluatedDescription eDescription = null; - oldEvaluatedDescription = evaluatedDescription; String desc = view.getSuggestClassPanel().getSuggestList() .getSelectedValue().toString(); if (model.getEvaluatedDescriptionList() != null) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-10-15 09:10:58 UTC (rev 1376) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-10-15 10:12:15 UTC (rev 1377) @@ -763,7 +763,6 @@ // TODO Auto-generated catch block e.printStackTrace(); } - } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-15 09:10:58 UTC (rev 1376) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-15 10:12:15 UTC (rev 1377) @@ -102,7 +102,7 @@ //checker = new OWLDescriptionChecker(editorKit); editor = new ExpressionEditor<OWLDescription>(editorKit, editorKit.getModelManager().getOWLExpressionCheckerFactory().getOWLDescriptionChecker()); editor.setExpressionObject(description); - dllearner = new DLLearnerView(frame, label); + dllearner = new DLLearnerView(frame, label, this); action = new ActionHandler(this.action, null, dllearner, null, editorKit); tabbedPane = new JTabbedPane(); @@ -279,7 +279,7 @@ public class DLLearnerView extends JPanel { private static final long serialVersionUID = 624829578325729385L; - + private OWLClassDescriptionEditorWithDLLearnerTab mainWindow; // this is the Component which shows the view of the dllearner private JComponent learner; @@ -344,12 +344,13 @@ * @param current OWLFrame * @param label String */ - public DLLearnerView(OWLFrame<OWLClass> current, String label) { + public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab tab) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); + mainWindow = tab; classSelectorPanel.firePropertyChange("test", false, true); - URL iconUrl = this.getClass().getResource("pfeil.gif"); + URL iconUrl = this.getClass().getResource("arrow.gif"); icon = new ImageIcon(iconUrl); - URL toggledIconUrl = this.getClass().getResource("pfeil2.gif"); + URL toggledIconUrl = this.getClass().getResource("arrow2.gif"); toggledIcon = new ImageIcon(toggledIconUrl); model = new DLLearnerModel(editorKit, current, label, this); sugPanel = new SuggestClassPanel(); @@ -393,8 +394,16 @@ public PosAndNegSelectPanel getPosAndNegSelectPanel() { return posPanel; } - + /** + * Returns the Mainwindow where the Plugin is integratet. + * @return OWLClassDescriptionWithDLLearnerTab MainWindow + */ + public OWLClassDescriptionEditorWithDLLearnerTab getMainWindow() + { + return mainWindow; + } + /** * This Method renders the view of the plugin. */ public void makeView() { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-10-15 09:10:58 UTC (rev 1376) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-10-15 10:12:15 UTC (rev 1377) @@ -19,21 +19,18 @@ */ package org.dllearner.tools.protege; -import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JComboBox; -import javax.swing.JDialog; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSpinner; -import javax.swing.JTextArea; import javax.swing.SpinnerNumberModel; -import javax.swing.WindowConstants; /** * This class is the Panel for the Check boxes where the positive and negative @@ -92,11 +89,6 @@ // This is the Text area where the help message is displayed. - private JTextArea help; - - // This is the frame that pops up when the help button is pressed. - - private JDialog assistPanel; private JComboBox optionBox; private JPanel optionBoxPanel; private JPanel spinnerPanel; @@ -105,8 +97,6 @@ private SpinnerNumberModel maxExecutionModel; private JSpinner optionSpinner; private ActionHandler action; - private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; - private final Color colorBlack = Color.black; /** * This is the constructor for the Panel that shows the check boxes. @@ -119,7 +109,6 @@ public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView window) { super(); pos = new JLabel("Positive Examples"); - view = window; neg = new JLabel("Negative Examples"); optionBoxPanel = new JPanel(new GridLayout(0, 1)); spinnerPanel = new JPanel(new GridLayout(0, 1)); @@ -300,28 +289,12 @@ */ public void renderHelpMessage(String assistance) { // renders scroll bar if necessary - JScrollPane scrollHelp = new JScrollPane( - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - help = new JTextArea(); - assistPanel = new JDialog(); - // no writing in the help panel is allowed - help.setEditable(false); - assistPanel.setName("help"); - assistPanel.setSize(300, 100); - // window will be disposed if the x or the ok button is pressed - assistPanel.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - assistPanel.setVisible(true); - assistPanel.setResizable(false); - // sets textcolor to black - help.setForeground(colorBlack); - help.setText("Help: " + assistance); - scrollHelp.setViewportView(help); - scrollHelp.setBounds(0, 0, 300, 100); - assistPanel.add(scrollHelp); - assistPanel.setLocationRelativeTo(view); + JOptionPane.showMessageDialog(null, + assistance, + "Help", + JOptionPane.WARNING_MESSAGE); } - + /** * This method adds the Action listener to the help buttons. * Added: trunk/src/dl-learner/org/dllearner/tools/protege/arrow.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/tools/protege/arrow.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/src/dl-learner/org/dllearner/tools/protege/arrow2.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/tools/protege/arrow2.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/pfeil.gif =================================================================== (Binary files differ) Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/pfeil2.gif =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-10-15 11:21:53
|
Revision: 1380 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1380&view=rev Author: heeroyuy Date: 2008-10-15 11:21:49 +0000 (Wed, 15 Oct 2008) Log Message: ----------- -checkstyle warnings fixed Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-10-15 11:15:18 UTC (rev 1379) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-10-15 11:21:49 UTC (rev 1380) @@ -195,7 +195,7 @@ private void setInformation() { if(eval!=null) { //sets the accuracy of the selected concept - conceptText.append(eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#",null)); + conceptText.append(eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null)); double acc = (eval.getAccuracy())*100; accuracyText.append(String.valueOf(acc)+"%"); //sets the positive examples that are covered Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-15 11:15:18 UTC (rev 1379) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-15 11:21:49 UTC (rev 1380) @@ -120,7 +120,7 @@ //checker = new OWLDescriptionChecker(editorKit); editor = new ExpressionEditor<OWLDescription>(editorKit, editorKit.getModelManager().getOWLExpressionCheckerFactory().getOWLDescriptionChecker()); editor.setExpressionObject(description); - dllearner = new DLLearnerView(frame, label, this); + dllearner = new DLLearnerView(frame, label); action = new ActionHandler(this.action, null, dllearner, null, editorKit); tabbedPane = new JTabbedPane(); @@ -363,9 +363,8 @@ * @param current OWLFrame * @param label String */ - public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab tab) { + public DLLearnerView(OWLFrame<OWLClass> current, String label) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); - mainWindow = tab; classSelectorPanel.firePropertyChange("test", false, true); URL iconUrl = this.getClass().getResource("arrow.gif"); icon = new ImageIcon(iconUrl); @@ -393,7 +392,7 @@ learner.setPreferredSize(new Dimension(600, 520)); accept.setPreferredSize(new Dimension(290, 50)); advanced.setName("Advanced"); - posPanel = new PosAndNegSelectPanel(model, action, this); + posPanel = new PosAndNegSelectPanel(model, action); addAcceptButtonListener(this.action); addRunButtonListener(this.action); addAdvancedButtonListener(this.action); @@ -418,8 +417,7 @@ * Returns the Mainwindow where the Plugin is integratet. * @return OWLClassDescriptionWithDLLearnerTab MainWindow */ - public OWLClassDescriptionEditorWithDLLearnerTab getMainWindow() - { + public OWLClassDescriptionEditorWithDLLearnerTab getMainWindow() { return mainWindow; } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-10-15 11:15:18 UTC (rev 1379) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-10-15 11:21:49 UTC (rev 1380) @@ -106,7 +106,7 @@ * @param act * ActionHandler */ - public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView window) { + public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act) { super(); pos = new JLabel("Positive Examples"); neg = new JLabel("Negative Examples"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-10-24 13:38:09
|
Revision: 1425 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1425&view=rev Author: heeroyuy Date: 2008-10-24 13:38:01 +0000 (Fri, 24 Oct 2008) Log Message: ----------- -added method that paints suggested concepts red that makes the ontology inconsistent Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-24 08:52:43 UTC (rev 1424) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -235,8 +235,9 @@ */ public void mouseClicked(MouseEvent m) { EvaluatedDescription eDescription = null; - String desc = view.getSuggestClassPanel().getSuggestList() - .getSelectedValue().toString(); + SuggestListItem item = (SuggestListItem) view.getSuggestClassPanel().getSuggestList() + .getSelectedValue(); + String desc = item.getValue(); if (model.getEvaluatedDescriptionList() != null) { for (Iterator<EvaluatedDescription> i = model .getEvaluatedDescriptionList().iterator(); i.hasNext();) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-10-24 08:52:43 UTC (rev 1424) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -20,6 +20,7 @@ package org.dllearner.tools.protege; +import java.awt.Color; import java.net.URI; import java.util.HashSet; import java.util.Iterator; @@ -32,7 +33,6 @@ import javax.swing.DefaultListModel; import javax.swing.JCheckBox; -import org.dllearner.algorithms.SimpleSuggestionLearningAlgorithm; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; @@ -112,7 +112,6 @@ // This is the count of Concepts which you get after learning - // A Array of Concepts which the DL-Learner suggested private Description[] description; @@ -185,11 +184,6 @@ private Set<Individual> individual; - // This is a simple learning algorithm to get the first concepts before - // learning - - private SimpleSuggestionLearningAlgorithm test; - // The error message which is rendered when an error occured private String error; @@ -228,7 +222,6 @@ owlDescription = new HashSet<OWLDescription>(); positiv = new Vector<JCheckBox>(); negativ = new Vector<JCheckBox>(); - test = new SimpleSuggestionLearningAlgorithm(); ComponentManager.setComponentClasses(componenten); cm = ComponentManager.getInstance(); ds = new HashSet<OWLDescription>(); @@ -246,29 +239,34 @@ alreadyLearned = false; setKnowledgeSource(); setReasoner(); - SortedSet<Individual> pos = rs.getIndividuals(); - Set<Description> descri = test.getSimpleSuggestions(rs, pos); - int i = 0; - for (Iterator<Description> j = descri.iterator(); j.hasNext();) { - suggestModel.add(i, j.next()); - } - // suggestModel.add(0,test.getCurrentlyBestEvaluatedDescription(). - // getDescription - // ().toManchesterSyntaxString(editor.getOWLModelManager(). - // getActiveOntology().getURI().toString()+"#", null)); } /** * This method adds the solutions from the DL-Learner to the List Model. */ private void addToListModel() { - evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getMaxNrOfResultsModelData(), view.getPosAndNegSelectPanel().getMinAccuracyModelData(), true); + evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view + .getPosAndNegSelectPanel().getMaxNrOfResultsModelData(), view + .getPosAndNegSelectPanel().getMinAccuracyModelData(), true); for (int j = 0; j < evalDescriptions.size(); j++) { - suggestModel.add(j, evalDescriptions.get(j) - .getDescription().toManchesterSyntaxString( - editor.getModelManager().getActiveOntology() - .getURI().toString() - + "#", null)); + System.out.println("KLICKEN: "+ evalDescriptions.get(j).getNotCoveredPositives()); + if (isConsistent(evalDescriptions.get(j))) { + suggestModel.add(j, new SuggestListItem(Color.GREEN, + evalDescriptions.get(j).getDescription() + .toManchesterSyntaxString( + editor.getModelManager() + .getActiveOntology().getURI() + .toString() + + "#", null))); + } else { + suggestModel.add(j, new SuggestListItem(Color.RED, + evalDescriptions.get(j).getDescription() + .toManchesterSyntaxString( + editor.getModelManager() + .getActiveOntology().getURI() + .toString() + + "#", null))); + } } } @@ -382,9 +380,12 @@ // TODO Auto-generated catch block e.printStackTrace(); } + System.out.println("3: " + + view.getPosAndNegSelectPanel().getMaxExecutionModelData()); cm.applyConfigEntry(la, "numberOfTrees", 100); cm.applyConfigEntry(la, "maxDepth", 5); - cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getMaxExecutionModelData()); + cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view + .getPosAndNegSelectPanel().getMaxExecutionModelData()); try { // initializes the learning algorithm la.init(); @@ -402,7 +403,8 @@ // start the algorithm and print the best concept found la.start(); description = new Description[la.getCurrentlyBestEvaluatedDescriptions( - view.getPosAndNegSelectPanel().getMaxNrOfResultsModelData()).size()]; + view.getPosAndNegSelectPanel().getMaxNrOfResultsModelData()) + .size()]; addToListModel(); // renders the errormessage view.renderErrorMessage(error); @@ -709,6 +711,15 @@ } /** + * This methode returns the Model for the suggested Concepts. + * + * @return DefaultListModel + */ + public DefaultListModel getSuggestModel() { + return suggestModel; + } + + /** * This method gets the old concept from checking the positive examples. */ private void setOldConceptOWLAPI() { @@ -742,7 +753,8 @@ * @param descript * Description learn by the DL-Learner */ - public void changeDLLearnerDescriptionsToOWLDescriptions(Description descript) { + public void changeDLLearnerDescriptionsToOWLDescriptions( + Description descript) { setNewConceptOWLAPI(descript); setOldConceptOWLAPI(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); @@ -783,8 +795,20 @@ public boolean getAlreadyLearned() { return alreadyLearned; } + + private boolean isConsistent(EvaluatedDescription eDescription) { + boolean isConsistent = false; + if (eDescription.getNotCoveredPositives().isEmpty()) { + isConsistent = true; + } else { + isConsistent = false; + } + return isConsistent; + } + /** * This Method returns the URI of the currently loaded Ontology. + * * @return URI Ontology URI */ public URI getURI() { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-24 08:52:43 UTC (rev 1424) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -128,13 +128,14 @@ editingComponent = new JPanel(new BorderLayout()); editingComponent.add(tabbedPane); editingComponent.setPreferredSize(new Dimension(600, 520)); - + if(dllearner.getNrOfIndividuals()!=0) { if (label.equals("Equivalent classes")) { tabbedPane.add(SUGGEST_EQUIVALENT_CLASS_LABEL, dllearner); } if (label.equals("Superclasses")) { tabbedPane.add(SUGGEST_SUBCLASS_LABEL, dllearner); } + } tabbedPane.add(CLASS_EXPRESSION_EDITOR_LABEL, new JScrollPane(editor)); if (description == null || !description.isAnonymous()) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); @@ -515,7 +516,7 @@ /** * Returns the last added description. - * @return OWLDescriptio + * @return OWLDescription */ public OWLDescription getSollution() { return model.getSolution(); @@ -532,8 +533,15 @@ posPanel.unsetPosAndNegPanel(); learner.removeAll(); } - /** + * This method returns the nummers of Individuals present in the Ontology. + * @return int amount of Individuals in the Ontology + */ + public int getNrOfIndividuals() { + int counter = model.getPosVector().size(); + return counter; + } + /** * Renders the error message when an error occured. * @param s String */ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-10-24 08:52:43 UTC (rev 1424) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -19,10 +19,12 @@ */ package org.dllearner.tools.protege; -import java.awt.Color; import java.awt.Dimension; -import javax.swing.*; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; /** * This class is the panel for the suggest list. @@ -65,6 +67,7 @@ suggestPanel.add(descriptions); suggestScroll.setPreferredSize(new Dimension(490, 108)); suggestScroll.setViewportView(descriptions); + descriptions.setCellRenderer(new SuggestListCellRenderer()); add(suggestScroll); } @@ -83,7 +86,6 @@ * @param desc List model of descriptions made by the DL-Learner */ public void setSuggestList(DefaultListModel desc) { - descriptions.setForeground(Color.GREEN); descriptions.setModel(desc); } /** Added: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -0,0 +1,72 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.tools.protege; + +import java.awt.Color; +import java.awt.Component; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +/** + * This is the class that is responsible for the rendering of the + * concepts that are shown in the SuggestPanel. + * @author Christian Koetteritzsch + * + */ +public class SuggestListCellRenderer extends JLabel implements ListCellRenderer { + + private static final long serialVersionUID = 8040385703448641356L; + /** + * Construktor for the Cell Renderer for the Suggest List. + */ + public SuggestListCellRenderer() { + setOpaque(true); + } + + /** + * Renderer for the entries of the SuggestPanel. + * @param list JList + * @param value Object + * @param arg2 int + * @param arg4 boolean + * @param iss boolean boolean if current element is selected. + * @return Component Returns the currently rendered component of the suggest list + */ + public Component getListCellRendererComponent(JList list, Object value, + int arg2, boolean iss, boolean arg4) { + // Set the text and + // background color for rendering + setText(((SuggestListItem) value).getValue()); + setBackground(Color.WHITE); + setForeground(((SuggestListItem) value).getColor()); + // Set a border if the list + // item is selected + if (iss) { + setBorder(BorderFactory.createLineBorder(Color.GRAY, 2)); + } else { + setBorder(BorderFactory.createLineBorder(list.getBackground(), 2)); + } + + return this; + } + +} Added: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListItem.java 2008-10-24 13:38:01 UTC (rev 1425) @@ -0,0 +1,59 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +package org.dllearner.tools.protege; + +import java.awt.Color; +/** + * This Class represents an entry of the suggest list. + * @author Christian Koetteritzsch + * + */ +public class SuggestListItem { + + private Color color; + private String value; + /** + * Constructor for the SuggestListItem. + * @param c Color Color in which the text is painted. + * @param s String text that is shown. + */ + public SuggestListItem( + Color c, String s) { + color = c; + value = s; + } + + /** + * This method returns the color of the current list item. + * @return Color Color of the current list item + */ + public Color getColor() { + return color; + } + + /** + * This Method returns the text of the current list item. + * @return String Text of the current list item + */ + public String getValue() { + return value; + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-02 12:53:37
|
Revision: 1488 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1488&view=rev Author: heeroyuy Date: 2008-11-02 12:53:29 +0000 (Sun, 02 Nov 2008) Log Message: ----------- -bugfixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-10-28 15:32:03 UTC (rev 1487) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-02 12:53:29 UTC (rev 1488) @@ -117,17 +117,13 @@ if (z.getActionCommand().equals("ADD")) { if (evaluatedDescription != null) { - model - .changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription - .getDescription()); + model.changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription.getDescription()); } else { - model - .changeDLLearnerDescriptionsToOWLDescriptions((Description) view - .getSuggestClassPanel().getSuggestList() - .getSelectedValue()); + model.changeDLLearnerDescriptionsToOWLDescriptions((Description) view.getSuggestClassPanel().getSuggestList().getSelectedValue()); } String message = "Concept added"; view.renderErrorMessage(message); + view.updateWindow(); } if (z.getActionCommand().equals("?")) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-10-28 15:32:03 UTC (rev 1487) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-02 12:53:29 UTC (rev 1488) @@ -249,7 +249,6 @@ .getPosAndNegSelectPanel().getMaxNrOfResultsModelData(), view .getPosAndNegSelectPanel().getMinAccuracyModelData(), true); for (int j = 0; j < evalDescriptions.size(); j++) { - System.out.println("KLICKEN: "+ evalDescriptions.get(j).getNotCoveredPositives()); if (isConsistent(evalDescriptions.get(j))) { suggestModel.add(j, new SuggestListItem(Color.GREEN, evalDescriptions.get(j).getDescription() @@ -490,8 +489,10 @@ public void unsetNewConcepts() { while (owlDescription.iterator().hasNext()) { owlDescription.remove(owlDescription.iterator().next()); + } } + /** * This method sets the individuals that belong to the concept which is @@ -738,6 +739,7 @@ .hasNext();) { OWLDescription oldOWLAPI = OWLAPIDescriptionConvertVisitor .getOWLDescription(k.next()); + oldConceptOWLAPI = oldOWLAPI; ds.add(oldOWLAPI); } @@ -763,8 +765,8 @@ if (id.equals("Equivalent classes")) { axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); } else { - axiomOWLAPI = factory.getOWLSubClassAxiom(oldConceptOWLAPI, - newConceptOWLAPI); + axiomOWLAPI = factory.getOWLSubClassAxiom(newConceptOWLAPI, + oldConceptOWLAPI); } OWLOntology onto = editor.getModelManager().getActiveOntology(); AddAxiom axiom = new AddAxiom(onto, axiomOWLAPI); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-10-28 15:32:03 UTC (rev 1487) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-02 12:53:29 UTC (rev 1488) @@ -82,8 +82,6 @@ private OWLEditorKit editorKit; - //private OWLDescriptionChecker checker; - private ExpressionEditor<OWLDescription> editor; private JComponent editingComponent; @@ -120,7 +118,7 @@ //checker = new OWLDescriptionChecker(editorKit); editor = new ExpressionEditor<OWLDescription>(editorKit, editorKit.getModelManager().getOWLExpressionCheckerFactory().getOWLDescriptionChecker()); editor.setExpressionObject(description); - dllearner = new DLLearnerView(frame, label); + dllearner = new DLLearnerView(frame, label, this); action = new ActionHandler(this.action, null, dllearner, null, editorKit); tabbedPane = new JTabbedPane(); @@ -136,6 +134,7 @@ tabbedPane.add(SUGGEST_SUBCLASS_LABEL, dllearner); } } + // tabbedPane.add(CLASS_EXPRESSION_EDITOR_LABEL, new JScrollPane(editor)); if (description == null || !description.isAnonymous()) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); @@ -154,6 +153,7 @@ tabbedPane.addChangeListener(changeListener); } + } private void handleVerifyEditorContents() { @@ -205,6 +205,7 @@ public void clear() { dllearner.unsetEverything(); dllearner.makeView(); + handleVerifyEditorContents(); // initialDescription = null; editor.setText(""); @@ -285,10 +286,12 @@ */ public void removeStatusChangedListener( InputVerificationStatusChangedListener listener) { + //TODO: Suchen + //System.out.println("Comp: "+editorKit.getWorkspace().getComponents()); listeners.remove(listener); editor.removeStatusChangedListener(listener); } - + /** * This class is responsible for the view of the dllearner. It renders the * output for the user and is the graphical component of the plugin. @@ -363,9 +366,11 @@ * * @param current OWLFrame * @param label String + * @param dlLearner OWLClassDescriptionEditorWithDLLearnerTab */ - public DLLearnerView(OWLFrame<OWLClass> current, String label) { + public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab dlLearner) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); + mainWindow = dlLearner; classSelectorPanel.firePropertyChange("test", false, true); URL iconUrl = this.getClass().getResource("arrow.gif"); icon = new ImageIcon(iconUrl); @@ -397,6 +402,7 @@ addAcceptButtonListener(this.action); addRunButtonListener(this.action); addAdvancedButtonListener(this.action); + } /** @@ -504,8 +510,14 @@ public JButton getAddButton() { return accept; } - /** + * This Method updates the the view of protege after + * adding a new concept. + */ + public void updateWindow() { + mainWindow.getHandler().handleEditingFinished(mainWindow.getEditedObjects()); + } + /** * Returns all added descriptions. * @return Set(OWLDescription) */ @@ -569,7 +581,6 @@ * Destroys the view after the plugin is closed. */ public void dispose() { - System.out.println("dispose"); } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-10-28 15:32:03 UTC (rev 1487) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-11-02 12:53:29 UTC (rev 1488) @@ -73,6 +73,7 @@ @Override protected void clear() { + added.clear(); } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2008-10-28 15:32:03 UTC (rev 1487) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2008-11-02 12:53:29 UTC (rev 1488) @@ -45,8 +45,8 @@ public void initialiseClassView() throws Exception { list = new OWLFrameList2<OWLClass>(getOWLEditorKit(), new ButtonList(getOWLEditorKit())); setLayout(new BorderLayout()); - JScrollPane hallo = new JScrollPane(list); - add(hallo); + JScrollPane dlLearner = new JScrollPane(list); + add(dlLearner); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-04 11:50:43
|
Revision: 1489 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1489&view=rev Author: heeroyuy Date: 2008-11-04 11:50:41 +0000 (Tue, 04 Nov 2008) Log Message: ----------- -bug fixed Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-02 12:53:29 UTC (rev 1488) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-04 11:50:41 UTC (rev 1489) @@ -231,28 +231,36 @@ */ public void mouseClicked(MouseEvent m) { EvaluatedDescription eDescription = null; - SuggestListItem item = (SuggestListItem) view.getSuggestClassPanel().getSuggestList() - .getSelectedValue(); - String desc = item.getValue(); - if (model.getEvaluatedDescriptionList() != null) { - for (Iterator<EvaluatedDescription> i = model - .getEvaluatedDescriptionList().iterator(); i.hasNext();) { - eDescription = i.next(); - if (desc.equals(eDescription.getDescription() - .toManchesterSyntaxString( - editorKit.getModelManager().getActiveOntology().getURI() - + "#", null))) { - evaluatedDescription = eDescription; - break; + if (view.getSuggestClassPanel().getSuggestList() + .getSelectedValue() != null) { + SuggestListItem item = (SuggestListItem) view.getSuggestClassPanel().getSuggestList() + .getSelectedValue(); + String desc = item.getValue(); + if (model.getEvaluatedDescriptionList() != null) { + for (Iterator<EvaluatedDescription> i = model + .getEvaluatedDescriptionList().iterator(); i.hasNext();) { + eDescription = i.next(); + if (desc.equals(eDescription.getDescription() + .toManchesterSyntaxString( + editorKit.getModelManager().getActiveOntology().getURI() + + "#", null))) { + evaluatedDescription = eDescription; + break; + } + } - } - } + + if(m.getClickCount()==2) { view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel( evaluatedDescription); } + } else { + String message = "No concept to select."; + view.renderErrorMessage(message); } + } /** * Nothing happens here. @@ -267,9 +275,12 @@ * @param m MouseEvent */ public void mousePressed(MouseEvent m) { - if (!view.getAddButton().isEnabled()) { - view.getAddButton().setEnabled(true); - } + if (view.getSuggestClassPanel().getSuggestList() + .getSelectedValue()!= null) { + if (!view.getAddButton().isEnabled()) { + view.getAddButton().setEnabled(true); + } + } } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-02 12:53:29 UTC (rev 1488) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-04 11:50:41 UTC (rev 1489) @@ -516,6 +516,7 @@ */ public void updateWindow() { mainWindow.getHandler().handleEditingFinished(mainWindow.getEditedObjects()); + mainWindow.dispose(); } /** * Returns all added descriptions. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-04 16:27:28
|
Revision: 1490 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1490&view=rev Author: heeroyuy Date: 2008-11-04 16:27:07 +0000 (Tue, 04 Nov 2008) Log Message: ----------- -added new panel for options such as min. execution time -removed base uri's in the selection panel -some minor changes in the GUI Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-04 11:50:41 UTC (rev 1489) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-04 16:27:07 UTC (rev 1490) @@ -89,9 +89,7 @@ * @param z ActionEvent */ public void actionPerformed(ActionEvent z) { - if(z.getActionCommand().equals("comboBoxChanged")) { - view.getPosAndNegSelectPanel().setOptionSpinner(); - } + if (z.getActionCommand().equals("Suggest " + id)) { if (model.getAlreadyLearned()) { @@ -102,6 +100,7 @@ view .renderErrorMessage("Could not start learning. No Examples where available"); } else { + view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); model.setKnowledgeSource(); model.setReasoner(); model.setPositiveAndNegativeExamples(); @@ -111,7 +110,7 @@ dlLearner.start(); view.getRunButton().setEnabled(false); view.renderErrorMessage("Learning started"); - view.getPosAndNegSelectPanel().unsetCheckBoxes(); + //view.getPosAndNegSelectPanel().unsetCheckBoxes(); } } @@ -128,7 +127,8 @@ if (z.getActionCommand().equals("?")) { if (z.getSource().toString().contains("PosHelpButton")) { - String help = "A Instance that follows from the classdescription.\nPer Default all that belongs to the class."; + String help = "An individual that should be an instance of the learned class description.\n" + +"Per Default all that belongs to the class."; view.getPosAndNegSelectPanel().renderHelpMessage(help); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-04 11:50:41 UTC (rev 1489) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-04 16:27:07 UTC (rev 1490) @@ -81,7 +81,6 @@ "org.dllearner.learningproblems.PosNegInclusionLP", "org.dllearner.learningproblems.PosNegDefinitionLP", "org.dllearner.algorithms.RandomGuesser", - "org.dllearner.algorithms.BruteForceLearner", "org.dllearner.algorithms.refinement.ROLearner", "org.dllearner.algorithms.refexamples.ExampleBasedROLComponent", "org.dllearner.algorithms.gp.GP" }; @@ -245,9 +244,7 @@ * This method adds the solutions from the DL-Learner to the List Model. */ private void addToListModel() { - evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view - .getPosAndNegSelectPanel().getMaxNrOfResultsModelData(), view - .getPosAndNegSelectPanel().getMinAccuracyModelData(), true); + evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts(), view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy(), true); for (int j = 0; j < evalDescriptions.size(); j++) { if (isConsistent(evalDescriptions.get(j))) { suggestModel.add(j, new SuggestListItem(Color.GREEN, @@ -278,11 +275,12 @@ negativeExamples = new TreeSet<String>(); for (int i = 0; i < positiv.size(); i++) { if (positiv.get(i).isSelected()) { - positiveExamples.add(positiv.get(i).getText()); + + positiveExamples.add(editor.getModelManager().getActiveOntology().getURI().toString()+"#"+positiv.get(i).getText()); } if (negativ.get(i).isSelected()) { - negativeExamples.add(negativ.get(i).getText()); + negativeExamples.add(editor.getModelManager().getActiveOntology().getURI().toString()+"#"+negativ.get(i).getText()); } } } @@ -346,12 +344,12 @@ * classes. */ public void setLearningProblem() { - if (id.equals("Equivalent classes")) { + if (id.equals("equivalent classes")) { // sets the learning problem to PosNegDefinitionLP when the // dllearner should suggest an equivalent class lp = cm.learningProblem(PosNegDefinitionLP.class, rs); } - if (id.equals("Superclasses")) { + if (id.equals("superclasses")) { // sets the learning problem to PosNegInclusionLP when the dllearner // should suggest a subclass lp = cm.learningProblem(PosNegInclusionLP.class, rs); @@ -379,12 +377,9 @@ // TODO Auto-generated catch block e.printStackTrace(); } - System.out.println("3: " - + view.getPosAndNegSelectPanel().getMaxExecutionModelData()); cm.applyConfigEntry(la, "numberOfTrees", 100); cm.applyConfigEntry(la, "maxDepth", 5); - cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view - .getPosAndNegSelectPanel().getMaxExecutionModelData()); + cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); try { // initializes the learning algorithm la.init(); @@ -399,17 +394,19 @@ */ public void run() { error = "Learning succesful"; + String message = "To view details about why a class description was suggested, please doubleclick on it."; // start the algorithm and print the best concept found la.start(); - description = new Description[la.getCurrentlyBestEvaluatedDescriptions( - view.getPosAndNegSelectPanel().getMaxNrOfResultsModelData()) + description = new Description[la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts()) .size()]; addToListModel(); // renders the errormessage view.renderErrorMessage(error); + view.setHintMessage(message); // reenables the run button view.getRunButton().setEnabled(true); // disables the cancel button + view.getPosAndNegSelectPanel().setCheckBoxesEnable(true); view.getSuggestClassPanel().setSuggestList(suggestModel); } @@ -458,7 +455,9 @@ setPositiveConcept(); for (Iterator<Individual> j = rs.getIndividuals().iterator(); j .hasNext();) { - String ind = j.next().toString(); + String ind = j.next().toManchesterSyntaxString(editor.getModelManager() + .getActiveOntology().getURI() + .toString()+"#", null); // checks if individual belongs to the selected concept if (setPositivExamplesChecked(ind)) { // when yes then it sets the positive example checked Modified: trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml 2008-11-04 11:50:41 UTC (rev 1489) +++ trunk/src/dl-learner/org/dllearner/tools/protege/META-INF/plugin.xml 2008-11-04 16:27:07 UTC (rev 1490) @@ -2,7 +2,7 @@ <plugin> <extension id="org.dllearner.tools.protege.ProtegePlugin" point="org.protege.editor.core.application.ViewComponent"> - <label value="DL-Learner Plugin"/> + <label value="Class Descriptions (including DL-Learner plugin)"/> <class value="org.dllearner.tools.protege.ProtegePlugin"/> <headerColor value="@org.protege.classcolor"/> <category value="@org.protege.classcategory"/> Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-04 11:50:41 UTC (rev 1489) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-04 16:27:07 UTC (rev 1490) @@ -18,9 +18,8 @@ * */ package org.dllearner.tools.protege; +import java.awt.Color; import java.awt.GridLayout; -import java.awt.Color; - import java.util.Iterator; import javax.swing.JDialog; @@ -100,7 +99,12 @@ private JScrollPane detailScroll; // Evaluated description of the selected concept - + private JPanel conceptPanel; + private JPanel accuracyPanel; + private JPanel posCoveredPanel; + private JPanel posNotCoveredPanel; + private JPanel negCoveredPanel; + private JPanel negNotCoveredPanel; private EvaluatedDescription eval; private final Color colorRed = Color.red; private JTextArea concept; @@ -128,7 +132,12 @@ */ public void renderDetailPanel(EvaluatedDescription desc) { eval = desc; - + conceptPanel = new JPanel(new GridLayout(0,2)); + accuracyPanel = new JPanel(new GridLayout(0,2)); + posCoveredPanel = new JPanel(new GridLayout(0,2)); + posNotCoveredPanel = new JPanel(new GridLayout(0,2)); + negCoveredPanel = new JPanel(new GridLayout(0,2)); + negNotCoveredPanel = new JPanel(new GridLayout(0,2)); accuracy = new JTextArea("Accuracy:"); accuracy.setEditable(false); conceptText = new JTextArea(); @@ -153,10 +162,10 @@ //sets accuracy text area not editable accuracyText.setEditable(false); //panel for the informations of the selected concept - examplePanel = new JPanel(new GridLayout(0, 2)); + examplePanel = new JPanel(new GridLayout(0,1)); //this method adds the informations for the selected concept to the panel setInformation(); - concept = new JTextArea("Concept:"); + concept = new JTextArea("Class Description:"); concept.setEditable(false); coveredPositiveExamples = new JLabel("Covered Positive Examples:"); coveredPositiveExamples.setForeground(colorGreen); @@ -174,18 +183,29 @@ detailPopup.setResizable(false); detailScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); //adds all information to the example panel - examplePanel.add(concept); - examplePanel.add(conceptText); - examplePanel.add(accuracy); - examplePanel.add(accuracyText); - examplePanel.add(coveredPositiveExamples); - examplePanel.add(notCoveredPositiveExamples); - examplePanel.add(posCoveredText); - examplePanel.add(posNotCoveredText); - examplePanel.add(coveredNegativeExamples); - examplePanel.add(notCoveredNegativeExamples); - examplePanel.add(negCoveredText); - examplePanel.add(negNotCoveredText); + conceptPanel.add(concept); + conceptPanel.add(conceptText); + accuracyPanel.add(accuracy); + accuracyPanel.add(accuracyText); + //examplePanel.add(concept); + //examplePanel.add(conceptText); + //examplePanel.add(accuracy); + //examplePanel.add(accuracyText); + posCoveredPanel.add(coveredPositiveExamples); + posCoveredPanel.add(posCoveredText); + posNotCoveredPanel.add(notCoveredPositiveExamples); + posNotCoveredPanel.add(posNotCoveredText); + negCoveredPanel.add(coveredNegativeExamples); + negCoveredPanel.add(negCoveredText); + negNotCoveredPanel.add(notCoveredNegativeExamples); + + negNotCoveredPanel.add(negNotCoveredText); + examplePanel.add(conceptPanel); + examplePanel.add(accuracyPanel); + examplePanel.add(posCoveredPanel); + examplePanel.add(posNotCoveredPanel); + examplePanel.add(negCoveredPanel); + examplePanel.add(negNotCoveredPanel); detailScroll.setViewportView(examplePanel); detailPopup.add(detailScroll); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-04 11:50:41 UTC (rev 1489) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-04 16:27:07 UTC (rev 1490) @@ -77,8 +77,8 @@ private static final String CLASS_EXPRESSION_EDITOR_LABEL = "Class expression editor"; private static final String CLASS_TREE_LABEL = "Class tree"; private static final String RESTRICTION_CREATOR_LABEL = "Restriction creator"; - private static final String SUGGEST_EQUIVALENT_CLASS_LABEL = "Suggest a equivalent class"; - private static final String SUGGEST_SUBCLASS_LABEL = "Suggest a subclass"; + private static final String SUGGEST_EQUIVALENT_CLASS_LABEL = "Suggest equivalent class"; + private static final String SUGGEST_SUBCLASS_LABEL = "Suggest super class"; private OWLEditorKit editorKit; @@ -127,10 +127,10 @@ editingComponent.add(tabbedPane); editingComponent.setPreferredSize(new Dimension(600, 520)); if(dllearner.getNrOfIndividuals()!=0) { - if (label.equals("Equivalent classes")) { + if (label.equals("equivalent classes")) { tabbedPane.add(SUGGEST_EQUIVALENT_CLASS_LABEL, dllearner); } - if (label.equals("Superclasses")) { + if (label.equals("superclasses")) { tabbedPane.add(SUGGEST_SUBCLASS_LABEL, dllearner); } } @@ -380,7 +380,7 @@ sugPanel = new SuggestClassPanel(); action = new ActionHandler(this.action, model, this, label, editorKit); - adv = new JLabel("Advanced"); + adv = new JLabel("Advanced Settings"); advanced = new JToggleButton(icon); advanced.setVisible(true); run = new JButton("Suggest " + label); @@ -391,7 +391,7 @@ errorMessage.setEditable(false); hint = new JTextArea(); hint.setEditable(false); - hint.setText("To get more Detail please doubleclick a concept"); + hint.setText("To get suggestions for class descriptions, please click the button above."); learner = new JPanel(); advanced.setSize(20, 20); learner.setLayout(null); @@ -478,8 +478,16 @@ advanced.setIcon(icon); } } - + /** + * This Method changes the hint message. + * @param message String hintmessage + */ + public void setHintMessage(String message) { + hint.setText(message); + } + + /** * This Method returns the DL_Learner tab. * @return JComponent */ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-11-04 11:50:41 UTC (rev 1489) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-11-04 16:27:07 UTC (rev 1490) @@ -52,7 +52,7 @@ extends AbstractOWLFrameSection<OWLClass, OWLEquivalentClassesAxiom, OWLDescription> { - private static final String LABEL = "Equivalent classes"; + private static final String LABEL = "equivalent classes"; private Set<OWLClass> added; Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java 2008-11-04 11:50:41 UTC (rev 1489) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java 2008-11-04 16:27:07 UTC (rev 1490) @@ -51,7 +51,7 @@ public class OWLSubClassAxiomFrameSection extends AbstractOWLFrameSection<OWLClass, OWLSubClassAxiom, OWLDescription> { - private static final String LABEL = "Superclasses"; + private static final String LABEL = "superclasses"; private Set<OWLDescription> added = new HashSet<OWLDescription>(); Added: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-04 16:27:07 UTC (rev 1490) @@ -0,0 +1,90 @@ +package org.dllearner.tools.protege; + +import java.awt.GridLayout; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSlider; +/** + * This Class is responsible for the Options of the DL-Learner. + * @author Christian Koetteritzsch + * + */ +public class OptionPanel extends JPanel { + + + private static final long serialVersionUID = 2190682281812478244L; + private JLabel minAccuracyLabel; + private JLabel maxExecutionTimeLabel; + private JLabel nrOfConceptsLabel; + private JSlider minAccuracy; + private JSlider maxExecutionTime; + private JSlider nrOfConcepts; + private JPanel optionPanel; + /** + * Construktor for the Option Panel. + */ + public OptionPanel() { + + + optionPanel = new JPanel(new GridLayout(0,2)); + minAccuracyLabel = new JLabel("minimum accuracy"); + maxExecutionTimeLabel = new JLabel("maximum execution time"); + nrOfConceptsLabel = new JLabel("maximum number of results"); + + minAccuracy = new JSlider(50, 100, 80); + minAccuracy.setPaintTicks(true); + minAccuracy.setMajorTickSpacing(10); + minAccuracy.setMinorTickSpacing(1); + minAccuracy.setPaintLabels(true); + + + maxExecutionTime = new JSlider(5, 20, 10); + maxExecutionTime.setPaintTicks(true); + maxExecutionTime.setMajorTickSpacing(5); + maxExecutionTime.setMinorTickSpacing(1); + maxExecutionTime.setPaintLabels(true); + + + nrOfConcepts = new JSlider(2, 20, 5); + nrOfConcepts.setPaintTicks(true); + nrOfConcepts.setMajorTickSpacing(2); + nrOfConcepts.setMinorTickSpacing(1); + nrOfConcepts.setPaintLabels(true); + + optionPanel.add(minAccuracyLabel); + optionPanel.add(minAccuracy); + optionPanel.add(maxExecutionTimeLabel); + optionPanel.add(maxExecutionTime); + optionPanel.add(nrOfConceptsLabel); + optionPanel.add(nrOfConcepts); + add(optionPanel); + + } + + /** + * This method returns the min accuracy chosen in the slider. + * @return double minAccuracy + */ + public double getMinAccuracy() { + int acc = minAccuracy.getValue(); + double accuracy = acc/100; + return accuracy; + } + + /** + * This method returns the max executiontime chosen in the slider. + * @return int maxExecutionTime + */ + public int getMaxExecutionTime() { + return maxExecutionTime.getValue(); + } + + /** + * This method returns the nr. of concepts chosen in the slider. + * @return int nrOfConcepts + */ + public int getNrOfConcepts() { + return nrOfConcepts.getValue(); + } +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-04 11:50:41 UTC (rev 1489) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-04 16:27:07 UTC (rev 1490) @@ -29,8 +29,6 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; /** * This class is the Panel for the Check boxes where the positive and negative @@ -88,14 +86,9 @@ private JButton helpForNegExamples; // This is the Text area where the help message is displayed. - + private OptionPanel optionPanel; private JComboBox optionBox; private JPanel optionBoxPanel; - private JPanel spinnerPanel; - private SpinnerNumberModel minAccuracyModel; - private SpinnerNumberModel maxNrOfResultsModel; - private SpinnerNumberModel maxExecutionModel; - private JSpinner optionSpinner; private ActionHandler action; /** @@ -107,25 +100,18 @@ * ActionHandler */ public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act) { - super(); + super(new GridLayout(0,1)); + optionPanel = new OptionPanel(); pos = new JLabel("Positive Examples"); neg = new JLabel("Negative Examples"); optionBoxPanel = new JPanel(new GridLayout(0, 1)); - spinnerPanel = new JPanel(new GridLayout(0, 1)); - action = act; - minAccuracyModel = new SpinnerNumberModel(0.8, 0.0 , 1.0, 0.05); - maxNrOfResultsModel = new SpinnerNumberModel(5.0, 1.0 , 20.0, 1.0); - maxExecutionModel = new SpinnerNumberModel(10.0, 1.0 , 60.0, 1.0); + action = act; optionBox = new JComboBox(); - optionSpinner = new JSpinner(); - optionSpinner.setModel(minAccuracyModel); - optionBox.addItem("min. Accuracy"); - optionBox.addItem("max. Nr. of Results"); - optionBox.addItem("max. Executiontime"); + optionBox.addItem("min. accuracy"); + optionBox.addItem("max. nr. of results"); + optionBox.addItem("max. executiontime"); optionBoxPanel.add(optionBox); - spinnerPanel.add(optionSpinner); setComboBoxListener(); - spinnerPanel.setSize(50, 20); // help button for positive examples helpForPosExamples = new JButton("?"); helpForPosExamples.setSize(10, 10); @@ -163,7 +149,9 @@ scrollPanel = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPanel.setViewportView(posAndNegPanel); - scrollPanel.setPreferredSize(new Dimension(490, 248)); + optionPanel.setPreferredSize(new Dimension(490, 70)); + scrollPanel.setPreferredSize(new Dimension(490, 180)); + add(optionPanel); add(scrollPanel); addListeners(action); } @@ -173,8 +161,6 @@ * positive and negative examples. */ public void setJCheckBoxes() { - posAndNegSelectPanel.add(optionBoxPanel); - posAndNegSelectPanel.add(spinnerPanel); posAndNegSelectPanel.add(posLabelPanel); posAndNegSelectPanel.add(negLabelPanel); // adds check boxes for all examples of the ontology @@ -188,65 +174,20 @@ } /** - * This Methode returns the min Accuracy that the concepts must have. - * @return min accuracy - */ - public float getMinAccuracyModelData() { - float minAccuracy = Float.valueOf(minAccuracyModel.getValue().toString()).floatValue(); - return minAccuracy; - } - - /** - * This Methode returns the max nr. of results selected in the option Panel. - * @return Max Nr. of Results - */ - public int getMaxNrOfResultsModelData() { - float maxNrOfRes = Float.valueOf(maxNrOfResultsModel.getValue().toString()).floatValue(); - int maxNrOfResults = Math.round(maxNrOfRes); - return maxNrOfResults; - } - - /** - * This Methode returns the max execution time selected in the Panel. - * @return Max Execution Time in seconds - */ - public int getMaxExecutionModelData() { - float maxExe = Float.valueOf(maxExecutionModel.getValue().toString()).floatValue(); - int maxExecution = Math.round(maxExe); - return maxExecution; - } - - /** * This method adds the ActionListener to the Option Combo Box. */ private void setComboBoxListener() { optionBox.addActionListener(action); } + /** - * This Methode sets the right Spinner for the selected Option. - */ - public void setOptionSpinner() { - if(optionBox.getSelectedItem().equals("min. Accuracy")) { - optionSpinner.setModel(minAccuracyModel); - } - - if(optionBox.getSelectedItem().equals("max. Nr. of Results")) { - optionSpinner.setModel(maxNrOfResultsModel); - } - - if(optionBox.getSelectedItem().equals("max. Executiontime")) { - optionSpinner.setModel(maxExecutionModel); - } - - } - /** * This method removes the Check boxes, the labels and the help buttons * after the DL-Learner tab is closed. */ public void unsetPosAndNegPanel() { posAndNegSelectPanel.removeAll(); } - + /** * This method adds the item listener for every check box. * @@ -263,7 +204,15 @@ } } - + + public void setCheckBoxesEnable(boolean enable) { + for (int j = 0; j < model.getPosVector().size(); j++) { + model.getPositivJCheckBox(j).setEnabled(enable); + model.getNegativJCheckBox(j).setEnabled(enable); + } + + } + /** * This method returns the Panel where the check boxes, labels and help * buttons are in. @@ -307,5 +256,9 @@ // adds listener to the help button for the negative examples helpForNegExamples.addActionListener(a); } + + public OptionPanel getOptionPanel() { + return optionPanel; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-05 12:51:52
|
Revision: 1492 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1492&view=rev Author: heeroyuy Date: 2008-11-05 12:51:43 +0000 (Wed, 05 Nov 2008) Log Message: ----------- -changes in detail panel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-04 17:02:56 UTC (rev 1491) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-05 12:51:43 UTC (rev 1492) @@ -198,6 +198,7 @@ // This is a List of evaluated descriptions to get more information of the // suggested concept private List<EvaluatedDescription> evalDescriptions; + private Vector<String> normalIndividuals; /** * This is the constructor for DL-Learner model. @@ -221,6 +222,7 @@ owlDescription = new HashSet<OWLDescription>(); positiv = new Vector<JCheckBox>(); negativ = new Vector<JCheckBox>(); + normalIndividuals = new Vector<String>(); ComponentManager.setComponentClasses(componenten); cm = ComponentManager.getInstance(); ds = new HashSet<OWLDescription>(); @@ -276,11 +278,11 @@ for (int i = 0; i < positiv.size(); i++) { if (positiv.get(i).isSelected()) { - positiveExamples.add(editor.getModelManager().getActiveOntology().getURI().toString()+"#"+positiv.get(i).getText()); + positiveExamples.add(normalIndividuals.get(i)); } if (negativ.get(i).isSelected()) { - negativeExamples.add(editor.getModelManager().getActiveOntology().getURI().toString()+"#"+negativ.get(i).getText()); + negativeExamples.add(normalIndividuals.get(i)); } } } @@ -377,8 +379,6 @@ // TODO Auto-generated catch block e.printStackTrace(); } - cm.applyConfigEntry(la, "numberOfTrees", 100); - cm.applyConfigEntry(la, "maxDepth", 5); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); try { // initializes the learning algorithm @@ -455,27 +455,27 @@ setPositiveConcept(); for (Iterator<Individual> j = rs.getIndividuals().iterator(); j .hasNext();) { - String ind = j.next().toManchesterSyntaxString(editor.getModelManager() - .getActiveOntology().getURI() - .toString()+"#", null); + Individual ind = j.next(); + normalIndividuals.add(ind.toString()); + String indiv = ind.toString(); // checks if individual belongs to the selected concept - if (setPositivExamplesChecked(ind)) { + if (setPositivExamplesChecked(indiv)) { // when yes then it sets the positive example checked - JCheckBox box = new JCheckBox(ind.toString(), true); + JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), true); box.setName("Positive"); positiv.add(box); // and ne genative examples unchecked - JCheckBox box2 = new JCheckBox(ind.toString(), false); + JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), false); box.setName("Negative"); negativ.add(box2); } else { // When no it unchecks the positive example - JCheckBox box = new JCheckBox(ind.toString(), false); + JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), false); box.setName("Positive"); positiv.add(box); // and checks the negative example - JCheckBox box2 = new JCheckBox(ind.toString(), true); + JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), true); box.setName("Negative"); negativ.add(box2); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-04 17:02:56 UTC (rev 1491) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-05 12:51:43 UTC (rev 1492) @@ -22,6 +22,7 @@ import java.awt.GridLayout; import java.util.Iterator; +import javax.swing.Box; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; @@ -116,6 +117,8 @@ */ public MoreDetailForSuggestedConceptsPanel(DLLearnerModel model) { this.model = model; + + } /** * This method returns the Detail Panel. @@ -132,12 +135,25 @@ */ public void renderDetailPanel(EvaluatedDescription desc) { eval = desc; - conceptPanel = new JPanel(new GridLayout(0,2)); - accuracyPanel = new JPanel(new GridLayout(0,2)); - posCoveredPanel = new JPanel(new GridLayout(0,2)); - posNotCoveredPanel = new JPanel(new GridLayout(0,2)); - negCoveredPanel = new JPanel(new GridLayout(0,2)); - negNotCoveredPanel = new JPanel(new GridLayout(0,2)); + JPanel posBox = new JPanel(new GridLayout(0,2)); + JPanel negBox = new JPanel(new GridLayout(0,2)); + Box exampleBox = Box.createVerticalBox(); + concept = new JTextArea("Class Description:"); + concept.setEditable(false); + coveredPositiveExamples = new JLabel("Covered Positive Examples:"); + coveredPositiveExamples.setForeground(colorGreen); + notCoveredPositiveExamples = new JLabel("Not Covered Positive Examples"); + notCoveredPositiveExamples.setForeground(colorRed); + coveredNegativeExamples = new JLabel("Covered Negative Examples:"); + coveredNegativeExamples.setForeground(colorRed); + notCoveredNegativeExamples = new JLabel("Not Covered Negative Examples"); + notCoveredNegativeExamples.setForeground(colorGreen); + conceptPanel = new JPanel(new GridLayout(0,1)); + accuracyPanel = new JPanel(new GridLayout(0,1)); + posCoveredPanel = new JPanel(new GridLayout(0,1)); + posNotCoveredPanel = new JPanel(new GridLayout(0,1)); + negCoveredPanel = new JPanel(new GridLayout(0,1)); + negNotCoveredPanel = new JPanel(new GridLayout(0,1)); accuracy = new JTextArea("Accuracy:"); accuracy.setEditable(false); conceptText = new JTextArea(); @@ -162,51 +178,33 @@ //sets accuracy text area not editable accuracyText.setEditable(false); //panel for the informations of the selected concept - examplePanel = new JPanel(new GridLayout(0,1)); + examplePanel = new JPanel(new GridLayout(0,2)); //this method adds the informations for the selected concept to the panel setInformation(); - concept = new JTextArea("Class Description:"); - concept.setEditable(false); - coveredPositiveExamples = new JLabel("Covered Positive Examples:"); - coveredPositiveExamples.setForeground(colorGreen); - notCoveredPositiveExamples = new JLabel("Not Covered Positive Examples"); - notCoveredPositiveExamples.setForeground(colorRed); - coveredNegativeExamples = new JLabel("Covered Negative Examples:"); - coveredNegativeExamples.setForeground(colorRed); - notCoveredNegativeExamples = new JLabel("Not Covered Negative Examples"); - notCoveredNegativeExamples.setForeground(colorGreen); + detailPopup = new JDialog(); detailPopup.setSize(400, 400); //window will be disposed if the x button is pressed detailPopup.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); detailPopup.setVisible(true); - detailPopup.setResizable(false); + detailPopup.setResizable(true); detailScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); //adds all information to the example panel conceptPanel.add(concept); conceptPanel.add(conceptText); + accuracyPanel.add(accuracy); accuracyPanel.add(accuracyText); - //examplePanel.add(concept); - //examplePanel.add(conceptText); - //examplePanel.add(accuracy); - //examplePanel.add(accuracyText); - posCoveredPanel.add(coveredPositiveExamples); - posCoveredPanel.add(posCoveredText); - posNotCoveredPanel.add(notCoveredPositiveExamples); - posNotCoveredPanel.add(posNotCoveredText); - negCoveredPanel.add(coveredNegativeExamples); - negCoveredPanel.add(negCoveredText); - negNotCoveredPanel.add(notCoveredNegativeExamples); - - negNotCoveredPanel.add(negNotCoveredText); - examplePanel.add(conceptPanel); - examplePanel.add(accuracyPanel); - examplePanel.add(posCoveredPanel); - examplePanel.add(posNotCoveredPanel); - examplePanel.add(negCoveredPanel); - examplePanel.add(negNotCoveredPanel); - detailScroll.setViewportView(examplePanel); + + exampleBox.add(conceptPanel); + exampleBox.add(accuracyPanel); + posBox.add(posCoveredPanel); + posBox.add(posNotCoveredPanel); + negBox.add(negCoveredPanel); + negBox.add(negNotCoveredPanel); + exampleBox.add(posBox); + exampleBox.add(negBox); + detailScroll.setViewportView(exampleBox); detailPopup.add(detailScroll); } /** @@ -219,20 +217,36 @@ double acc = (eval.getAccuracy())*100; accuracyText.append(String.valueOf(acc)+"%"); //sets the positive examples that are covered + posCoveredPanel.add(coveredPositiveExamples); + posNotCoveredPanel.add(notCoveredPositiveExamples); + negCoveredPanel.add(coveredNegativeExamples); + negNotCoveredPanel.add(notCoveredNegativeExamples); for(Iterator<Individual> i = eval.getCoveredPositives().iterator(); i.hasNext();) { - posCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); + JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); + posLabel.setForeground(colorGreen); + posCoveredPanel.add(posLabel); + //posCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } //sets the positive examples that are not covered for(Iterator<Individual> i = eval.getNotCoveredPositives().iterator(); i.hasNext();) { - posNotCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); + JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); + posLabel.setForeground(colorRed); + posNotCoveredPanel.add(posLabel); + //posNotCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } //sets the negative examples that are covered for(Iterator<Individual> i = eval.getCoveredNegatives().iterator(); i.hasNext();) { - negCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); + JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); + posLabel.setForeground(colorRed); + negCoveredPanel.add(posLabel); + //negCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } //sets the negative examples that are not covered for(Iterator<Individual> i = eval.getNotCoveredNegatives().iterator(); i.hasNext();) { - negNotCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); + JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); + posLabel.setForeground(colorGreen); + negNotCoveredPanel.add(posLabel); + //negNotCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-04 17:02:56 UTC (rev 1491) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-05 12:51:43 UTC (rev 1492) @@ -36,6 +36,7 @@ import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -355,6 +356,7 @@ // Picture of the advanced button when it is toggled private JPanel addButtonPanel; + private JTextArea wikiPane; private ImageIcon toggledIcon; private JTextArea hint; // This is the Panel for more details of the suggested concept @@ -371,6 +373,8 @@ public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab dlLearner) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); mainWindow = dlLearner; + wikiPane = new JTextArea("See http://dl-learner.org/wiki/ProtegePlugin for an introduction."); + wikiPane.setEditable(false); classSelectorPanel.firePropertyChange("test", false, true); URL iconUrl = this.getClass().getResource("arrow.gif"); icon = new ImageIcon(iconUrl); @@ -445,6 +449,7 @@ advanced.setSelected(false); sugPanel.setBounds(10, 35, 490, 110); adv.setBounds(40, 200, 200, 20); + wikiPane.setBounds(220, 10, 350, 30); addButtonPanel.setBounds(510, 40, 80, 110); run.setBounds(10, 0, 200, 30); advanced.setBounds(10, 200, 20, 20); @@ -455,6 +460,7 @@ hint.setBounds(10, 150, 490, 20); errorMessage.setBounds(10, 170, 490, 20); learner.add(run); + learner.add(wikiPane); learner.add(adv); learner.add(advanced); learner.add(sugPanel); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-04 17:02:56 UTC (rev 1491) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-05 12:51:43 UTC (rev 1492) @@ -1,5 +1,6 @@ package org.dllearner.tools.protege; +import java.awt.Dimension; import java.awt.GridLayout; import javax.swing.JLabel; @@ -26,7 +27,8 @@ */ public OptionPanel() { - + setPreferredSize(new Dimension(490, 120)); + setLayout(new GridLayout(0,1)); optionPanel = new JPanel(new GridLayout(0,2)); minAccuracyLabel = new JLabel("minimum accuracy"); maxExecutionTimeLabel = new JLabel("maximum execution time"); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-04 17:02:56 UTC (rev 1491) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-05 12:51:43 UTC (rev 1492) @@ -100,7 +100,9 @@ * ActionHandler */ public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act) { - super(new GridLayout(0,1)); + super(); + setLayout(new GridLayout(0,1)); + setPreferredSize(new Dimension(490, 250)); optionPanel = new OptionPanel(); pos = new JLabel("Positive Examples"); neg = new JLabel("Negative Examples"); @@ -149,8 +151,8 @@ scrollPanel = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPanel.setViewportView(posAndNegPanel); - optionPanel.setPreferredSize(new Dimension(490, 70)); - scrollPanel.setPreferredSize(new Dimension(490, 180)); + optionPanel.setPreferredSize(new Dimension(490, 100)); + scrollPanel.setPreferredSize(new Dimension(490, 140)); add(optionPanel); add(scrollPanel); addListeners(action); @@ -241,7 +243,7 @@ JOptionPane.showMessageDialog(null, assistance, "Help", - JOptionPane.WARNING_MESSAGE); + JOptionPane.OK_OPTION); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-06 13:29:11
|
Revision: 1494 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1494&view=rev Author: heeroyuy Date: 2008-11-06 13:29:04 +0000 (Thu, 06 Nov 2008) Log Message: ----------- -some changes in GUI Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -257,8 +257,7 @@ evaluatedDescription); } } else { - String message = "No concept to select."; - view.renderErrorMessage(message); + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -25,6 +25,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -194,6 +195,8 @@ // This is necessary to get the details of the suggested concept private JXTaskPane detailPane; + private String ontologyURI; + private Map<String, String> prefixes; // This is a List of evaluated descriptions to get more information of the // suggested concept @@ -219,6 +222,7 @@ current = h; this.id = id; this.view = view; + ontologyURI = editor.getModelManager().getActiveOntology().getURI().toString()+"#"; owlDescription = new HashSet<OWLDescription>(); positiv = new Vector<JCheckBox>(); negativ = new Vector<JCheckBox>(); @@ -240,30 +244,25 @@ alreadyLearned = false; setKnowledgeSource(); setReasoner(); + prefixes = reasoner.getPrefixes(); + } /** * This method adds the solutions from the DL-Learner to the List Model. */ private void addToListModel() { + evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts(), view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy(), true); for (int j = 0; j < evalDescriptions.size(); j++) { if (isConsistent(evalDescriptions.get(j))) { suggestModel.add(j, new SuggestListItem(Color.GREEN, evalDescriptions.get(j).getDescription() - .toManchesterSyntaxString( - editor.getModelManager() - .getActiveOntology().getURI() - .toString() - + "#", null))); + .toManchesterSyntaxString(ontologyURI, prefixes))); } else { suggestModel.add(j, new SuggestListItem(Color.RED, evalDescriptions.get(j).getDescription() - .toManchesterSyntaxString( - editor.getModelManager() - .getActiveOntology().getURI() - .toString() - + "#", null))); + .toManchesterSyntaxString(ontologyURI, prefixes))); } } } @@ -351,7 +350,7 @@ // dllearner should suggest an equivalent class lp = cm.learningProblem(PosNegDefinitionLP.class, rs); } - if (id.equals("superclasses")) { + if (id.equals("super classes")) { // sets the learning problem to PosNegInclusionLP when the dllearner // should suggest a subclass lp = cm.learningProblem(PosNegInclusionLP.class, rs); @@ -379,6 +378,7 @@ // TODO Auto-generated catch block e.printStackTrace(); } + System.out.println("TIME: "+view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); try { // initializes the learning algorithm @@ -461,21 +461,21 @@ // checks if individual belongs to the selected concept if (setPositivExamplesChecked(indiv)) { // when yes then it sets the positive example checked - JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), true); + JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), true); box.setName("Positive"); positiv.add(box); // and ne genative examples unchecked - JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), false); + JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), false); box.setName("Negative"); negativ.add(box2); } else { // When no it unchecks the positive example - JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), false); + JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), false); box.setName("Positive"); positiv.add(box); // and checks the negative example - JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(editor.getModelManager().getActiveOntology().getURI().toString()+"#", null), true); + JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), true); box.setName("Negative"); negativ.add(box2); } @@ -524,7 +524,27 @@ individual = rs.getIndividuals(); } } - + public boolean hasIndividuals(OWLClass OWLConcept) { + boolean hasIndividuals = false; + NamedClass concept = null; + NamedClass selectedConcept = null; + Iterator<NamedClass> it = reasoner.getAtomicConcepts().iterator(); + while(it.hasNext()) { + concept = it.next(); + if (concept.toManchesterSyntaxString(ontologyURI, prefixes).equals(OWLConcept.toString())) { + selectedConcept = concept; + break; + } + } + System.out.println("CON: "+ concept); + System.out.println("SIZE: "+ reasoner.retrieval(concept).size()); + if (reasoner.retrieval(selectedConcept).size() > 0) { + hasIndividuals = true; + } + concept = null; + selectedConcept = null; + return hasIndividuals; + } /** * This method gets an Individual and checks if this individual belongs to * the concept chosen in protege. Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -24,6 +24,7 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; @@ -36,7 +37,6 @@ import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; -import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -127,14 +127,13 @@ editingComponent = new JPanel(new BorderLayout()); editingComponent.add(tabbedPane); editingComponent.setPreferredSize(new Dimension(600, 520)); - if(dllearner.getNrOfIndividuals()!=0) { if (label.equals("equivalent classes")) { tabbedPane.add(SUGGEST_EQUIVALENT_CLASS_LABEL, dllearner); } - if (label.equals("superclasses")) { + if (label.equals("super classes")) { tabbedPane.add(SUGGEST_SUBCLASS_LABEL, dllearner); } - } + // tabbedPane.add(CLASS_EXPRESSION_EDITOR_LABEL, new JScrollPane(editor)); if (description == null || !description.isAnonymous()) { @@ -356,11 +355,13 @@ // Picture of the advanced button when it is toggled private JPanel addButtonPanel; - private JTextArea wikiPane; + private JLabel wikiPane; private ImageIcon toggledIcon; private JTextArea hint; // This is the Panel for more details of the suggested concept private MoreDetailForSuggestedConceptsPanel detail; + OWLFrame<OWLClass> frame; + private URL pluginURL; /** * The constructor for the DL-Learner tab in the class description @@ -373,8 +374,16 @@ public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab dlLearner) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); mainWindow = dlLearner; - wikiPane = new JTextArea("See http://dl-learner.org/wiki/ProtegePlugin for an introduction."); - wikiPane.setEditable(false); + frame = current; + try { + pluginURL = new URL("http://dl-learner.org/wiki/ProtegePlugin"); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + wikiPane = new JLabel("See " + pluginURL + " for an introduction."); + //wikiPane.setEditable(false); + classSelectorPanel.firePropertyChange("test", false, true); URL iconUrl = this.getClass().getResource("arrow.gif"); icon = new ImageIcon(iconUrl); @@ -387,6 +396,7 @@ adv = new JLabel("Advanced Settings"); advanced = new JToggleButton(icon); advanced.setVisible(true); + run = new JButton("Suggest " + label); accept = new JButton("ADD"); addButtonPanel = new JPanel(new BorderLayout()); @@ -435,6 +445,15 @@ * This Method renders the view of the plugin. */ public void makeView() { + System.out.println("CURRENT: "+ frame.getRootObject()); + System.out.println("MODEL: "+model.hasIndividuals(frame.getRootObject())); + if (model.hasIndividuals(frame.getRootObject())) { + run.setEnabled(true); + } else { + run.setEnabled(false); + String message ="There are no Instances for "+ frame.getRootObject()+" available. Please insert some Instances."; + renderErrorMessage(message); + } advanced.setIcon(icon); model.clearVector(); model.unsetListModel(); @@ -596,6 +615,12 @@ * Destroys the view after the plugin is closed. */ public void dispose() { + System.out.println("hier"); + run.removeActionListener(action); + accept.removeActionListener(action); + advanced.removeActionListener(action); + posPanel.removeListeners(action); + posPanel.removeHelpButtonListener(action); } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLEquivalentClassesAxiomFrameSection.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -57,6 +57,7 @@ private Set<OWLClass> added; private boolean inferredEquivalentClasses = true; + private OWLClassDescriptionEditorWithDLLearnerTab dlLearner; private OWLFrame<OWLClass> frame; /** @@ -146,8 +147,9 @@ public OWLFrameSectionRowObjectEditor<OWLDescription> getObjectEditor() { // Own OWLClassDescriptionEditor to integrate the dllearner in protege // This is to suggest equivalent classes - return new OWLClassDescriptionEditorWithDLLearnerTab(getOWLEditorKit(), + dlLearner = new OWLClassDescriptionEditorWithDLLearnerTab(getOWLEditorKit(), null, frame, LABEL); + return dlLearner; } @Override Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLSubClassAxiomFrameSection.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -51,11 +51,12 @@ public class OWLSubClassAxiomFrameSection extends AbstractOWLFrameSection<OWLClass, OWLSubClassAxiom, OWLDescription> { - private static final String LABEL = "superclasses"; + private static final String LABEL = "super classes"; private Set<OWLDescription> added = new HashSet<OWLDescription>(); private OWLFrame<OWLClass> frame; + private OWLClassDescriptionEditorWithDLLearnerTab dlLearner; /** * Constructor of the OWLSubClassesAxiomFrameSection. * @param editorKit OWLEditorKit @@ -121,8 +122,9 @@ public OWLFrameSectionRowObjectEditor<OWLDescription> getObjectEditor() { // Own OWLClassDescriptionEditor to integrate the dllearner in protege // this is to suggest subclasses - return new OWLClassDescriptionEditorWithDLLearnerTab(getOWLEditorKit(), + dlLearner = new OWLClassDescriptionEditorWithDLLearnerTab(getOWLEditorKit(), null, frame, LABEL); + return dlLearner; } @Override Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -207,6 +207,17 @@ } + public void removeListeners(ActionHandler act) { + // adds the listener for the checkboxes + for (int i = 0; i < model.getPosVector().size(); i++) { + // listener for the check boxes of the positive examples + model.getPositivJCheckBox(i).removeItemListener(act); + // listener for the check boxes of the negative examples + model.getNegativJCheckBox(i).removeItemListener(act); + } + + } + public void setCheckBoxesEnable(boolean enable) { for (int j = 0; j < model.getPosVector().size(); j++) { model.getPositivJCheckBox(j).setEnabled(enable); @@ -240,10 +251,8 @@ */ public void renderHelpMessage(String assistance) { // renders scroll bar if necessary - JOptionPane.showMessageDialog(null, - assistance, - "Help", - JOptionPane.OK_OPTION); + JOptionPane.showMessageDialog(null, assistance); + } /** @@ -259,6 +268,10 @@ helpForNegExamples.addActionListener(a); } + public void removeHelpButtonListener(ActionHandler a) { + helpForPosExamples.removeActionListener(a); + helpForNegExamples.removeActionListener(a); + } public OptionPanel getOptionPanel() { return optionPanel; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2008-11-06 12:02:22 UTC (rev 1493) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestListCellRenderer.java 2008-11-06 13:29:04 UTC (rev 1494) @@ -65,6 +65,7 @@ } else { setBorder(BorderFactory.createLineBorder(list.getBackground(), 2)); } + setEnabled(list.isEnabled()); return this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-07 17:46:44
|
Revision: 1496 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1496&view=rev Author: heeroyuy Date: 2008-11-07 17:46:34 +0000 (Fri, 07 Nov 2008) Log Message: ----------- -changes in panel where the examples are set Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -124,20 +124,6 @@ view.renderErrorMessage(message); view.updateWindow(); } - - if (z.getActionCommand().equals("?")) { - if (z.getSource().toString().contains("PosHelpButton")) { - String help = "An individual that should be an instance of the learned class description.\n" - +"Per Default all that belongs to the class."; - view.getPosAndNegSelectPanel().renderHelpMessage(help); - } - - if (z.getSource().toString().contains("NegHelpButton")) { - String help = "A Instance tht doesn't follow from the classdescription."; - view.getPosAndNegSelectPanel().renderHelpMessage(help); - } - - } if (z.getActionCommand().equals("")) { if (!toggled) { toggled = true; Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -197,6 +197,9 @@ private JXTaskPane detailPane; private String ontologyURI; private Map<String, String> prefixes; + private DefaultListModel posListModel; + private DefaultListModel negListModel; + private Vector<IndividualObject> individualVector; // This is a List of evaluated descriptions to get more information of the // suggested concept @@ -225,9 +228,12 @@ ontologyURI = editor.getModelManager().getActiveOntology().getURI().toString()+"#"; owlDescription = new HashSet<OWLDescription>(); positiv = new Vector<JCheckBox>(); + posListModel = new DefaultListModel(); + negListModel = new DefaultListModel(); negativ = new Vector<JCheckBox>(); normalIndividuals = new Vector<String>(); ComponentManager.setComponentClasses(componenten); + individualVector = new Vector<IndividualObject>(); cm = ComponentManager.getInstance(); ds = new HashSet<OWLDescription>(); suggestModel = new DefaultListModel(); @@ -461,23 +467,13 @@ // checks if individual belongs to the selected concept if (setPositivExamplesChecked(indiv)) { // when yes then it sets the positive example checked - JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), true); - box.setName("Positive"); - positiv.add(box); - // and ne genative examples unchecked - JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), false); - box.setName("Negative"); - negativ.add(box2); + posListModel.add(0, ind.toManchesterSyntaxString(ontologyURI, prefixes)); + individualVector.add(new IndividualObject(indiv, ind.toManchesterSyntaxString(ontologyURI, prefixes), true)); } else { // When no it unchecks the positive example - JCheckBox box = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), false); - box.setName("Positive"); - positiv.add(box); - // and checks the negative example - JCheckBox box2 = new JCheckBox(ind.toManchesterSyntaxString(ontologyURI, prefixes), true); - box.setName("Negative"); - negativ.add(box2); + negListModel.add(0, ind.toManchesterSyntaxString(ontologyURI, prefixes)); + individualVector.add(new IndividualObject(indiv, ind.toManchesterSyntaxString(ontologyURI, prefixes), false)); } } } @@ -492,7 +488,9 @@ } } - + public Vector<IndividualObject> getIndividualVector() { + return individualVector; + } /** * This method sets the individuals that belong to the concept which is * chosen in protege. @@ -573,6 +571,9 @@ * closed. */ public void clearVector() { + individualVector.removeAllElements(); + posListModel.removeAllElements(); + negListModel.removeAllElements(); positiv.removeAllElements(); negativ.removeAllElements(); } @@ -587,7 +588,14 @@ public void setDescriptionList(Description[] list) { description = list; } - + + public DefaultListModel getPosListModel() { + return posListModel; + } + + public DefaultListModel getNegListModel() { + return negListModel; + } /** * This method returns the current learning algorithm that is used to learn * new concepts. Added: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -0,0 +1,30 @@ +package org.dllearner.tools.protege; + +public class IndividualObject { + + private String normalIndividual; + private String manchesterIndividual; + private boolean isPos; + + public IndividualObject(String normal, String manchester, boolean pos) { + normalIndividual = normal; + manchesterIndividual = manchester; + isPos = pos; + } + + public String getIndividualString() { + return normalIndividual; + } + + public String getManchesterIndividual() { + return manchesterIndividual; + } + + public boolean isPositiveExample() { + return isPos; + } + + public void setExamplePositive(boolean pos) { + isPos = pos; + } +} Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -73,7 +73,7 @@ // Panel where the informations of the selected panel are rendered - private JPanel examplePanel; + //private JPanel examplePanel; // Text area that shows the covered positive examples @@ -178,7 +178,7 @@ //sets accuracy text area not editable accuracyText.setEditable(false); //panel for the informations of the selected concept - examplePanel = new JPanel(new GridLayout(0,2)); + //examplePanel = new JPanel(new GridLayout(0,2)); //this method adds the informations for the selected concept to the panel setInformation(); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -412,7 +412,7 @@ learner.setPreferredSize(new Dimension(600, 520)); accept.setPreferredSize(new Dimension(290, 50)); advanced.setName("Advanced"); - posPanel = new PosAndNegSelectPanel(model, action); + posPanel = new PosAndNegSelectPanel(model, action, this); addAcceptButtonListener(this.action); addRunButtonListener(this.action); addAdvancedButtonListener(this.action); @@ -445,21 +445,21 @@ * This Method renders the view of the plugin. */ public void makeView() { - System.out.println("CURRENT: "+ frame.getRootObject()); - System.out.println("MODEL: "+model.hasIndividuals(frame.getRootObject())); + /* if (model.hasIndividuals(frame.getRootObject())) { run.setEnabled(true); } else { run.setEnabled(false); String message ="There are no Instances for "+ frame.getRootObject()+" available. Please insert some Instances."; renderErrorMessage(message); - } + }*/ advanced.setIcon(icon); model.clearVector(); model.unsetListModel(); - //model.initReasoner(); + model.initReasoner(); model.setPosVector(); - posPanel.setJCheckBoxes(); + System.out.println(model.getPosListModel()); + posPanel.setExampleList(model.getPosListModel(), model.getNegListModel()); accept.setEnabled(false); action.resetToggled(); addButtonPanel.add("North", accept); @@ -487,7 +487,6 @@ learner.add(hint); learner.add(errorMessage); learner.add(posPanel); - posPanel.addHelpButtonListener(action); detail = new MoreDetailForSuggestedConceptsPanel(model); add(learner); } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-07 14:31:10 UTC (rev 1495) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -20,12 +20,12 @@ package org.dllearner.tools.protege; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.GridLayout; +import javax.swing.DefaultListModel; import javax.swing.JButton; -import javax.swing.JComboBox; import javax.swing.JLabel; +import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -44,7 +44,7 @@ // This is the Panel here the check boxes, the labels, and the help buttons // are in. - private JPanel posAndNegPanel; + //private JPanel posAndNegPanel; // this is the Panel where the check boxes are. @@ -57,7 +57,19 @@ // This is the Scroll pane if there are more Check boxes than the view can // show - private JScrollPane scrollPanel; + private JScrollPane posScrollList; + + private JScrollPane negScrollList; + + private JList posList; + private JList negList; + private JPanel posPanel; + private JPanel negPanel; + private JPanel buttonPanel; + private JButton addToNegExamples; + private JButton addToPosExamples; + private JPanel posLabelPanel; + private JPanel negLabelPanel; // This is the Label that shows "Positive Examples" @@ -70,13 +82,7 @@ // This is the Panel where the Label for Positive Examples and // a help Button is in - private JPanel posLabelPanel; - // This is the Panel where the Label for Negative Examples and - // a help Button is in - - private JPanel negLabelPanel; - // This is the Help button for positive examples private JButton helpForPosExamples; @@ -87,9 +93,14 @@ // This is the Text area where the help message is displayed. private OptionPanel optionPanel; - private JComboBox optionBox; - private JPanel optionBoxPanel; - private ActionHandler action; + //private JComboBox optionBox; + //private JPanel optionBoxPanel; + //private ActionHandler action; + private DefaultListModel posListModel; + private DefaultListModel negListModel; + private JPanel examplePanel; + private PosAndNegSelectPanelHandler handler; + private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; /** * This is the constructor for the Panel that shows the check boxes. @@ -99,95 +110,107 @@ * @param act * ActionHandler */ - public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act) { + public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView v) { + //set layout for parent Panel super(); - setLayout(new GridLayout(0,1)); + setLayout(new GridLayout(0, 1)); setPreferredSize(new Dimension(490, 250)); + view = v; + this.model = model; + handler = new PosAndNegSelectPanelHandler(model, view, this); + //Instantiate all objects needed optionPanel = new OptionPanel(); + examplePanel = new JPanel(null); + posLabelPanel = new JPanel(null); + negLabelPanel = new JPanel(null); + posListModel = new DefaultListModel(); + negListModel = new DefaultListModel(); pos = new JLabel("Positive Examples"); + pos.setBounds(0, 0, 100, 30); neg = new JLabel("Negative Examples"); - optionBoxPanel = new JPanel(new GridLayout(0, 1)); - action = act; - optionBox = new JComboBox(); - optionBox.addItem("min. accuracy"); - optionBox.addItem("max. nr. of results"); - optionBox.addItem("max. executiontime"); - optionBoxPanel.add(optionBox); - setComboBoxListener(); - // help button for positive examples + neg.setBounds(0, 0, 100, 30); + posList = new JList(posListModel); + negList = new JList(negListModel); + addToPosExamples = new JButton("pos"); + addToNegExamples = new JButton("neg"); helpForPosExamples = new JButton("?"); - helpForPosExamples.setSize(10, 10); - // help button for negative examples + helpForPosExamples.setBounds(100, 5, 20, 20); helpForNegExamples = new JButton("?"); - helpForNegExamples.setSize(10, 10); - posLabelPanel = new JPanel(new GridLayout(0, 1)); - negLabelPanel = new JPanel(new GridLayout(0, 1)); - // panel for the positive check boxes with flow layout - posLabelPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); - // panel for the negative check boxes with flow layout - negLabelPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); - // sets the name for the positive examples help button to - // differ which button is pressed + helpForNegExamples.setBounds(100, 5, 20, 20); helpForPosExamples.setName("PosHelpButton"); + helpForNegExamples.setName("NegHelpButton"); + //set size for components that have no layout. + posPanel = new JPanel(null); + posPanel.setPreferredSize(new Dimension(200, 100)); + negPanel = new JPanel(null); + negPanel.setPreferredSize(new Dimension(200, 100)); + buttonPanel = new JPanel(null); + buttonPanel.setPreferredSize(new Dimension(90, 85)); + addToPosExamples.setBounds(0, 50, 70, 30); + addToNegExamples.setBounds(0, 80, 70, 30); + addToPosExamples.setEnabled(false); + addToNegExamples.setEnabled(false); + buttonPanel.add(addToPosExamples); + buttonPanel.add(addToNegExamples); posLabelPanel.add(pos); posLabelPanel.add(helpForPosExamples); - // sets the name for the negative examples help button to - // differ which button is pressed - helpForNegExamples.setName("NegHelpButton"); negLabelPanel.add(neg); negLabelPanel.add(helpForNegExamples); - this.model = model; - // panel for the check boxes - posAndNegSelectPanel = new JPanel(new GridLayout(0, 2)); - - model.clearVector(); - model.unsetListModel(); - model.initReasoner(); + posScrollList = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + posScrollList.setViewportView(posList); - model.setPosVector(); - posAndNegPanel = new JPanel(new GridLayout(0, 1)); - posAndNegPanel.add(posAndNegSelectPanel); - // renders scroll bars if necessary - scrollPanel = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + negScrollList = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - scrollPanel.setViewportView(posAndNegPanel); - optionPanel.setPreferredSize(new Dimension(490, 100)); - scrollPanel.setPreferredSize(new Dimension(490, 140)); + negScrollList.setViewportView(negList); + + posLabelPanel.setBounds(0, 0, 200, 30); + posScrollList.setBounds(0, 40, 190, 85); + + posPanel.add(posScrollList); + posPanel.add(posLabelPanel); + + negLabelPanel.setBounds(0, 0, 200, 30); + negScrollList.setBounds(0, 40, 185, 85); + negPanel.add(negLabelPanel); + negPanel.add(negScrollList); + + posPanel.setBounds(0, 0, 200, 250); + buttonPanel.setBounds(210, 0, 90, 250); + negPanel.setBounds(300, 0, 200, 250); + examplePanel.add(posPanel); + examplePanel.add(buttonPanel); + examplePanel.add(negPanel); + addHelpButtonListener(handler); add(optionPanel); - add(scrollPanel); - addListeners(action); + add(examplePanel); } /** * This method adds the check boxes, the labels and the help buttons for * positive and negative examples. */ - public void setJCheckBoxes() { - posAndNegSelectPanel.add(posLabelPanel); - posAndNegSelectPanel.add(negLabelPanel); - // adds check boxes for all examples of the ontology - for (int j = 0; j < model.getPosVector().size(); j++) { - // this is for the check boxes of the positive examples - posAndNegSelectPanel.add(model.getPositivJCheckBox(j)); - // this is for the check boxes of the negative examples - posAndNegSelectPanel.add(model.getNegativJCheckBox(j)); - } - + public void setExampleList(DefaultListModel posData, DefaultListModel negData) { + posListModel = posData; + negListModel = negData; + posList.setModel(posListModel); + negList.setModel(negListModel); } - /** - * This method adds the ActionListener to the Option Combo Box. - */ - private void setComboBoxListener() { - optionBox.addActionListener(action); + public JButton getAddToPosPanelButton() { + return addToPosExamples; } + public JButton getAddToNegPanelButton() { + return addToNegExamples; + } + /** * This method removes the Check boxes, the labels and the help buttons * after the DL-Learner tab is closed. */ public void unsetPosAndNegPanel() { - posAndNegSelectPanel.removeAll(); + } /** @@ -198,32 +221,14 @@ */ public void addListeners(ActionHandler act) { // adds the listener for the checkboxes - for (int i = 0; i < model.getPosVector().size(); i++) { - // listener for the check boxes of the positive examples - model.getPositivJCheckBox(i).addItemListener(act); - // listener for the check boxes of the negative examples - model.getNegativJCheckBox(i).addItemListener(act); - } } public void removeListeners(ActionHandler act) { - // adds the listener for the checkboxes - for (int i = 0; i < model.getPosVector().size(); i++) { - // listener for the check boxes of the positive examples - model.getPositivJCheckBox(i).removeItemListener(act); - // listener for the check boxes of the negative examples - model.getNegativJCheckBox(i).removeItemListener(act); - } } public void setCheckBoxesEnable(boolean enable) { - for (int j = 0; j < model.getPosVector().size(); j++) { - model.getPositivJCheckBox(j).setEnabled(enable); - model.getNegativJCheckBox(j).setEnabled(enable); - } - } /** @@ -261,11 +266,11 @@ * @param a * ActionHandler */ - public void addHelpButtonListener(ActionHandler a) { + public void addHelpButtonListener(PosAndNegSelectPanelHandler handle) { // adds listener to the help button for the positive examples - helpForPosExamples.addActionListener(a); + helpForPosExamples.addActionListener(handle); // adds listener to the help button for the negative examples - helpForNegExamples.addActionListener(a); + helpForNegExamples.addActionListener(handle); } public void removeHelpButtonListener(ActionHandler a) { Added: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-07 17:46:34 UTC (rev 1496) @@ -0,0 +1,151 @@ +package org.dllearner.tools.protege; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + + +public class PosAndNegSelectPanelHandler implements ActionListener, MouseListener { + + +// This is the DLLearnerModel. + +private DLLearnerModel model; +//private PosAndNegSelectPanel panel; +// This is the view of the DL-Learner tab. +private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; + +/** + * This is the constructor for the action handler. + * + * @param a + * ActionHandler + * @param m + * DLLearnerModel + * @param view + * DLlearner tab + * @param i + * id if it is a subclass or an equivalent class + * @param editor OWLEditorKit + */ +public PosAndNegSelectPanelHandler(DLLearnerModel m, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView v, PosAndNegSelectPanel p) { + model = m; + //panel = p; + view = v; +} + +/** + * When a Button is pressed this method select the right. + * @param z ActionEvent + */ +public void actionPerformed(ActionEvent action) { + + + if (action.getActionCommand().equals("pos")) { + + } + + if (action.getActionCommand().equals("neg")) { + + } + + if (action.getActionCommand().equals("?")) { + if (action.getSource().toString().contains("PosHelpButton")) { + String help = "An individual that should be an instance of the learned class description.\n" + +"Per Default all that belongs to the class."; + view.getPosAndNegSelectPanel().renderHelpMessage(help); + } + + if (action.getSource().toString().contains("NegHelpButton")) { + String help = "A Instance tht doesn't follow from the classdescription."; + view.getPosAndNegSelectPanel().renderHelpMessage(help); + } + + } +} + +/** + * select/deselect the Check boxes. + * @param i ItemEvent + */ +public void itemStateChanged(ItemEvent i) { + if (i.getItem().toString().contains("Positive")) { + for (int j = 0; j < model.getPosVector().size(); j++) { + if (i.getItem().toString().contains( + model.getPosVector().get(j).getText().toString())) { + if (!model.getPosVector().get(j).isSelected()) { + model.getPosVector().get(j).setSelected(true); + break; + } + if (model.getPosVector().get(j).isSelected()) { + model.getPosVector().get(j).setSelected(false); + break; + } + } + } + } + if (i.getItem().toString().contains("Negative")) { + for (int j = 0; j < model.getNegVector().size(); j++) { + if (i.getItem().toString().contains( + model.getNegVector().get(j).getText().toString())) { + if (!model.getNegVector().get(j).isSelected()) { + model.getNegVector().get(j).setSelected(true); + break; + } + if (model.getNegVector().get(j).isSelected()) { + model.getNegVector().get(j).setSelected(false); + break; + } + } + } + } +} + + +/** + * Nothing happens here. + * @param m MouseEvent + */ +public void mouseReleased(MouseEvent m) { + +} + + /** + * Nothing happens here. + * @param m MouseEvent + */ +public void mouseEntered(MouseEvent m) { + +} + +/** + * Choses the right EvaluatedDescription object after a concept is chosen in the list. + * @param m MouseEvent + */ +public void mouseClicked(MouseEvent m) { + if (view.getSuggestClassPanel().getSuggestList() + .getSelectedValue() != null) { + } else { + +} +} + +/** + * Nothing happens here. + * @param m MouseEvent + */ +public void mouseExited(MouseEvent m) { + +} + +/** + * Sets the ADD button enable after a concept is chosen. + * @param m MouseEvent + */ +public void mousePressed(MouseEvent m) { +} + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-07 18:41:53
|
Revision: 1497 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1497&view=rev Author: heeroyuy Date: 2008-11-07 18:41:48 +0000 (Fri, 07 Nov 2008) Log Message: ----------- -added listener to new example panel -some bug fixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-07 17:46:34 UTC (rev 1496) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-07 18:41:48 UTC (rev 1497) @@ -95,11 +95,6 @@ if (model.getAlreadyLearned()) { model.unsetListModel(); } - if (view.getPosAndNegSelectPanel().getPosAndNegSelectPanel() - .getComponentCount() <= 2) { - view - .renderErrorMessage("Could not start learning. No Examples where available"); - } else { view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); model.setKnowledgeSource(); model.setReasoner(); @@ -111,7 +106,7 @@ view.getRunButton().setEnabled(false); view.renderErrorMessage("Learning started"); //view.getPosAndNegSelectPanel().unsetCheckBoxes(); - } + } if (z.getActionCommand().equals("ADD")) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-07 17:46:34 UTC (rev 1496) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-07 18:41:48 UTC (rev 1497) @@ -280,15 +280,12 @@ public void setPositiveAndNegativeExamples() { positiveExamples = new TreeSet<String>(); negativeExamples = new TreeSet<String>(); - for (int i = 0; i < positiv.size(); i++) { - if (positiv.get(i).isSelected()) { - - positiveExamples.add(normalIndividuals.get(i)); + for (int i = 0; i < individualVector.size(); i++) { + if (individualVector.get(i).isPositiveExample()) { + positiveExamples.add(individualVector.get(i).getIndividualString()); + } else { + negativeExamples.add(individualVector.get(i).getIndividualString()); } - - if (negativ.get(i).isSelected()) { - negativeExamples.add(normalIndividuals.get(i)); - } } } @@ -400,6 +397,7 @@ */ public void run() { error = "Learning succesful"; + String message = "To view details about why a class description was suggested, please doubleclick on it."; // start the algorithm and print the best concept found la.start(); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-07 17:46:34 UTC (rev 1496) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-07 18:41:48 UTC (rev 1497) @@ -27,4 +27,5 @@ public void setExamplePositive(boolean pos) { isPos = pos; } + } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-07 17:46:34 UTC (rev 1496) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-07 18:41:48 UTC (rev 1497) @@ -458,7 +458,6 @@ model.unsetListModel(); model.initReasoner(); model.setPosVector(); - System.out.println(model.getPosListModel()); posPanel.setExampleList(model.getPosListModel(), model.getNegListModel()); accept.setEnabled(false); action.resetToggled(); @@ -474,6 +473,8 @@ advanced.setBounds(10, 200, 20, 20); sugPanel.setVisible(true); posPanel.setVisible(false); + posPanel.getAddToNegPanelButton().setEnabled(false); + posPanel.getAddToPosPanelButton().setEnabled(false); posPanel.setBounds(10, 230, 490, 250); accept.setBounds(510, 40, 80, 110); hint.setBounds(10, 150, 490, 20); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-07 17:46:34 UTC (rev 1496) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-07 18:41:48 UTC (rev 1497) @@ -148,8 +148,6 @@ buttonPanel.setPreferredSize(new Dimension(90, 85)); addToPosExamples.setBounds(0, 50, 70, 30); addToNegExamples.setBounds(0, 80, 70, 30); - addToPosExamples.setEnabled(false); - addToNegExamples.setEnabled(false); buttonPanel.add(addToPosExamples); buttonPanel.add(addToNegExamples); posLabelPanel.add(pos); @@ -184,6 +182,10 @@ addHelpButtonListener(handler); add(optionPanel); add(examplePanel); + posList.addMouseListener(handler); + negList.addMouseListener(handler); + addToPosExamples.addActionListener(handler); + addToNegExamples.addActionListener(handler); } /** @@ -260,6 +262,41 @@ } + public void setExampleToOtherList(boolean toPos, String example) { + if (toPos) { + for(int i = 0; i < negListModel.size(); i++) { + if(negListModel.get(i).equals(example)) { + negListModel.remove(i); + for (int j = 0; j < model.getIndividualVector().size(); j++ ) { + if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { + model.getIndividualVector().get(j).setExamplePositive(true); + break; + } + } + + } + } + posListModel.add(0, example); + } else { + for(int i = 0; i < posListModel.size(); i++) { + if(posListModel.get(i).equals(example)) { + posListModel.remove(i); + for (int j = 0; j < model.getIndividualVector().size(); j++ ) { + if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { + model.getIndividualVector().get(j).setExamplePositive(false); + } + } + break; + } + } + negListModel.add(0, example); + } + setExampleList(posListModel, negListModel); + addToPosExamples.setEnabled(false); + addToNegExamples.setEnabled(false); + + } + /** * This method adds the Action listener to the help buttons. * @@ -280,5 +317,13 @@ public OptionPanel getOptionPanel() { return optionPanel; } + + public JList getPosExampleList() { + return posList; + } + + public JList getNegExampleList() { + return negList; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-07 17:46:34 UTC (rev 1496) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-07 18:41:48 UTC (rev 1497) @@ -13,7 +13,7 @@ // This is the DLLearnerModel. private DLLearnerModel model; -//private PosAndNegSelectPanel panel; +private PosAndNegSelectPanel panel; // This is the view of the DL-Learner tab. private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; @@ -32,7 +32,7 @@ */ public PosAndNegSelectPanelHandler(DLLearnerModel m, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView v, PosAndNegSelectPanel p) { model = m; - //panel = p; + panel = p; view = v; } @@ -44,11 +44,11 @@ if (action.getActionCommand().equals("pos")) { - + panel.setExampleToOtherList(true, panel.getNegExampleList().getSelectedValue().toString()); } if (action.getActionCommand().equals("neg")) { - + panel.setExampleToOtherList(false, panel.getPosExampleList().getSelectedValue().toString()); } if (action.getActionCommand().equals("?")) { @@ -125,12 +125,17 @@ * @param m MouseEvent */ public void mouseClicked(MouseEvent m) { - if (view.getSuggestClassPanel().getSuggestList() - .getSelectedValue() != null) { + if (panel.getPosExampleList().getSelectedValue() != null) { + panel.getAddToNegPanelButton().setEnabled(true); } else { - + panel.getAddToNegPanelButton().setEnabled(false); + } + if (panel.getNegExampleList().getSelectedValue()!= null) { + panel.getAddToPosPanelButton().setEnabled(true); + } else { + panel.getAddToPosPanelButton().setEnabled(false); + } } -} /** * Nothing happens here. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-14 15:04:17
|
Revision: 1513 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1513&view=rev Author: heeroyuy Date: 2008-11-14 15:04:06 +0000 (Fri, 14 Nov 2008) Log Message: ----------- -fixed updateproblem of the suggest panel after learning Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -19,6 +19,7 @@ */ package org.dllearner.tools.protege; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -26,7 +27,14 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Iterator; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ExecutionException; +import javax.swing.DefaultListModel; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import javax.swing.event.ListSelectionEvent; @@ -37,7 +45,8 @@ import org.protege.editor.owl.OWLEditorKit; /** - * This class processes input from the user. + * This class processes input from the user. + * * @author Christian Koetteritzsch * */ @@ -59,6 +68,7 @@ private EvaluatedDescription evaluatedDescription; // This is the view of the DL-Learner tab. private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; + private Timer timer; /** * This is the constructor for the action handler. @@ -71,7 +81,8 @@ * DLlearner tab * @param i * id if it is a subclass or an equivalent class - * @param editor OWLEditorKit + * @param editor + * OWLEditorKit */ public ActionHandler(ActionHandler a, DLLearnerModel m, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view, @@ -86,34 +97,36 @@ /** * When a Button is pressed this method select the right. - * @param z ActionEvent + * + * @param z + * ActionEvent */ public void actionPerformed(ActionEvent z) { - if (z.getActionCommand().equals("Suggest " + id)) { if (model.getAlreadyLearned()) { model.unsetListModel(); } - view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); - model.setKnowledgeSource(); - model.setReasoner(); - model.setPositiveAndNegativeExamples(); - model.setLearningProblem(); - model.setLearningAlgorithm(); - this.dlLearner = new Thread(model); - dlLearner.start(); - view.getRunButton().setEnabled(false); - view.renderErrorMessage("Learning started"); - //view.getPosAndNegSelectPanel().unsetCheckBoxes(); - + view.getRunButton().setEnabled(false); + view.renderErrorMessage("Learning started"); + view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); + final SuggestionRetriever retriever = new SuggestionRetriever(); + // + // dlLearner.start(); + retriever.execute(); + } if (z.getActionCommand().equals("ADD")) { if (evaluatedDescription != null) { - model.changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription.getDescription()); + model + .changeDLLearnerDescriptionsToOWLDescriptions(evaluatedDescription + .getDescription()); } else { - model.changeDLLearnerDescriptionsToOWLDescriptions((Description) view.getSuggestClassPanel().getSuggestList().getSelectedValue()); + model + .changeDLLearnerDescriptionsToOWLDescriptions((Description) view + .getSuggestClassPanel().getSuggestList() + .getSelectedValue()); } String message = "Concept added"; view.renderErrorMessage(message); @@ -144,47 +157,21 @@ return id; } - /** * select/deselect the Check boxes. - * @param i ItemEvent + * + * @param i + * ItemEvent */ public void itemStateChanged(ItemEvent i) { - if (i.getItem().toString().contains("Positive")) { - for (int j = 0; j < model.getPosVector().size(); j++) { - if (i.getItem().toString().contains( - model.getPosVector().get(j).getText().toString())) { - if (!model.getPosVector().get(j).isSelected()) { - model.getPosVector().get(j).setSelected(true); - break; - } - if (model.getPosVector().get(j).isSelected()) { - model.getPosVector().get(j).setSelected(false); - break; - } - } - } - } - if (i.getItem().toString().contains("Negative")) { - for (int j = 0; j < model.getNegVector().size(); j++) { - if (i.getItem().toString().contains( - model.getNegVector().get(j).getText().toString())) { - if (!model.getNegVector().get(j).isSelected()) { - model.getNegVector().get(j).setSelected(true); - break; - } - if (model.getNegVector().get(j).isSelected()) { - model.getNegVector().get(j).setSelected(false); - break; - } - } - } - } + } - + /** * Nothing happens here. - * @param e ListSelectionEvent + * + * @param e + * ListSelectionEvent */ public void valueChanged(ListSelectionEvent e) { @@ -192,30 +179,37 @@ /** * Nothing happens here. - * @param m MouseEvent + * + * @param m + * MouseEvent */ public void mouseReleased(MouseEvent m) { } - /** + /** * Nothing happens here. - * @param m MouseEvent + * + * @param m + * MouseEvent */ public void mouseEntered(MouseEvent m) { } /** - * Choses the right EvaluatedDescription object after a concept is chosen in the list. - * @param m MouseEvent + * Choses the right EvaluatedDescription object after a concept is chosen in + * the list. + * + * @param m + * MouseEvent */ public void mouseClicked(MouseEvent m) { EvaluatedDescription eDescription = null; - if (view.getSuggestClassPanel().getSuggestList() - .getSelectedValue() != null) { - SuggestListItem item = (SuggestListItem) view.getSuggestClassPanel().getSuggestList() - .getSelectedValue(); + + if (view.getSuggestClassPanel().getSuggestList().getSelectedValue() != null) { + SuggestListItem item = (SuggestListItem) view + .getSuggestClassPanel().getSuggestList().getSelectedValue(); String desc = item.getValue(); if (model.getEvaluatedDescriptionList() != null) { for (Iterator<EvaluatedDescription> i = model @@ -223,28 +217,29 @@ eDescription = i.next(); if (desc.equals(eDescription.getDescription() .toManchesterSyntaxString( - editorKit.getModelManager().getActiveOntology().getURI() + editorKit.getModelManager() + .getActiveOntology().getURI() + "#", null))) { evaluatedDescription = eDescription; + break; } } } - - - if(m.getClickCount()==2) { - view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel( - evaluatedDescription); + + if (m.getClickCount() == 2) { + view.getMoreDetailForSuggestedConceptsPanel() + .renderDetailPanel(evaluatedDescription); + } } - } else { - } - } /** * Nothing happens here. - * @param m MouseEvent + * + * @param m + * MouseEvent */ public void mouseExited(MouseEvent m) { @@ -252,15 +247,16 @@ /** * Sets the ADD button enable after a concept is chosen. - * @param m MouseEvent + * + * @param m + * MouseEvent */ public void mousePressed(MouseEvent m) { - if (view.getSuggestClassPanel().getSuggestList() - .getSelectedValue()!= null) { + if (view.getSuggestClassPanel().getSuggestList().getSelectedValue() != null) { if (!view.getAddButton().isEnabled()) { view.getAddButton().setEnabled(true); - } - } + } + } } /** @@ -271,7 +267,7 @@ } /** - * Resets the toggled Button after the plugin is closed. + * Resets the toggled Button after the plugin is closed. */ public void resetToggled() { toggled = false; @@ -280,19 +276,131 @@ @Override public void contentsChanged(ListDataEvent listEvent) { System.out.println(listEvent); - + } @Override public void intervalAdded(ListDataEvent listEvent) { // TODO Auto-generated method stub - + } @Override public void intervalRemoved(ListDataEvent listEvent) { // TODO Auto-generated method stub - + } + class SuggestionRetriever extends + SwingWorker<List<EvaluatedDescription>, List<EvaluatedDescription>> { + + public SuggestionRetriever() { + + } + + @Override + protected List<EvaluatedDescription> doInBackground() throws Exception { + // DefaultListModel descriptions = new DefaultListModel(); + // List<Description> descriptionList = + // model.getLearningAlgorithm().getCurrentlyBestDescriptions(); + // Iterator<Description> it = descriptionList.iterator(); + timer = new Timer(); + timer.schedule(new TimerTask() { + + @SuppressWarnings("unchecked") + @Override + public void run() { + if (model.getLearningAlgorithm() != null) { + publish(model.getLearningAlgorithm() + .getCurrentlyBestEvaluatedDescriptions(30, 0.0, + true)); + } + } + + }, 1000, 2000); + + dlLearner = new Thread(new Runnable() { + + @Override + public void run() { + + model.run(); + } + + }); + dlLearner.start(); + + try { + dlLearner.join(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + List<EvaluatedDescription> result = model.getLearningAlgorithm() + .getCurrentlyBestEvaluatedDescriptions( + view.getPosAndNegSelectPanel().getOptionPanel() + .getNrOfConcepts(), + view.getPosAndNegSelectPanel().getOptionPanel() + .getMinAccuracy(), true); + + + return result; + } + + @Override + public void done() { + + timer.cancel(); + List<EvaluatedDescription> result = null; + try { + result = get(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + + view.getRunButton().setEnabled(true); + updateList(result); + } + + @Override + protected void process(List<List<EvaluatedDescription>> resultLists) { + + // panel4.getModel().clear(); + + for (List<EvaluatedDescription> list : resultLists) { + updateList(list); + } + } + + private void updateList(final List<EvaluatedDescription> result) { + + Runnable doUpdateList = new Runnable() { + + DefaultListModel dm = new DefaultListModel(); + + public void run() { + model.setSuggestList(result); + // learnPanel.getListModel().clear(); + Iterator<EvaluatedDescription> it = result.iterator(); + //it.next().getDescription().toManchesterSyntaxString(baseURI, prefixes); + while (it.hasNext()) { + EvaluatedDescription eval = it.next(); + if(model.isConsistent(eval)) { + dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null))); + } else { + dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null))); + } + } + view.getSuggestClassPanel().getSuggestList().setModel(dm); + + } + }; + SwingUtilities.invokeLater(doUpdateList); + + } + + } + } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -32,7 +32,6 @@ import java.util.Vector; import javax.swing.DefaultListModel; -import javax.swing.JCheckBox; import org.dllearner.algorithms.refexamples.ExampleBasedROLComponent; import org.dllearner.core.ComponentInitException; @@ -86,14 +85,7 @@ "org.dllearner.algorithms.refexamples.ExampleBasedROLComponent", "org.dllearner.algorithms.gp.GP" }; - // This Vector stores the check boxes for the view. - private Vector<JCheckBox> positiv; - - // This Vector stores the negative Examples. - - private Vector<JCheckBox> negativ; - // Component Manager that manages the components of the DL-Learner private ComponentManager cm; @@ -204,7 +196,6 @@ // This is a List of evaluated descriptions to get more information of the // suggested concept private List<EvaluatedDescription> evalDescriptions; - private Vector<String> normalIndividuals; /** * This is the constructor for DL-Learner model. @@ -227,11 +218,8 @@ this.view = view; ontologyURI = editor.getModelManager().getActiveOntology().getURI().toString()+"#"; owlDescription = new HashSet<OWLDescription>(); - positiv = new Vector<JCheckBox>(); posListModel = new DefaultListModel(); negListModel = new DefaultListModel(); - negativ = new Vector<JCheckBox>(); - normalIndividuals = new Vector<String>(); ComponentManager.setComponentClasses(componenten); individualVector = new Vector<IndividualObject>(); cm = ComponentManager.getInstance(); @@ -351,12 +339,12 @@ if (id.equals("equivalent classes")) { // sets the learning problem to PosNegDefinitionLP when the // dllearner should suggest an equivalent class - lp = cm.learningProblem(PosNegDefinitionLP.class, rs); + lp = cm.learningProblem(PosNegDefinitionLP.class, reasoner); } if (id.equals("super classes")) { // sets the learning problem to PosNegInclusionLP when the dllearner // should suggest a subclass - lp = cm.learningProblem(PosNegInclusionLP.class, rs); + lp = cm.learningProblem(PosNegInclusionLP.class, reasoner); } // adds the positive examples cm.applyConfigEntry(lp, "positiveExamples", positiveExamples); @@ -376,7 +364,7 @@ try { // sets the learning algorithm to ROlearner this.la = cm.learningAlgorithm(ExampleBasedROLComponent.class, lp, - rs); + reasoner); } catch (LearningProblemUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -397,21 +385,25 @@ */ public void run() { error = "Learning succesful"; - + setKnowledgeSource(); + setReasoner(); + setPositiveAndNegativeExamples(); + setLearningProblem(); + setLearningAlgorithm(); String message = "To view details about why a class description was suggested, please doubleclick on it."; // start the algorithm and print the best concept found la.start(); - description = new Description[la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts()) - .size()]; - addToListModel(); + //description = new Description[la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts()) + // .size()]; + //addToListModel(); // renders the errormessage view.renderErrorMessage(error); view.setHintMessage(message); // reenables the run button - view.getRunButton().setEnabled(true); + //view.getRunButton().setEnabled(true); // disables the cancel button - view.getPosAndNegSelectPanel().setCheckBoxesEnable(true); - view.getSuggestClassPanel().setSuggestList(suggestModel); + //view.getPosAndNegSelectPanel().setCheckBoxesEnable(true); + //view.getSuggestClassPanel().setSuggestList(suggestModel); } /** @@ -424,24 +416,6 @@ } /** - * This method returns the check boxes for the positive examples. - * - * @return Vector of check boxes for positive examples - */ - public Vector<JCheckBox> getPosVector() { - return positiv; - } - - /** - * This method returns the check boxes for the negative examples. - * - * @return Vector of check boxes for negative examples - */ - public Vector<JCheckBox> getNegVector() { - return negativ; - } - - /** * This method gets an error message and storess it. * * @param err @@ -457,10 +431,10 @@ */ public void setPosVector() { setPositiveConcept(); - for (Iterator<Individual> j = rs.getIndividuals().iterator(); j + + for (Iterator<Individual> j = reasoner.getIndividuals().iterator(); j .hasNext();) { Individual ind = j.next(); - normalIndividuals.add(ind.toString()); String indiv = ind.toString(); // checks if individual belongs to the selected concept if (setPositivExamplesChecked(indiv)) { @@ -486,6 +460,10 @@ } } + /** + * This method returns the Vector of IndividualObjects. + * @return individualVector Vector + */ public Vector<IndividualObject> getIndividualVector() { return individualVector; } @@ -495,11 +473,12 @@ */ public void setPositiveConcept() { SortedSet<Individual> individuals = null; + //System.out.println("TEST: " + rs.getNamedClasses()); // checks if selected concept is thing when yes then it selects all // individuals if (!current.getRootObject().toString().equals("Thing")) { - - for (Iterator<NamedClass> i = rs.getNamedClasses().iterator(); i + + for (Iterator<NamedClass> i = reasoner.getAtomicConceptsList().iterator(); i .hasNext();) { // if individuals is null if (individuals == null) { @@ -509,31 +488,35 @@ "#" + current.getRootObject().toString())) { // if individuals is not null it gets all individuals of // the concept - if (rs.getIndividuals(concept) != null) { - individual = rs.getIndividuals(concept); + if (reasoner.getIndividuals(concept) != null) { + individual = reasoner.getIndividuals(concept); break; } } } } } else { - individual = rs.getIndividuals(); + individual = reasoner.getIndividuals(); } } - public boolean hasIndividuals(OWLClass OWLConcept) { + + /** + * This Method checks if the selected class has any individuals. + * @param owlConcept OWLClass + * @return boolean hasIndividuals + */ + public boolean hasIndividuals(OWLClass owlConcept) { boolean hasIndividuals = false; NamedClass concept = null; NamedClass selectedConcept = null; Iterator<NamedClass> it = reasoner.getNamedClasses().iterator(); while(it.hasNext()) { concept = it.next(); - if (concept.toManchesterSyntaxString(ontologyURI, prefixes).equals(OWLConcept.toString())) { + if (concept.toManchesterSyntaxString(ontologyURI, prefixes).equals(owlConcept.toString())) { selectedConcept = concept; break; } } - System.out.println("CON: "+ concept); - System.out.println("SIZE: "+ reasoner.getIndividuals(concept).size()); if (reasoner.getIndividuals(selectedConcept).size() > 0) { hasIndividuals = true; } @@ -572,8 +555,6 @@ individualVector.removeAllElements(); posListModel.removeAllElements(); negListModel.removeAllElements(); - positiv.removeAllElements(); - negativ.removeAllElements(); } /** @@ -587,10 +568,18 @@ description = list; } + /** + * This method returns the PosListModel. + * @return DefaultListModel posListModel + */ public DefaultListModel getPosListModel() { return posListModel; } + /** + * This method returns the NegListModel. + * @return DefaultListModel negListModel + */ public DefaultListModel getNegListModel() { return negListModel; } @@ -605,30 +594,6 @@ } /** - * This method gets an integer to return the positive examples check box on - * that position. - * - * @param i - * integer for the position in the vector - * @return Positive examples check box on position i. - */ - public JCheckBox getPositivJCheckBox(int i) { - return positiv.get(i); - } - - /** - * This method gets an integer to return the negative examples check box on - * that position. - * - * @param i - * integer for the position in the vector - * @return Negative examples check box on position i. - */ - public JCheckBox getNegativJCheckBox(int i) { - return negativ.get(i); - } - - /** * This method resets the array of concepts from the DL_Learner. It is * called after the DL-Learner tab is closed. */ @@ -639,27 +604,6 @@ } /** - * This method unchecks the checkboxes that are checked after the process of - * learning. - */ - public void unsetJCheckBoxen() { - for (int j = 0; j < positiv.size(); j++) { - // unselect all check poxes of the positive examples - if (positiv.get(j).isSelected()) { - JCheckBox i = positiv.get(j); - i.setSelected(false); - positiv.set(j, i); - } - // unselect all check boxes of the negative examples - if (negativ.get(j).isSelected()) { - JCheckBox i = negativ.get(j); - i.setSelected(false); - negativ.set(j, i); - } - } - } - - /** * This method resets the model for the suggest panel. It is called befor * the DL-Learner learns the second time or when the DL-Learner tab is * closed. @@ -750,7 +694,7 @@ */ private void setOldConceptOWLAPI() { // gets all individuals - SortedSet<Individual> indi = rs.getIndividuals(); + SortedSet<Individual> indi = reasoner.getIndividuals(); // Iterator of Individuals for (Iterator<Individual> i = indi.iterator(); i.hasNext();) { Individual indi2 = i.next(); @@ -823,7 +767,7 @@ return alreadyLearned; } - private boolean isConsistent(EvaluatedDescription eDescription) { + public boolean isConsistent(EvaluatedDescription eDescription) { boolean isConsistent = false; if (eDescription.getNotCoveredPositives().isEmpty()) { isConsistent = true; @@ -841,4 +785,8 @@ public URI getURI() { return editor.getModelManager().getActiveOntology().getURI(); } + + public void setSuggestList(List<EvaluatedDescription> list) { + evalDescriptions = list; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -1,29 +1,74 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.tools.protege; - +/** + * This Class handles the manchester String, the normal string and if the Individual is a positive Individual. + * @author Christian Koetteritzsch + * + */ public class IndividualObject { private String normalIndividual; private String manchesterIndividual; private boolean isPos; + /** + * Constructor for the IndividualObject. + * @param normal String + * @param manchester String + * @param pos boolean + */ public IndividualObject(String normal, String manchester, boolean pos) { normalIndividual = normal; manchesterIndividual = manchester; isPos = pos; } + /** + * This method returns the String of the Individual. + * @return String normalIndividual + */ public String getIndividualString() { return normalIndividual; } + /** + * This method returns the manchester String of the Individual. + * @return String manchesterIndividual + */ public String getManchesterIndividual() { return manchesterIndividual; } + /** + * This method returns if the Example is a positive Example. + * @return boolean isPos + */ public boolean isPositiveExample() { return isPos; } + /** + * This method sets the example positive or negative if changed to the othe list. + * @param pos boolean + */ public void setExamplePositive(boolean pos) { isPos = pos; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -71,10 +71,6 @@ private JDialog detailPopup; - // Panel where the informations of the selected panel are rendered - - //private JPanel examplePanel; - // Text area that shows the covered positive examples private JTextArea posCoveredText; @@ -135,8 +131,8 @@ */ public void renderDetailPanel(EvaluatedDescription desc) { eval = desc; - JPanel posBox = new JPanel(new GridLayout(0,2)); - JPanel negBox = new JPanel(new GridLayout(0,2)); + JPanel posBox = new JPanel(new GridLayout(0, 2)); + JPanel negBox = new JPanel(new GridLayout(0, 2)); Box exampleBox = Box.createVerticalBox(); concept = new JTextArea("Class Description:"); concept.setEditable(false); @@ -148,12 +144,12 @@ coveredNegativeExamples.setForeground(colorRed); notCoveredNegativeExamples = new JLabel("Not Covered Negative Examples"); notCoveredNegativeExamples.setForeground(colorGreen); - conceptPanel = new JPanel(new GridLayout(0,1)); - accuracyPanel = new JPanel(new GridLayout(0,1)); - posCoveredPanel = new JPanel(new GridLayout(0,1)); - posNotCoveredPanel = new JPanel(new GridLayout(0,1)); - negCoveredPanel = new JPanel(new GridLayout(0,1)); - negNotCoveredPanel = new JPanel(new GridLayout(0,1)); + conceptPanel = new JPanel(new GridLayout(0, 1)); + accuracyPanel = new JPanel(new GridLayout(0, 1)); + posCoveredPanel = new JPanel(new GridLayout(0, 1)); + posNotCoveredPanel = new JPanel(new GridLayout(0, 1)); + negCoveredPanel = new JPanel(new GridLayout(0, 1)); + negNotCoveredPanel = new JPanel(new GridLayout(0, 1)); accuracy = new JTextArea("Accuracy:"); accuracy.setEditable(false); conceptText = new JTextArea(); @@ -178,7 +174,6 @@ //sets accuracy text area not editable accuracyText.setEditable(false); //panel for the informations of the selected concept - //examplePanel = new JPanel(new GridLayout(0,2)); //this method adds the informations for the selected concept to the panel setInformation(); @@ -225,28 +220,24 @@ JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); posLabel.setForeground(colorGreen); posCoveredPanel.add(posLabel); - //posCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } //sets the positive examples that are not covered for(Iterator<Individual> i = eval.getNotCoveredPositives().iterator(); i.hasNext();) { JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); posLabel.setForeground(colorRed); posNotCoveredPanel.add(posLabel); - //posNotCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } //sets the negative examples that are covered for(Iterator<Individual> i = eval.getCoveredNegatives().iterator(); i.hasNext();) { JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); posLabel.setForeground(colorRed); negCoveredPanel.add(posLabel); - //negCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } //sets the negative examples that are not covered for(Iterator<Individual> i = eval.getNotCoveredNegatives().iterator(); i.hasNext();) { JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); posLabel.setForeground(colorGreen); negNotCoveredPanel.add(posLabel); - //negNotCoveredText.append(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)+"\n"); } } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -315,8 +315,6 @@ private JButton run; - // private JButton why; - // This is the label for the advanced button. private JLabel adv; @@ -360,7 +358,7 @@ private JTextArea hint; // This is the Panel for more details of the suggested concept private MoreDetailForSuggestedConceptsPanel detail; - OWLFrame<OWLClass> frame; + //private OWLFrame<OWLClass> frame; private URL pluginURL; /** @@ -374,7 +372,7 @@ public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab dlLearner) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); mainWindow = dlLearner; - frame = current; + //frame = current; try { pluginURL = new URL("http://dl-learner.org/wiki/ProtegePlugin"); } catch (MalformedURLException e) { @@ -549,7 +547,6 @@ */ public void updateWindow() { mainWindow.getHandler().handleEditingFinished(mainWindow.getEditedObjects()); - mainWindow.dispose(); } /** * Returns all added descriptions. @@ -579,15 +576,8 @@ posPanel.unsetPosAndNegPanel(); learner.removeAll(); } + /** - * This method returns the nummers of Individuals present in the Ontology. - * @return int amount of Individuals in the Ontology - */ - public int getNrOfIndividuals() { - int counter = model.getPosVector().size(); - return counter; - } - /** * Renders the error message when an error occured. * @param s String */ @@ -615,7 +605,6 @@ * Destroys the view after the plugin is closed. */ public void dispose() { - System.out.println("hier"); run.removeActionListener(action); accept.removeActionListener(action); advanced.removeActionListener(action); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.tools.protege; import java.awt.Dimension; @@ -28,8 +47,8 @@ public OptionPanel() { setPreferredSize(new Dimension(490, 120)); - setLayout(new GridLayout(0,1)); - optionPanel = new JPanel(new GridLayout(0,2)); + setLayout(new GridLayout(0, 1)); + optionPanel = new JPanel(new GridLayout(0, 2)); minAccuracyLabel = new JLabel("minimum accuracy"); maxExecutionTimeLabel = new JLabel("maximum execution time"); nrOfConceptsLabel = new JLabel("maximum number of results"); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -41,11 +41,6 @@ private static final long serialVersionUID = 23632947283479L; - // This is the Panel here the check boxes, the labels, and the help buttons - // are in. - - //private JPanel posAndNegPanel; - // this is the Panel where the check boxes are. private JPanel posAndNegSelectPanel; @@ -93,9 +88,6 @@ // This is the Text area where the help message is displayed. private OptionPanel optionPanel; - //private JComboBox optionBox; - //private JPanel optionBoxPanel; - //private ActionHandler action; private DefaultListModel posListModel; private DefaultListModel negListModel; private JPanel examplePanel; @@ -109,6 +101,7 @@ * DLLearnerModel * @param act * ActionHandler + * @param v DLLearnerView */ public PosAndNegSelectPanel(DLLearnerModel model, ActionHandler act, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView v) { //set layout for parent Panel @@ -191,6 +184,8 @@ /** * This method adds the check boxes, the labels and the help buttons for * positive and negative examples. + * @param posData DefaultListModel + * @param negData DefaultListModel */ public void setExampleList(DefaultListModel posData, DefaultListModel negData) { posListModel = posData; @@ -199,10 +194,18 @@ negList.setModel(negListModel); } + /** + * This method returns the pos button. + * @return JButton + */ public JButton getAddToPosPanelButton() { return addToPosExamples; } + /** + * This method returns the neg button. + * @return JButton + */ public JButton getAddToNegPanelButton() { return addToNegExamples; } @@ -226,10 +229,18 @@ } + /** + * Nothing. + * @param act ActionHandler + */ public void removeListeners(ActionHandler act) { } + /** + * Nothing. + * @param enable boolean + */ public void setCheckBoxesEnable(boolean enable) { } @@ -244,14 +255,6 @@ } /** - * This method unselect the selected check boxes after learning. - */ - public void unsetCheckBoxes() { - // after the learning the check boxes will be unset. - model.unsetJCheckBoxen(); - } - - /** * This message displays the help message after the help button is pressed. * * @param assistance String @@ -262,12 +265,17 @@ } + /** + * this method sets the example to the other list when button is pressed. + * @param toPos boolean + * @param example String + */ public void setExampleToOtherList(boolean toPos, String example) { if (toPos) { for(int i = 0; i < negListModel.size(); i++) { if(negListModel.get(i).equals(example)) { negListModel.remove(i); - for (int j = 0; j < model.getIndividualVector().size(); j++ ) { + for (int j = 0; j < model.getIndividualVector().size(); j++) { if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { model.getIndividualVector().get(j).setExamplePositive(true); break; @@ -281,7 +289,7 @@ for(int i = 0; i < posListModel.size(); i++) { if(posListModel.get(i).equals(example)) { posListModel.remove(i); - for (int j = 0; j < model.getIndividualVector().size(); j++ ) { + for (int j = 0; j < model.getIndividualVector().size(); j++) { if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { model.getIndividualVector().get(j).setExamplePositive(false); } @@ -300,8 +308,8 @@ /** * This method adds the Action listener to the help buttons. * - * @param a - * ActionHandler + * @param handle + * PosAndNegSelectPanelHandler */ public void addHelpButtonListener(PosAndNegSelectPanelHandler handle) { // adds listener to the help button for the positive examples @@ -309,19 +317,35 @@ // adds listener to the help button for the negative examples helpForNegExamples.addActionListener(handle); } - + /** + * This Method removes the listeners for the help button. + * @param a ActionHandler + */ public void removeHelpButtonListener(ActionHandler a) { helpForPosExamples.removeActionListener(a); helpForNegExamples.removeActionListener(a); } + + /** + * This method returns the option panel. + * @return OptionPanel + */ public OptionPanel getOptionPanel() { return optionPanel; } + /** + * This method returns the list of positive examples. + * @return JList posExampleList + */ public JList getPosExampleList() { return posList; } + /** + * This method returns the list of negative examples. + * @return JList negExampleList + */ public JList getNegExampleList() { return negList; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-14 11:48:57 UTC (rev 1512) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-14 15:04:06 UTC (rev 1513) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2008, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.tools.protege; import java.awt.event.ActionEvent; @@ -2,7 +21,10 @@ import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; - +/** + * This class handles the commands for the example panel. + * @author christian Koetteritzsch + * + */ public class PosAndNegSelectPanelHandler implements ActionListener, MouseListener { @@ -12,33 +34,29 @@ // This is the DLLearnerModel. -private DLLearnerModel model; +//private DLLearnerModel model; private PosAndNegSelectPanel panel; // This is the view of the DL-Learner tab. private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; /** - * This is the constructor for the action handler. - * - * @param a - * ActionHandler + * This is the constructor for the PosAndNegSelectPanelHandler. * @param m * DLLearnerModel - * @param view - * DLlearner tab - * @param i - * id if it is a subclass or an equivalent class - * @param editor OWLEditorKit + * @param v + * OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView + * @param p + * PosAndNegSelectPanel */ public PosAndNegSelectPanelHandler(DLLearnerModel m, OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView v, PosAndNegSelectPanel p) { - model = m; + //model = m; panel = p; view = v; } /** * When a Button is pressed this method select the right. - * @param z ActionEvent + * @param action ActionEvent */ public void actionPerformed(ActionEvent action) { @@ -66,44 +84,9 @@ } } -/** - * select/deselect the Check boxes. - * @param i ItemEvent - */ -public void itemStateChanged(ItemEvent i) { - if (i.getItem().toString().contains("Positive")) { - for (int j = 0; j < model.getPosVector().size(); j++) { - if (i.getItem().toString().contains( - model.getPosVector().get(j).getText().toString())) { - if (!model.getPosVector().get(j).isSelected()) { - model.getPosVector().get(j).setSelected(true); - break; - } - if (model.getPosVector().get(j).isSelected()) { - model.getPosVector().get(j).setSelected(false); - break; - } - } - } - } - if (i.getItem().toString().contains("Negative")) { - for (int j = 0; j < model.getNegVector().size(); j++) { - if (i.getItem().toString().contains( - model.getNegVector().get(j).getText().toString())) { - if (!model.getNegVector().get(j).isSelected()) { - model.getNegVector().get(j).setSelected(true); - break; - } - if (model.getNegVector().get(j).isSelected()) { - model.getNegVector().get(j).setSelected(false); - break; - } - } - } - } -} + /** * Nothing happens here. * @param m MouseEvent This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-16 14:38:37
|
Revision: 1517 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1517&view=rev Author: heeroyuy Date: 2008-11-16 14:38:32 +0000 (Sun, 16 Nov 2008) Log Message: ----------- -some small changes -some changes in GUI Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-15 08:43:53 UTC (rev 1516) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-16 14:38:32 UTC (rev 1517) @@ -41,6 +41,7 @@ import javax.swing.event.ListSelectionListener; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.owl.Description; import org.protege.editor.owl.OWLEditorKit; @@ -64,11 +65,12 @@ // this is a boolean that checked if the advanced button was pressed or not. private boolean toggled; // This is the Tread of the DL-Learner - private Thread dlLearner; private EvaluatedDescription evaluatedDescription; // This is the view of the DL-Learner tab. private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; private Timer timer; + private LearningAlgorithm la; + private SuggestionRetriever retriever; /** * This is the constructor for the action handler. @@ -107,10 +109,15 @@ if (model.getAlreadyLearned()) { model.unsetListModel(); } + model.setKnowledgeSource(); + model.setReasoner(); + model.setPositiveAndNegativeExamples(); + model.setLearningProblem(); + model.setLearningAlgorithm(); view.getRunButton().setEnabled(false); view.renderErrorMessage("Learning started"); view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); - final SuggestionRetriever retriever = new SuggestionRetriever(); + retriever = new SuggestionRetriever(); // // dlLearner.start(); retriever.execute(); @@ -263,7 +270,7 @@ * Destroys the Thread after the Pluigin is closed. */ public void destroyDLLearnerThread() { - dlLearner = null; + //dlLearner = null; } /** @@ -290,40 +297,51 @@ // TODO Auto-generated method stub } - +/** + * Inner Class that retrieves the concepts given by the DL-Learner. + * @author Christian Koetteritzsch + * + */ class SuggestionRetriever extends SwingWorker<List<EvaluatedDescription>, List<EvaluatedDescription>> { - + + private Thread dlLearner; + /** + * Constructor for the SuggestionRetriever. + */ public SuggestionRetriever() { } - + @SuppressWarnings("unchecked") @Override protected List<EvaluatedDescription> doInBackground() throws Exception { // DefaultListModel descriptions = new DefaultListModel(); // List<Description> descriptionList = // model.getLearningAlgorithm().getCurrentlyBestDescriptions(); // Iterator<Description> it = descriptionList.iterator(); + la = model.getLearningAlgorithm(); timer = new Timer(); - timer.schedule(new TimerTask() { - - @SuppressWarnings("unchecked") + timer.schedule(new TimerTask(){ + @Override public void run() { - if (model.getLearningAlgorithm() != null) { - publish(model.getLearningAlgorithm() - .getCurrentlyBestEvaluatedDescriptions(30, 0.0, - true)); + if (la != null) { + + publish(la + .getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel() + .getNrOfConcepts(), + view.getPosAndNegSelectPanel().getOptionPanel() + .getMinAccuracy(), true)); } } - }, 1000, 2000); + }, 0, 100); dlLearner = new Thread(new Runnable() { @Override public void run() { - + model.run(); } @@ -336,14 +354,12 @@ // TODO Auto-generated catch block e.printStackTrace(); } - List<EvaluatedDescription> result = model.getLearningAlgorithm() - .getCurrentlyBestEvaluatedDescriptions( + List<EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions( view.getPosAndNegSelectPanel().getOptionPanel() .getNrOfConcepts(), view.getPosAndNegSelectPanel().getOptionPanel() .getMinAccuracy(), true); - return result; } @@ -367,7 +383,6 @@ @Override protected void process(List<List<EvaluatedDescription>> resultLists) { - // panel4.getModel().clear(); for (List<EvaluatedDescription> list : resultLists) { updateList(list); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-15 08:43:53 UTC (rev 1516) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-16 14:38:32 UTC (rev 1517) @@ -20,7 +20,6 @@ package org.dllearner.tools.protege; -import java.awt.Color; import java.net.URI; import java.util.HashSet; import java.util.Iterator; @@ -243,25 +242,6 @@ } /** - * This method adds the solutions from the DL-Learner to the List Model. - */ - private void addToListModel() { - - evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts(), view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy(), true); - for (int j = 0; j < evalDescriptions.size(); j++) { - if (isConsistent(evalDescriptions.get(j))) { - suggestModel.add(j, new SuggestListItem(Color.GREEN, - evalDescriptions.get(j).getDescription() - .toManchesterSyntaxString(ontologyURI, prefixes))); - } else { - suggestModel.add(j, new SuggestListItem(Color.RED, - evalDescriptions.get(j).getDescription() - .toManchesterSyntaxString(ontologyURI, prefixes))); - } - } - } - - /** * This method checks which positive and negative examples are checked and * puts the checked examples into a tree set. */ @@ -385,11 +365,6 @@ */ public void run() { error = "Learning succesful"; - setKnowledgeSource(); - setReasoner(); - setPositiveAndNegativeExamples(); - setLearningProblem(); - setLearningAlgorithm(); String message = "To view details about why a class description was suggested, please doubleclick on it."; // start the algorithm and print the best concept found la.start(); @@ -766,7 +741,13 @@ public boolean getAlreadyLearned() { return alreadyLearned; } - + + /** + * This Method checks if after inserting of this concept the ontology is still + * consistent. + * @param eDescription EvauatedDescription + * @return isConsistent boolean + */ public boolean isConsistent(EvaluatedDescription eDescription) { boolean isConsistent = false; if (eDescription.getNotCoveredPositives().isEmpty()) { @@ -786,6 +767,10 @@ return editor.getModelManager().getActiveOntology().getURI(); } + /** + * This method sets the suggestion list. + * @param list List(EvaluatedDescription) + */ public void setSuggestList(List<EvaluatedDescription> list) { evalDescriptions = list; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-15 08:43:53 UTC (rev 1516) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-16 14:38:32 UTC (rev 1517) @@ -19,10 +19,10 @@ */ package org.dllearner.tools.protege; import java.awt.Color; +import java.awt.Dimension; import java.awt.GridLayout; import java.util.Iterator; -import javax.swing.Box; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; @@ -93,8 +93,10 @@ // Scroll pane if scroll bar is necessary to show all covered examples - private JScrollPane detailScroll; - + private JScrollPane posCoveredScroll; + private JScrollPane posNotCoveredScroll; + private JScrollPane negCoveredScroll; + private JScrollPane negNotCoveredScroll; // Evaluated description of the selected concept private JPanel conceptPanel; private JPanel accuracyPanel; @@ -112,6 +114,9 @@ * @param model DLLearnerModel */ public MoreDetailForSuggestedConceptsPanel(DLLearnerModel model) { + super(); + setLayout(null); + setPreferredSize(new Dimension(600, 500)); this.model = model; @@ -130,22 +135,36 @@ * @param desc selected description */ public void renderDetailPanel(EvaluatedDescription desc) { + posCoveredScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + posCoveredScroll.setBounds(5, 150, 280, 140); + posNotCoveredScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + posNotCoveredScroll.setBounds(300, 150, 280, 140); + negCoveredScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + negCoveredScroll.setBounds(5, 325, 280, 140); + negNotCoveredScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + negNotCoveredScroll.setBounds(300, 325, 280, 140); eval = desc; - JPanel posBox = new JPanel(new GridLayout(0, 2)); - JPanel negBox = new JPanel(new GridLayout(0, 2)); - Box exampleBox = Box.createVerticalBox(); concept = new JTextArea("Class Description:"); concept.setEditable(false); + coveredPositiveExamples = new JLabel("Covered Positive Examples:"); coveredPositiveExamples.setForeground(colorGreen); + coveredPositiveExamples.setBounds(5, 110, 280, 30); notCoveredPositiveExamples = new JLabel("Not Covered Positive Examples"); notCoveredPositiveExamples.setForeground(colorRed); + notCoveredPositiveExamples.setBounds(300, 110, 280, 30); coveredNegativeExamples = new JLabel("Covered Negative Examples:"); coveredNegativeExamples.setForeground(colorRed); + coveredNegativeExamples.setBounds(5, 295, 280, 30); notCoveredNegativeExamples = new JLabel("Not Covered Negative Examples"); notCoveredNegativeExamples.setForeground(colorGreen); + notCoveredNegativeExamples.setBounds(300, 295, 280, 30); + conceptPanel = new JPanel(new GridLayout(0, 1)); + conceptPanel.setBounds(5, 0, 600, 50); accuracyPanel = new JPanel(new GridLayout(0, 1)); + accuracyPanel.setBounds(5, 60, 600, 50); + posCoveredPanel = new JPanel(new GridLayout(0, 1)); posNotCoveredPanel = new JPanel(new GridLayout(0, 1)); negCoveredPanel = new JPanel(new GridLayout(0, 1)); @@ -178,12 +197,11 @@ setInformation(); detailPopup = new JDialog(); - detailPopup.setSize(400, 400); + detailPopup.setSize(600, 500); //window will be disposed if the x button is pressed detailPopup.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); detailPopup.setVisible(true); - detailPopup.setResizable(true); - detailScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + detailPopup.setResizable(false); //adds all information to the example panel conceptPanel.add(concept); conceptPanel.add(conceptText); @@ -191,16 +209,22 @@ accuracyPanel.add(accuracy); accuracyPanel.add(accuracyText); - exampleBox.add(conceptPanel); - exampleBox.add(accuracyPanel); - posBox.add(posCoveredPanel); - posBox.add(posNotCoveredPanel); - negBox.add(negCoveredPanel); - negBox.add(negNotCoveredPanel); - exampleBox.add(posBox); - exampleBox.add(negBox); - detailScroll.setViewportView(exampleBox); - detailPopup.add(detailScroll); + posCoveredScroll.setViewportView(posCoveredPanel); + posNotCoveredScroll.setViewportView(posNotCoveredPanel); + negCoveredScroll.setViewportView(negCoveredPanel); + negNotCoveredScroll.setViewportView(negNotCoveredPanel); + + add(conceptPanel); + add(accuracyPanel); + add(coveredPositiveExamples); + add(notCoveredPositiveExamples); + add(coveredNegativeExamples); + add(notCoveredNegativeExamples); + add(posCoveredScroll); + add(posNotCoveredScroll); + add(negCoveredScroll); + add(negNotCoveredScroll); + detailPopup.add(this); } /** * This method sets the Informations of the selected description. @@ -211,11 +235,6 @@ conceptText.append(eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null)); double acc = (eval.getAccuracy())*100; accuracyText.append(String.valueOf(acc)+"%"); - //sets the positive examples that are covered - posCoveredPanel.add(coveredPositiveExamples); - posNotCoveredPanel.add(notCoveredPositiveExamples); - negCoveredPanel.add(coveredNegativeExamples); - negNotCoveredPanel.add(notCoveredNegativeExamples); for(Iterator<Individual> i = eval.getCoveredPositives().iterator(); i.hasNext();) { JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); posLabel.setForeground(colorGreen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-18 18:05:13
|
Revision: 1519 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1519&view=rev Author: heeroyuy Date: 2008-11-18 18:05:10 +0000 (Tue, 18 Nov 2008) Log Message: ----------- -some buxfixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -44,6 +44,7 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.owl.Description; import org.protege.editor.owl.OWLEditorKit; +import org.semanticweb.owl.model.OWLOntology; /** * This class processes input from the user. @@ -399,13 +400,20 @@ model.setSuggestList(result); // learnPanel.getListModel().clear(); Iterator<EvaluatedDescription> it = result.iterator(); - //it.next().getDescription().toManchesterSyntaxString(baseURI, prefixes); + while (it.hasNext()) { + Iterator<OWLOntology> ont = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); EvaluatedDescription eval = it.next(); - if(model.isConsistent(eval)) { - dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null))); - } else { - dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null))); + while(ont.hasNext()) { + String onto = ont.next().getURI().toString(); + System.out.println(eval.getDescription()); + if(eval.getDescription().toString().contains(onto)) { + if(model.isConsistent(eval)) { + dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto+"#", null))); + } else { + dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(onto+"#", null))); + } + } } } view.getSuggestClassPanel().getSuggestList().setModel(dm); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -58,6 +58,7 @@ import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLDataFactory; import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.OWLIndividual; import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.model.OWLOntologyChangeException; import org.semanticweb.owl.model.OWLOntologyManager; @@ -186,7 +187,6 @@ // This is necessary to get the details of the suggested concept private JXTaskPane detailPane; - private String ontologyURI; private Map<String, String> prefixes; private DefaultListModel posListModel; private DefaultListModel negListModel; @@ -215,7 +215,6 @@ current = h; this.id = id; this.view = view; - ontologyURI = editor.getModelManager().getActiveOntology().getURI().toString()+"#"; owlDescription = new HashSet<OWLDescription>(); posListModel = new DefaultListModel(); negListModel = new DefaultListModel(); @@ -349,7 +348,6 @@ // TODO Auto-generated catch block e.printStackTrace(); } - System.out.println("TIME: "+view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); try { // initializes the learning algorithm @@ -406,23 +404,37 @@ */ public void setPosVector() { setPositiveConcept(); + Set<OWLIndividual> individual = editor.getModelManager().getActiveOntology().getReferencedIndividuals(); + Iterator<OWLIndividual> it = individual.iterator(); + while (it.hasNext()) { + OWLIndividual individum = it.next(); + String individuals = individum.toString(); + if (setPositivExamplesChecked(individuals)) { + // when yes then it sets the positive example checked + posListModel.add(0, individuals); - for (Iterator<Individual> j = reasoner.getIndividuals().iterator(); j - .hasNext();) { - Individual ind = j.next(); + } else { + // When no it unchecks the positive example + negListModel.add(0, individuals); + } + } + SortedSet<Individual> reasonerIndi = reasoner.getIndividuals(); + Iterator<Individual> reasonerIt = reasonerIndi.iterator(); + while(reasonerIt.hasNext()) { + Individual ind = reasonerIt.next(); + String indiv = ind.toString(); // checks if individual belongs to the selected concept if (setPositivExamplesChecked(indiv)) { // when yes then it sets the positive example checked - posListModel.add(0, ind.toManchesterSyntaxString(ontologyURI, prefixes)); - individualVector.add(new IndividualObject(indiv, ind.toManchesterSyntaxString(ontologyURI, prefixes), true)); + individualVector.add(new IndividualObject(indiv, true)); } else { // When no it unchecks the positive example - negListModel.add(0, ind.toManchesterSyntaxString(ontologyURI, prefixes)); - individualVector.add(new IndividualObject(indiv, ind.toManchesterSyntaxString(ontologyURI, prefixes), false)); + individualVector.add(new IndividualObject(indiv, false)); } } + } /** @@ -487,13 +499,23 @@ Iterator<NamedClass> it = reasoner.getNamedClasses().iterator(); while(it.hasNext()) { concept = it.next(); - if (concept.toManchesterSyntaxString(ontologyURI, prefixes).equals(owlConcept.toString())) { - selectedConcept = concept; - break; + Iterator<OWLOntology> onto = editor.getModelManager().getActiveOntologies().iterator(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if (concept.toString().contains(uri)) { + if (concept.toManchesterSyntaxString(uri+"#", prefixes).equals(owlConcept.toString())) { + selectedConcept = concept; + break; + } + } + } + } - if (reasoner.getIndividuals(selectedConcept).size() > 0) { - hasIndividuals = true; + if(selectedConcept != null) { + if (reasoner.getIndividuals(selectedConcept).size() > 0) { + hasIndividuals = true; + } } concept = null; selectedConcept = null; @@ -774,4 +796,8 @@ public void setSuggestList(List<EvaluatedDescription> list) { evalDescriptions = list; } + + public OWLEditorKit getOWLEditorKit() { + return editor; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -26,7 +26,6 @@ public class IndividualObject { private String normalIndividual; - private String manchesterIndividual; private boolean isPos; /** @@ -35,9 +34,8 @@ * @param manchester String * @param pos boolean */ - public IndividualObject(String normal, String manchester, boolean pos) { + public IndividualObject(String normal, boolean pos) { normalIndividual = normal; - manchesterIndividual = manchester; isPos = pos; } @@ -50,14 +48,6 @@ } /** - * This method returns the manchester String of the Individual. - * @return String manchesterIndividual - */ - public String getManchesterIndividual() { - return manchesterIndividual; - } - - /** * This method returns if the Example is a positive Example. * @return boolean isPos */ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -32,6 +32,10 @@ import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.owl.Individual; +import org.semanticweb.owl.model.OWLOntology; + + + /** * This class shows more details of the suggested concepts. It shows the positive and negative examples * that are covered and that are not covered by the suggested concepts. It also shows the accuracya of the @@ -146,7 +150,6 @@ eval = desc; concept = new JTextArea("Class Description:"); concept.setEditable(false); - coveredPositiveExamples = new JLabel("Covered Positive Examples:"); coveredPositiveExamples.setForeground(colorGreen); coveredPositiveExamples.setBounds(5, 110, 280, 30); @@ -195,7 +198,6 @@ //panel for the informations of the selected concept //this method adds the informations for the selected concept to the panel setInformation(); - detailPopup = new JDialog(); detailPopup.setSize(600, 500); //window will be disposed if the x button is pressed @@ -235,28 +237,71 @@ conceptText.append(eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null)); double acc = (eval.getAccuracy())*100; accuracyText.append(String.valueOf(acc)+"%"); - for(Iterator<Individual> i = eval.getCoveredPositives().iterator(); i.hasNext();) { - JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); - posLabel.setForeground(colorGreen); - posCoveredPanel.add(posLabel); + Iterator<Individual> i = eval.getCoveredPositives().iterator(); + while (i.hasNext()) { + Iterator<OWLOntology> onto = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); + Individual ind = i.next(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + posLabel.setForeground(colorGreen); + posCoveredPanel.add(posLabel); + } + } + + } //sets the positive examples that are not covered - for(Iterator<Individual> i = eval.getNotCoveredPositives().iterator(); i.hasNext();) { - JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); - posLabel.setForeground(colorRed); - posNotCoveredPanel.add(posLabel); + Iterator<Individual> a = eval.getNotCoveredPositives().iterator(); + while (a.hasNext()) { + Iterator<OWLOntology> onto = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); + Individual ind = a.next(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + posLabel.setForeground(colorRed); + posNotCoveredPanel.add(posLabel); + } + } + + } + + //sets the negative examples that are covered - for(Iterator<Individual> i = eval.getCoveredNegatives().iterator(); i.hasNext();) { - JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); - posLabel.setForeground(colorRed); - negCoveredPanel.add(posLabel); + Iterator<Individual> b = eval.getCoveredNegatives().iterator(); + while (b.hasNext()) { + Iterator<OWLOntology> onto = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); + Individual ind = b.next(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + posLabel.setForeground(colorRed); + negCoveredPanel.add(posLabel); + } + } + + } + //sets the negative examples that are not covered - for(Iterator<Individual> i = eval.getNotCoveredNegatives().iterator(); i.hasNext();) { - JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); - posLabel.setForeground(colorGreen); - negNotCoveredPanel.add(posLabel); + Iterator<Individual> c = eval.getNotCoveredNegatives().iterator(); + while (c.hasNext()) { + Iterator<OWLOntology> onto = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); + Individual ind = c.next(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + posLabel.setForeground(colorGreen); + negNotCoveredPanel.add(posLabel); + } + } + + } } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -24,7 +24,6 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; @@ -358,8 +357,7 @@ private JTextArea hint; // This is the Panel for more details of the suggested concept private MoreDetailForSuggestedConceptsPanel detail; - //private OWLFrame<OWLClass> frame; - private URL pluginURL; + private OWLFrame<OWLClass> frame; /** * The constructor for the DL-Learner tab in the class description @@ -372,16 +370,8 @@ public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab dlLearner) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); mainWindow = dlLearner; - //frame = current; - try { - pluginURL = new URL("http://dl-learner.org/wiki/ProtegePlugin"); - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - wikiPane = new JLabel("See " + pluginURL + " for an introduction."); - //wikiPane.setEditable(false); - + frame = current; + wikiPane = new JLabel("<html>See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">http://dl-learner.org/wiki/ProtegePlugin</a> for an introduction.</html>"); classSelectorPanel.firePropertyChange("test", false, true); URL iconUrl = this.getClass().getResource("arrow.gif"); icon = new ImageIcon(iconUrl); @@ -443,19 +433,22 @@ * This Method renders the view of the plugin. */ public void makeView() { - /* + + model.clearVector(); + model.unsetListModel(); + model.initReasoner(); + model.setPosVector(); + hint.setVisible(true); if (model.hasIndividuals(frame.getRootObject())) { run.setEnabled(true); } else { run.setEnabled(false); + hint.setVisible(false); String message ="There are no Instances for "+ frame.getRootObject()+" available. Please insert some Instances."; renderErrorMessage(message); - }*/ + } advanced.setIcon(icon); - model.clearVector(); - model.unsetListModel(); - model.initReasoner(); - model.setPosVector(); + posPanel.setExampleList(model.getPosListModel(), model.getNegListModel()); accept.setEnabled(false); action.resetToggled(); @@ -465,7 +458,7 @@ advanced.setSelected(false); sugPanel.setBounds(10, 35, 490, 110); adv.setBounds(40, 200, 200, 20); - wikiPane.setBounds(220, 10, 350, 30); + wikiPane.setBounds(220, 0, 350, 30); addButtonPanel.setBounds(510, 40, 80, 110); run.setBounds(10, 0, 200, 30); advanced.setBounds(10, 200, 20, 20); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -41,6 +41,7 @@ private JSlider maxExecutionTime; private JSlider nrOfConcepts; private JPanel optionPanel; + private double accuracy; /** * Construktor for the Option Panel. */ @@ -89,7 +90,7 @@ */ public double getMinAccuracy() { int acc = minAccuracy.getValue(); - double accuracy = acc/100; + accuracy = (acc/100.0); return accuracy; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -29,6 +29,7 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; /** * This class is the Panel for the Check boxes where the positive and negative @@ -123,7 +124,11 @@ neg = new JLabel("Negative Examples"); neg.setBounds(0, 0, 100, 30); posList = new JList(posListModel); - negList = new JList(negListModel); + posList.setName("pos"); + posList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + negList = new JList(negListModel); + negList.setName("neg"); + negList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); addToPosExamples = new JButton("pos"); addToNegExamples = new JButton("neg"); helpForPosExamples = new JButton("?"); @@ -276,7 +281,7 @@ if(negListModel.get(i).equals(example)) { negListModel.remove(i); for (int j = 0; j < model.getIndividualVector().size(); j++) { - if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { + if (model.getIndividualVector().get(j).getIndividualString().contains(example)) { model.getIndividualVector().get(j).setExamplePositive(true); break; } @@ -290,7 +295,7 @@ if(posListModel.get(i).equals(example)) { posListModel.remove(i); for (int j = 0; j < model.getIndividualVector().size(); j++) { - if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { + if (model.getIndividualVector().get(j).getIndividualString().contains(example)) { model.getIndividualVector().get(j).setExamplePositive(false); } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -108,16 +108,16 @@ * @param m MouseEvent */ public void mouseClicked(MouseEvent m) { - if (panel.getPosExampleList().getSelectedValue() != null) { + if (!panel.getPosExampleList().isSelectionEmpty() && m.toString().contains("pos")) { panel.getAddToNegPanelButton().setEnabled(true); - } else { - panel.getAddToNegPanelButton().setEnabled(false); + panel.getAddToPosPanelButton().setEnabled(false); + panel.getNegExampleList().clearSelection(); } - if (panel.getNegExampleList().getSelectedValue()!= null) { + if (!panel.getNegExampleList().isSelectionEmpty() && m.toString().contains("neg")) { panel.getAddToPosPanelButton().setEnabled(true); - } else { - panel.getAddToPosPanelButton().setEnabled(false); - } + panel.getAddToNegPanelButton().setEnabled(false); + panel.getPosExampleList().clearSelection(); + } } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -25,6 +25,7 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; /** * This class is the panel for the suggest list. @@ -62,6 +63,7 @@ suggestScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); model = new DefaultListModel(); descriptions = new JList(model); + descriptions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); suggestPanel = new JPanel(); descriptions.setVisible(true); suggestPanel.add(descriptions); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-28 12:13:31
|
Revision: 1524 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1524&view=rev Author: heeroyuy Date: 2008-11-28 12:13:18 +0000 (Fri, 28 Nov 2008) Log Message: ----------- -some bugfixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-27 11:54:33 UTC (rev 1523) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-28 12:13:18 UTC (rev 1524) @@ -226,8 +226,8 @@ if (desc.equals(eDescription.getDescription() .toManchesterSyntaxString( editorKit.getModelManager() - .getActiveOntology().getURI() - + "#", null))) { + .getActiveOntology().getURI().toString() + , null))) { evaluatedDescription = eDescription; break; @@ -406,12 +406,13 @@ EvaluatedDescription eval = it.next(); while(ont.hasNext()) { String onto = ont.next().getURI().toString(); - System.out.println(eval.getDescription()); if(eval.getDescription().toString().contains(onto)) { if(model.isConsistent(eval)) { - dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto+"#", null))); + dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto, null))); + break; } else { - dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(onto+"#", null))); + dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(onto, null))); + break; } } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-27 11:54:33 UTC (rev 1523) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-28 12:13:18 UTC (rev 1524) @@ -24,7 +24,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -36,7 +35,6 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.EvaluatedDescription; -import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; @@ -58,7 +56,6 @@ import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLDataFactory; import org.semanticweb.owl.model.OWLDescription; -import org.semanticweb.owl.model.OWLIndividual; import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.model.OWLOntologyChangeException; import org.semanticweb.owl.model.OWLOntologyManager; @@ -85,7 +82,6 @@ "org.dllearner.algorithms.refexamples.ExampleBasedROLComponent", "org.dllearner.algorithms.gp.GP" }; - // Component Manager that manages the components of the DL-Learner private ComponentManager cm; @@ -96,7 +92,7 @@ // The Knowledge source for the reasoner - private KnowledgeSource source; + private OWLAPIOntology source; // The View of the DL-Learner Plugin @@ -187,9 +183,10 @@ // This is necessary to get the details of the suggested concept private JXTaskPane detailPane; - private Map<String, String> prefixes; private DefaultListModel posListModel; private DefaultListModel negListModel; + private boolean hasIndividuals; + private NamedClass currentConcept; private Vector<IndividualObject> individualVector; // This is a List of evaluated descriptions to get more information of the @@ -236,7 +233,6 @@ alreadyLearned = false; setKnowledgeSource(); setReasoner(); - prefixes = reasoner.getPrefixes(); } @@ -249,11 +245,14 @@ negativeExamples = new TreeSet<String>(); for (int i = 0; i < individualVector.size(); i++) { if (individualVector.get(i).isPositiveExample()) { - positiveExamples.add(individualVector.get(i).getIndividualString()); + positiveExamples.add(individualVector.get(i) + .getIndividualString()); } else { - negativeExamples.add(individualVector.get(i).getIndividualString()); + negativeExamples.add(individualVector.get(i) + .getIndividualString()); } } + System.out.println("TEST: " + positiveExamples); } /** @@ -291,6 +290,8 @@ public void setKnowledgeSource() { this.source = new OWLAPIOntology(editor.getModelManager() .getActiveOntology()); + source.setOWLOntologies(editor.getModelManager().getActiveOntologies()); + } /** @@ -306,7 +307,7 @@ System.out.println("fehler!!!!!!!!!"); e.printStackTrace(); } -// rs = cm.reasoningService(reasoner); + // rs = cm.reasoningService(reasoner); } /** @@ -348,7 +349,9 @@ // TODO Auto-generated catch block e.printStackTrace(); } - cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); + cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view + .getPosAndNegSelectPanel().getOptionPanel() + .getMaxExecutionTime()); try { // initializes the learning algorithm la.init(); @@ -366,17 +369,8 @@ String message = "To view details about why a class description was suggested, please doubleclick on it."; // start the algorithm and print the best concept found la.start(); - //description = new Description[la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts()) - // .size()]; - //addToListModel(); - // renders the errormessage view.renderErrorMessage(error); view.setHintMessage(message); - // reenables the run button - //view.getRunButton().setEnabled(true); - // disables the cancel button - //view.getPosAndNegSelectPanel().setCheckBoxesEnable(true); - //view.getSuggestClassPanel().setSuggestList(suggestModel); } /** @@ -404,37 +398,40 @@ */ public void setPosVector() { setPositiveConcept(); - Set<OWLIndividual> individual = editor.getModelManager().getActiveOntology().getReferencedIndividuals(); - Iterator<OWLIndividual> it = individual.iterator(); - while (it.hasNext()) { - OWLIndividual individum = it.next(); - String individuals = individum.toString(); - if (setPositivExamplesChecked(individuals)) { - // when yes then it sets the positive example checked - posListModel.add(0, individuals); - - } else { - // When no it unchecks the positive example - negListModel.add(0, individuals); - } - } SortedSet<Individual> reasonerIndi = reasoner.getIndividuals(); Iterator<Individual> reasonerIt = reasonerIndi.iterator(); - while(reasonerIt.hasNext()) { + while (reasonerIt.hasNext()) { Individual ind = reasonerIt.next(); - - String indiv = ind.toString(); - // checks if individual belongs to the selected concept - if (setPositivExamplesChecked(indiv)) { - // when yes then it sets the positive example checked - individualVector.add(new IndividualObject(indiv, true)); + Iterator<OWLOntology> onto = editor.getModelManager() + .getActiveOntologies().iterator(); + while (onto.hasNext()) { + OWLOntology ont = onto.next(); + String indiv = ind.toString(); + // checks if individual belongs to the selected concept + if (setPositivExamplesChecked(indiv)) { + if (indiv.contains(ont.getURI().toString())) { + // when yes then it sets the positive example checked + + //OWLExpressionCheckerFactory + posListModel.add(0, ind.toManchesterSyntaxString(ont + .getURI().toString(), null)); + individualVector.add(new IndividualObject(indiv, true)); + break; + } - } else { - // When no it unchecks the positive example - individualVector.add(new IndividualObject(indiv, false)); + } else { + // When no it unchecks the positive example + if (indiv.contains(ont.getURI().toString())) { + individualVector + .add(new IndividualObject(indiv, false)); + negListModel.add(0, ind.toManchesterSyntaxString(ont + .getURI().toString(), null)); + break; + } + } } } - + } /** @@ -443,39 +440,45 @@ public void unsetNewConcepts() { while (owlDescription.iterator().hasNext()) { owlDescription.remove(owlDescription.iterator().next()); - + } } - + /** * This method returns the Vector of IndividualObjects. + * * @return individualVector Vector */ public Vector<IndividualObject> getIndividualVector() { return individualVector; } + /** * This method sets the individuals that belong to the concept which is * chosen in protege. */ public void setPositiveConcept() { SortedSet<Individual> individuals = null; - //System.out.println("TEST: " + rs.getNamedClasses()); + hasIndividuals = false; // checks if selected concept is thing when yes then it selects all // individuals if (!current.getRootObject().toString().equals("Thing")) { - - for (Iterator<NamedClass> i = reasoner.getAtomicConceptsList().iterator(); i - .hasNext();) { + + for (Iterator<NamedClass> i = reasoner.getAtomicConceptsList() + .iterator(); i.hasNext();) { // if individuals is null if (individuals == null) { NamedClass concept = i.next(); // checks if the concept is the selected concept in protege if (concept.toString().endsWith( - "#" + current.getRootObject().toString())) { + current.getRootObject().toString())) { // if individuals is not null it gets all individuals of // the concept + currentConcept = concept; if (reasoner.getIndividuals(concept) != null) { + if (reasoner.getIndividuals(concept).size() > 0) { + hasIndividuals = true; + } individual = reasoner.getIndividuals(concept); break; } @@ -483,44 +486,24 @@ } } } else { + if (reasoner.getIndividuals().size() > 0) { + hasIndividuals = true; + } individual = reasoner.getIndividuals(); } } - + /** * This Method checks if the selected class has any individuals. - * @param owlConcept OWLClass + * + * @param owlConcept + * OWLClass * @return boolean hasIndividuals */ - public boolean hasIndividuals(OWLClass owlConcept) { - boolean hasIndividuals = false; - NamedClass concept = null; - NamedClass selectedConcept = null; - Iterator<NamedClass> it = reasoner.getNamedClasses().iterator(); - while(it.hasNext()) { - concept = it.next(); - Iterator<OWLOntology> onto = editor.getModelManager().getActiveOntologies().iterator(); - while (onto.hasNext()) { - String uri = onto.next().getURI().toString(); - if (concept.toString().contains(uri)) { - if (concept.toManchesterSyntaxString(uri+"#", prefixes).equals(owlConcept.toString())) { - selectedConcept = concept; - break; - } - } - - } - - } - if(selectedConcept != null) { - if (reasoner.getIndividuals(selectedConcept).size() > 0) { - hasIndividuals = true; - } - } - concept = null; - selectedConcept = null; + public boolean hasIndividuals() { return hasIndividuals; } + /** * This method gets an Individual and checks if this individual belongs to * the concept chosen in protege. @@ -564,22 +547,25 @@ public void setDescriptionList(Description[] list) { description = list; } - + /** * This method returns the PosListModel. + * * @return DefaultListModel posListModel */ public DefaultListModel getPosListModel() { return posListModel; } - + /** * This method returns the NegListModel. + * * @return DefaultListModel negListModel */ public DefaultListModel getNegListModel() { return negListModel; } + /** * This method returns the current learning algorithm that is used to learn * new concepts. @@ -686,34 +672,25 @@ return suggestModel; } - /** + /* * This method gets the old concept from checking the positive examples. + * + * private void setOldConceptOWLAPI() { // gets all individuals + * SortedSet<Individual> indi = reasoner.getIndividuals(); // Iterator of + * Individuals for (Iterator<Individual> i = indi.iterator(); i.hasNext();) + * { Individual indi2 = i.next(); // checks if the current individual + * belongs to positive examples if (positiveExamples != null) { if + * (positiveExamples.toString().contains(indi2.toString())) { // if yes then + * get the concepts of this individuals Set<NamedClass> concept = + * reasoner.getTypes(indi2); // adds all concepts to old concept OWLAPI for + * (Iterator<NamedClass> k = concept.iterator(); k .hasNext();) { + * OWLDescription oldOWLAPI = OWLAPIDescriptionConvertVisitor + * .getOWLDescription(k.next()); oldConceptOWLAPI = oldOWLAPI; + * ds.add(oldOWLAPI); } + * + * } } } } */ - private void setOldConceptOWLAPI() { - // gets all individuals - SortedSet<Individual> indi = reasoner.getIndividuals(); - // Iterator of Individuals - for (Iterator<Individual> i = indi.iterator(); i.hasNext();) { - Individual indi2 = i.next(); - // checks if the current individual belongs to positive examples - if (positiveExamples != null) { - if (positiveExamples.toString().contains(indi2.toString())) { - // if yes then get the concepts of this individuals - Set<NamedClass> concept = reasoner.getTypes(indi2); - // adds all concepts to old concept OWLAPI - for (Iterator<NamedClass> k = concept.iterator(); k - .hasNext();) { - OWLDescription oldOWLAPI = OWLAPIDescriptionConvertVisitor - .getOWLDescription(k.next()); - oldConceptOWLAPI = oldOWLAPI; - ds.add(oldOWLAPI); - } - } - } - } - } - /** * This method stores the new concept learned by the DL-Learner in the * Ontology. @@ -724,7 +701,10 @@ public void changeDLLearnerDescriptionsToOWLDescriptions( Description descript) { setNewConceptOWLAPI(descript); - setOldConceptOWLAPI(); + // setOldConceptOWLAPI(); + oldConceptOWLAPI = OWLAPIDescriptionConvertVisitor + .getOWLDescription(currentConcept); + ds.add(oldConceptOWLAPI); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = manager.getOWLDataFactory(); @@ -763,11 +743,13 @@ public boolean getAlreadyLearned() { return alreadyLearned; } - + /** - * This Method checks if after inserting of this concept the ontology is still - * consistent. - * @param eDescription EvauatedDescription + * This Method checks if after inserting of this concept the ontology is + * still consistent. + * + * @param eDescription + * EvauatedDescription * @return isConsistent boolean */ public boolean isConsistent(EvaluatedDescription eDescription) { @@ -788,15 +770,17 @@ public URI getURI() { return editor.getModelManager().getActiveOntology().getURI(); } - + /** * This method sets the suggestion list. - * @param list List(EvaluatedDescription) + * + * @param list + * List(EvaluatedDescription) */ public void setSuggestList(List<EvaluatedDescription> list) { evalDescriptions = list; } - + public OWLEditorKit getOWLEditorKit() { return editor; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-27 11:54:33 UTC (rev 1523) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-28 12:13:18 UTC (rev 1524) @@ -139,6 +139,7 @@ * @param desc selected description */ public void renderDetailPanel(EvaluatedDescription desc) { + unsetEverything(); posCoveredScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); posCoveredScroll.setBounds(5, 150, 280, 140); posNotCoveredScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); @@ -228,15 +229,19 @@ add(negNotCoveredScroll); detailPopup.add(this); } + + private void unsetEverything() { + removeAll(); + } /** * This method sets the Informations of the selected description. */ private void setInformation() { if(eval!=null) { //sets the accuracy of the selected concept - conceptText.append(eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null)); + conceptText.setText(eval.getDescription().toManchesterSyntaxString(model.getURI().toString(), null)); double acc = (eval.getAccuracy())*100; - accuracyText.append(String.valueOf(acc)+"%"); + accuracyText.setText(String.valueOf(acc)+"%"); Iterator<Individual> i = eval.getCoveredPositives().iterator(); while (i.hasNext()) { Iterator<OWLOntology> onto = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); @@ -244,7 +249,7 @@ while (onto.hasNext()) { String uri = onto.next().getURI().toString(); if(ind.toString().contains(uri)) { - JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); posLabel.setForeground(colorGreen); posCoveredPanel.add(posLabel); } @@ -260,7 +265,7 @@ while (onto.hasNext()) { String uri = onto.next().getURI().toString(); if(ind.toString().contains(uri)) { - JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); posLabel.setForeground(colorRed); posNotCoveredPanel.add(posLabel); } @@ -278,7 +283,7 @@ while (onto.hasNext()) { String uri = onto.next().getURI().toString(); if(ind.toString().contains(uri)) { - JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); posLabel.setForeground(colorRed); negCoveredPanel.add(posLabel); } @@ -295,7 +300,7 @@ while (onto.hasNext()) { String uri = onto.next().getURI().toString(); if(ind.toString().contains(uri)) { - JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); posLabel.setForeground(colorGreen); negNotCoveredPanel.add(posLabel); } @@ -304,5 +309,5 @@ } } - } + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-27 11:54:33 UTC (rev 1523) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-28 12:13:18 UTC (rev 1524) @@ -384,7 +384,6 @@ adv = new JLabel("Advanced Settings"); advanced = new JToggleButton(icon); advanced.setVisible(true); - run = new JButton("Suggest " + label); accept = new JButton("ADD"); addButtonPanel = new JPanel(new BorderLayout()); @@ -439,7 +438,7 @@ model.initReasoner(); model.setPosVector(); hint.setVisible(true); - if (model.hasIndividuals(frame.getRootObject())) { + if (model.hasIndividuals()) { run.setEnabled(true); } else { run.setEnabled(false); @@ -604,7 +603,7 @@ posPanel.removeListeners(action); posPanel.removeHelpButtonListener(action); } - + /** * Adds Actionlistener to the run button. * @param a ActionListener Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-27 11:54:33 UTC (rev 1523) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-28 12:13:18 UTC (rev 1524) @@ -63,6 +63,10 @@ if (action.getActionCommand().equals("pos")) { panel.setExampleToOtherList(true, panel.getNegExampleList().getSelectedValue().toString()); + System.out.println("COUNT: " + panel.getPosExampleList().getModel().getSize()); + if(panel.getPosExampleList().getModel().getSize()>0) { + view.getRunButton().setEnabled(true); + } } if (action.getActionCommand().equals("neg")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-29 20:38:15
|
Revision: 1530 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1530&view=rev Author: heeroyuy Date: 2008-11-29 20:38:13 +0000 (Sat, 29 Nov 2008) Log Message: ----------- -some bugfixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -40,6 +40,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import org.apache.log4j.Logger; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.owl.Description; @@ -106,7 +107,7 @@ */ public void actionPerformed(ActionEvent z) { - if (z.getActionCommand().equals("Suggest " + id)) { + if (z.getActionCommand().equals(id)) { if (model.getAlreadyLearned()) { model.unsetListModel(); } @@ -116,7 +117,7 @@ model.setLearningProblem(); model.setLearningAlgorithm(); view.getRunButton().setEnabled(false); - view.renderErrorMessage("Learning started"); + view.renderErrorMessage("learning started"); view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); retriever = new SuggestionRetriever(); // @@ -136,7 +137,7 @@ .getSuggestClassPanel().getSuggestList() .getSelectedValue()); } - String message = "Concept added"; + String message = "class description added"; view.renderErrorMessage(message); view.updateWindow(); } @@ -307,43 +308,40 @@ SwingWorker<List<EvaluatedDescription>, List<EvaluatedDescription>> { private Thread dlLearner; - /** - * Constructor for the SuggestionRetriever. - */ - public SuggestionRetriever() { - - } + private DefaultListModel dm = new DefaultListModel(); + Logger logger = Logger.getLogger(SuggestionRetriever.class); + Logger rootLogger = Logger.getRootLogger(); + @SuppressWarnings("unchecked") @Override protected List<EvaluatedDescription> doInBackground() throws Exception { - // DefaultListModel descriptions = new DefaultListModel(); - // List<Description> descriptionList = - // model.getLearningAlgorithm().getCurrentlyBestDescriptions(); - // Iterator<Description> it = descriptionList.iterator(); la = model.getLearningAlgorithm(); timer = new Timer(); timer.schedule(new TimerTask(){ @Override public void run() { + System.out.println("DA BIN ICH:"); if (la != null) { - - publish(la - .getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel() - .getNrOfConcepts(), - view.getPosAndNegSelectPanel().getOptionPanel() - .getMinAccuracy(), true)); + + //System.out.println("EVAL: " + la.getCurrentlyBestEvaluatedDescriptions().isEmpty()); + //System.out.println("SIZE: " + la.getCurrentlyBestEvaluatedDescriptions().size()); + publish(la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts() + , view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy(), true)); } } - }, 0, 100); + }, 0, 1000); dlLearner = new Thread(new Runnable() { @Override public void run() { - + try { model.run(); + } catch (Exception e) { + e.printStackTrace(); + } } }); @@ -355,11 +353,8 @@ // TODO Auto-generated catch block e.printStackTrace(); } - List<EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions( - view.getPosAndNegSelectPanel().getOptionPanel() - .getNrOfConcepts(), - view.getPosAndNegSelectPanel().getOptionPanel() - .getMinAccuracy(), true); + List<EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts() + , view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy(), true); return result; } @@ -378,6 +373,7 @@ } view.getRunButton().setEnabled(true); + System.out.println("DONE"); updateList(result); } @@ -394,31 +390,35 @@ Runnable doUpdateList = new Runnable() { - DefaultListModel dm = new DefaultListModel(); + public void run() { + System.out.println("JETZT HIER:"); model.setSuggestList(result); // learnPanel.getListModel().clear(); Iterator<EvaluatedDescription> it = result.iterator(); - + int i = 0; while (it.hasNext()) { Iterator<OWLOntology> ont = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); EvaluatedDescription eval = it.next(); while(ont.hasNext()) { String onto = ont.next().getURI().toString(); + if(eval.getDescription().toString().contains(onto)) { if(model.isConsistent(eval)) { - dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto, null))); + dm.add(i, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto, null))); + i++; break; } else { - dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(onto, null))); + dm.add(i, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(onto, null))); + i++; break; } } } } - view.getSuggestClassPanel().getSuggestList().setModel(dm); - + System.out.println("NAJA NUN HIER"); + view.getSuggestClassPanel().setSuggestList(dm); } }; SwingUtilities.invokeLater(doUpdateList); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -35,6 +35,7 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; @@ -90,10 +91,6 @@ private ReasonerComponent rs; - // The Knowledge source for the reasoner - - private OWLAPIOntology source; - // The View of the DL-Learner Plugin private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; @@ -171,6 +168,7 @@ // The Individuals of the Ontology private Set<Individual> individual; + private Set<OWLAPIOntology> ontologies; // The error message which is rendered when an error occured @@ -185,6 +183,8 @@ private JXTaskPane detailPane; private DefaultListModel posListModel; private DefaultListModel negListModel; + private Set<KnowledgeSource> sources; + //private KnowledgeSource source; private boolean hasIndividuals; private NamedClass currentConcept; private Vector<IndividualObject> individualVector; @@ -222,6 +222,7 @@ suggestModel = new DefaultListModel(); detailPane = new JXTaskPane(); detailPane.setTitle("Details"); + sources = new HashSet<KnowledgeSource>(); } @@ -252,7 +253,6 @@ .getIndividualString()); } } - System.out.println("TEST: " + positiveExamples); } /** @@ -288,10 +288,11 @@ * OWLAPIOntology will be available. */ public void setKnowledgeSource() { - this.source = new OWLAPIOntology(editor.getModelManager() - .getActiveOntology()); - source.setOWLOntologies(editor.getModelManager().getActiveOntologies()); - + //Ssource = new OWLAPIOntology(editor.getModelManager().getActiveOntology()); + Iterator<OWLOntology> it = editor.getModelManager().getActiveOntologies().iterator(); + while (it.hasNext()) { + sources.add(new OWLAPIOntology(it.next())); + } } /** @@ -299,7 +300,8 @@ * OWLAPIReasoner is available. */ public void setReasoner() { - this.reasoner = cm.reasoner(OWLAPIReasoner.class, source); + this.reasoner = cm.reasoner(OWLAPIReasoner.class, sources); + try { reasoner.init(); } catch (ComponentInitException e) { @@ -316,12 +318,12 @@ * classes. */ public void setLearningProblem() { - if (id.equals("equivalent classes")) { + if (id.equals("Suggest equivalent class")) { // sets the learning problem to PosNegDefinitionLP when the // dllearner should suggest an equivalent class lp = cm.learningProblem(PosNegDefinitionLP.class, reasoner); } - if (id.equals("super classes")) { + if (id.equals("Suggest super class")) { // sets the learning problem to PosNegInclusionLP when the dllearner // should suggest a subclass lp = cm.learningProblem(PosNegInclusionLP.class, reasoner); @@ -349,6 +351,9 @@ // TODO Auto-generated catch block e.printStackTrace(); } + Set<String> ignore = new TreeSet<String>(); + ignore.add(currentConcept.toString()); + cm.applyConfigEntry(la, "ignoredConcepts", ignore); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view .getPosAndNegSelectPanel().getOptionPanel() .getMaxExecutionTime()); @@ -365,7 +370,7 @@ * This method starts the learning process. */ public void run() { - error = "Learning succesful"; + error = "learning succesful"; String message = "To view details about why a class description was suggested, please doubleclick on it."; // start the algorithm and print the best concept found la.start(); @@ -470,18 +475,34 @@ if (individuals == null) { NamedClass concept = i.next(); // checks if the concept is the selected concept in protege - if (concept.toString().endsWith( - current.getRootObject().toString())) { - // if individuals is not null it gets all individuals of - // the concept - currentConcept = concept; - if (reasoner.getIndividuals(concept) != null) { - if (reasoner.getIndividuals(concept).size() > 0) { - hasIndividuals = true; + if(concept.toString().contains("#")) { + if (concept.toString().endsWith("#"+ + current.getRootObject().toString())) { + // if individuals is not null it gets all individuals of + // the concept + currentConcept = concept; + if (reasoner.getIndividuals(concept) != null) { + if (reasoner.getIndividuals(concept).size() > 0) { + hasIndividuals = true; + } + individual = reasoner.getIndividuals(concept); + break; } - individual = reasoner.getIndividuals(concept); - break; } + } else { + if (concept.toString().endsWith( + current.getRootObject().toString())) { + // if individuals is not null it gets all individuals of + // the concept + currentConcept = concept; + if (reasoner.getIndividuals(concept) != null) { + if (reasoner.getIndividuals(concept).size() > 0) { + hasIndividuals = true; + } + individual = reasoner.getIndividuals(concept); + break; + } + } } } } @@ -784,4 +805,17 @@ public OWLEditorKit getOWLEditorKit() { return editor; } + + /** + * This method returns the currently used ontoloies including + * importet ontologies. + * @return Set<OWLAPIOntology> ontologies + */ + public Set<OWLAPIOntology> getOWLOntologies() { + return ontologies; + } + + public Set<KnowledgeSource> getKnowledgeSources() { + return sources; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -118,7 +118,7 @@ //checker = new OWLDescriptionChecker(editorKit); editor = new ExpressionEditor<OWLDescription>(editorKit, editorKit.getModelManager().getOWLExpressionCheckerFactory().getOWLDescriptionChecker()); editor.setExpressionObject(description); - dllearner = new DLLearnerView(frame, label, this); + action = new ActionHandler(this.action, null, dllearner, null, editorKit); tabbedPane = new JTabbedPane(); @@ -127,9 +127,11 @@ editingComponent.add(tabbedPane); editingComponent.setPreferredSize(new Dimension(600, 520)); if (label.equals("equivalent classes")) { + dllearner = new DLLearnerView(frame, SUGGEST_EQUIVALENT_CLASS_LABEL, this); tabbedPane.add(SUGGEST_EQUIVALENT_CLASS_LABEL, dllearner); } if (label.equals("super classes")) { + dllearner = new DLLearnerView(frame, SUGGEST_SUBCLASS_LABEL, this); tabbedPane.add(SUGGEST_SUBCLASS_LABEL, dllearner); } @@ -384,7 +386,7 @@ adv = new JLabel("Advanced Settings"); advanced = new JToggleButton(icon); advanced.setVisible(true); - run = new JButton("Suggest " + label); + run = new JButton(label); accept = new JButton("ADD"); addButtonPanel = new JPanel(new BorderLayout()); sugPanel.addSuggestPanelMouseListener(action); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -54,7 +54,7 @@ maxExecutionTimeLabel = new JLabel("maximum execution time"); nrOfConceptsLabel = new JLabel("maximum number of results"); - minAccuracy = new JSlider(50, 100, 80); + minAccuracy = new JSlider(50, 100, 50); minAccuracy.setPaintTicks(true); minAccuracy.setMajorTickSpacing(10); minAccuracy.setMinorTickSpacing(1); @@ -68,7 +68,7 @@ maxExecutionTime.setPaintLabels(true); - nrOfConcepts = new JSlider(2, 20, 5); + nrOfConcepts = new JSlider(2, 20, 10); nrOfConcepts.setPaintTicks(true); nrOfConcepts.setMajorTickSpacing(2); nrOfConcepts.setMinorTickSpacing(1); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -88,7 +88,9 @@ * @param desc List model of descriptions made by the DL-Learner */ public void setSuggestList(DefaultListModel desc) { + System.out.println("HUHU"); descriptions.setModel(desc); + repaint(); } /** * This method returns the current Description list. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-11-29 23:07:34
|
Revision: 1532 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1532&view=rev Author: jenslehmann Date: 2008-11-29 23:07:28 +0000 (Sat, 29 Nov 2008) Log Message: ----------- added log4j logging for protege plugin Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-29 22:33:54 UTC (rev 1531) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-29 23:07:28 UTC (rev 1532) @@ -58,6 +58,8 @@ // This is the DLLearnerModel. + private static Logger logger = Logger.getLogger(ActionHandler.class); + private DLLearnerModel model; private OWLEditorKit editorKit; @@ -388,6 +390,8 @@ private void updateList(final List<EvaluatedDescription> result) { + logger.debug("update list with " + result); + Runnable doUpdateList = new Runnable() { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2008-11-29 22:33:54 UTC (rev 1531) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ProtegePlugin.java 2008-11-29 23:07:28 UTC (rev 1532) @@ -19,6 +19,11 @@ */ package org.dllearner.tools.protege; +import org.apache.log4j.FileAppender; +import org.apache.log4j.HTMLLayout; +import org.apache.log4j.Layout; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; import org.protege.editor.owl.ui.view.AbstractOWLClassViewComponent; import org.semanticweb.owl.model.OWLClass; import org.protege.editor.owl.ui.framelist.OWLFrameList2; @@ -48,7 +53,17 @@ JScrollPane dlLearner = new JScrollPane(list); add(dlLearner); - + // add file logger (comment out if not needed) + boolean useAdditionalLogger = true; + if(useAdditionalLogger) { + Layout layout = new HTMLLayout(); + String fileName = "logs/dllearner_log.html"; + FileAppender fileAppender = new FileAppender(layout, fileName); + // only add log statements in protege package to log file + Logger protegeLogger = Logger.getLogger("org.dllearner.tools.protege"); + protegeLogger.addAppender(fileAppender); + protegeLogger.setLevel(Level.DEBUG); + } } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-30 12:37:33
|
Revision: 1534 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1534&view=rev Author: heeroyuy Date: 2008-11-30 12:37:29 +0000 (Sun, 30 Nov 2008) Log Message: ----------- -fixed bug that suggestList isn't cleared before updating List -fixed bug that equivalent class is also put to subclass Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-29 23:26:05 UTC (rev 1533) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-30 12:37:29 UTC (rev 1534) @@ -400,6 +400,7 @@ System.out.println("JETZT HIER:"); model.setSuggestList(result); // learnPanel.getListModel().clear(); + dm.clear(); Iterator<EvaluatedDescription> it = result.iterator(); int i = 0; while (it.hasNext()) { @@ -407,7 +408,6 @@ EvaluatedDescription eval = it.next(); while(ont.hasNext()) { String onto = ont.next().getURI().toString(); - if(eval.getDescription().toString().contains(onto)) { if(model.isConsistent(eval)) { dm.add(i, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto, null))); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-29 23:26:05 UTC (rev 1533) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-30 12:37:29 UTC (rev 1534) @@ -729,7 +729,7 @@ OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = manager.getOWLDataFactory(); - if (id.equals("Equivalent classes")) { + if (id.equals("Suggest equivalent class")) { axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); } else { axiomOWLAPI = factory.getOWLSubClassAxiom(newConceptOWLAPI, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-11-30 16:29:30
|
Revision: 1538 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1538&view=rev Author: heeroyuy Date: 2008-11-30 16:29:25 +0000 (Sun, 30 Nov 2008) Log Message: ----------- -fixed problem with listupdate while learning Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-30 15:09:42 UTC (rev 1537) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-30 16:29:25 UTC (rev 1538) @@ -75,7 +75,6 @@ private Timer timer; private LearningAlgorithm la; private SuggestionRetriever retriever; - /** * This is the constructor for the action handler. * @@ -110,9 +109,6 @@ public void actionPerformed(ActionEvent z) { if (z.getActionCommand().equals(id)) { - if (model.getAlreadyLearned()) { - model.unsetListModel(); - } model.setKnowledgeSource(); model.setReasoner(); model.setPositiveAndNegativeExamples(); @@ -122,8 +118,6 @@ view.renderErrorMessage("learning started"); view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); retriever = new SuggestionRetriever(); - // - // dlLearner.start(); retriever.execute(); } @@ -301,6 +295,9 @@ // TODO Auto-generated method stub } + + + /** * Inner Class that retrieves the concepts given by the DL-Learner. * @author Christian Koetteritzsch @@ -322,18 +319,14 @@ timer.schedule(new TimerTask(){ @Override - public void run() { - System.out.println("DA BIN ICH:"); + public void run() { if (la != null) { - - //System.out.println("EVAL: " + la.getCurrentlyBestEvaluatedDescriptions().isEmpty()); - //System.out.println("SIZE: " + la.getCurrentlyBestEvaluatedDescriptions().size()); publish(la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts() , view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy(), true)); } } - }, 0, 1000); + }, 0, 500); dlLearner = new Thread(new Runnable() { @@ -374,8 +367,7 @@ e.printStackTrace(); } - view.getRunButton().setEnabled(true); - System.out.println("DONE"); + view.algorithmTerminated(); updateList(result); } @@ -397,7 +389,6 @@ public void run() { - System.out.println("JETZT HIER:"); model.setSuggestList(result); // learnPanel.getListModel().clear(); dm.clear(); @@ -421,7 +412,6 @@ } } } - System.out.println("NAJA NUN HIER"); view.getSuggestClassPanel().setSuggestList(dm); } }; Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-30 15:09:42 UTC (rev 1537) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-30 16:29:25 UTC (rev 1538) @@ -46,7 +46,7 @@ import org.dllearner.kb.OWLAPIOntology; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; -import org.dllearner.reasoning.OWLAPIReasoner; +import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.utilities.owl.OWLAPIDescriptionConvertVisitor; import org.jdesktop.swingx.JXTaskPane; import org.protege.editor.owl.OWLEditorKit; @@ -68,13 +68,13 @@ * @author Christian Koetteritzsch * */ -public class DLLearnerModel implements Runnable { +public class DLLearnerModel implements Runnable{ // The Sting is for components that are available in the DL-Learner private String[] componenten = { "org.dllearner.kb.OWLFile", "org.dllearner.reasoning.OWLAPIReasoner", - "org.dllearner.reasoning.DIGReasoner", + "org.dllearner.reasoning.FastInstanceChecker", "org.dllearner.reasoning.FastRetrievalReasoner", "org.dllearner.learningproblems.PosNegInclusionLP", "org.dllearner.learningproblems.PosNegDefinitionLP", @@ -90,6 +90,8 @@ // The Reasoning Service for the Reasoner private ReasonerComponent rs; + private static final String EQUIVALENT_CLASS_AXIOM_STRING = "Suggest equivalent class"; + private static final String SUPER_CLASS_AXIOM_STRING = "Suggest super class"; // The View of the DL-Learner Plugin @@ -127,7 +129,7 @@ // The Reasoner which is used to learn - private OWLAPIReasoner reasoner; + private FastInstanceChecker reasoner; // A Set of Descriptions in OWL Syntax which the DL-Learner suggested @@ -172,7 +174,6 @@ // The error message which is rendered when an error occured - private String error; // This is the new axiom which will be added to the Ontology @@ -184,7 +185,7 @@ private DefaultListModel posListModel; private DefaultListModel negListModel; private Set<KnowledgeSource> sources; - //private KnowledgeSource source; + // private KnowledgeSource source; private boolean hasIndividuals; private NamedClass currentConcept; private Vector<IndividualObject> individualVector; @@ -288,20 +289,22 @@ * OWLAPIOntology will be available. */ public void setKnowledgeSource() { - //Ssource = new OWLAPIOntology(editor.getModelManager().getActiveOntology()); - Iterator<OWLOntology> it = editor.getModelManager().getActiveOntologies().iterator(); + // source = new + // OWLAPIOntology(editor.getModelManager().getActiveOntology()); + Iterator<OWLOntology> it = editor.getModelManager() + .getActiveOntologies().iterator(); while (it.hasNext()) { sources.add(new OWLAPIOntology(it.next())); } } /** - * This method sets the reasoner and the reasoning service Only - * OWLAPIReasoner is available. + * This method sets the reasoner. Only + * FastInstanceChecker is available. */ public void setReasoner() { - this.reasoner = cm.reasoner(OWLAPIReasoner.class, sources); - + this.reasoner = cm.reasoner(FastInstanceChecker.class, sources); + try { reasoner.init(); } catch (ComponentInitException e) { @@ -318,12 +321,12 @@ * classes. */ public void setLearningProblem() { - if (id.equals("Suggest equivalent class")) { + if (id.equals(EQUIVALENT_CLASS_AXIOM_STRING)) { // sets the learning problem to PosNegDefinitionLP when the // dllearner should suggest an equivalent class lp = cm.learningProblem(PosNegDefinitionLP.class, reasoner); } - if (id.equals("Suggest super class")) { + if (id.equals(SUPER_CLASS_AXIOM_STRING)) { // sets the learning problem to PosNegInclusionLP when the dllearner // should suggest a subclass lp = cm.learningProblem(PosNegInclusionLP.class, reasoner); @@ -354,6 +357,9 @@ Set<String> ignore = new TreeSet<String>(); ignore.add(currentConcept.toString()); cm.applyConfigEntry(la, "ignoredConcepts", ignore); + cm.applyConfigEntry(la, "noisePercentage", 5); + cm.applyConfigEntry(la, "terminateOnNoiseReached", false); + cm.applyConfigEntry(la, "negationPenalty", 2); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view .getPosAndNegSelectPanel().getOptionPanel() .getMaxExecutionTime()); @@ -367,18 +373,6 @@ } /** - * This method starts the learning process. - */ - public void run() { - error = "learning succesful"; - String message = "To view details about why a class description was suggested, please doubleclick on it."; - // start the algorithm and print the best concept found - la.start(); - view.renderErrorMessage(error); - view.setHintMessage(message); - } - - /** * This method returns the Concepts from the DL-Learner. * * @return Array of learned Concepts. @@ -386,17 +380,12 @@ public Description[] getSolutions() { return description; } - /** - * This method gets an error message and storess it. - * - * @param err - * error message + * Starts the learning algorithm. */ - public void setErrorMessage(String err) { - this.error = err; + public void run() { + la.start(); } - /** * This method sets the check boxes for the positive check boxes checked if * the individuals matches the concept that is chosen in protege. @@ -416,8 +405,8 @@ if (setPositivExamplesChecked(indiv)) { if (indiv.contains(ont.getURI().toString())) { // when yes then it sets the positive example checked - - //OWLExpressionCheckerFactory + + // OWLExpressionCheckerFactory posListModel.add(0, ind.toManchesterSyntaxString(ont .getURI().toString(), null)); individualVector.add(new IndividualObject(indiv, true)); @@ -475,10 +464,11 @@ if (individuals == null) { NamedClass concept = i.next(); // checks if the concept is the selected concept in protege - if(concept.toString().contains("#")) { - if (concept.toString().endsWith("#"+ - current.getRootObject().toString())) { - // if individuals is not null it gets all individuals of + if (concept.toString().contains("#")) { + if (concept.toString().endsWith( + "#" + current.getRootObject().toString())) { + // if individuals is not null it gets all + // individuals of // the concept currentConcept = concept; if (reasoner.getIndividuals(concept) != null) { @@ -491,8 +481,9 @@ } } else { if (concept.toString().endsWith( - current.getRootObject().toString())) { - // if individuals is not null it gets all individuals of + current.getRootObject().toString())) { + // if individuals is not null it gets all + // individuals of // the concept currentConcept = concept; if (reasoner.getIndividuals(concept) != null) { @@ -517,8 +508,6 @@ /** * This Method checks if the selected class has any individuals. * - * @param owlConcept - * OWLClass * @return boolean hasIndividuals */ public boolean hasIndividuals() { @@ -729,11 +718,11 @@ OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLDataFactory factory = manager.getOWLDataFactory(); - if (id.equals("Suggest equivalent class")) { + if (id.equals(EQUIVALENT_CLASS_AXIOM_STRING)) { axiomOWLAPI = factory.getOWLEquivalentClassesAxiom(ds); } else { - axiomOWLAPI = factory.getOWLSubClassAxiom(newConceptOWLAPI, - oldConceptOWLAPI); + axiomOWLAPI = factory.getOWLSubClassAxiom(oldConceptOWLAPI, + newConceptOWLAPI); } OWLOntology onto = editor.getModelManager().getActiveOntology(); AddAxiom axiom = new AddAxiom(onto, axiomOWLAPI); @@ -801,21 +790,73 @@ public void setSuggestList(List<EvaluatedDescription> list) { evalDescriptions = list; } - + + /** + * This method returns the OWLEditorKit. + * @return OWLEditorKit + */ public OWLEditorKit getOWLEditorKit() { return editor; } - + /** - * This method returns the currently used ontoloies including - * importet ontologies. + * This method returns the currently used ontoloies including importet + * ontologies. + * * @return Set<OWLAPIOntology> ontologies */ public Set<OWLAPIOntology> getOWLOntologies() { return ontologies; } - + + /** + * This method returns the Knowledgesources currenty used. + * @return Set<KnowledgSource> + */ public Set<KnowledgeSource> getKnowledgeSources() { return sources; } + + /*public void updateSuggestListItems() { + evalDescriptions = la.getCurrentlyBestEvaluatedDescriptions(view + .getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts(), + view.getPosAndNegSelectPanel().getOptionPanel() + .getMinAccuracy(), true); + // learnPanel.getListModel().clear(); + DefaultListModel dm = new DefaultListModel(); + Iterator<EvaluatedDescription> it = evalDescriptions.iterator(); + int i = 0; + while (it.hasNext()) { + Iterator<OWLOntology> ont = editor.getModelManager() + .getActiveOntologies().iterator(); + EvaluatedDescription eval = it.next(); + while (ont.hasNext()) { + String onto = ont.next().getURI().toString(); + if (eval.getDescription().toString().contains(onto)) { + if (isConsistent(eval)) { + dm.add(i, new SuggestListItem(Color.GREEN, eval + .getDescription().toManchesterSyntaxString( + onto, null))); + i++; + break; + } else { + dm.add(i, new SuggestListItem(Color.RED, eval + .getDescription().toManchesterSyntaxString( + onto, null))); + i++; + break; + } + } + } + } + view.getSuggestClassPanel().setSuggestList(dm); + } + + public void algorithmTerminated() { + error = "learning succesful"; + String message = "To view details about why a class description was suggested, please doubleclick on it."; + // start the algorithm and print the best concept found + view.renderErrorMessage(error); + view.setHintMessage(message); + }*/ } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-30 15:09:42 UTC (rev 1537) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-30 16:29:25 UTC (rev 1538) @@ -31,7 +31,6 @@ /** * Constructor for the IndividualObject. * @param normal String - * @param manchester String * @param pos boolean */ public IndividualObject(String normal, boolean pos) { Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-30 15:09:42 UTC (rev 1537) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-30 16:29:25 UTC (rev 1538) @@ -629,6 +629,18 @@ public void addAdvancedButtonListener(ActionListener a) { advanced.addActionListener(a); } + + /** + * This method sets the run button enable after learning. + */ + public void algorithmTerminated() { + String error = "learning succesful"; + String message = "To view details about why a class description was suggested, please doubleclick on it."; + run.setEnabled(true); + // start the algorithm and print the best concept found + renderErrorMessage(error); + setHintMessage(message); + } } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-30 15:09:42 UTC (rev 1537) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-30 16:29:25 UTC (rev 1538) @@ -54,14 +54,14 @@ maxExecutionTimeLabel = new JLabel("maximum execution time"); nrOfConceptsLabel = new JLabel("maximum number of results"); - minAccuracy = new JSlider(50, 100, 50); + minAccuracy = new JSlider(50, 100, 90); minAccuracy.setPaintTicks(true); minAccuracy.setMajorTickSpacing(10); minAccuracy.setMinorTickSpacing(1); minAccuracy.setPaintLabels(true); - maxExecutionTime = new JSlider(5, 20, 10); + maxExecutionTime = new JSlider(2, 20, 3); maxExecutionTime.setPaintTicks(true); maxExecutionTime.setMajorTickSpacing(5); maxExecutionTime.setMinorTickSpacing(1); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-30 15:09:42 UTC (rev 1537) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-30 16:29:25 UTC (rev 1538) @@ -88,7 +88,6 @@ * @param desc List model of descriptions made by the DL-Learner */ public void setSuggestList(DefaultListModel desc) { - System.out.println("HUHU"); descriptions.setModel(desc); repaint(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-12-07 22:42:12
|
Revision: 1543 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1543&view=rev Author: heeroyuy Date: 2008-12-07 22:42:06 +0000 (Sun, 07 Dec 2008) Log Message: ----------- -added arrows for the buttons to change an individual to positive or negative example list -added install and readme Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/Install_protege trunk/src/dl-learner/org/dllearner/tools/protege/Readme_protege trunk/src/dl-learner/org/dllearner/tools/protege/backspace.gif trunk/src/dl-learner/org/dllearner/tools/protege/space.gif Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-12-02 15:26:20 UTC (rev 1542) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-12-07 22:42:06 UTC (rev 1543) @@ -75,6 +75,8 @@ private Timer timer; private LearningAlgorithm la; private SuggestionRetriever retriever; + private final Color colorRed = new Color(139,0,0); + private final Color colorGreen = new Color(0,139,0); /** * This is the constructor for the action handler. * @@ -220,16 +222,27 @@ for (Iterator<EvaluatedDescription> i = model .getEvaluatedDescriptionList().iterator(); i.hasNext();) { eDescription = i.next(); - if (desc.equals(eDescription.getDescription() - .toManchesterSyntaxString( - editorKit.getModelManager() - .getActiveOntology().getURI().toString() - , null))) { - evaluatedDescription = eDescription; - - break; + if(eDescription.getDescription().toString().contains("#")) { + if (desc.equals(eDescription.getDescription() + .toManchesterSyntaxString( + editorKit.getModelManager() + .getActiveOntology().getURI().toString() + "#" + , null))) { + evaluatedDescription = eDescription; + + break; + } + } else { + if (desc.equals(eDescription.getDescription() + .toManchesterSyntaxString( + editorKit.getModelManager() + .getActiveOntology().getURI().toString() + , null))) { + evaluatedDescription = eDescription; + + break; + } } - } } @@ -400,14 +413,26 @@ while(ont.hasNext()) { String onto = ont.next().getURI().toString(); if(eval.getDescription().toString().contains(onto)) { - if(model.isConsistent(eval)) { - dm.add(i, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto, null))); - i++; - break; + if(eval.getDescription().toString().contains("#")) { + if(model.isConsistent(eval)) { + dm.add(i, new SuggestListItem(colorGreen, eval.getDescription().toManchesterSyntaxString(onto+"#", null))); + i++; + break; + } else { + dm.add(i, new SuggestListItem(colorRed, eval.getDescription().toManchesterSyntaxString(onto+"#", null))); + i++; + break; + } } else { - dm.add(i, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(onto, null))); - i++; - break; + if(model.isConsistent(eval)) { + dm.add(i, new SuggestListItem(colorGreen, eval.getDescription().toManchesterSyntaxString(onto, null))); + i++; + break; + } else { + dm.add(i, new SuggestListItem(colorRed, eval.getDescription().toManchesterSyntaxString(onto, null))); + i++; + break; + } } } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-12-02 15:26:20 UTC (rev 1542) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-12-07 22:42:06 UTC (rev 1543) @@ -402,25 +402,49 @@ OWLOntology ont = onto.next(); String indiv = ind.toString(); // checks if individual belongs to the selected concept - if (setPositivExamplesChecked(indiv)) { - if (indiv.contains(ont.getURI().toString())) { - // when yes then it sets the positive example checked + if(ind.toString().contains("#")) { + if (setPositivExamplesChecked(indiv)) { + if (indiv.contains(ont.getURI().toString())) { + // when yes then it sets the positive example checked - // OWLExpressionCheckerFactory - posListModel.add(0, ind.toManchesterSyntaxString(ont - .getURI().toString(), null)); - individualVector.add(new IndividualObject(indiv, true)); - break; + // OWLExpressionCheckerFactory + posListModel.add(0, ind.toManchesterSyntaxString(ont + .getURI().toString()+"#", null)); + individualVector.add(new IndividualObject(indiv, true)); + break; + } + + } else { + // When no it unchecks the positive example + if (indiv.contains(ont.getURI().toString())) { + individualVector + .add(new IndividualObject(indiv, false)); + negListModel.add(0, ind.toManchesterSyntaxString(ont + .getURI().toString()+"#", null)); + break; + } } + } else { + if (setPositivExamplesChecked(indiv)) { + if (indiv.contains(ont.getURI().toString())) { + // when yes then it sets the positive example checked - } else { - // When no it unchecks the positive example - if (indiv.contains(ont.getURI().toString())) { - individualVector - .add(new IndividualObject(indiv, false)); - negListModel.add(0, ind.toManchesterSyntaxString(ont - .getURI().toString(), null)); - break; + // OWLExpressionCheckerFactory + posListModel.add(0, ind.toManchesterSyntaxString(ont + .getURI().toString(), null)); + individualVector.add(new IndividualObject(indiv, true)); + break; + } + + } else { + // When no it unchecks the positive example + if (indiv.contains(ont.getURI().toString())) { + individualVector + .add(new IndividualObject(indiv, false)); + negListModel.add(0, ind.toManchesterSyntaxString(ont + .getURI().toString(), null)); + break; + } } } } Added: trunk/src/dl-learner/org/dllearner/tools/protege/Install_protege =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/Install_protege (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/Install_protege 2008-12-07 22:42:06 UTC (rev 1543) @@ -0,0 +1,15 @@ +Requirements +============ +Java 6 and the Prot\xE9g\xE9 4.0 Beta are required. (All other libraries are included in the release.) + +Installation +============ +Put the DL-Learner-protege-plugin.jar in your plugin folder of Prot\xE9g\xE9. + +Running Instructions +==================== +To use the plugin go to view --> class views and click on class descriptions (including DL-Learner plugin). +Put the new frame somewhere in the classes tab in Prot\xE9g\xE9 and close the old class description view. All features are included in the plugin. +If you have problems look at the screen cast in the release bundle. + + Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-12-02 15:26:20 UTC (rev 1542) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-12-07 22:42:06 UTC (rev 1543) @@ -109,10 +109,10 @@ private JPanel negCoveredPanel; private JPanel negNotCoveredPanel; private EvaluatedDescription eval; - private final Color colorRed = Color.red; private JTextArea concept; private JTextArea conceptText; - private final Color colorGreen = Color.green; + private final Color colorRed = new Color(139,0,0); + private final Color colorGreen = new Color(0,139,0); /** * This is the constructor for the Panel. * @param model DLLearnerModel @@ -239,7 +239,12 @@ private void setInformation() { if(eval!=null) { //sets the accuracy of the selected concept - conceptText.setText(eval.getDescription().toManchesterSyntaxString(model.getURI().toString(), null)); + System.out.println("EVAL: " + eval.getDescription()); + if(eval.getDescription().toString().contains("#")) { + conceptText.setText(eval.getDescription().toManchesterSyntaxString(model.getURI().toString() + "#", null)); + } else { + conceptText.setText(eval.getDescription().toManchesterSyntaxString(model.getURI().toString(), null)); + } double acc = (eval.getAccuracy())*100; accuracyText.setText(String.valueOf(acc)+"%"); Iterator<Individual> i = eval.getCoveredPositives().iterator(); @@ -248,10 +253,20 @@ Individual ind = i.next(); while (onto.hasNext()) { String uri = onto.next().getURI().toString(); - if(ind.toString().contains(uri)) { - JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); - posLabel.setForeground(colorGreen); - posCoveredPanel.add(posLabel); + if(ind.toString().contains("#")) { + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri + "#", null)); + posLabel.setForeground(colorGreen); + posCoveredPanel.add(posLabel); + break; + } + } else { + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); + posLabel.setForeground(colorGreen); + posCoveredPanel.add(posLabel); + break; + } } } @@ -264,10 +279,20 @@ Individual ind = a.next(); while (onto.hasNext()) { String uri = onto.next().getURI().toString(); - if(ind.toString().contains(uri)) { - JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); - posLabel.setForeground(colorRed); - posNotCoveredPanel.add(posLabel); + if(ind.toString().contains("#")) { + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri + "#", null)); + posLabel.setForeground(colorRed); + posNotCoveredPanel.add(posLabel); + break; + } + } else { + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); + posLabel.setForeground(colorRed); + posNotCoveredPanel.add(posLabel); + break; + } } } @@ -282,10 +307,20 @@ Individual ind = b.next(); while (onto.hasNext()) { String uri = onto.next().getURI().toString(); - if(ind.toString().contains(uri)) { - JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); - posLabel.setForeground(colorRed); - negCoveredPanel.add(posLabel); + if(ind.toString().contains("#")) { + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri + "#", null)); + posLabel.setForeground(colorRed); + negCoveredPanel.add(posLabel); + break; + } + } else { + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); + posLabel.setForeground(colorRed); + negCoveredPanel.add(posLabel); + break; + } } } @@ -299,10 +334,18 @@ Individual ind = c.next(); while (onto.hasNext()) { String uri = onto.next().getURI().toString(); - if(ind.toString().contains(uri)) { - JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); - posLabel.setForeground(colorGreen); - negNotCoveredPanel.add(posLabel); + if(ind.toString().contains("#")) { + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri + "#", null)); + posLabel.setForeground(colorGreen); + negNotCoveredPanel.add(posLabel); + } + } else { + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri, null)); + posLabel.setForeground(colorGreen); + negNotCoveredPanel.add(posLabel); + } } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-12-02 15:26:20 UTC (rev 1542) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-12-07 22:42:06 UTC (rev 1543) @@ -61,7 +61,7 @@ minAccuracy.setPaintLabels(true); - maxExecutionTime = new JSlider(2, 20, 3); + maxExecutionTime = new JSlider(2, 20, 5); maxExecutionTime.setPaintTicks(true); maxExecutionTime.setMajorTickSpacing(5); maxExecutionTime.setMinorTickSpacing(1); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-12-02 15:26:20 UTC (rev 1542) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-12-07 22:42:06 UTC (rev 1543) @@ -21,8 +21,10 @@ import java.awt.Dimension; import java.awt.GridLayout; +import java.net.URL; import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; @@ -90,6 +92,8 @@ // This is the Text area where the help message is displayed. private OptionPanel optionPanel; private DefaultListModel posListModel; + private ImageIcon addToPosListIcon; + private ImageIcon addToNegListIcon; private DefaultListModel negListModel; private JPanel examplePanel; private PosAndNegSelectPanelHandler handler; @@ -117,6 +121,10 @@ examplePanel = new JPanel(null); posLabelPanel = new JPanel(null); negLabelPanel = new JPanel(null); + URL iconUrl = this.getClass().getResource("backspace.gif"); + addToPosListIcon = new ImageIcon(iconUrl); + URL toggledIconUrl = this.getClass().getResource("space.gif"); + addToNegListIcon = new ImageIcon(toggledIconUrl); posListModel = new DefaultListModel(); negListModel = new DefaultListModel(); pos = new JLabel("Positive Examples"); @@ -129,8 +137,10 @@ negList = new JList(negListModel); negList.setName("neg"); negList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - addToPosExamples = new JButton("pos"); - addToNegExamples = new JButton("neg"); + addToPosExamples = new JButton(addToPosListIcon); + addToPosExamples.setName("pos"); + addToNegExamples = new JButton(addToNegListIcon); + addToNegExamples.setName("neg"); helpForPosExamples = new JButton("?"); helpForPosExamples.setBounds(100, 5, 20, 20); helpForNegExamples = new JButton("?"); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-12-02 15:26:20 UTC (rev 1542) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-12-07 22:42:06 UTC (rev 1543) @@ -60,8 +60,8 @@ */ public void actionPerformed(ActionEvent action) { - - if (action.getActionCommand().equals("pos")) { + System.out.println(action.getSource()); + if (action.getSource().toString().contains("pos")) { panel.setExampleToOtherList(true, panel.getNegExampleList().getSelectedValue().toString()); System.out.println("COUNT: " + panel.getPosExampleList().getModel().getSize()); if(panel.getPosExampleList().getModel().getSize()>0) { @@ -69,7 +69,7 @@ } } - if (action.getActionCommand().equals("neg")) { + if (action.getSource().toString().contains("neg")) { panel.setExampleToOtherList(false, panel.getPosExampleList().getSelectedValue().toString()); } Added: trunk/src/dl-learner/org/dllearner/tools/protege/Readme_protege =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/Readme_protege (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/Readme_protege 2008-12-07 22:42:06 UTC (rev 1543) @@ -0,0 +1,15 @@ +README +====== +The Prot\xE9g\xE9 DL-Learner plugin allows to learn equivalence and super class axioms based on +the instance data in the ontologies loaded in Prot\xE9g\xE9. It integrated seamlessly in Prot\xE9g\xE9. + +Homepage: http://dl-learner.org/wiki/ProtegePlugin +Sourceforge.net Project Page: http://sourceforge.net/projects/dl-learner/ +Bugs & Feature Requests: http://sourceforge.net/tracker/?group_id=203619 +Mailing Lists: http://sourceforge.net/mail/?group_id=203619 +Latest Release: http://sourceforge.net/project/showfiles.php?group_id=203619 + +The Prot\xE9g\xE9 Plugin is Open Source and licenced under the GNU General Public License. + +Documentation for the Prot\xE9g\xE9 Plugin can be found +at http://dl-learner.org/wiki/ProtegePlugin. Added: trunk/src/dl-learner/org/dllearner/tools/protege/backspace.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/tools/protege/backspace.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/src/dl-learner/org/dllearner/tools/protege/space.gif =================================================================== (Binary files differ) Property changes on: trunk/src/dl-learner/org/dllearner/tools/protege/space.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hee...@us...> - 2008-12-09 11:02:49
|
Revision: 1546 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1546&view=rev Author: heeroyuy Date: 2008-12-09 11:02:46 +0000 (Tue, 09 Dec 2008) Log Message: ----------- -added link to the screen cast Added Paths: ----------- trunk/src/dl-learner/org/dllearner/tools/protege/DL-Learner-Protege-plugin-screencast.url trunk/src/dl-learner/org/dllearner/tools/protege/INSTALL trunk/src/dl-learner/org/dllearner/tools/protege/README Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/tools/protege/Install_protege trunk/src/dl-learner/org/dllearner/tools/protege/Readme_protege Added: trunk/src/dl-learner/org/dllearner/tools/protege/DL-Learner-Protege-plugin-screencast.url =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DL-Learner-Protege-plugin-screencast.url (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DL-Learner-Protege-plugin-screencast.url 2008-12-09 11:02:46 UTC (rev 1546) @@ -0,0 +1,6 @@ +[InternetShortcut] +URL=http://dl-learner.org/files/screencast/protege/prot.htm +HotKey=0 +IDList= +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,2 Added: trunk/src/dl-learner/org/dllearner/tools/protege/INSTALL =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/INSTALL (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/INSTALL 2008-12-09 11:02:46 UTC (rev 1546) @@ -0,0 +1,15 @@ +Requirements +============ +Java 6 and the Prot\xE9g\xE9 4.0 Beta are required. (All other libraries are included in the release.) + +Installation +============ +Put the DL-Learner-protege-plugin.jar in your plugin folder of Prot\xE9g\xE9. + +Running Instructions +==================== +To use the plugin go to view --> class views and click on class descriptions (including DL-Learner plugin). +Put the new frame somewhere in the classes tab in Prot\xE9g\xE9 and close the old class description view. All features are included in the plugin. +If you have problems look at the screen cast link in the release bundle. + + Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/Install_protege =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/Install_protege 2008-12-08 13:06:44 UTC (rev 1545) +++ trunk/src/dl-learner/org/dllearner/tools/protege/Install_protege 2008-12-09 11:02:46 UTC (rev 1546) @@ -1,15 +0,0 @@ -Requirements -============ -Java 6 and the Prot\xE9g\xE9 4.0 Beta are required. (All other libraries are included in the release.) - -Installation -============ -Put the DL-Learner-protege-plugin.jar in your plugin folder of Prot\xE9g\xE9. - -Running Instructions -==================== -To use the plugin go to view --> class views and click on class descriptions (including DL-Learner plugin). -Put the new frame somewhere in the classes tab in Prot\xE9g\xE9 and close the old class description view. All features are included in the plugin. -If you have problems look at the screen cast in the release bundle. - - Added: trunk/src/dl-learner/org/dllearner/tools/protege/README =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/README (rev 0) +++ trunk/src/dl-learner/org/dllearner/tools/protege/README 2008-12-09 11:02:46 UTC (rev 1546) @@ -0,0 +1,15 @@ +README +====== +The Prot\xE9g\xE9 DL-Learner plugin allows to learn equivalence and super class axioms based on +the instance data in the ontologies loaded in Prot\xE9g\xE9. It integrated seamlessly in Prot\xE9g\xE9. + +Homepage: http://dl-learner.org/wiki/ProtegePlugin +Sourceforge.net Project Page: http://sourceforge.net/projects/dl-learner/ +Bugs & Feature Requests: http://sourceforge.net/tracker/?group_id=203619 +Mailing Lists: http://sourceforge.net/mail/?group_id=203619 +Latest Release: http://sourceforge.net/project/showfiles.php?group_id=203619 + +The Prot\xE9g\xE9 Plugin is Open Source and licenced under the GNU General Public License. + +Documentation for the Prot\xE9g\xE9 Plugin can be found +at http://dl-learner.org/wiki/ProtegePlugin. Deleted: trunk/src/dl-learner/org/dllearner/tools/protege/Readme_protege =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/Readme_protege 2008-12-08 13:06:44 UTC (rev 1545) +++ trunk/src/dl-learner/org/dllearner/tools/protege/Readme_protege 2008-12-09 11:02:46 UTC (rev 1546) @@ -1,15 +0,0 @@ -README -====== -The Prot\xE9g\xE9 DL-Learner plugin allows to learn equivalence and super class axioms based on -the instance data in the ontologies loaded in Prot\xE9g\xE9. It integrated seamlessly in Prot\xE9g\xE9. - -Homepage: http://dl-learner.org/wiki/ProtegePlugin -Sourceforge.net Project Page: http://sourceforge.net/projects/dl-learner/ -Bugs & Feature Requests: http://sourceforge.net/tracker/?group_id=203619 -Mailing Lists: http://sourceforge.net/mail/?group_id=203619 -Latest Release: http://sourceforge.net/project/showfiles.php?group_id=203619 - -The Prot\xE9g\xE9 Plugin is Open Source and licenced under the GNU General Public License. - -Documentation for the Prot\xE9g\xE9 Plugin can be found -at http://dl-learner.org/wiki/ProtegePlugin. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |