Closed cthoyt closed 6 years ago
Getting the individuals in an ontology would be really great! It would help me to improve my ontology spec generator a lot.
Ok I'll try to add that with the next release.
Great! Looking forward to it.
Added with v1.8.8. Sorry it's taken so long! You can now do this:
for instance in class.instances:
print instance.uri, instance.qname
Note: instances are extracted on demand (once the method is called) so to avoid unnecessary calculations due to metaclasses and the same object being at the same time an instance and a class.
That's wonderful, thanks so much!
I would like to get the name of all of the instances of a given class, but without the URI prefix. I think this is more of an
RDFLib
specific issue dealing with URIRef objects, but maybe there's a solution insideontospy
that I haven't found yetOutput:
None of the functions listed with
dir
return what I want (I iterated through all them and ran them) What I'd like is simply a way to retrieve:And make it a bit more general than splitting on the
#
character, since not all ontologies have to use a#
to differentiate the base IRI and the members, correct? Thanks so much for the help!