From: <ton...@us...> - 2008-01-09 21:00:30
|
Revision: 358 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=358&view=rev Author: tonytacker Date: 2008-01-09 13:00:23 -0800 (Wed, 09 Jan 2008) Log Message: ----------- now it runs with owl-files, you have to choose every tab from left to right and use all buttons Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-09 21:00:23 UTC (rev 358) @@ -21,13 +21,15 @@ */ import java.io.File; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; -import org.dllearner.core.dl.Individual; /** * config @@ -44,8 +46,10 @@ private File selectedFile; private ReasonerComponent reasoner; private ReasoningService rs; - private List<Individual> individuals; private String[] kbBoxItems = {"Pleae select a type", "KBFile", "OWLFile", "SparqleEndpoint"}; + private Set<String> exampleSet = new HashSet<String>(); + private LearningProblem lp; + private LearningAlgorithm la; /** * status should show witch variables are set @@ -53,6 +57,9 @@ * status[1] ... KnowledgeSource * status[2] ... File or URL * status[3] ... Resoner + * status[4] ... ReasoningService + * status[5] ... ExampleSet + * status[6] ... LearningProblem */ protected static boolean[] status = new boolean[8]; @@ -99,14 +106,6 @@ rs = input; } - protected List<Individual> getListIndividuals () { - return individuals; - } - - protected void setListIndividuals (List<Individual> input) { - individuals = input; - } - protected String[] getKBBoxItems() { return kbBoxItems; } @@ -120,4 +119,32 @@ source = input; } + protected void setExampleSet(Set<String> input) { + status[5] = true; + exampleSet = input; + } + + protected Set<String> getExampleSet () { + return exampleSet; + } + + protected void setLearningProblem (LearningProblem input) { + status[6] = true; + lp = input; + } + + protected LearningProblem getLearningProblem () { + return lp; + } + + protected void setLearningAlgorithm (LearningAlgorithm input) { + status[6] = true; + la = input; + } + + protected LearningAlgorithm getLearningAlgorithm () { + return la; + } + + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-09 21:00:23 UTC (rev 358) @@ -22,6 +22,14 @@ import javax.swing.*; +import org.dllearner.algorithms.refinement.ROLearner; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + + /** * LearningAlgorithmPanel * @@ -29,11 +37,29 @@ * */ -public class LearningAlgorithmPanel extends JPanel { +public class LearningAlgorithmPanel extends JPanel implements ActionListener { private static final long serialVersionUID = 8721490771860452959L; + + private JPanel laPanel = new JPanel(); + private JButton laButton; + + LearningAlgorithmPanel() { + super(new BorderLayout()); - LearningAlgorithmPanel() { + laButton = new JButton("Use ROLearner"); + laButton.addActionListener(this); + laPanel.add(laButton); + add(laPanel, BorderLayout.PAGE_START); } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == laButton) { + if (StartGUI.myconfig.getStatus(6)) { + StartGUI.myconfig.setLearningAlgorithm(StartGUI.myconfig.getComponentManager().learningAlgorithm(ROLearner.class, StartGUI.myconfig.getLearningProblem(), StartGUI.myconfig.getReasoningService())); + StartGUI.myconfig.getLearningAlgorithm().init(); + } + } + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-09 21:00:23 UTC (rev 358) @@ -20,8 +20,14 @@ * */ +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import javax.swing.*; +import org.dllearner.learningproblems.PosOnlyDefinitionLP; + /** * LearningProblemPanel * @@ -29,11 +35,32 @@ * */ -public class LearningProblemPanel extends JPanel { +public class LearningProblemPanel extends JPanel implements ActionListener { private static final long serialVersionUID = -3819627680918930203L; + private JPanel lpPanel = new JPanel(); + private JButton lpButton; + LearningProblemPanel() { + super(new BorderLayout()); + + lpButton = new JButton("Use PosOnlyDefinitionLP"); + lpButton.addActionListener(this); + lpPanel.add(lpButton); + add(lpPanel, BorderLayout.PAGE_START); } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == lpButton) { + if (StartGUI.myconfig.getStatus(5)) { + System.out.println(StartGUI.myconfig.getExampleSet()); + StartGUI.myconfig.setLearningProblem(StartGUI.myconfig.getComponentManager().learningProblem(PosOnlyDefinitionLP.class, StartGUI.myconfig.getReasoningService())); + StartGUI.myconfig.getComponentManager().applyConfigEntry(StartGUI.myconfig.getLearningProblem(), "positiveExamples", StartGUI.myconfig.getExampleSet()); + StartGUI.myconfig.getLearningProblem().init(); + } + } + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-09 21:00:23 UTC (rev 358) @@ -26,6 +26,8 @@ import javax.swing.*; +import org.dllearner.core.dl.Concept; + /** * OutputPanel * @@ -38,6 +40,7 @@ private static final long serialVersionUID = 1643304576470046636L; private JButton showButton; + private JButton runButton; private JTextArea infoArea; OutputPanel() { @@ -45,11 +48,16 @@ showButton = new JButton("Show Variables"); showButton.addActionListener(this); + + runButton = new JButton("Run"); + runButton.addActionListener(this); + infoArea = new JTextArea(20, 50); JScrollPane infoScroll = new JScrollPane(infoArea); JPanel showPanel = new JPanel(); showPanel.add(showButton); + showPanel.add(runButton); JPanel infoPanel = new JPanel(); infoPanel.add(infoScroll); @@ -76,5 +84,12 @@ } } } + if (e.getSource() == runButton) { + if (StartGUI.myconfig.getStatus(6)) { + StartGUI.myconfig.getLearningAlgorithm().start(); + Concept solution = StartGUI.myconfig.getLearningAlgorithm().getBestSolution(); + infoArea.setText(solution.toString()); + } + } } } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-09 17:55:25 UTC (rev 357) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-09 21:00:23 UTC (rev 358) @@ -24,11 +24,13 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import javax.swing.*; +import javax.swing.event.*; import org.dllearner.core.dl.Individual; import org.dllearner.reasoning.DIGReasoner; @@ -68,13 +70,27 @@ digList.setVisibleRowCount(-1); JScrollPane listScroller = new JScrollPane(digList); listScroller.setPreferredSize(new Dimension(550, 350)); - + digPanel.add(digButton); add(digPanel, BorderLayout.PAGE_START); centerPanel.add(listScroller); add(centerPanel, BorderLayout.CENTER); + digList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + if (evt.getValueIsAdjusting()) + return; + //System.out.println("Selected from " + evt.getFirstIndex() + " to " + evt.getLastIndex()); + // detect which examples have been selected + Set<String> exampleSet = new HashSet<String>(); + int[] selectedIndices = digList.getSelectedIndices(); + for(int i : selectedIndices) + exampleSet.add(individuals.get(i).toString()); + StartGUI.myconfig.setExampleSet(exampleSet); + System.out.println("digList: " + StartGUI.myconfig.getExampleSet() ); + } + }); } public void actionPerformed(ActionEvent e) { @@ -96,15 +112,16 @@ // make list DefaultListModel listModel = new DefaultListModel(); - for(Individual ind : individuals) { + for(Individual ind : individuals) listModel.addElement(ind); - } - //System.out.println("listModel: " + listModel); + digList.setModel(listModel); + // graphic digList.setModel(listModel); StartGUI.myrun.renew(); + //return; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |