swooptoldreasoner.java
来自「Semantic Web Ontology Editor」· Java 代码 · 共 990 行 · 第 1/3 页
JAVA
990 行
OWLDescription desc = (OWLDescription) iter.next(); if (!(desc instanceof OWLClass)) types.remove(desc); } return this.getSetofEquivalentSets(types); } public String getExpressivity() throws OWLException { if (indices!=null) { String expressivity = indices.getExpressivity(ontology); return ExpressivityChecker.getExplanation(expressivity); } return "Unable to determine"; } public Set allTypesOf(OWLIndividual ind) throws OWLException { return this.typesOf(ind); } public Set disjointClassesOf(OWLClass c) throws OWLException { if (disjoints.containsKey(c)) return this.getSetofEquivalentSets((HashSet) disjoints.get(c)); else return new HashSet(); } public Set complementClassesOf(OWLClass c) throws OWLException { if (complements.containsKey(c)) return this.getSetofEquivalentSets((HashSet) complements.get(c)); else return new HashSet(); } public Set getOntologies() { return this.ontologies; } public Set getClasses() { return new HashSet(classes); } public Set getProperties() { return new HashSet(properties); } public Set getObjectProperties() { Set set = new HashSet(); for(int i = 0; i < properties.size(); i++) if(properties.get(i) instanceof OWLObjectProperty) set.add(properties.get(i)); return set; } public Set getDataProperties() { Set set = new HashSet(); for(int i = 0; i < properties.size(); i++) if(properties.get(i) instanceof OWLDataProperty) set.add(properties.get(i)); return set; } public Set getAnnotationProperties() { Set set = new HashSet(); for(int i = 0; i < properties.size(); i++) if(properties.get(i) instanceof OWLAnnotationProperty) set.add(properties.get(i)); return set; } public Set getIndividuals() { return new HashSet(individuals); } public boolean supportsExplanation() { return false; } public void setDoExplanation(boolean explain) { } public boolean getDoExplanation() { return false; } public String getExplanation(ShortFormProvider shortForms) { return null; } public Set getExplanationSet() { return null; } public Set instancesOf(OWLClass c) throws OWLException { return this.instancesOf((OWLDescription) c); } public Set allInstancesOf(OWLClass c) throws OWLException { return instancesOf(c); } public OWLOntology getOntology() throws OWLException { return ontology; } public boolean isSubClassOf(OWLDescription d1, OWLDescription d2) throws OWLException { if (d1 instanceof OWLClass && d2 instanceof OWLClass) { return (this.superClassesOf(d1).contains(d2)); } else return false; } public boolean isEquivalentClass(OWLDescription d1, OWLDescription d2) throws OWLException { if (this.equivalents.containsKey(d1)) { return ((HashSet) equivalents.get(d1)).contains(d2); } else return false; } public boolean isConsistent(OWLDescription d1) throws OWLException { return true; } public Set superClassesOf(OWLDescription d) throws OWLException { Set resultSet = new HashSet(); Set claSet = new HashSet(); claSet.add(d);// // also find equivalents// if (equivalents.containsKey(d)) { // claSet.addAll((HashSet) equivalents.get(d));// } // get direct superclasses of all classes in claSet for (Iterator iter = claSet.iterator(); iter.hasNext();) { OWLDescription desc = (OWLDescription) iter.next(); if (desc instanceof OWLClass && outLinks.containsKey(desc)) { Set superClaSet = (HashSet) this.outLinks.get(desc); resultSet.addAll(this.getSetofEquivalentSets(superClaSet)); } } return resultSet; } public Set ancestorClassesOf(OWLDescription d) throws OWLException { return this.superClassesOf(d); } public Set subClassesOf(OWLDescription d) throws OWLException { Set resultSet = new HashSet(); Set classSet = new HashSet(equivalentClassesOf(d)); classSet.add(d); // get direct subclasses of all classes in classSet for (Iterator iter = classSet.iterator(); iter.hasNext();) { OWLDescription desc = (OWLDescription) iter.next(); if (desc instanceof OWLClass && incLinks.containsKey(desc)) { Set subClassSet = (HashSet) this.incLinks.get(desc); resultSet.addAll(this.getSetofEquivalentSets(subClassSet)); } } return resultSet; } public Set descendantClassesOf(OWLDescription d) throws OWLException { return this.subClassesOf(d); } public Set equivalentClassesOf(OWLDescription d) throws OWLException { if (d instanceof OWLClass && equivalents.containsKey(d)) { Set equSet = new HashSet((HashSet) equivalents.get(d)); equSet.remove(d); return equSet; } return new HashSet(); } public boolean isInstanceOf(OWLIndividual i, OWLDescription d) throws OWLException { return false; } public Set instancesOf(OWLDescription d) throws OWLException { Set resultSet = new HashSet(); Set claSet = new HashSet(); claSet.add(d);// // also find equivalents// if (equivalents.containsKey(d)) { // claSet.addAll((HashSet) equivalents.get(d));// } // get individuals of all classes in claSet for (Iterator iter = claSet.iterator(); iter.hasNext();) { OWLClass cla = (OWLClass) iter.next(); if (classInds.containsKey(cla)) { Set inds = (HashSet) classInds.get(cla); resultSet.addAll(inds); } } return resultSet; } public boolean isSubPropertyOf(OWLProperty p1, OWLProperty p2) throws OWLException { return this.superPropertiesOf(p1).contains(p2); } public Set superPropertiesOf(OWLProperty prop) throws OWLException { Set resultSet = new HashSet(); Set propSet = new HashSet(); propSet.add(prop);// // also find equivalents// if (equivalents.containsKey(prop)) { // propSet.addAll((HashSet) equivalents.get(prop));// } // get direct superproperties of all properties in propSet for (Iterator iter = propSet.iterator(); iter.hasNext();) { OWLProperty p = (OWLProperty) iter.next(); if (outLinks.containsKey(p)) { Set subPropSet = (HashSet) this.outLinks.get(p); resultSet.addAll(this.getSetofEquivalentSets(subPropSet)); } } return resultSet; } public Set ancestorPropertiesOf(OWLProperty prop) throws OWLException { return this.superPropertiesOf(prop); } /** * Return a 'set of equivalent sets' given a set of objects i.e. for each * object 'obj' in the input set, get its equivalent set (using the hashmap * 'equivalents') and add it to result set * @param set - set of objects whose equivalents have to be determined * @return */ public Set getSetofEquivalentSets(Set set) { Set resultSet = new HashSet(); for (Iterator iter = set.iterator(); iter.hasNext(); ) { Object obj = iter.next(); Set equObjs = new HashSet(); equObjs.add(obj); if (equivalents.containsKey(obj)) equObjs = (HashSet) equivalents.get(obj); resultSet.add(equObjs); } return resultSet; } public Set subPropertiesOf(OWLProperty prop) throws OWLException { Set resultSet = new HashSet(); Set propSet = new HashSet(); propSet.add(prop);// // also find equivalents// if (equivalents.containsKey(prop)) { // propSet.addAll((HashSet) equivalents.get(prop));// } // get direct subproperties of all properties in propSet for (Iterator iter = propSet.iterator(); iter.hasNext();) { OWLProperty p = (OWLProperty) iter.next(); if (incLinks.containsKey(p)) { Set subPropSet = (HashSet) this.incLinks.get(p); resultSet.addAll(this.getSetofEquivalentSets(subPropSet)); } } return resultSet; } public Set descendantPropertiesOf(OWLProperty prop) throws OWLException { return this.subPropertiesOf(prop); } public Set equivalentPropertiesOf(OWLProperty prop) throws OWLException { if (equivalents.containsKey(prop)) { Set equSet = new HashSet((HashSet) equivalents.get(prop)); equSet.remove(prop); return equSet; } return new HashSet(); } public Set inversePropertiesOf(OWLObjectProperty prop) throws OWLException { Set inverses = prop.getInverses(ontologies); return this.getSetofEquivalentSets(inverses); } public Set rangesOf(OWLProperty prop) throws OWLException { Set ranges = prop.getRanges(ontologies); return ranges; //return this.getSetofEquivalentSets(ranges); } public Set domainsOf(OWLProperty prop) throws OWLException { Set domains = prop.getDomains(ontologies); return domains; //return this.getSetofEquivalentSets(domains); } public Set superClassesOf(OWLClass cl) throws OWLException { return this.superClassesOf((OWLDescription) cl); } public Set ancestorClassesOf(OWLClass cl) throws OWLException { return this.ancestorClassesOf((OWLDescription) cl); } public Set subClassesOf(OWLClass cl) throws OWLException { return this.subClassesOf((OWLDescription) cl); } public Set descendantClassesOf(OWLClass cl) throws OWLException { return this.descendantClassesOf((OWLDescription) cl); } public Set equivalentClassesOf(OWLClass cl) throws OWLException { return this.equivalentClassesOf((OWLDescription) cl); } public Map getDataPropertyValues(OWLIndividual ind) throws OWLException { return ind.getDataPropertyValues( getOntologies() ); } public Map getObjectPropertyValues(OWLIndividual ind) throws OWLException{ return ind.getObjectPropertyValues( getOntologies() ); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?