From: <lor...@us...> - 2008-09-21 12:49:00
|
Revision: 1233 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1233&view=rev Author: lorenz_b Date: 2008-09-21 12:48:48 +0000 (Sun, 21 Sep 2008) Log Message: ----------- some javadoc and checkstyle Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/ore/ChangePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ChangesPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWL.java trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWLDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparql.java trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparqlDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/ColorListCellRenderer.java trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/LeftPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/Main.java trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifier.java trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/SPARQLTest.java trunk/src/dl-learner/org/dllearner/tools/ore/SavePanel.java trunk/src/dl-learner/org/dllearner/tools/ore/SavePanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java trunk/src/dl-learner/org/dllearner/tools/ore/UndoLabel.java trunk/src/dl-learner/org/dllearner/tools/ore/Wizard.java trunk/src/dl-learner/org/dllearner/tools/ore/WizardController.java trunk/src/dl-learner/org/dllearner/tools/ore/WizardModel.java trunk/src/dl-learner/org/dllearner/tools/ore/WizardPanelDescriptor.java trunk/src/dl-learner/org/dllearner/tools/ore/WizardPanelNotFoundException.java Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ChangePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ChangePanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ChangePanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -29,7 +29,11 @@ import javax.swing.JPanel; import org.semanticweb.owl.model.OWLOntologyChange; - +/** + * JPanel where an ontology change and his undo function is listed. + * @author Lorenz Buehmann + * + */ public class ChangePanel extends JPanel{ /** @@ -38,7 +42,7 @@ private static final long serialVersionUID = -934113184795465461L; /** - * Constructor for a JPanel where an ontology change and his undo function is listed + * Constructor * @param label * @param changes * @param mL Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ChangesPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ChangesPanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ChangesPanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -28,12 +28,13 @@ import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.border.BevelBorder; - +/** + * JPanel where all ontology changes are shown. + * @author Lorenz Buehmann + * + */ public class ChangesPanel extends JPanel{ - /** - * - */ private static final long serialVersionUID = -7538532926820669891L; public ChangesPanel(){ @@ -45,7 +46,10 @@ } - + /** + * Refresh the actual panel. + * @param cont + */ public void updatePanel(Container cont){ remove(cont); SwingUtilities.updateComponentTreeUI(this); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWL.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWL.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWL.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -36,7 +36,11 @@ import org.jdesktop.swingx.icon.EmptyIcon; import org.jdesktop.swingx.painter.BusyPainter; - +/** + * Wizard panel where atomic classes are shown in list. + * @author Lorenz Buehmann + * + */ public class ClassPanelOWL extends JPanel{ private static final long serialVersionUID = 3026319637264844550L; @@ -78,7 +82,7 @@ contentPanel = getContentPanel(); setLayout(new java.awt.BorderLayout()); - add(contentPanel,BorderLayout.CENTER); + add(contentPanel, BorderLayout.CENTER); add(labelPanel, BorderLayout.SOUTH); } @@ -89,7 +93,7 @@ conceptList = new JList(model); - scroll.setPreferredSize(new Dimension(400,400)); + scroll.setPreferredSize(new Dimension(400, 400)); scroll.setViewportView(conceptList); contentPanel1.add(scroll); @@ -102,10 +106,8 @@ return model; } - public void setModel(DefaultListModel dm){ - conceptList.setModel(dm); - } + public void addSelectionListener(ListSelectionListener l){ conceptList.addListSelectionListener(l); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWLDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWLDescriptor.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelOWLDescriptor.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -27,12 +27,17 @@ - +/** + * Wizard panel descriptor for selecting one of the atomic classes in OWL-ontology that + * has to be (re)learned. + * @author Lorenz Buehmann + * + */ public class ClassPanelOWLDescriptor extends WizardPanelDescriptor implements ListSelectionListener{ public static final String IDENTIFIER = "CLASS_CHOOSE_OWL_PANEL"; public static final String INFORMATION = "In this panel all atomic classes in the ontology are shown in the list above. " + - "Select one of them which should be (re)learned from then press \"Next-Button\""; + "Select one of them which should be (re)learned from, then press \"Next-Button\""; private ClassPanelOWL owlClassPanel; @@ -65,7 +70,7 @@ public void valueChanged(ListSelectionEvent e) { setNextButtonAccordingToConceptSelected(); if (!e.getValueIsAdjusting()) - getWizardModel().getOre().setConcept((NamedClass)owlClassPanel.getList().getSelectedValue()); + getWizardModel().getOre().setClassToLearn((NamedClass)owlClassPanel.getList().getSelectedValue()); } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparql.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparql.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparql.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -33,7 +33,11 @@ import org.jdesktop.swingx.icon.EmptyIcon; import org.jdesktop.swingx.painter.BusyPainter; - +/** + * Wizard Panel for SPARQL-Mode. + * @author Lorenz Buehmann + * + */ public class ClassPanelSparql extends JPanel{ private static final long serialVersionUID = 3026319637264844550L; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparqlDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparqlDescriptor.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ClassPanelSparqlDescriptor.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -20,10 +20,11 @@ package org.dllearner.tools.ore; - - - - +/** + * Class for SPARQL-Mode + * @author Lorenz Buehmann + * + */ public class ClassPanelSparqlDescriptor extends WizardPanelDescriptor{ public static final String IDENTIFIER = "CLASS_CHOOSE_SPARQL_PANEL"; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ColorListCellRenderer.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ColorListCellRenderer.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ColorListCellRenderer.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -30,6 +30,11 @@ import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; +/** + * List cell renderer for colored lines to provide better view on list values. + * @author Lorenz Buehmann + * + */ public class ColorListCellRenderer extends JLabel implements ListCellRenderer { private static final long serialVersionUID = -7592805113197759247L; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionLabel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -43,6 +43,11 @@ import org.dllearner.core.owl.ObjectSomeRestriction; import org.dllearner.core.owl.Thing; +/** + * Label that might have menu items when clicked on it. + * @author Lorenz Buehmann + * + */ public class DescriptionLabel extends JLabel implements MouseListener{ /** * @@ -84,7 +89,7 @@ } /** - * initialize description label with solution + * initialize description label with solution. */ public void init(){ baseURI = ore.getBaseURI(); @@ -241,14 +246,14 @@ /** - * returns actual description + * returns actual description. */ public Description getDescription(){ return desc; } /** - * adds action listeners to menu items + * adds action listeners to menu items. * @param aL */ public void addActionListeners(ActionListener aL){ @@ -275,6 +280,9 @@ } + /** + * Underlining label when mouse over. + */ public void mouseEntered(MouseEvent e) { setText("<html><u>" + ((Description) desc).toManchesterSyntaxString(ore @@ -286,6 +294,9 @@ } + /** + * Removing underlining when mosue relased. + */ public void mouseExited(MouseEvent e) { setText(((Description) desc).toManchesterSyntaxString(ore.getBaseURI(), ore.getPrefixes())); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionMenuItem.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -24,6 +24,11 @@ import org.dllearner.core.owl.Description; +/** + * Item for possible repair action. + * @author Lorenz Buehmann + * + */ public class DescriptionMenuItem extends JMenuItem { /** @@ -57,11 +62,18 @@ this.action = action; } - + /** + * Returns the description part where item is asserted to. + * @return description + */ public Description getDescription(){ return desc; } + /** + * Returns action type represented as number.. + * @return number + */ public int getActionID(){ return action; } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionPanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/DescriptionPanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -33,6 +33,11 @@ import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; +/** + * Panel where learned class description is shown, and parts that might occur errors are red colored. + * @author Lorenz Buehmann + * + */ public class DescriptionPanel extends JPanel{ /** @@ -44,7 +49,7 @@ private Individual ind; private ActionListener aL; private String mode; - boolean correct = false; + private boolean correct = false; private Description newClassDescription; public DescriptionPanel(ORE ore, Individual ind, ActionListener aL, String mode){ @@ -52,7 +57,7 @@ setBackground(Color.WHITE); setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); this.ore = ore; - this.newClassDescription = ore.getNewClassDescription(); + this.newClassDescription = ore.getNewClassDescription().getDescription(); this.ind = ind; this.aL = aL; this.mode = mode; @@ -70,7 +75,7 @@ } } else if(mode.equals("pos")){ - for(JLabel jL : ore.DescriptionToJLabelPos(ind, newClassDescription)){ + for(JLabel jL : ore.descriptionToJLabelPos(ind, newClassDescription)){ add(jL); if(jL instanceof DescriptionLabel){ @@ -84,6 +89,9 @@ } } + /** + * Updates the panel. + */ public void updatePanel(){ for(Component c : getComponents()) if(c instanceof JLabel) @@ -104,7 +112,7 @@ } } else if(mode.equals("pos")){ - for (JLabel jL : ore.DescriptionToJLabelPos(ind, newClassDescription)) { + for (JLabel jL : ore.descriptionToJLabelPos(ind, newClassDescription)) { add(jL); if (jL instanceof DescriptionLabel) { ((DescriptionLabel) jL).setIndOre(ore, ind); @@ -119,7 +127,10 @@ } - + /** + * Checks whether description is covered by positive example, or not covered by negative example. + * @return true if description is covered by positive example, or not covered by negative example, otherwise false is returned + */ public boolean isCorrect(){ return correct; } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -32,7 +32,11 @@ import javax.swing.JTextArea; import javax.swing.UIManager; - +/** + * Wizard panel with introduction text. + * @author Lorenz Buehmann + * + */ public class IntroductionPanel extends JPanel { private static final long serialVersionUID = 7184544803724152044L; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanelDescriptor.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/IntroductionPanelDescriptor.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -21,7 +21,11 @@ package org.dllearner.tools.ore; - +/** + * Wizard panel descriptor with some informations for the tool. + * @author Lorenz Buehmann + * + */ public class IntroductionPanelDescriptor extends WizardPanelDescriptor { public static final String IDENTIFIER = "INTRODUCTION_PANEL"; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -39,6 +39,12 @@ import javax.swing.event.DocumentListener; import javax.swing.filechooser.FileFilter; +/** + * Wizard panel where radio buttons for choosing knowledge source type, button for browsing + * file system and textfields for inserting file name or SPARQL-URL are added. + * @author Lorenz Buehmann + * + */ public class KnowledgeSourcePanel extends JPanel{ private static final long serialVersionUID = -3997200565180270088L; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanelDescriptor.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/KnowledgeSourcePanelDescriptor.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -26,7 +26,11 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; - +/** + * Wizard panel descriptor where knowledge source is selected. + * @author Lorenz Buehmann + * + */ public class KnowledgeSourcePanelDescriptor extends WizardPanelDescriptor implements ActionListener, DocumentListener{ public static final String IDENTIFIER = "KNOWLEDGESOURCE_CHOOSE_PANEL"; @@ -66,6 +70,9 @@ setNextButtonAccordingToExistingOWLFile(); } + /** + * Actions for buttons. + */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if(cmd.equals("browse")){ @@ -110,7 +117,7 @@ setNextButtonAccordingToExistingOWLFile(); } - public KnowledgeSourcePanel getPanel() { + public KnowledgeSourcePanel getPanel() { return knowledgePanel; } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -47,7 +47,11 @@ import org.jdesktop.swingx.painter.BusyPainter; - +/** + * The wizard panel where list and buttons for learning step are shown. + * @author Lorenz Buehmann + * + */ public class LearningPanel extends JPanel{ private static final long serialVersionUID = -7411197973240429632L; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/LearningPanelDescriptor.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -33,12 +33,16 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; -import org.dllearner.core.owl.Description; - +/** + * Wizard panel descriptor where learned class description are shown. + * @author Lorenz Buehmann + * + */ public class LearningPanelDescriptor extends WizardPanelDescriptor implements ActionListener, ListSelectionListener{ public static final String IDENTIFIER = "LEARNING_PANEL"; @@ -94,13 +98,14 @@ // Description de = new NamedClass("http://example.com/father#male"); if (!e.getValueIsAdjusting()){ - getWizardModel().getOre().setNewClassDescription((Description)(learnPanel.getResultList().getSelectedValue())); - - + getWizardModel().getOre().setNewClassDescription(((EvaluatedDescription) (learnPanel.getResultList().getSelectedValue()))); } } + /** + * Actions for pressing start- or stop-button. + */ public void actionPerformed(ActionEvent event) { if(event.getActionCommand().equals("Start")){ learnPanel.getListModel().clear(); @@ -120,12 +125,8 @@ } - - } - - private void setNextButtonAccordingToConceptSelected() { if (learnPanel.getResultList().getSelectedValue()!= null){ @@ -136,35 +137,51 @@ } + /** + * Returns the swing worker thread instance. + * @return swing worker + */ public LearnSwingWorker getWorkerThread(){ return worker; } + /** + * Returns the timer instance. + * @return timer + */ public Timer getTimer(){ return timer; } + /** + * Returns the learning algorithm instance. + * @return learning algorithm + */ public LearningAlgorithm getLa() { return la; } + /** + * Clear list and loading message. + */ public void setPanelDefaults(){ learnPanel.getListModel().clear(); learnPanel.getStatusLabel().setText(""); } - - class LearnSwingWorker extends SwingWorker<List<Description>, List<Description>> { - - + /** + * Inner class, containing the background thread for learning class descriptions. + * @author Lorenz Buehmann + * + */ + class LearnSwingWorker extends SwingWorker<List<EvaluatedDescription>, List<EvaluatedDescription>> { + Thread t; - - @SuppressWarnings("unchecked") @Override - public List<Description> doInBackground() { + public List<EvaluatedDescription> doInBackground() { learnPanel.getResultList().setCellRenderer(new ColumnListCellRenderer(getWizardModel().getOre())); learnPanel.getLoadingLabel().setBusy(true); @@ -177,8 +194,7 @@ @Override public void run() { if(la != null){ - - publish(la.getCurrentlyBestDescriptions(30, true)); + publish(la.getCurrentlyBestEvaluatedDescriptions(30, 0.0, true)); } } @@ -204,7 +220,7 @@ // TODO Auto-generated catch block e.printStackTrace(); } - List<Description> result = getWizardModel().getOre().getLearningResults(30); + List<EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions(30, 0.0, true); return result; } @@ -213,7 +229,7 @@ public void done() { timer.cancel(); - List<Description> result = null; + List<EvaluatedDescription> result = null; try { result = get(); } catch (InterruptedException e) { @@ -230,16 +246,16 @@ } @Override - protected void process(List<List<Description>> resultLists) { + protected void process(List<List<EvaluatedDescription>> resultLists) { // panel4.getModel().clear(); - for (List<Description> list : resultLists) { + for (List<EvaluatedDescription> list : resultLists) { updateList(list); } } - void updateList(final List<Description> result) { + void updateList(final List<EvaluatedDescription> result) { Runnable doUpdateList = new Runnable() { @@ -247,7 +263,7 @@ DefaultListModel dm = new DefaultListModel(); public void run() { // learnPanel.getListModel().clear(); - for (Description d : result) { + for (EvaluatedDescription d : result) { dm.addElement(d); // panel4.getModel().addElement(d); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/LeftPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/LeftPanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/LeftPanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -28,6 +28,11 @@ import javax.swing.JLabel; import javax.swing.JPanel; +/** + * Navigation panel where it's shown the actual wizard step and former and following steps. + * @author Lorenz Buehmann + * + */ public class LeftPanel extends JPanel{ private static final long serialVersionUID = -1205252523136710091L; @@ -56,6 +61,10 @@ } + /** + * Sets the actual step, that has to be printed bold in the navigation panel. + * @param i number of the step + */ public void set(int i){ removeAll(); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/Main.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/Main.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/Main.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -26,9 +26,17 @@ import javax.swing.UnsupportedLookAndFeelException; - +/** + * Main class starting the wizard and registering wizard panels. + * @author Lorenz Buehmann + * + */ public class Main { + /** + * main method. + * @param args possible is to use OWL-File as parameter + */ public static void main(String[] args) { try { UIManager.setLookAndFeel( Modified: trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/ORE.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -21,8 +21,7 @@ package org.dllearner.tools.ore; import java.io.File; -import java.math.BigDecimal; -import java.util.ArrayList; +import java.net.MalformedURLException; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -37,6 +36,7 @@ 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.LearningAlgorithm; import org.dllearner.core.LearningProblemUnsupportedException; @@ -54,7 +54,11 @@ import org.dllearner.reasoning.FastInstanceChecker; import org.dllearner.reasoning.OWLAPIReasoner; - +/** + * This class contains init methods, and is used as broker between wizard and OWL-API. + * @author Lorenz Buehmann + * + */ public class ORE { private LearningAlgorithm la; @@ -69,9 +73,9 @@ private SortedSet<Individual> posExamples; private SortedSet<Individual> negExamples; - private NamedClass ignoredConcept; - private Description newClassDescription; - private Set<NamedClass> allAtomicConcepts; + private NamedClass classToLearn; + private EvaluatedDescription newClassDescription; + private OntologyModifier modifier; @@ -89,12 +93,19 @@ // step 1: detect knowledge sources + /** + * Applying knowledge source. + */ public void setKnowledgeSource(File f) { - Class<OWLFile> owl = OWLFile.class; - ks = cm.knowledgeSource(owl); + ks = cm.knowledgeSource(OWLFile.class); - cm.applyConfigEntry(ks, "url", f.toURI().toString()); + try { + cm.applyConfigEntry(ks, "url", f.toURI().toURL()); + } catch (MalformedURLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } try { ks.init(); @@ -106,7 +117,9 @@ } - + /** + * Initialize the reasoners. + */ public void initReasoners(){ fastReasoner = cm.reasoner(FastInstanceChecker.class, ks); @@ -127,22 +140,24 @@ e.printStackTrace(); } rs = cm.reasoningService(fastReasoner); - modifier = new OntologyModifier(owlReasoner); + modifier = new OntologyModifier(owlReasoner, rs); baseURI = fastReasoner.getBaseURI(); prefixes = fastReasoner.getPrefixes(); } + /** + * Returns the reasoningservice. + * @return reasoning service + */ public ReasoningService getReasoningService(){ return rs; } - public SortedSet<Individual> getPosExamples(){ - return posExamples; - } + public void setPosNegExamples(){ - posExamples = rs.retrieval(ignoredConcept); + posExamples = rs.retrieval(classToLearn); negExamples = rs.getIndividuals(); for (Individual pos : posExamples){ @@ -150,16 +165,13 @@ } } - public SortedSet<Individual> getNegExamples(){ - return negExamples; - } - + public OntologyModifier getModifier() { return modifier; } - public Description getNewClassDescription() { + public EvaluatedDescription getNewClassDescription() { return newClassDescription; } @@ -200,7 +212,7 @@ Set<String> t = new TreeSet<String>(); - t.add(ignoredConcept.getName()); + t.add(classToLearn.getName()); cm.applyConfigEntry(la, "ignoredConcepts", t); cm.applyConfigEntry(la, "guaranteeXgoodDescriptions", 10); try { @@ -212,8 +224,12 @@ } - public void setConcept(NamedClass concept){ - this.ignoredConcept = concept; + /** + * Sets the class that has to be learned. + * @param oldClass class that is choosen to be (re)learned + */ + public void setClassToLearn(NamedClass oldClass){ + this.classToLearn = oldClass; } public void init(){ @@ -230,9 +246,13 @@ } - public LearningAlgorithm start(){ + /** + * Starts the learning algorithm, setting noise value and ignored concepts. + * + */ + public void start(){ Set<String> t = new TreeSet<String>(); - t.add(ignoredConcept.getName()); + t.add(classToLearn.getName()); cm.applyConfigEntry(la, "ignoredConcepts", t); cm.applyConfigEntry(la, "noisePercentage", noise); try { @@ -243,119 +263,10 @@ } la.start(); - return la; - } - - public List<Description> getLearningResults(int anzahl){ - return la.getCurrentlyBestDescriptions(anzahl, true); - } - - /** - * returns accuracy of a description - * @param d - * @return - */ - public BigDecimal computeAccuracy(Description d){ - int numberPosExamples = 0; - int numberNegExamples = 0; - double result_tmp = 0.0f; - for(Individual ind : posExamples){ - if(rs.instanceCheck(d, ind)) - numberPosExamples++; - } - for(Individual ind : negExamples){ - if(!rs.instanceCheck(d, ind)) - numberNegExamples++; - } - - result_tmp = ((float)(numberPosExamples) + (float)(numberNegExamples))/((float)(posExamples.size())+(float)(negExamples.size())) * 100; - BigDecimal result = new BigDecimal( result_tmp ); - result = result.setScale( 2, BigDecimal.ROUND_HALF_UP ); - return result; - - } - - public HashSet<Individual> getNegFailureExamples(){ - FastInstanceChecker instanceReasoner = cm.reasoner(FastInstanceChecker.class, ks); - try { - instanceReasoner.init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - ReasoningService instanceRs = cm.reasoningService(instanceReasoner); - HashSet<Individual> negFailureExamples = new HashSet<Individual>() ; - - for(Individual ind : negExamples){ - if(instanceRs.instanceCheck(newClassDescription, ind)) - negFailureExamples.add(ind); - - } - - return negFailureExamples; - } - - public List<HashSet<Individual>> getFailureExamples(){ - List<HashSet<Individual>> list = new ArrayList<HashSet<Individual>>(); - - FastInstanceChecker instanceReasoner = cm.reasoner(FastInstanceChecker.class, ks); - try { - instanceReasoner.init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - ReasoningService instanceRs = cm.reasoningService(instanceReasoner); - - HashSet<Individual> posFailureExamples = new HashSet<Individual>() ; - for(Individual ind : posExamples){ - if(!instanceRs.instanceCheck(newClassDescription, ind)) - posFailureExamples.add(ind); - } - - HashSet<Individual> negFailureExamples = new HashSet<Individual>() ; - for(Individual ind : negExamples){ - if(instanceRs.instanceCheck(newClassDescription, ind)) - negFailureExamples.add(ind); - } - - list.add(posFailureExamples); - list.add(negFailureExamples); - - - - return list; - - } - public HashSet<Individual> getPosFailureExamples(){ - FastInstanceChecker instanceReasoner = cm.reasoner(FastInstanceChecker.class, ks); - try { - instanceReasoner.init(); - } catch (ComponentInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - ReasoningService instanceRs = cm.reasoningService(instanceReasoner); - - HashSet<Individual> posFailureExamples = new HashSet<Individual>() ; - - - for(Individual ind : posExamples){ - if(!instanceRs.instanceCheck(newClassDescription, ind)) - posFailureExamples.add(ind); - - } - - return posFailureExamples; - } - - public void setNewClassDescription(Description newClassDescription) { + public void setNewClassDescription(EvaluatedDescription newClassDescription) { this.newClassDescription = newClassDescription; } @@ -364,15 +275,13 @@ } public NamedClass getIgnoredConcept() { - return ignoredConcept; + return classToLearn; } - public void setAllAtomicConcepts(Set<NamedClass> allAtomicConcepts) { - this.allAtomicConcepts = allAtomicConcepts; - } + /** - * finds out description parts that might cause inconsistency - for negative examples only + * retrieves description parts that might cause inconsistency - for negative examples only * @param ind * @param desc * @return @@ -404,7 +313,7 @@ return criticals; } /** - * finds the description that might cause inconsistency for negative examples + * Retrieves the description parts, that might cause inconsistency - for negative examples. * @param ind * @param desc * @return vector of JLabel @@ -467,12 +376,12 @@ } /** - * finds the description that might cause inconsistency for positive examples + * Retrieves the description parts that might cause inconsistency - for positive examples. * @param ind * @param desc * @return vector of JLabel */ - public Collection<JLabel> DescriptionToJLabelPos(Individual ind, Description desc){ + public Collection<JLabel> descriptionToJLabelPos(Individual ind, Description desc){ Collection<JLabel> criticals = new Vector<JLabel>(); List<Description> children = desc.getChildren(); @@ -485,17 +394,17 @@ if(desc instanceof Union){ criticals.add(new JLabel("(")); for(int i = 0; i<children.size()-1; i++){ - criticals.addAll(DescriptionToJLabelPos(ind, desc.getChild(i))); + criticals.addAll(descriptionToJLabelPos(ind, desc.getChild(i))); criticals.add(new JLabel("or")); } - criticals.addAll(DescriptionToJLabelPos(ind, desc.getChild(children.size()-1))); + criticals.addAll(descriptionToJLabelPos(ind, desc.getChild(children.size()-1))); criticals.add(new JLabel(")")); } else if(desc instanceof Intersection){ criticals.add(new JLabel("(")); for(int i = 0; i<children.size()-1; i++){ if(!fastReasoner.instanceCheck(desc.getChild(i), ind)){ - criticals.addAll(DescriptionToJLabelPos(ind, desc.getChild(i))); + criticals.addAll(descriptionToJLabelPos(ind, desc.getChild(i))); } else{ criticals.add(new JLabel(desc.getChild(i).toManchesterSyntaxString(baseURI, prefixes))); @@ -503,7 +412,7 @@ criticals.add(new JLabel("and")); } if(!fastReasoner.instanceCheck(desc.getChild(children.size()-1), ind)){ - criticals.addAll(DescriptionToJLabelPos(ind, desc.getChild(children.size()-1))); + criticals.addAll(descriptionToJLabelPos(ind, desc.getChild(children.size()-1))); } else{ criticals.add(new JLabel(desc.getChild(children.size()-1).toManchesterSyntaxString(baseURI, prefixes))); @@ -529,7 +438,7 @@ } /** - * returns individuals that are in range of property + * Returns individuals that are in range of property. * @param objRestr * @param ind * @return @@ -543,7 +452,7 @@ } /** - * returns individuals that are not in range of property + * Returns individuals that are not in range of property. * @param objRestr * @param ind * @return @@ -569,6 +478,11 @@ return allIndividuals; } + /** + * Returns classes where individual might moved to. + * @param ind the individual + * @return set of classes + */ public Set<NamedClass> getpossibleClassesMoveTo(Individual ind){ Set<NamedClass> moveClasses = new HashSet<NamedClass>(); for(NamedClass nc : rs.getNamedClasses()){ @@ -576,11 +490,16 @@ moveClasses.add(nc); } } - moveClasses.remove(ignoredConcept); + moveClasses.remove(classToLearn); return moveClasses; } + /** + * Returns classes where individual might moved from. + * @param ind the individual + * @return set of classes + */ public Set<NamedClass> getpossibleClassesMoveFrom(Individual ind){ Set<NamedClass> moveClasses = new HashSet<NamedClass>(); for(NamedClass nc : rs.getNamedClasses()){ @@ -588,11 +507,14 @@ moveClasses.add(nc); } } - moveClasses.remove(ignoredConcept); + moveClasses.remove(classToLearn); return moveClasses; } + /** + * Update reasoners ontology. + */ public void updateReasoner(){ fastReasoner = cm.reasoner(FastInstanceChecker.class, new OWLAPIOntology(modifier.getOntology())); try { @@ -614,7 +536,7 @@ } /** - * get the complement classes where individual is asserted to + * Get the complement classes where individual is asserted to. * @param desc * @param ind * @return @@ -622,10 +544,11 @@ public Set<NamedClass> getComplements(Description desc, Individual ind){ Set<NamedClass> complements = new HashSet<NamedClass>(); for(NamedClass nc : owlReasoner.getAtomicConcepts()){ - - if(owlReasoner.instanceCheck(nc, ind)){ - if(modifier.isComplement(desc, nc)){ - complements.add(nc); + if(!(nc.toString().endsWith("Thing"))){ + if(owlReasoner.instanceCheck(nc, ind)){ + if(modifier.isComplement(desc, nc)){ + complements.add(nc); + } } } } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifier.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifier.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/OntologyModifier.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -28,6 +28,7 @@ import java.util.List; import java.util.Set; +import org.dllearner.core.ReasoningService; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.Individual; import org.dllearner.core.owl.NamedClass; @@ -66,24 +67,30 @@ import org.semanticweb.owl.model.UnknownOWLOntologyException; import org.semanticweb.owl.util.OWLEntityRemover; +/** + * This class provides several methods to modify the ontology by using OWL-API. + * @author Lorenz Buehmann + * + */ public class OntologyModifier { private OWLOntology ontology; private OWLAPIReasoner reasoner; private OWLDataFactory factory; private OWLOntologyManager manager; + private ReasoningService rs; - public OntologyModifier(OWLAPIReasoner reasoner){ + public OntologyModifier(OWLAPIReasoner reasoner, ReasoningService rs){ this.reasoner = reasoner; this.manager = OWLManager.createOWLOntologyManager(); this.factory = manager.getOWLDataFactory(); this.ontology = reasoner.getOWLAPIOntologies().get(0); - + this.rs = rs; } /** - * Adds an EquivalentClassesAxiom axiom to the ontology + * Adds an EquivalentClassesAxiom axiom to the ontology. * @param newDesc new axiom to add * @param oldDesc old description * @return @@ -113,11 +120,11 @@ } /** - * rewrite ontology by replacing old class with new learned class description + * Rewrite ontology by replacing old class with new learned class description. * @param newDesc * @param oldClass */ - public void rewriteClassDescription(Description newDesc, Description oldClass){ + public List<OWLOntologyChange> rewriteClassDescription(Description newDesc, Description oldClass){ OWLDescription newClassDesc = OWLAPIDescriptionConvertVisitor.getOWLDescription(newDesc); // OWLDescription oldClassDesc = OWLAPIDescriptionConvertVisitor.getOWLDescription(oldClass); @@ -150,10 +157,12 @@ e.printStackTrace(); } + return changes; + } /** - * saves the ontology as RDF-file + * Saves the ontology as RDF-file. */ public void saveOntology(){ @@ -173,7 +182,7 @@ } /** - * Deletes the complete individual from the ontology + * Deletes the complete individual from the ontology. * @param ind the individual to delete */ public List<OWLOntologyChange> deleteIndividual(Individual ind){ @@ -201,7 +210,7 @@ } /** - * Removes a classAssertion + * Removes a classAssertion. * @param ind the individual which has to removed from class * @param desc the class to which the individual is asserted * @return changes that have been done @@ -231,7 +240,7 @@ } /** - * adds a classAssertion + * Adds a classAssertion. * @param ind the individual which has to be asserted to class * @param desc the class to which the individual has to be asserted * @return changes that have been done @@ -264,7 +273,7 @@ } /** - * removes classAssertion between individual to a old class, and creates a new classAssertion + * Removes classAssertion between individual to a old class, and creates a new classAssertion. * @param ind individual which has to be moved * @param oldClass class where individual is asserted before * @param newClass class where individual is moved to @@ -304,7 +313,7 @@ } /** - * + * Removes all object property assertions with role, and it's inverse. * @param ind the individual which property has to be removed * @param objSome the property which has to be removed * @return changes that have been done @@ -321,22 +330,29 @@ OWLObjectPropertyExpression invProperty = null; - for(OWLInverseObjectPropertiesAxiom inv : invProperties) - if(propertyOWLAPI.equals(inv.getSecondProperty())) + for(OWLInverseObjectPropertiesAxiom inv : invProperties){ + if(propertyOWLAPI.equals(inv.getSecondProperty())){ invProperty = inv.getFirstProperty(); - else + } + else{ invProperty = inv.getSecondProperty(); + } + } List<RemoveAxiom> removeList = new LinkedList<RemoveAxiom>(); for(OWLObjectPropertyAssertionAxiom o :properties){ - if( (o.getProperty().equals(propertyOWLAPI)) && (o.getSubject().equals(individualOWLAPI))) + if( (o.getProperty().equals(propertyOWLAPI)) && (o.getSubject().equals(individualOWLAPI))){ removeList.add(new RemoveAxiom(ontology, o)); - if(invProperty != null) - for(OWLObjectPropertyAssertionAxiom ob :ontology.getObjectPropertyAssertionAxioms(o.getObject())) - if(ob.getProperty().equals(invProperty) && ob.getObject().equals(individualOWLAPI)) + } + if(invProperty != null){ + for(OWLObjectPropertyAssertionAxiom ob :ontology.getObjectPropertyAssertionAxioms(o.getObject())){ + if(ob.getProperty().equals(invProperty) && ob.getObject().equals(individualOWLAPI)){ removeList.add(new RemoveAxiom(ontology, ob)); + } + } + } } @@ -356,7 +372,7 @@ /** - * removes an object property assertion from the ontology if the axiom is existing in the ontology + * Removes an object property assertion from the ontology if the axiom is existing in the ontology. * @param subject * @param objSome * @param object @@ -396,7 +412,7 @@ } /** - * + * Adds an object property assertion to the ontology. * @param subInd the individual which is subject in the objectProperty * @param objSome the property which has to be added to subject * @param objInd the individual which is object in the objectProperty @@ -457,7 +473,7 @@ } /** - * checks whether desc1 and desc2 are complement of each other + * checks whether desc1 and desc2 are disjoint. * @param desc1 class 1 * @param desc2 class 2 * @return @@ -467,25 +483,35 @@ OWLClass owlClass1 = OWLAPIDescriptionConvertVisitor.getOWLDescription(desc1).asOWLClass(); OWLClass owlClass2 = OWLAPIDescriptionConvertVisitor.getOWLDescription(desc2).asOWLClass(); - //superclasses and class1 - Set<OWLDescription> superClasses1 = owlClass1.getSuperClasses(ontology); +// Set<OWLDescription> superClasses1 = owlClass1.getSuperClasses(ontology); + Set<OWLDescription> superClasses1 = new HashSet<OWLDescription>(); + for(Description d : rs.getMoreGeneralConcepts(desc1)){ + superClasses1.add(OWLAPIDescriptionConvertVisitor.getOWLDescription(d)); + } superClasses1.add(owlClass1); +// System.out.println(desc1 + "::" + superClasses1); //superclasses and class2 - Set<OWLDescription> superClasses2 = owlClass2.getSuperClasses(ontology); +// Set<OWLDescription> superClasses2 = owlClass2.getSuperClasses(ontology); + Set<OWLDescription> superClasses2 = new HashSet<OWLDescription>(); + for(Description d : rs.getMoreGeneralConcepts(desc2)){ + superClasses2.add(OWLAPIDescriptionConvertVisitor.getOWLDescription(d)); + } superClasses2.add(owlClass2); for(OWLAxiom ax : ontology.getAxioms()){ for(OWLDescription o1 : superClasses1){ + OWLDescription negO1 = OWLAPIDescriptionConvertVisitor.getOWLDescription(new Negation(new NamedClass(o1.toString()))); for(OWLDescription o2 : superClasses2){ +// System.out.println(o1 + " " + o2); OWLDescription negO2 = OWLAPIDescriptionConvertVisitor.getOWLDescription(new Negation(new NamedClass(o2.toString()))); - - if(ax.equals(factory.getOWLDisjointClassesAxiom(o1, o2))){ + System.out.println(factory.getOWLDisjointClassesAxiom(o1, o2)); + if(ax.toString().equals(factory.getOWLDisjointClassesAxiom(o1, o2).toString())){ return true; - }else if(ax.equals(factory.getOWLDisjointClassesAxiom(o2, o1))){ + }else if(ax.toString().equals(factory.getOWLDisjointClassesAxiom(o2, o1).toString())){ return true; }else if(ax.toString().equals(factory.getOWLEquivalentClassesAxiom(o1, negO2).toString())){ return true; Modified: trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/RepairDialog.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -54,6 +54,12 @@ import org.dllearner.core.owl.ObjectSomeRestriction; import org.semanticweb.owl.model.OWLOntologyChange; +/** + * The repair dialog where the learned class description (including error parts), + * the statistics and the undo options are shown. + * @author Lorenz Buehmann + * + */ public class RepairDialog extends JDialog implements ActionListener, MouseListener{ /** @@ -130,6 +136,10 @@ } + /** + * Initializing and making dialog visible. + * @return integer value + */ public int showDialog(){ baseURI = ore.getBaseURI(); prefixes = ore.getPrefixes(); @@ -200,6 +210,9 @@ } + /** + * Method controls action events triggered by clicking on red labels in class description at the top of the dialog. + */ public void actionPerformed(ActionEvent e) { if(e.getSource() instanceof DescriptionMenuItem){ Modified: trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -28,15 +28,12 @@ import java.awt.Insets; import java.awt.event.ActionListener; import java.awt.event.MouseListener; -import java.awt.geom.Ellipse2D; -import java.awt.geom.RoundRectangle2D; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JComponent; -import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -44,43 +41,37 @@ import javax.swing.border.TitledBorder; import javax.swing.event.ListSelectionListener; -import org.jdesktop.swingx.JXBusyLabel; -import org.jdesktop.swingx.icon.EmptyIcon; -import org.jdesktop.swingx.painter.BusyPainter; - +/** + * JPanel for repairing action. + * @author Lorenz Buehmann + * + */ public class RepairPanel extends JPanel{ private static final long serialVersionUID = -7411197973240429632L; private JPanel contentPanel; - private DefaultListModel posFailureModel; private DefaultListModel negFailureModel; - - private JLabel statusLabel; - private JXBusyLabel loadingLabel; - - - private JPanel posPanel; - private JList posList; private JScrollPane posScrollPane; - private JScrollPane negScrollPane; + private JList posList; + private JPanel posButtonPanel; private JButton pos_repairButton; private JButton pos_deleteButton; private JButton pos_removeButton; - private JPanel posButtonPanel; + + private JPanel negPanel; + private JScrollPane negScrollPane; + private JList negList; + private JPanel negButtonPanel; private JButton neg_repairButton; private JButton neg_deleteButton; private JButton neg_addButton; - private JPanel negButtonPanel; - private JList negList; - private JPanel negPanel; - @SuppressWarnings("unchecked") public RepairPanel() { super(); @@ -90,21 +81,7 @@ this.setLayout(new java.awt.BorderLayout()); JPanel labelPanel = new JPanel(); - statusLabel = new JLabel(); - - loadingLabel = new JXBusyLabel(new Dimension(15,15)); - BusyPainter painter = new BusyPainter( - new RoundRectangle2D.Float(0, 0,6.0f,2.6f,10.0f,10.0f), - new Ellipse2D.Float(2.0f,2.0f,11.0f,11.0f)); - painter.setTrailLength(2); - painter.setPoints(7); - painter.setFrame(-1); - loadingLabel.setPreferredSize(new Dimension(15,15)); - loadingLabel.setIcon(new EmptyIcon(15,15)); - loadingLabel.setBusyPainter(painter); - labelPanel.add(loadingLabel); - labelPanel.add(statusLabel); - + contentPanel = getContentPanel(); add(contentPanel,BorderLayout.CENTER); @@ -247,43 +224,51 @@ return contentPanel; } - - - public JLabel getStatusLabel() { - return statusLabel; - } - - public JXBusyLabel getLoadingLabel() { - return loadingLabel; - } - + /** + * Returns the list model for positive examples. + * @return list model + */ public DefaultListModel getPosFailureModel() { return posFailureModel; } + /** + * Returns the list model for negative examples. + * @return list model + */ public DefaultListModel getNegFailureModel() { return negFailureModel; } + /** + * Returns the list for positive examples. + * @return positive list + */ public javax.swing.JList getPosFailureList() { return posList; } + /** + * Returns the list for negative examples. + * @return negative list + */ public javax.swing.JList getNegFailureList() { return negList; } + /** + * adds the list selection listener for lists. + * @param l list selection listener + */ public void addSelectionListeners(ListSelectionListener l){ posList.addListSelectionListener(l); negList.addListSelectionListener(l); } - - public void addMouseListeners(MouseListener mL){ - posList.addMouseListener(mL); - negList.addMouseListener(mL); - } - + /** + * Adds the action listener to buttons. + * @param aL action listener + */ public void addActionListeners(ActionListener aL){ pos_removeButton.addActionListener(aL); pos_deleteButton.addActionListener(aL); @@ -293,6 +278,19 @@ neg_repairButton.addActionListener(aL); } + /** + * Adds mouse listener to lists. + * @param mL mouse listener + */ + public void addMouseListeners(MouseListener mL){ + posList.addMouseListener(mL); + negList.addMouseListener(mL); + } + + /** + * Sets custom cell renderer to the lists. + * @param ore + */ public void setCellRenderers(ORE ore){ ColorListCellRenderer cell = new ColorListCellRenderer(ore); posList.setCellRenderer(cell); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/RepairPanelDescriptor.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.Set; +import javax.swing.DefaultListModel; import javax.swing.JButton; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @@ -36,7 +37,11 @@ - +/** + * Wizard panel descriptor where it is possible torepair wrong examples. + * @author Lorenz Buehmann + * + */ public class RepairPanelDescriptor extends WizardPanelDescriptor implements ActionListener, ListSelectionListener, MouseListener{ public static final String IDENTIFIER = "REPAIR_PANEL"; @@ -56,7 +61,7 @@ repairPanel.addActionListeners(this); repairPanel.addSelectionListeners(this); repairPanel.addMouseListeners(this); - + setPanelDescriptorIdentifier(IDENTIFIER); setPanelComponent(repairPanel); ontologyChanges = new HashSet<OWLOntologyChange>(); @@ -79,23 +84,34 @@ getWizard().getInformationField().setText(INFORMATION); } - public void clearLists(){ - repairPanel.getNegFailureModel().clear(); - repairPanel.getPosFailureModel().clear(); + /** + * Adds the wrong negative and positive examples to the lists. + */ + public void refreshExampleLists(){ + this.ore = getWizardModel().getOre(); + repairPanel.setCellRenderers(ore); + + DefaultListModel negModel = repairPanel.getNegFailureModel(); + negModel.clear(); + for(Individual ind : ore.getNewClassDescription().getCoveredNegatives()){ + negModel.addElement(ind); + } + + DefaultListModel posModel = repairPanel.getPosFailureModel(); + posModel.clear(); + for(Individual ind : ore.getNewClassDescription().getNotCoveredPositives()){ + posModel.addElement(ind); + } + + } - - - public void valueChanged(ListSelectionEvent e) { - -// if (!e.getValueIsAdjusting()) -// System.err.println(panel4.getNegFailureList().getSelectedValue()); - - } - + /** + * Method to control actions by button pressed. + */ public void actionPerformed(ActionEvent event) { - ore = getWizardModel().getOre(); +// ore = getWizardModel().getOre(); modi = ore.getModifier(); String actionName = ((JButton)event.getSource()).getName(); String actionType = ((JButton)event.getSource()).getParent().getName(); @@ -152,6 +168,9 @@ } + /** + * Method provides repair action by double click on list element. + */ public void mouseClicked(MouseEvent e) { if(e.getClickCount() == 2){ @@ -186,22 +205,6 @@ } public void mouseEntered(MouseEvent e) { -// JList negList = repairPanel.getNegFailureList(); -// DefaultListModel negModel = repairPanel.getNegFailureModel(); -// if(e.getSource() instanceof JList){ -// int index = negList.locationToIndex(e.getPoint()); -// if (-1 < index) { -// Individual ind = (Individual)negModel.getElementAt(index); -// StringBuffer strBuf = new StringBuffer(); -// strBuf.append("<html><b><u>classes:</b></u><br><br><BLOCKQUOTE>"); -// -// for(NamedClass n: getWizardModel().getOre().reasoner2.getConcepts(ind)) -// strBuf.append("<br>" + n ); -// strBuf.append("</BLOCKQUOTE></html>"); -// negList.setToolTipText(strBuf.toString()); -// } -// } - } @@ -220,13 +223,20 @@ } - + /** + * Returns all ontology changes been done by repairing ontology. + * @return + */ public Set<OWLOntologyChange> getOntologyChanges() { return ontologyChanges; } + + @Override + public void valueChanged(ListSelectionEvent arg0) { + // TODO Auto-generated method stub + + } - - } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/SPARQLTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/SPARQLTest.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/SPARQLTest.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -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.ore; import java.util.SortedSet; @@ -7,11 +26,17 @@ import org.dllearner.core.LearningProblemUnsupportedException; import org.dllearner.kb.sparql.SPARQLTasks; import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL; import org.dllearner.utilities.examples.AutomaticPositiveExampleFinderSPARQL; import org.dllearner.utilities.learn.LearnSPARQLConfiguration; import org.dllearner.utilities.learn.LearnSparql; +/** + * Test class for SPARQL mode. + * @author Lorenz Buehmann + * + */ public class SPARQLTest{ public static void main(String[] args){ @@ -31,15 +56,17 @@ LearnSparql learn = new LearnSparql(conf); LearningAlgorithm la = null; -// try { -// la = learn.learn(posExamples, negExamples); -// } catch (ComponentInitException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } catch (LearningProblemUnsupportedException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// la.start(); + + try { + la = learn.learn(posExamples, negExamples, OWLAPIReasoner.class); + } catch (ComponentInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (LearningProblemUnsupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + la.start(); } } Modified: trunk/src/dl-learner/org/dllearner/tools/ore/SavePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/SavePanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/SavePanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -25,7 +25,11 @@ import javax.swing.JButton; import javax.swing.JPanel; - +/** + * JPanel where to buttons are added to save and go back to class choose panel. + * @author Lorenz Buehmann + * + */ public class SavePanel extends JPanel{ /** @@ -43,6 +47,10 @@ add(saveGoBack); } + /** + * Adds the action listener to both buttons. + * @param aL action listener + */ public void addActionListeners(ActionListener aL){ saveExit.addActionListener(aL); saveGoBack.addActionListener(aL); Modified: trunk/src/dl-learner/org/dllearner/tools/ore/SavePanelDescriptor.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/SavePanelDescriptor.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/SavePanelDescriptor.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -23,6 +23,11 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +/** + * Wizard panel descriptor that provides saving ontology and going back to class choose panel. + * @author Lorenz Buehmann + * + */ public class SavePanelDescriptor extends WizardPanelDescriptor implements ActionListener{ public static final String IDENTIFIER = "SAVE_PANEL"; public static final String INFORMATION = "Press 'Save and exit' button to save the changes you made and exit the program, " + Modified: trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java 2008-09-19 11:53:26 UTC (rev 1232) +++ trunk/src/dl-learner/org/dllearner/tools/ore/StatsPanel.java 2008-09-21 12:48:48 UTC (rev 1233) @@ -40,10 +40,13 @@ import org.jdesktop.swingx.JXTaskPane; import org.jdesktop.swingx.JXTaskPaneContainer; +/** + * Here are shown the name of the individual, class assertions and object properties of the individual which is selected to repair. + * @author Lorenz B... [truncated message content] |