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] |