From: <hee...@us...> - 2009-11-25 10:59:23
|
Revision: 1920 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=1920&view=rev Author: heeroyuy Date: 2009-11-25 10:59:10 +0000 (Wed, 25 Nov 2009) Log Message: ----------- -fixed bug that individuals in some classes where not recognized Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-11-25 10:57:13 UTC (rev 1919) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ActionHandler.java 2009-11-25 10:59:10 UTC (rev 1920) @@ -148,13 +148,21 @@ } } if (z.toString().contains(HELP_BUTTON_STRING)) { - String helpText = "<html><font size=\"3\">What does a sentence like 'Learning started. Currently searching class expressions with length between 4 and 7.' mean?<br>" - + "Length: In Manchester OWL Syntax (the syntax used for class expressions in Protege), we define length simply as the number of words needed to write down the class expression.<br><br>" - + "The learning algorithm (called CELOE) for suggesting class expressions starts with the most general expression owl:Thing and then further specializes it.<br>" - + "Those class expressions, which fit the existing instances of a given class ($currentClass in this case) get a high accuracy and are displayed as suggestions.<br>" - + "The learning algorithm prefers short expressions. 'Currently searching class expressions with length between 4 and 7.' means that it has already evaluated all class expressions of length 1 to 3<br>" - + "or excluded them as possible suggestions. All the expressions currently evaluated have length between 4 and 7. If you want to search for longer expressions, then you have to increase<br>" - + "the maximum runtime setting (it is set to $defaultRuntime seconds by default).<br><br>" + + Set<String> uris = model.getOntologyURIString(); + String currentClass = ""; + for(String uri : uris) { + if(model.getCurrentConcept().toString().contains(uri)) { + currentClass = model.getCurrentConcept().toManchesterSyntaxString(uri, null); + } + } + String helpText = "<html><font size=\"3\">What does a sentence like 'Learning started. Currently searching class expressions with length between 4 and 7.' mean?<br><br>" + + "Length: In Manchester OWL Syntax (the syntax used for class expressions in Protege), we define length <br>simply as the number of words needed to write down the class expression.<br><br>" + + "The learning algorithm (called CELOE) for suggesting class expressions starts with the most general expression <br>owl:Thing and then further specializes it.<br>" + + "Those class expressions, which fit the existing instances of a given class (" + currentClass + " in this case) get <br>a high accuracy and are displayed as suggestions.<br>" + + "The learning algorithm prefers short expressions. 'Currently searching class expressions with length between 4 and 7.' <br>means that it has already evaluated all class expressions of length 1 to 3<br>" + + "or excluded them as possible suggestions. All the expressions currently evaluated have length between 4 and 7. If you <br>want to search for longer expressions, then you have to increase<br>" + + "the maximum runtime setting (it is set to " + view.getPosAndNegSelectPanel().getOptionPanel().getMaxExecutionTime() + " <br>seconds by default).<br><br>" + "See <a href=\"http://dl-learner.org/wiki/ProtegePlugin\">Protege Plugin Wiki</a> for more details.</font></html>"; help = new JTextPane(); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2009-11-25 10:57:13 UTC (rev 1919) +++ trunk/src/dl-learner/org/dllearner/tools/protege/DLLearnerView.java 2009-11-25 10:59:10 UTC (rev 1920) @@ -516,7 +516,7 @@ String message = "<html><font size=\"3\" color=\"black\">Learning successful. All expressions up to length " + (celoe.getMinimumHorizontalExpansion()-1) + " and some expressions up to <br>length " + celoe.getMaximumHorizontalExpansion() + " searched."; hint.setForeground(Color.RED); if(isInconsistent) { - message +="<font size=\"3\" color=\"red\"><br>Class expressions marked red will lead to an inconsistent ontology. <br>Please double click on them to view detail information.</font></html>"; + message +="<font size=\"3\" color=\"red\"><br>Class expressions marked red will lead to an inconsistent ontology. <br>Please click on them to view detail information.</font></html>"; } else { message +="<br>To view details about why a class expression was suggested, please click on it.</font><html>"; } Modified: trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-11-25 10:57:13 UTC (rev 1919) +++ trunk/src/dl-learner/org/dllearner/tools/protege/GraphicalCoveragePanel.java 2009-11-25 10:59:10 UTC (rev 1920) @@ -164,7 +164,7 @@ Ellipse2D circlePoint = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint); g2D.setColor(Color.BLACK); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.ORANGE); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); @@ -173,51 +173,51 @@ g2D.fillOval(525, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(OK)", 320, p); + g2D.drawString("(OK)</html>", 320, p); p = p + 20; if(id.equals(EQUI_STRING)) { g2D.setColor(darkRed); Ellipse2D circlePoint2 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint2); g2D.setColor(Color.BLACK); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.ORANGE); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(potential problem)", 320, p); + g2D.drawString("(potential problem)</html>", 320, p); p = p + 20; g2D.setColor(darkRed); Ellipse2D circlePoint3 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint3); g2D.setColor(Color.BLACK); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.YELLOW); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(potential problem)", 320, p); + g2D.drawString("(potential problem)</html>", 320, p); } else { g2D.setColor(Color.BLACK); Ellipse2D circlePoint2 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint2); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.ORANGE); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(no problem)", 320, p); + g2D.drawString("(no problem)</html>", 320, p); p = p + 20; g2D.setColor(darkRed); Ellipse2D circlePoint3 = new Ellipse2D.Double(315 - 1, p - 6, 4, 4); g2D.fill(circlePoint3); g2D.setColor(Color.BLACK); - g2D.drawString("individuals covered by", 320, p); + g2D.drawString("<html>individuals covered by", 320, p); g2D.setColor(Color.YELLOW); g2D.fillOval(455, p - 9, 9, 9); g2D.setColor(Color.BLACK); p = p + 20; - g2D.drawString("(potential problem)", 320, p); + g2D.drawString("(potential problem)</html>", 320, p); } g2D.setColor(Color.YELLOW); Modified: trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java =================================================================== --- trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2009-11-25 10:57:13 UTC (rev 1919) +++ trunk/src/dl-learner/org/dllearner/tools/protege/ReadingOntologyThread.java 2009-11-25 10:59:10 UTC (rev 1920) @@ -30,16 +30,15 @@ import org.dllearner.reasoning.FastInstanceChecker; import org.protege.editor.owl.OWLEditorKit; import org.semanticweb.owl.model.OWLClass; -import org.semanticweb.owl.model.OWLOntology; /** * This class reads the ontologie in a separate thread. + * * @author Christian Koetteritzsch - * + * */ public class ReadingOntologyThread extends Thread { - private boolean hasIndividuals; private FastInstanceChecker reasoner; private NamedClass currentConcept; @@ -50,52 +49,64 @@ private boolean isInconsistent; private OWLClass current; private DLLearnerView view; - + /** * This is the constructor of the ReadingOntologyThread. - * @param editorKit OWLEditorKit - * @param v DL-Learner view - * @param m DL-Learner model + * + * @param editorKit + * OWLEditorKit + * @param v + * DL-Learner view + * @param m + * DL-Learner model */ - public ReadingOntologyThread(OWLEditorKit editorKit, DLLearnerView v, DLLearnerModel m) { + public ReadingOntologyThread(OWLEditorKit editorKit, DLLearnerView v, + DLLearnerModel m) { this.editor = editorKit; this.view = v; this.model = m; } - + /** * This method sets the view of the DL-Learner plugin. - * @param v DLLearnerView + * + * @param v + * DLLearnerView */ public void setDLLearnerView(DLLearnerView v) { this.view = v; } - + /** * This method sets the model of the DL-Learner plugin. - * @param m DLLearnerModel + * + * @param m + * DLLearnerModel */ public void setDLLearnerModel(DLLearnerModel m) { this.model = m; } + /** * This method sets the individuals that belong to the concept which is * chosen in protege. */ private void setPositiveConcept() { - current = editor.getOWLWorkspace().getOWLSelectionModel().getLastSelectedClass(); - if(current != null) { + current = editor.getOWLWorkspace().getOWLSelectionModel() + .getLastSelectedClass(); + if (current != null) { SortedSet<Individual> individuals = null; hasIndividuals = false; // checks if selected concept is thing when yes then it selects all // individuals if (!(current.toString().equals("Thing"))) { List<NamedClass> classList = reasoner.getAtomicConceptsList(); - for(NamedClass concept : classList) { + for (NamedClass concept : classList) { // if individuals is null if (individuals == null) { - // checks if the concept is the selected concept in protege - for(String onto : ontologieURI) { + // checks if the concept is the selected concept in + // protege + for (String onto : ontologieURI) { if (concept.toString().contains(onto)) { if (concept.toString().equals( onto + current.toString())) { @@ -104,10 +115,12 @@ // the concept currentConcept = concept; if (reasoner.getIndividuals(concept) != null) { - if (reasoner.getIndividuals(concept).size() > 0) { + if (reasoner.getIndividuals(concept) + .size() > 0) { hasIndividuals = true; } - individual = reasoner.getIndividuals(concept); + individual = reasoner + .getIndividuals(concept); model.setIndividuals(individual); model.setHasIndividuals(hasIndividuals); model.setCurrentConcept(currentConcept); @@ -122,7 +135,7 @@ } else { if (reasoner.getIndividuals().size() > 0) { hasIndividuals = true; - + } individual = reasoner.getIndividuals(); model.setIndividuals(individual); @@ -130,7 +143,7 @@ } } } - + /** * This Method checks if the selected class has any individuals. * @@ -139,66 +152,87 @@ public boolean hasIndividuals() { return hasIndividuals; } - + /** - * Checks the URI if a "#" is in it. + * Puts every base uri in a HashSet. */ private void checkURI() { ontologieURI = new HashSet<String>(); - Set<OWLOntology> ont = editor.getModelManager().getActiveOntologies(); Set<Individual> indi = reasoner.getIndividuals(); - for(OWLOntology onto : ont) { - String ontURI = onto.getURI().toString(); - for(Individual ind : indi) { - if(ind.toString().contains(ontURI)) { - if(ind.toString().contains("#")) { - ontologieURI.add(onto.getURI().toString()+"#"); + for (Individual ind : indi) { + int ontURI = ind.toString().lastIndexOf("/"); + int ontURI2 = ind.toString().lastIndexOf("#"); + String uriNeu = ""; + String uriAlt = ""; + if (ontURI2 != -1) { + uriNeu = ind.toString().substring(0, ontURI2 + 1); + if (uriNeu != uriAlt) { + ontologieURI.add(uriNeu); + uriAlt = uriNeu; + uriNeu = ""; + String uriTest = indi.toString().replace(uriAlt, ""); + if(!uriTest.contains("/") && !uriTest.contains("#")) { break; - } else { - ontologieURI.add(onto.getURI().toString()); - break; } } - } + } else { + uriNeu = ind.toString().substring(0, ontURI + 1); + if (uriNeu != uriAlt) { + ontologieURI.add(uriNeu); + uriAlt = uriNeu; + uriNeu = ""; + String uriTest = indi.toString().replace(uriAlt, ""); + if(!uriTest.contains("/") && !uriTest.contains("#")) { + break; + } + + } + } } model.setOntologyURIString(ontologieURI); } - + @Override public void run() { - String loading ="<html><font size=\"3\">loading instances...</font></html>"; + String loading = "<html><font size=\"3\">loading instances...</font></html>"; view.getHintPanel().setForeground(Color.RED); view.setHintMessage(loading); - if(!model.isReasonerSet() || model.getIsKnowledgeSourceIsUpdated() == true) { + if (!model.isReasonerSet() + || model.getIsKnowledgeSourceIsUpdated() == true) { model.setKnowledgeSource(); model.setReasoner(); } reasoner = model.getReasoner(); isInconsistent = view.getIsInconsistent(); - if(!isInconsistent) { + if (!isInconsistent) { this.checkURI(); this.setPositiveConcept(); if (this.hasIndividuals()) { view.getRunButton().setEnabled(true); view.getHintPanel().setForeground(Color.BLACK); - view.setHintMessage("<html><font size=\"3\">To get suggestions for class descriptions, please click the button above.</font></html>"); - + view + .setHintMessage("<html><font size=\"3\">To get suggestions for class descriptions, please click the button above.</font></html>"); + } else { view.getRunButton().setEnabled(false); view.getHintPanel().setVisible(true); - String message ="<html><font size=\"3\" color=\"red\">There are no Instances for " + current + " available. Please insert some Instances.</font></html>"; + String message = "<html><font size=\"3\" color=\"red\">There are no Instances for " + + current + + " available. Please insert some Instances.</font></html>"; view.getHintPanel().setForeground(Color.RED); view.setHintMessage(message); } } else { view.getHintPanel().setForeground(Color.RED); view.getRunButton().setEnabled(false); - view.setHintMessage("The ontology is inconsistent and suggestions for class descriptions can only \nbe computed on consistent ontologies. Please repair the ontology first"); + view + .setHintMessage("The ontology is inconsistent and suggestions for class descriptions can only \nbe computed on consistent ontologies. Please repair the ontology first"); } } - + /** * This method returns the NamedClass for the currently selected class. + * * @return NamedClass of the currently selected class */ public NamedClass getCurrentConcept() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |