From: <hee...@us...> - 2008-11-29 20:38:15
|
Revision: 1530 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1530&view=rev Author: heeroyuy Date: 2008-11-29 20:38:13 +0000 (Sat, 29 Nov 2008) Log Message: ----------- -some bugfixes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -40,6 +40,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import org.apache.log4j.Logger; import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.owl.Description; @@ -106,7 +107,7 @@ */ public void actionPerformed(ActionEvent z) { - if (z.getActionCommand().equals("Suggest " + id)) { + if (z.getActionCommand().equals(id)) { if (model.getAlreadyLearned()) { model.unsetListModel(); } @@ -116,7 +117,7 @@ model.setLearningProblem(); model.setLearningAlgorithm(); view.getRunButton().setEnabled(false); - view.renderErrorMessage("Learning started"); + view.renderErrorMessage("learning started"); view.getPosAndNegSelectPanel().setCheckBoxesEnable(false); retriever = new SuggestionRetriever(); // @@ -136,7 +137,7 @@ .getSuggestClassPanel().getSuggestList() .getSelectedValue()); } - String message = "Concept added"; + String message = "class description added"; view.renderErrorMessage(message); view.updateWindow(); } @@ -307,43 +308,40 @@ SwingWorker<List<EvaluatedDescription>, List<EvaluatedDescription>> { private Thread dlLearner; - /** - * Constructor for the SuggestionRetriever. - */ - public SuggestionRetriever() { - - } + private DefaultListModel dm = new DefaultListModel(); + Logger logger = Logger.getLogger(SuggestionRetriever.class); + Logger rootLogger = Logger.getRootLogger(); + @SuppressWarnings("unchecked") @Override protected List<EvaluatedDescription> doInBackground() throws Exception { - // DefaultListModel descriptions = new DefaultListModel(); - // List<Description> descriptionList = - // model.getLearningAlgorithm().getCurrentlyBestDescriptions(); - // Iterator<Description> it = descriptionList.iterator(); la = model.getLearningAlgorithm(); timer = new Timer(); timer.schedule(new TimerTask(){ @Override public void run() { + System.out.println("DA BIN ICH:"); if (la != null) { - - publish(la - .getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel() - .getNrOfConcepts(), - view.getPosAndNegSelectPanel().getOptionPanel() - .getMinAccuracy(), true)); + + //System.out.println("EVAL: " + la.getCurrentlyBestEvaluatedDescriptions().isEmpty()); + //System.out.println("SIZE: " + la.getCurrentlyBestEvaluatedDescriptions().size()); + publish(la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts() + , view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy(), true)); } } - }, 0, 100); + }, 0, 1000); dlLearner = new Thread(new Runnable() { @Override public void run() { - + try { model.run(); + } catch (Exception e) { + e.printStackTrace(); + } } }); @@ -355,11 +353,8 @@ // TODO Auto-generated catch block e.printStackTrace(); } - List<EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions( - view.getPosAndNegSelectPanel().getOptionPanel() - .getNrOfConcepts(), - view.getPosAndNegSelectPanel().getOptionPanel() - .getMinAccuracy(), true); + List<EvaluatedDescription> result = la.getCurrentlyBestEvaluatedDescriptions(view.getPosAndNegSelectPanel().getOptionPanel().getNrOfConcepts() + , view.getPosAndNegSelectPanel().getOptionPanel().getMinAccuracy(), true); return result; } @@ -378,6 +373,7 @@ } view.getRunButton().setEnabled(true); + System.out.println("DONE"); updateList(result); } @@ -394,31 +390,35 @@ Runnable doUpdateList = new Runnable() { - DefaultListModel dm = new DefaultListModel(); + public void run() { + System.out.println("JETZT HIER:"); model.setSuggestList(result); // learnPanel.getListModel().clear(); Iterator<EvaluatedDescription> it = result.iterator(); - + int i = 0; while (it.hasNext()) { Iterator<OWLOntology> ont = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); EvaluatedDescription eval = it.next(); while(ont.hasNext()) { String onto = ont.next().getURI().toString(); + if(eval.getDescription().toString().contains(onto)) { if(model.isConsistent(eval)) { - dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto, null))); + dm.add(i, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto, null))); + i++; break; } else { - dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(onto, null))); + dm.add(i, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(onto, null))); + i++; break; } } } } - view.getSuggestClassPanel().getSuggestList().setModel(dm); - + System.out.println("NAJA NUN HIER"); + view.getSuggestClassPanel().setSuggestList(dm); } }; SwingUtilities.invokeLater(doUpdateList); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -35,6 +35,7 @@ import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.EvaluatedDescription; +import org.dllearner.core.KnowledgeSource; import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.LearningProblem; import org.dllearner.core.LearningProblemUnsupportedException; @@ -90,10 +91,6 @@ private ReasonerComponent rs; - // The Knowledge source for the reasoner - - private OWLAPIOntology source; - // The View of the DL-Learner Plugin private OWLClassDescriptionEditorWithDLLearnerTab.DLLearnerView view; @@ -171,6 +168,7 @@ // The Individuals of the Ontology private Set<Individual> individual; + private Set<OWLAPIOntology> ontologies; // The error message which is rendered when an error occured @@ -185,6 +183,8 @@ private JXTaskPane detailPane; private DefaultListModel posListModel; private DefaultListModel negListModel; + private Set<KnowledgeSource> sources; + //private KnowledgeSource source; private boolean hasIndividuals; private NamedClass currentConcept; private Vector<IndividualObject> individualVector; @@ -222,6 +222,7 @@ suggestModel = new DefaultListModel(); detailPane = new JXTaskPane(); detailPane.setTitle("Details"); + sources = new HashSet<KnowledgeSource>(); } @@ -252,7 +253,6 @@ .getIndividualString()); } } - System.out.println("TEST: " + positiveExamples); } /** @@ -288,10 +288,11 @@ * OWLAPIOntology will be available. */ public void setKnowledgeSource() { - this.source = new OWLAPIOntology(editor.getModelManager() - .getActiveOntology()); - source.setOWLOntologies(editor.getModelManager().getActiveOntologies()); - + //Ssource = new OWLAPIOntology(editor.getModelManager().getActiveOntology()); + Iterator<OWLOntology> it = editor.getModelManager().getActiveOntologies().iterator(); + while (it.hasNext()) { + sources.add(new OWLAPIOntology(it.next())); + } } /** @@ -299,7 +300,8 @@ * OWLAPIReasoner is available. */ public void setReasoner() { - this.reasoner = cm.reasoner(OWLAPIReasoner.class, source); + this.reasoner = cm.reasoner(OWLAPIReasoner.class, sources); + try { reasoner.init(); } catch (ComponentInitException e) { @@ -316,12 +318,12 @@ * classes. */ public void setLearningProblem() { - if (id.equals("equivalent classes")) { + if (id.equals("Suggest equivalent class")) { // sets the learning problem to PosNegDefinitionLP when the // dllearner should suggest an equivalent class lp = cm.learningProblem(PosNegDefinitionLP.class, reasoner); } - if (id.equals("super classes")) { + if (id.equals("Suggest super class")) { // sets the learning problem to PosNegInclusionLP when the dllearner // should suggest a subclass lp = cm.learningProblem(PosNegInclusionLP.class, reasoner); @@ -349,6 +351,9 @@ // TODO Auto-generated catch block e.printStackTrace(); } + Set<String> ignore = new TreeSet<String>(); + ignore.add(currentConcept.toString()); + cm.applyConfigEntry(la, "ignoredConcepts", ignore); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view .getPosAndNegSelectPanel().getOptionPanel() .getMaxExecutionTime()); @@ -365,7 +370,7 @@ * This method starts the learning process. */ public void run() { - error = "Learning succesful"; + error = "learning succesful"; String message = "To view details about why a class description was suggested, please doubleclick on it."; // start the algorithm and print the best concept found la.start(); @@ -470,18 +475,34 @@ if (individuals == null) { NamedClass concept = i.next(); // checks if the concept is the selected concept in protege - if (concept.toString().endsWith( - current.getRootObject().toString())) { - // if individuals is not null it gets all individuals of - // the concept - currentConcept = concept; - if (reasoner.getIndividuals(concept) != null) { - if (reasoner.getIndividuals(concept).size() > 0) { - hasIndividuals = true; + if(concept.toString().contains("#")) { + if (concept.toString().endsWith("#"+ + current.getRootObject().toString())) { + // if individuals is not null it gets all individuals of + // the concept + currentConcept = concept; + if (reasoner.getIndividuals(concept) != null) { + if (reasoner.getIndividuals(concept).size() > 0) { + hasIndividuals = true; + } + individual = reasoner.getIndividuals(concept); + break; } - individual = reasoner.getIndividuals(concept); - break; } + } else { + if (concept.toString().endsWith( + current.getRootObject().toString())) { + // if individuals is not null it gets all individuals of + // the concept + currentConcept = concept; + if (reasoner.getIndividuals(concept) != null) { + if (reasoner.getIndividuals(concept).size() > 0) { + hasIndividuals = true; + } + individual = reasoner.getIndividuals(concept); + break; + } + } } } } @@ -784,4 +805,17 @@ public OWLEditorKit getOWLEditorKit() { return editor; } + + /** + * This method returns the currently used ontoloies including + * importet ontologies. + * @return Set<OWLAPIOntology> ontologies + */ + public Set<OWLAPIOntology> getOWLOntologies() { + return ontologies; + } + + public Set<KnowledgeSource> getKnowledgeSources() { + return sources; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -118,7 +118,7 @@ //checker = new OWLDescriptionChecker(editorKit); editor = new ExpressionEditor<OWLDescription>(editorKit, editorKit.getModelManager().getOWLExpressionCheckerFactory().getOWLDescriptionChecker()); editor.setExpressionObject(description); - dllearner = new DLLearnerView(frame, label, this); + action = new ActionHandler(this.action, null, dllearner, null, editorKit); tabbedPane = new JTabbedPane(); @@ -127,9 +127,11 @@ editingComponent.add(tabbedPane); editingComponent.setPreferredSize(new Dimension(600, 520)); if (label.equals("equivalent classes")) { + dllearner = new DLLearnerView(frame, SUGGEST_EQUIVALENT_CLASS_LABEL, this); tabbedPane.add(SUGGEST_EQUIVALENT_CLASS_LABEL, dllearner); } if (label.equals("super classes")) { + dllearner = new DLLearnerView(frame, SUGGEST_SUBCLASS_LABEL, this); tabbedPane.add(SUGGEST_SUBCLASS_LABEL, dllearner); } @@ -384,7 +386,7 @@ adv = new JLabel("Advanced Settings"); advanced = new JToggleButton(icon); advanced.setVisible(true); - run = new JButton("Suggest " + label); + run = new JButton(label); accept = new JButton("ADD"); addButtonPanel = new JPanel(new BorderLayout()); sugPanel.addSuggestPanelMouseListener(action); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -54,7 +54,7 @@ maxExecutionTimeLabel = new JLabel("maximum execution time"); nrOfConceptsLabel = new JLabel("maximum number of results"); - minAccuracy = new JSlider(50, 100, 80); + minAccuracy = new JSlider(50, 100, 50); minAccuracy.setPaintTicks(true); minAccuracy.setMajorTickSpacing(10); minAccuracy.setMinorTickSpacing(1); @@ -68,7 +68,7 @@ maxExecutionTime.setPaintLabels(true); - nrOfConcepts = new JSlider(2, 20, 5); + nrOfConcepts = new JSlider(2, 20, 10); nrOfConcepts.setPaintTicks(true); nrOfConcepts.setMajorTickSpacing(2); nrOfConcepts.setMinorTickSpacing(1); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-29 20:37:20 UTC (rev 1529) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-29 20:38:13 UTC (rev 1530) @@ -88,7 +88,9 @@ * @param desc List model of descriptions made by the DL-Learner */ public void setSuggestList(DefaultListModel desc) { + System.out.println("HUHU"); descriptions.setModel(desc); + repaint(); } /** * This method returns the current Description list. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |