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