|
How can I enumerate all classess defined in ontology using DotNetRDF? I load ontology to start with and then need a way to get (enumerate) all classes. To load the ontology:
I use VB, but have no problems if you use C# to help me with this :) |
|
Assuming all your classes are defined as belonging to some common type like
We'll look at adding a Notes for improvements filed as CORE-293 (http://dotnetrdf.org/tracker/Issues/IssueDetail.aspx?id=293) - please register and add further comments if there are other missing features you'd like to see See https://bitbucket.org/dotnetrdf/dotnetrdf/commits/1142f2971eefb8fffb7143153015e960e22b8d00 for some new methods and properties already added, the code there should provide alternative answers to your question |


You made a comment about number of classes reported in Protege vs dotNetRDF but that appears to have been removed. From what I can see of the data you posted the problem is one of OWL vs RDF. The OWL defines lots of classes in terms of computations on lots of other classes so there are a lot of
<x> a owl:Classtype triples which means dotNetRDF identifies lots of classes. As Protege works in terms of OWL it boils the ontology down to its definitions and so gives you the much smaller number of classes.Thanks Rob, the approach I've taken is to find the distinct class URIs searching through the subjects and objects of the triples returned by the above function you suggested. Still have to think how to eliminate anonymous classes, but that shouldn't be a big issue.
Great addition in your documentation would be a graphic representation of the terms you used in the library (OntologyResource, OntologyClass, Ontology and similar). Or at least something like, "OntologyResource as defined in RFC....". Some terms (not just as used in your library, but in the whole field in general) are used interchangeably in the various related texts and can confuse a user.
Thanks for your continious help.
Ah, if the problem is getting the same class reported multiple times then that is likely something that can be fairly easily fixed in the library. I will take a closer look and see if I can't get that fixed for the next release if it is a bug. The documentation suggestion is a good idea as well, thanks for that.
Hmmm, not sure that there is a problem here. When I try the code I gave on the data you gave I get 95 classes reported and all are distinct. Can you share your exact code please?