Request for OWL namespace usage Example using RDFSharp
ozgukaptan opened this issue · 3 comments
Hi,
I read your RDFSharp documentation where I found the FOAF namespace example.
Actually I have ODR.xml(Ontology dietry Recommender) file , I would like to read these xml using RDFSharp library for OWL namespace in my .net code.
If you have any examples related to these , kindly share or you can recommend any supportive material.
Thanks and Regards
Hi,
you have to read the file into a RDFGraph then get an ontology from that graph:
using RDFSharp.Model;
using RDFSharp.Semantics.OWL;
RDFGraph graph = RDFGraph.FromFile(RDFModelEnums.RDFFormats.RdfXml, "path_to_your_file.xml");
RDFOntology ontology = RDFOntology.FromRDFGraph(graph);
//Work with your ontology (modify, build reasoners, etc...)
Be aware that the passage from RDF model to OWL model may be lossy due to the higher expressivity level of the target realm, so not every RDF triple may find the proper place in the formal OWL ontology structure. Beside, this passage requires at least OWL-DL completeness in declaration of your classes, properties and individuals: ensure to properly declare them with rdf:type
Can you give an example of querying for owl? I want to query on this ontology. in xml format but i uploaded as txt.
thank you
example.txt
.
Once the ontology is loaded (sorry, there is a bug in the current version which makes T-BOX loading under certain circumstances very slow. It has been addressed for the next version, but at the moment I can't schedule exactly when it will be available) you have 2 ways of working:
- Build a reasoner with desired inference rules, apply to the ontology, then merge evidences into the ontology. Now you can apply SPARQL queries on the ontology (it has been enriched with inferences from the reasoner and will respond with more answers than the original ontology).
- Directly use the library APIs for navigating and exploring the T-BOX / A-BOX relations: here is the docs. Check Page 11 for building lenses, Page 22 for navigating/querying the semantic relations.
Regards,
Marco