Reputation: 115
While I'm trying to get classes of Dbpedia ontology using the code below
public void classofontology(){
Set<OWLClass> classes = ontology.getClassesInSignature();
System.out.println("le nombre des classes total de l'ontologie est : "+classes.size());
for(OWLClass clss: classes)
System.out.println(clss.getIRI().getFragment());
}
I get the total number of classes, So they're all browsed but I can't have the name of classes: I get as output "null" but when I try by using directly clss
instead of clss.getIRI().getFragment()
I get the IRI . I need just the name of the classes and I can't understand why I can't get it, I would be grateful
If you can help me to get it. Thank you
Ps: I notice that classes don't have all the same IRI as you can see for Building and Book classes, Can this be the source of the problem ?
Building IRI gotten by the code http://dbpedia.org/ontology/Building
Book IRI gotten by the code http://schema.org/Book
Upvotes: 0
Views: 59
Reputation: 10659
In short, IRIs do not have names.
The last part of an IRI
(from the last slash or hash character, or digit) is returned by the getFragment()
method; however, there is no guarantee that a valid IRI
has such a fragment (the IRI
might be terminated with a hash or a dash, or it might have only numbers after the last value). The reason behind this is that the fragment must be an XML QName - it is used in RDF/XML for naming tags.
For example, IRI.create("http://www.example.com/test/1234").getFragment()
will return an empty string.
As suggested by AKSW, use either a SimpleIRIShortFormProvider
or, if your entities have labels, an AnnotationValueShortFormProvider
.
Upvotes: 1