Edit : This answer was sent in response to the original, another question.
I have to get A, but I get nothing!
No, you shouldn't. RDF itself does not contain anything about ontologies, its just a dumb schedule, and this is what RDFLib does.
Going beyond this is called data reasoning. This is an extra layer. Bare RDFLib does not make any reasoning because it is complex and, as a rule, very expensive. There are third-party reasoning solutions, but before you use them, you must understand what they are doing and what impact they will have on performance.
The naive approach to RDFS and OWL 2 reasoning over the RDFLib graph is the implementation of Ivan Hermans OWL 2 RL . It is very easy to use, but you almost certainly do not want it, unless you are making a toy application, because its mute algorithm takes a lot of time on a graph of a realistic size.
FuXi is a more powerful library that implements the smarter Rete -UL. But I'm not sure if it is supported or can be used with current versions of RDFLib.
There are also many non-Python-based reasoning solutions such as Pellet , but integrating them with RDFLib - or any other RDF library - can be a daunting task.
You should also consider what type of output your application requires. Do you need to conclude that membership is a subclass? If so, maybe all you need? - then perhaps you could do it manually, iterating over three X rdfs:subClassOf Y using RDFLib and inserting new A rdf:type Y triples.
In any case, remember that the discussion of the semantic network is a complex topic that is highly dependent on the application.
Vasiliy Faronov
source share