Jos Lehmann
2017-02-22 11:36:00 UTC
Hi there
I would like to list subclass assertions *completely*, i.e., also including object properties with their restrictions.
At the moment I am getting a mixed bag:
- Subclass assertions proper return output like [1] or [2] in MY OUTPUT below (*that's OK*);
- Subclass assertions that use anonymous classes (i.e. a property + restriction + range) return output like [3] in MY OUTPUT below (*not OK*);
How should I change MY CODE below to see what's inside -7d9d6f3d:15a658d8bb4:-7f27 (in terms of object property, restriction and range of restriction for the particular class at hand) ?
Thanks, Jos
MY CODE
ExtendedIterator classes = model.listClasses();
while (classes.hasNext()) {
OntClass thisClass = (OntClass) classes.next();
ExtendedIterator properties = thisClass.listProperties();
while (properties.hasNext()){
Statement thisProperty = (Statement) properties.next();
if (thisProperty.getPredicate().toString().contains("sub")) {
System.out.println("Contains sub_P: " + thisProperty.getPredicate() + " Contains sub_O: " + thisProperty.getObject());
}
}
}
MY OUTPUT
[1] Contains sub_P: http://www.w3.org/2000/01/rdf-schema#subClassOf Contains sub_O: http://www.bauhaus-luftfahrt.net/ontologies/2016/Ls_Ontology.owl#XXX
[2] Contains sub_P: http://www.w3.org/2000/01/rdf-schema#subClassOf Contains sub_O: http://www.bauhaus-luftfahrt.net/ontologies/2016/Ls_Ontology.owl#YYY
[3] Contains sub_P: http://www.w3.org/2000/01/rdf-schema#subClassO
I would like to list subclass assertions *completely*, i.e., also including object properties with their restrictions.
At the moment I am getting a mixed bag:
- Subclass assertions proper return output like [1] or [2] in MY OUTPUT below (*that's OK*);
- Subclass assertions that use anonymous classes (i.e. a property + restriction + range) return output like [3] in MY OUTPUT below (*not OK*);
How should I change MY CODE below to see what's inside -7d9d6f3d:15a658d8bb4:-7f27 (in terms of object property, restriction and range of restriction for the particular class at hand) ?
Thanks, Jos
MY CODE
ExtendedIterator classes = model.listClasses();
while (classes.hasNext()) {
OntClass thisClass = (OntClass) classes.next();
ExtendedIterator properties = thisClass.listProperties();
while (properties.hasNext()){
Statement thisProperty = (Statement) properties.next();
if (thisProperty.getPredicate().toString().contains("sub")) {
System.out.println("Contains sub_P: " + thisProperty.getPredicate() + " Contains sub_O: " + thisProperty.getObject());
}
}
}
MY OUTPUT
[1] Contains sub_P: http://www.w3.org/2000/01/rdf-schema#subClassOf Contains sub_O: http://www.bauhaus-luftfahrt.net/ontologies/2016/Ls_Ontology.owl#XXX
[2] Contains sub_P: http://www.w3.org/2000/01/rdf-schema#subClassOf Contains sub_O: http://www.bauhaus-luftfahrt.net/ontologies/2016/Ls_Ontology.owl#YYY
[3] Contains sub_P: http://www.w3.org/2000/01/rdf-schema#subClassO