From: <hee...@us...> - 2008-11-18 18:05:13
|
Revision: 1519 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1519&view=rev Author: heeroyuy Date: 2008-11-18 18:05:10 +0000 (Tue, 18 Nov 2008) Log Message: ----------- -some buxfixes 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/IndividualObject.java trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.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-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -44,6 +44,7 @@ import org.dllearner.core.LearningAlgorithm; import org.dllearner.core.owl.Description; import org.protege.editor.owl.OWLEditorKit; +import org.semanticweb.owl.model.OWLOntology; /** * This class processes input from the user. @@ -399,13 +400,20 @@ model.setSuggestList(result); // learnPanel.getListModel().clear(); Iterator<EvaluatedDescription> it = result.iterator(); - //it.next().getDescription().toManchesterSyntaxString(baseURI, prefixes); + while (it.hasNext()) { + Iterator<OWLOntology> ont = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); EvaluatedDescription eval = it.next(); - if(model.isConsistent(eval)) { - dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null))); - } else { - dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null))); + while(ont.hasNext()) { + String onto = ont.next().getURI().toString(); + System.out.println(eval.getDescription()); + if(eval.getDescription().toString().contains(onto)) { + if(model.isConsistent(eval)) { + dm.add(0, new SuggestListItem(Color.GREEN, eval.getDescription().toManchesterSyntaxString(onto+"#", null))); + } else { + dm.add(0, new SuggestListItem(Color.RED, eval.getDescription().toManchesterSyntaxString(onto+"#", null))); + } + } } } view.getSuggestClassPanel().getSuggestList().setModel(dm); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerModel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -58,6 +58,7 @@ import org.semanticweb.owl.model.OWLClass; import org.semanticweb.owl.model.OWLDataFactory; import org.semanticweb.owl.model.OWLDescription; +import org.semanticweb.owl.model.OWLIndividual; import org.semanticweb.owl.model.OWLOntology; import org.semanticweb.owl.model.OWLOntologyChangeException; import org.semanticweb.owl.model.OWLOntologyManager; @@ -186,7 +187,6 @@ // This is necessary to get the details of the suggested concept private JXTaskPane detailPane; - private String ontologyURI; private Map<String, String> prefixes; private DefaultListModel posListModel; private DefaultListModel negListModel; @@ -215,7 +215,6 @@ current = h; this.id = id; this.view = view; - ontologyURI = editor.getModelManager().getActiveOntology().getURI().toString()+"#"; owlDescription = new HashSet<OWLDescription>(); posListModel = new DefaultListModel(); negListModel = new DefaultListModel(); @@ -349,7 +348,6 @@ // TODO Auto-generated catch block e.printStackTrace(); } - System.out.println("TIME: "+view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); cm.applyConfigEntry(la, "maxExecutionTimeInSeconds", view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime()); try { // initializes the learning algorithm @@ -406,23 +404,37 @@ */ public void setPosVector() { setPositiveConcept(); + Set<OWLIndividual> individual = editor.getModelManager().getActiveOntology().getReferencedIndividuals(); + Iterator<OWLIndividual> it = individual.iterator(); + while (it.hasNext()) { + OWLIndividual individum = it.next(); + String individuals = individum.toString(); + if (setPositivExamplesChecked(individuals)) { + // when yes then it sets the positive example checked + posListModel.add(0, individuals); - for (Iterator<Individual> j = reasoner.getIndividuals().iterator(); j - .hasNext();) { - Individual ind = j.next(); + } else { + // When no it unchecks the positive example + negListModel.add(0, individuals); + } + } + SortedSet<Individual> reasonerIndi = reasoner.getIndividuals(); + Iterator<Individual> reasonerIt = reasonerIndi.iterator(); + while(reasonerIt.hasNext()) { + Individual ind = reasonerIt.next(); + String indiv = ind.toString(); // checks if individual belongs to the selected concept if (setPositivExamplesChecked(indiv)) { // when yes then it sets the positive example checked - posListModel.add(0, ind.toManchesterSyntaxString(ontologyURI, prefixes)); - individualVector.add(new IndividualObject(indiv, ind.toManchesterSyntaxString(ontologyURI, prefixes), true)); + individualVector.add(new IndividualObject(indiv, true)); } else { // When no it unchecks the positive example - negListModel.add(0, ind.toManchesterSyntaxString(ontologyURI, prefixes)); - individualVector.add(new IndividualObject(indiv, ind.toManchesterSyntaxString(ontologyURI, prefixes), false)); + individualVector.add(new IndividualObject(indiv, false)); } } + } /** @@ -487,13 +499,23 @@ Iterator<NamedClass> it = reasoner.getNamedClasses().iterator(); while(it.hasNext()) { concept = it.next(); - if (concept.toManchesterSyntaxString(ontologyURI, prefixes).equals(owlConcept.toString())) { - selectedConcept = concept; - break; + Iterator<OWLOntology> onto = editor.getModelManager().getActiveOntologies().iterator(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if (concept.toString().contains(uri)) { + if (concept.toManchesterSyntaxString(uri+"#", prefixes).equals(owlConcept.toString())) { + selectedConcept = concept; + break; + } + } + } + } - if (reasoner.getIndividuals(selectedConcept).size() > 0) { - hasIndividuals = true; + if(selectedConcept != null) { + if (reasoner.getIndividuals(selectedConcept).size() > 0) { + hasIndividuals = true; + } } concept = null; selectedConcept = null; @@ -774,4 +796,8 @@ public void setSuggestList(List<EvaluatedDescription> list) { evalDescriptions = list; } + + public OWLEditorKit getOWLEditorKit() { + return editor; + } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/IndividualObject.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -26,7 +26,6 @@ public class IndividualObject { private String normalIndividual; - private String manchesterIndividual; private boolean isPos; /** @@ -35,9 +34,8 @@ * @param manchester String * @param pos boolean */ - public IndividualObject(String normal, String manchester, boolean pos) { + public IndividualObject(String normal, boolean pos) { normalIndividual = normal; - manchesterIndividual = manchester; isPos = pos; } @@ -50,14 +48,6 @@ } /** - * This method returns the manchester String of the Individual. - * @return String manchesterIndividual - */ - public String getManchesterIndividual() { - return manchesterIndividual; - } - - /** * This method returns if the Example is a positive Example. * @return boolean isPos */ Modified: trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/MoreDetailForSuggestedConceptsPanel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -32,6 +32,10 @@ import org.dllearner.core.EvaluatedDescription; import org.dllearner.core.owl.Individual; +import org.semanticweb.owl.model.OWLOntology; + + + /** * This class shows more details of the suggested concepts. It shows the positive and negative examples * that are covered and that are not covered by the suggested concepts. It also shows the accuracya of the @@ -146,7 +150,6 @@ eval = desc; concept = new JTextArea("Class Description:"); concept.setEditable(false); - coveredPositiveExamples = new JLabel("Covered Positive Examples:"); coveredPositiveExamples.setForeground(colorGreen); coveredPositiveExamples.setBounds(5, 110, 280, 30); @@ -195,7 +198,6 @@ //panel for the informations of the selected concept //this method adds the informations for the selected concept to the panel setInformation(); - detailPopup = new JDialog(); detailPopup.setSize(600, 500); //window will be disposed if the x button is pressed @@ -235,28 +237,71 @@ conceptText.append(eval.getDescription().toManchesterSyntaxString(model.getURI().toString()+"#", null)); double acc = (eval.getAccuracy())*100; accuracyText.append(String.valueOf(acc)+"%"); - for(Iterator<Individual> i = eval.getCoveredPositives().iterator(); i.hasNext();) { - JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); - posLabel.setForeground(colorGreen); - posCoveredPanel.add(posLabel); + Iterator<Individual> i = eval.getCoveredPositives().iterator(); + while (i.hasNext()) { + Iterator<OWLOntology> onto = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); + Individual ind = i.next(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + posLabel.setForeground(colorGreen); + posCoveredPanel.add(posLabel); + } + } + + } //sets the positive examples that are not covered - for(Iterator<Individual> i = eval.getNotCoveredPositives().iterator(); i.hasNext();) { - JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); - posLabel.setForeground(colorRed); - posNotCoveredPanel.add(posLabel); + Iterator<Individual> a = eval.getNotCoveredPositives().iterator(); + while (a.hasNext()) { + Iterator<OWLOntology> onto = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); + Individual ind = a.next(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + posLabel.setForeground(colorRed); + posNotCoveredPanel.add(posLabel); + } + } + + } + + //sets the negative examples that are covered - for(Iterator<Individual> i = eval.getCoveredNegatives().iterator(); i.hasNext();) { - JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); - posLabel.setForeground(colorRed); - negCoveredPanel.add(posLabel); + Iterator<Individual> b = eval.getCoveredNegatives().iterator(); + while (b.hasNext()) { + Iterator<OWLOntology> onto = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); + Individual ind = b.next(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + posLabel.setForeground(colorRed); + negCoveredPanel.add(posLabel); + } + } + + } + //sets the negative examples that are not covered - for(Iterator<Individual> i = eval.getNotCoveredNegatives().iterator(); i.hasNext();) { - JLabel posLabel = new JLabel(i.next().toManchesterSyntaxString(model.getURI().toString()+"#", null)); - posLabel.setForeground(colorGreen); - negNotCoveredPanel.add(posLabel); + Iterator<Individual> c = eval.getNotCoveredNegatives().iterator(); + while (c.hasNext()) { + Iterator<OWLOntology> onto = model.getOWLEditorKit().getModelManager().getActiveOntologies().iterator(); + Individual ind = c.next(); + while (onto.hasNext()) { + String uri = onto.next().getURI().toString(); + if(ind.toString().contains(uri)) { + JLabel posLabel = new JLabel(ind.toManchesterSyntaxString(uri+"#", null)); + posLabel.setForeground(colorGreen); + negNotCoveredPanel.add(posLabel); + } + } + + } } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OWLClassDescriptionEditorWithDLLearnerTab.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -24,7 +24,6 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; @@ -358,8 +357,7 @@ private JTextArea hint; // This is the Panel for more details of the suggested concept private MoreDetailForSuggestedConceptsPanel detail; - //private OWLFrame<OWLClass> frame; - private URL pluginURL; + private OWLFrame<OWLClass> frame; /** * The constructor for the DL-Learner tab in the class description @@ -372,16 +370,8 @@ public DLLearnerView(OWLFrame<OWLClass> current, String label, OWLClassDescriptionEditorWithDLLearnerTab dlLearner) { classSelectorPanel = new OWLClassSelectorPanel(editorKit); mainWindow = dlLearner; - //frame = current; - try { - pluginURL = new URL("http://dl-learner.org/wiki/ProtegePlugin"); - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - wikiPane = new JLabel("See " + pluginURL + " for an introduction."); - //wikiPane.setEditable(false); - + frame = current; + wikiPane = new JLabel("<html>See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">http://dl-learner.org/wiki/ProtegePlugin</a> for an introduction.</html>"); classSelectorPanel.firePropertyChange("test", false, true); URL iconUrl = this.getClass().getResource("arrow.gif"); icon = new ImageIcon(iconUrl); @@ -443,19 +433,22 @@ * This Method renders the view of the plugin. */ public void makeView() { - /* + + model.clearVector(); + model.unsetListModel(); + model.initReasoner(); + model.setPosVector(); + hint.setVisible(true); if (model.hasIndividuals(frame.getRootObject())) { run.setEnabled(true); } else { run.setEnabled(false); + hint.setVisible(false); String message ="There are no Instances for "+ frame.getRootObject()+" available. Please insert some Instances."; renderErrorMessage(message); - }*/ + } advanced.setIcon(icon); - model.clearVector(); - model.unsetListModel(); - model.initReasoner(); - model.setPosVector(); + posPanel.setExampleList(model.getPosListModel(), model.getNegListModel()); accept.setEnabled(false); action.resetToggled(); @@ -465,7 +458,7 @@ advanced.setSelected(false); sugPanel.setBounds(10, 35, 490, 110); adv.setBounds(40, 200, 200, 20); - wikiPane.setBounds(220, 10, 350, 30); + wikiPane.setBounds(220, 0, 350, 30); addButtonPanel.setBounds(510, 40, 80, 110); run.setBounds(10, 0, 200, 30); advanced.setBounds(10, 200, 20, 20); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/OptionPanel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -41,6 +41,7 @@ private JSlider maxExecutionTime; private JSlider nrOfConcepts; private JPanel optionPanel; + private double accuracy; /** * Construktor for the Option Panel. */ @@ -89,7 +90,7 @@ */ public double getMinAccuracy() { int acc = minAccuracy.getValue(); - double accuracy = acc/100; + accuracy = (acc/100.0); return accuracy; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -29,6 +29,7 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; /** * This class is the Panel for the Check boxes where the positive and negative @@ -123,7 +124,11 @@ neg = new JLabel("Negative Examples"); neg.setBounds(0, 0, 100, 30); posList = new JList(posListModel); - negList = new JList(negListModel); + posList.setName("pos"); + posList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + negList = new JList(negListModel); + negList.setName("neg"); + negList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); addToPosExamples = new JButton("pos"); addToNegExamples = new JButton("neg"); helpForPosExamples = new JButton("?"); @@ -276,7 +281,7 @@ if(negListModel.get(i).equals(example)) { negListModel.remove(i); for (int j = 0; j < model.getIndividualVector().size(); j++) { - if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { + if (model.getIndividualVector().get(j).getIndividualString().contains(example)) { model.getIndividualVector().get(j).setExamplePositive(true); break; } @@ -290,7 +295,7 @@ if(posListModel.get(i).equals(example)) { posListModel.remove(i); for (int j = 0; j < model.getIndividualVector().size(); j++) { - if (model.getIndividualVector().get(j).getManchesterIndividual().equals(example)) { + if (model.getIndividualVector().get(j).getIndividualString().contains(example)) { model.getIndividualVector().get(j).setExamplePositive(false); } } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/PosAndNegSelectPanelHandler.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -108,16 +108,16 @@ * @param m MouseEvent */ public void mouseClicked(MouseEvent m) { - if (panel.getPosExampleList().getSelectedValue() != null) { + if (!panel.getPosExampleList().isSelectionEmpty() && m.toString().contains("pos")) { panel.getAddToNegPanelButton().setEnabled(true); - } else { - panel.getAddToNegPanelButton().setEnabled(false); + panel.getAddToPosPanelButton().setEnabled(false); + panel.getNegExampleList().clearSelection(); } - if (panel.getNegExampleList().getSelectedValue()!= null) { + if (!panel.getNegExampleList().isSelectionEmpty() && m.toString().contains("neg")) { panel.getAddToPosPanelButton().setEnabled(true); - } else { - panel.getAddToPosPanelButton().setEnabled(false); - } + panel.getAddToNegPanelButton().setEnabled(false); + panel.getPosExampleList().clearSelection(); + } } /** Modified: trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-16 19:20:34 UTC (rev 1518) +++ trunk/src/dl-learner/org/dllearner/tools/protege/SuggestClassPanel.java 2008-11-18 18:05:10 UTC (rev 1519) @@ -25,6 +25,7 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; /** * This class is the panel for the suggest list. @@ -62,6 +63,7 @@ suggestScroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); model = new DefaultListModel(); descriptions = new JList(model); + descriptions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); suggestPanel = new JPanel(); descriptions.setVisible(true); suggestPanel.add(descriptions); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |