swoopontologyinfo.java

来自「Semantic Web Ontology Editor」· Java 代码 · 共 936 行 · 第 1/3 页

JAVA
936
字号
            statistics.print("<br><b>Total Number of Datatype Properties:</b> ");                     statistics.print(String.valueOf(totalDataProps));            statistics.print("&nbsp;(Defined: "+String.valueOf(numberOfDatatypeProperties) + ",&nbsp;Imported: "+String.valueOf(totalDataProps-numberOfDatatypeProperties)+")");                        statsText += "Total Number of Datatype Properties: "+String.valueOf(totalDataProps)+ " (Defined: "+String.valueOf(numberOfDatatypeProperties) + ", Imported: "+String.valueOf(totalDataProps-numberOfDatatypeProperties)+")"+NEWLINE;                        statistics.print("<br><b>Total Number of Object Properties:</b> ");            statistics.print(String.valueOf(totalObjProps));            statistics.print("&nbsp;(Defined: "+String.valueOf(numberOfObjectProperties) + ",&nbsp;Imported: "+String.valueOf(totalObjProps-numberOfObjectProperties)+")");                        statsText += "Total Number of Object Properties: "+String.valueOf(totalObjProps)+ " (Defined: "+String.valueOf(numberOfObjectProperties) + ", Imported: "+String.valueOf(totalObjProps-numberOfObjectProperties)+")"+NEWLINE;                        statistics.print("<br><b>Total Number of Annotation Properties:</b> ");            statistics.print(String.valueOf(totalAnnotatedProps));            statistics.print("&nbsp;(Defined: "+String.valueOf(numberOfAnnotationProperties) + ",&nbsp;Imported: "+String.valueOf(totalAnnotatedProps-numberOfAnnotationProperties)+")");                        statsText += "Total Number of Annotation Properties: "+String.valueOf(totalAnnotatedProps)+ " (Defined: "+String.valueOf(numberOfAnnotationProperties) + ", Imported: "+String.valueOf(totalAnnotatedProps-numberOfAnnotationProperties)+")"+NEWLINE;                        statistics.print("<br><b>Total Number of Individuals:</b> ");            statistics.print(String.valueOf(totalIndividuals));            statistics.print("&nbsp;(Defined: "+String.valueOf(numberOfInstances) + ",&nbsp;Imported: "+String.valueOf(totalIndividuals-numberOfInstances)+")");                        statsText += "Total Number of Individuals: "+String.valueOf(totalIndividuals)+ " (Defined: "+String.valueOf(numberOfInstances) + ", Imported: "+String.valueOf(totalIndividuals-numberOfInstances)+")"+NEWLINE;                        // Advanced Statistics using SwoopStatistics                        HashMap advStats = swoopModel.getOntStats(swoopModel.getSelectedOntology());            if (swoopModel.getSelectedOntology()!=null && advStats.keySet().size()>0) {	            Set unsat = (HashSet) advStats.get(SwoopStatistics.UNSATISFIABLE_CLASSES);            	Set gci = (HashSet) advStats.get(SwoopStatistics.NO_GCI);	            String subsumptions = (String) advStats.get(SwoopStatistics.NO_SUBSUMPTIONS);            	Set disj = (HashSet) advStats.get(SwoopStatistics.NO_DISJOINT);            	            Set func = (HashSet) advStats.get(SwoopStatistics.NO_FUNCTIONAL);	            Set ifunc = (HashSet) advStats.get(SwoopStatistics.NO_INVFUNCTIONAL);	            Set tran = (HashSet) advStats.get(SwoopStatistics.NO_TRANSITIVE);	            Set symm = (HashSet) advStats.get(SwoopStatistics.NO_SYMMETRIC);	            Set inv = (HashSet) advStats.get(SwoopStatistics.NO_INVERSE);	            List maxCList = (List) advStats.get(SwoopStatistics.MAX_DEPTH_CLASS_TREE);	            List minCList = (List) advStats.get(SwoopStatistics.MIN_DEPTH_CLASS_TREE);	            String avgC = "?"; 	            if (advStats.containsKey(SwoopStatistics.AVG_DEPTH_CLASS_TREE)) avgC = advStats.get(SwoopStatistics.AVG_DEPTH_CLASS_TREE).toString();	            	            List maxBList = (List) advStats.get(SwoopStatistics.MAX_BRANCHING_FACTOR);	            List minBList = (List) advStats.get(SwoopStatistics.MIN_BRANCHING_FACTOR);	            String avgB = advStats.get(SwoopStatistics.AVG_BRANCHING_FACTOR).toString();	            	            List maxPList = (List) advStats.get(SwoopStatistics.MAX_DEPTH_PROP_TREE);	            List minPList = (List) advStats.get(SwoopStatistics.MIN_DEPTH_PROP_TREE);	            String avgP = "?"; 	            if (advStats.containsKey(SwoopStatistics.AVG_DEPTH_PROP_TREE)) avgP = advStats.get(SwoopStatistics.AVG_DEPTH_PROP_TREE).toString();	            Set multC = (HashSet) advStats.get(SwoopStatistics.MULTIPLE_INHERITANCE_CLASS);	            Set multP = (HashSet) advStats.get(SwoopStatistics.MULTIPLE_INHERITANCE_PROP);	            	            statistics.print("<br><br><p><b>Advanced Ontology Statistics:</b></p>\n\n"); // (<a href=\"<RESTAT\">Recompute</a>)<br>");	            statsText += HLINE + "Advanced Ontology Statistics:" + NEWLINE + HLINE;	            statistics.print("<table border=\"1\">");	            	            statistics.print("<tr>");	            statistics.print("<td> General Statistics </td>");	            statistics.print("<td> Property Tree Statistics </td>");	            statistics.print("<td> Satisfiable Class Tree Statistics </td>");	            statistics.print("</tr>");	            	            statistics.print("<tr>");	            	            statistics.print("<td>");	            statsText += "General Statistics" + NEWLINE;	            if (unsat!=null && unsat.size()>0) {	            	statistics.print("<font color=\"red\"><b>No. of Unsatisfiable Classes: <a href=\"<CSTAT:"+SwoopStatistics.UNSATISFIABLE_CLASSES+"\">"+unsat.size()+"</a></b></font>");	            	statsText += "No. of Unsatisfiable Classes: "+unsat.size();	            }	            if(ont.getLinkProperties().isEmpty()){	            	String express = swoopModel.getReasoner().getExpressivity();	            	String exprShort = express;	            	if (express.indexOf("<br>")>=0) exprShort = express.substring(0, express.indexOf("<br>"));	            	statistics.print("<br>DL Expressivity: <a href=\"<DLEXP:"+express+"\">"+exprShort+"</a>");	            	statsText += "DL Expressivity: "+exprShort+NEWLINE;	             }	            statistics.print("<br>No. of <i>GCIs:</i> "+gci.size());	            statsText += "GCIs: "+gci.size()+NEWLINE;	            statistics.print("<br>No. of <i>Sub-classes:</i> "+subsumptions);	            statsText += "No. of Sub-class Axioms: " + subsumptions + NEWLINE;	            statistics.print("<br>No. of <i>Disjoint Axioms:</i> <a href=\"<CSTAT:"+SwoopStatistics.NO_DISJOINT+"\">"+disj.size()+"</a>");	            statsText += "Disjoint Axioms: "+disj.size()+NEWLINE;	            statistics.print("<br>No. of <i>Functional</i> Properties: <a href=\"<PSTAT:"+SwoopStatistics.NO_FUNCTIONAL+"\">"+func.size()+"</a>");	            statsText += "Functional Properties: "+func.size()+NEWLINE;	            statistics.print("<br>No. of <i>Inverse Functional</i> Properties: <a href=\"<PSTAT:"+SwoopStatistics.NO_INVFUNCTIONAL+"\">"+ifunc.size()+"</a>");	            statsText += "Inverse Functional Properties: "+ifunc.size()+NEWLINE;	            statistics.print("<br>No. of <i>Transitive</i> Properties: <a href=\"<PSTAT:"+SwoopStatistics.NO_TRANSITIVE+"\">"+tran.size()+"</a>");	            statsText += "Transitive Properties: "+tran.size()+NEWLINE;	            statistics.print("<br>No. of <i>Symmetric</i> Properties: <a href=\"<PSTAT:"+SwoopStatistics.NO_SYMMETRIC+"\">"+symm.size()+"</a>");	            statsText += "Symmetric Properties: "+symm.size()+NEWLINE;	            statistics.print("<br>No. of <i>Inverse</i> Properties: <a href=\"<PSTAT:"+SwoopStatistics.NO_INVERSE+"\">"+inv.size()+"</a>");	            statsText += "Inverse Properties: "+inv.size()+NEWLINE;	            statistics.print("</td>");	            	            statistics.print("<td>");	            statsText += HLINE+"Property Tree Statistics"+NEWLINE;	            statistics.print("<br>Properties with <i>Multiple Inheritance</i>: <a href=\"<PSTAT:"+SwoopStatistics.MULTIPLE_INHERITANCE_PROP+"\">"+multP.size()+"</a>");	            statsText += "Properties with Multiple Inheritance: "+multP.size()+NEWLINE;	            statistics.print("<br><i>Max. Depth</i> of Property Tree: <a href=\"<PSTAT:"+SwoopStatistics.MAX_DEPTH_PROP_TREE+"\">"+maxPList.get(0).toString()+"</a>");	            statsText += "Max. Depth of Property Tree: "+maxPList.get(0).toString()+NEWLINE;	            statistics.print("<br><i>Min. Depth</i> of Property Tree: <a href=\"<PSTAT:"+SwoopStatistics.MIN_DEPTH_PROP_TREE+"\">"+minPList.get(0).toString()+"</a>");	            statsText += "Min. Depth of Property Tree: "+minPList.get(0).toString()+NEWLINE;	            statistics.print("<br><i>Avg. Depth</i> of Property Tree: "+avgP);	            statsText += "Avg. Depth of Property Tree: "+avgP+NEWLINE;	            statistics.print("</td>");	            	            statistics.print("<td>");	            statsText += HLINE+"Class Tree Statistics"+NEWLINE;	            statistics.print("<br>Classes with <i>Multiple Inheritance</i>: <a href=\"<CSTAT:"+SwoopStatistics.MULTIPLE_INHERITANCE_CLASS+"\">"+multC.size()+"</a>");	            statsText += "Classes with Multiple Inheritance: "+multC.size()+NEWLINE;	            statistics.print("<br><i>Max. Depth</i> of Class Tree: <a href=\"<CSTAT:"+SwoopStatistics.MAX_DEPTH_CLASS_TREE+"\">"+maxCList.get(0).toString()+"</a>");	            statsText += "Max. Depth of Class Tree: "+maxCList.get(0).toString()+NEWLINE;	            statistics.print("<br><i>Min. Depth</i> of Class Tree: <a href=\"<CSTAT:"+SwoopStatistics.MIN_DEPTH_CLASS_TREE+"\">"+minCList.get(0).toString()+"</a>");	            statsText += "Min. Depth of Class Tree: "+minCList.get(0).toString()+NEWLINE;	            statistics.print("<br><i>Avg. Depth</i> of Class Tree: "+avgC);	            statsText += "Avg. Depth of Class Tree: "+avgC+NEWLINE;	            statistics.print("<br><i>Max. Branching Factor</i> of Class Tree: <a href=\"<CSTAT:"+SwoopStatistics.MAX_BRANCHING_FACTOR+"\">"+maxBList.get(0).toString()+"</a>");	            statsText += "Max. Branching Factor of Class Tree: "+maxBList.get(0).toString()+NEWLINE;	            statistics.print("<br><i>Min. Branching Factor</i> of Class Tree: <a href=\"<CSTAT:"+SwoopStatistics.MIN_BRANCHING_FACTOR+"\">"+minBList.get(0).toString()+"</a>");	            statsText += "Min. Branching Factor of Class Tree: "+minBList.get(0).toString()+NEWLINE;	            statistics.print("<br><i>Avg. Branching Factor</i> of Class Tree: "+avgB);	            statsText += "Avg. Branching Factor of Class Tree: "+avgB+NEWLINE;	            statistics.print("</td>");	            statistics.print("</tr>");	            statistics.print("</table>");	            statsText += HLINE;            }//            statistics.print("<FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+swoopModel.getFontSize()+">");                        //***************************************************            //Added for Econnections            //****************************************************            if(swoopModel.isEconnectedOntology(ont)){                            statistics.print("<br><br><i> This Ontology is part of an Econnection </i>");              statistics.print("<br><b>It has links to the following Ontologies</b> ");              Iterator iter = foreignOntologies.iterator();              while(iter.hasNext()){              	URI u = (URI)iter.next();          	              	statistics.print("<br><a href=\""+u.toString()+"\">"+swoopModel.shortForm(u)+"</a>" );              }              statistics.print("<br><b>Number of Defined Link Properties:</b> ");              statistics.print(String.valueOf(numberOfLinkProperties));              //statistics.print("<br><b>Number of Foreign Entities:</b> ");              //statistics.print(String.valueOf(numberOfForeignEntities));              statistics.print("<br><b>Number of Foreign Classes:</b> ");              statistics.print(String.valueOf(numberOfForeignClasses));              statistics.print("<br><b>Number of Foreign Properties:</b> ");              statistics.print(String.valueOf(numberOfForeignProperties));              statistics.print("<br><b>Number of Foreign Individuals:</b> ");              statistics.print(String.valueOf(numberOfForeignIndividuals));                          }            //*****************************************************			//***************************************************			//Added for Rules			//****************************************************			if (swoopModel.getEnableRules()) {				RulesExpressivity rulesExpress = swoopModel.getRuleExpr();								rulesExpress.setRulesExpress();											statistics.print("<br><br><b>Rules Expressivity:</b> "						+ rulesExpress.getRulesExpress());				statistics.print("<br><br><b>Total Number of Rules:</b> "						+ rulesExpress.getNumRules());				if (!(rulesExpress.getNumRules() == 0)) {					for (int i = 0; i < 6; i++) {						statistics.print("<br><br><b>Total Number of "								+ rulesExpress.getTypeRulesExpress()[i]								+ " rules </b>: "								+ rulesExpress.getNumRulesExpress()[i]);				}			}			}        } catch(OWLException ex) {            System.out.println(ex.getMessage());        }    }    public void render(OWLOntology ont, SwoopModel swoopModel, Writer writer) {        out = new PrintWriter(writer);        this.OWLObjectHash = new HashMap();        this.swoopModel = swoopModel;                out.print("<html><body style=\"background-color: white; color: black;\"><FONT FACE=\""+swoopModel.getFontFace()+"\" SIZE="+swoopModel.getFontSize()+">");        try {			out.print("<b>OWL Ontology:</b> <a href=\""+ont.getURI()+"\">"+swoopModel.shortForm(ont.getURI())+"</a>");			if (this.editorEnabled) out.print("&nbsp;&nbsp;(<font color=\"red\"><a href=\"<EditURL\">Edit URI</a></font>)");			out.print("<br>");		} catch (OWLException e) {			e.printStackTrace();		}                        try {            // print annotations        	boolean annotPrinted = this.renderAnnotations(ont);        	if (!annotPrinted) {        		String annTitle = " <b>Annotations</b>:";    			if (editorEnabled) annTitle += addTitle("O-ANN");    			out.print("<br>"+annTitle+"<br>");    			        	}            // print imported ontologies            if(ont.getIncludedOntologies() != null) {                Set inclOntSet = ont.getIncludedOntologies();                Iterator iter = inclOntSet.iterator();                String impStr = "<b>Imports:</b>";                if(editorEnabled) impStr += addTitle("O-IMP");                boolean displayImports = false;                while(iter.hasNext()) {                	displayImports = true;                    OWLOntology inclOnt = (OWLOntology) iter.next();                    URI inclOntURI = inclOnt.getURI();                    String inclOntLbl = inclOntURI.toString(); //swoopModel.shortForm(inclOnt.getURI());                                        OntologyChange oc = editorEnabled ? isDeleted(ont, inclOnt) : null;                    boolean deleted = (oc != null);                    if(deleted) impStr += "<font color=\"red\"><strike>";                    impStr += "<br>" + "<a href=\"" + inclOntURI + "\">"                            + inclOntLbl + "</a>";                    if(deleted) {                    	// strike out and add undo link                    	OWLObjectHash.put(String.valueOf(oc.hashCode()), oc);                        impStr += "</strike></font>";                        impStr += "&nbsp;&nbsp;(<font color=\"red\"><a href=\"<UndoO-IMP:"                                + oc.hashCode()                                + "\">Undo</a></font>)";                    }                     else if(editorEnabled) {                    	// add delete link                    	OWLObjectHash.put(String.valueOf(inclOnt.hashCode()), inclOnt);                    	impStr += "&nbsp;&nbsp;(<font color=\"red\"><a href=\"<DeleteO-IMP:"                            + inclOnt.hashCode()+ "\">Delete</a></font>)";                    }                                            }                if (editorEnabled || displayImports) out.print("<br>"+impStr);            }            		                if(editorEnabled) {                printAddedImports(ont);            }                        //*** explanations for inconsistent ontology            SwoopReasoner reasoner = swoopModel.getReasoner();//	        reasoner.setOntology(ont);            if (reasoner.getOntology()!=null) {	            if(reasoner.isConsistent()) {	                // consistent ontology - find unsatisfiable classes	        		OWLClass owlNothing = reasoner.getOntology().getOWLDataFactory().getOWLNothing();	        		Set unsat = reasoner.equivalentClassesOf(owlNothing);	        		if(!unsat.isEmpty()) {	        		    	                    // print dependencies between unsat. classes if debugging is enabled	                    if (reasoner instanceof PelletReasoner && swoopModel.isDebugBlack()) {	                    		                    	String plural = unsat.size() > 1 ? "es" : ""; 	  	                    out.print("<br><br>");	  	                    out.print("<font color=\"red\"><b>Root/Derived Debugging Information:<b><br>");	  	                    out.print(unsat.size());	  	                    out.print(" unsatisfiable class" + plural + ":</b></font><br>");	                    		                    	PelletReasoner pellet = (PelletReasoner) reasoner;	                    	if (pellet.depFinder==null) pellet.autoRootDiscovery();	                    	List rootList = pellet.depFinder.rootClasses;	                    	List derivedList = pellet.depFinder.derivedClasses;	                    	Map dependencyMap = pellet.depFinder.dependencyMap;	                    		                    	Set roots = new TreeSet(EntityComparator.INSTANCE);	                    	roots.addAll(rootList);	                    	Set derived = new TreeSet(EntityComparator.INSTANCE);	                    	derived.addAll(derivedList);	                    		                    	out.print("<table border=1>");	                    	out.print("<tr>"+insFont()+"<b>root</b> unsat. classes ("+roots.size()+")");							out.print("</tr>");	                    	for (Iterator iter = roots.iterator(); iter.hasNext(); ) {	                    		OWLClass root = (OWLClass) iter.next();	                    		URI uri = root.getURI();	                    		out.print("<tr>"+insFont());	                    		out.print("<a href=\"" + uri + "\">" + swoopModel.shortForm(uri) + "</a> ("+ ((HashSet) pellet.depFinder.childMap.get(root)).size() +")<br>");	                    		out.print("</tr>");	                    	}	                    	out.print("</table>");	                    		                    	if (derived.size()>0) {		                    	out.print("<br><table border=1>"); // font FACE=\""+swoopModel.getFontFace()+"\" SIZE="+swoopModel.getFontSize()+">");		                    	out.print("<tr><td>"+insFont()+"<b>derived</b> unsat. classes ("+derived.size()+")"+"</td><td>"+insFont()+"<b>parent dependencies</b></td></tr>");		                    	for (Iterator iter = derived.iterator(); iter.hasNext(); ) {		                    		out.print("<tr><td>"+insFont());		                    		OWLClass der = (OWLClass) iter.next();		                    		URI uri = der.getURI();		                    		out.print("<a href=\"" + uri + "\">" + swoopModel.shortForm(uri) + "</a>");			                    		// also print dependency for derived		                    		out.print("</td><td>"+insFont());		                    		Set allDep = unfoldSet((HashSet) dependencyMap.get(der));		                    		for (Iterator iter2 = allDep.iterator(); iter2.hasNext();) {		                    			Object obj = iter2.next();		                    			if (obj instanceof OWLClass) {		                    				OWLClass dep = (OWLClass) obj;	                    						                    			URI uri2 = dep.getURI();			                    			if (uri2.equals(uri)) continue;// dont print class itself				                    		out.print("<a href=\"" + uri2 + "\">" + swoopModel.shortForm(uri2) + "</a>,&nbsp;");		                    			}		                    			else {		                    				out.print(obj.toString()+",&nbsp;");

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?