While Using Jena (java) Or Rdflib (python), How Should I Find Out Whether To Open The Ontology As 'turtle' Or 'xml'?
Ontology files usually have extensions such as .owl or .rdf. I want to know when I should open ontologies with 'turtle' and when with 'xml' or other formats? Because it seems that
Solution 1:
You are opening RDF files, not ontologies.
RDF is an abstract data model. It has several serialization formats:
<?xml version="1.0"?><rdf:RDFxmlns="http://example.com/ontology#"xml:base="http://example.com/ontology"xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:owl="http://www.w3.org/2002/07/owl#"xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"><owl:Ontologyrdf:about="http://example.com/ontology"/><owl:Classrdf:about="http://example.com/ontology#Person"/><owl:Classrdf:about="http://example.com/ontology#Woman"><rdfs:subClassOfrdf:resource="http://example.com/ontology#Person"/></owl:Class></rdf:RDF>
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<http://example.com/ontology> a owl:Ontology .
<http://example.com/ontology#Person> a owl:Class .
<http://example.com/ontology#Woman>
a owl:Class ;
rdfs:subClassOf <http://example.com/ontology#Person> .
[{"@id":"http://example.com/ontology","@type":["http://www.w3.org/2002/07/owl#Ontology"]},{"@id":"http://example.com/ontology#Person","@type":["http://www.w3.org/2002/07/owl#Class"]},{"@id":"http://example.com/ontology#Woman","@type":["http://www.w3.org/2002/07/owl#Class"],"http://www.w3.org/2000/01/rdf-schema#subClassOf":[{"@id":"http://example.com/ontology#Person"}]}]
Open your file with a text editor, view what your file content looks similar to, and select approptiate option. You can use this online service to convert RDF files from one serialization format to another.
RDF (abstract) syntax is not the only syntax for OWL ontologies. There are few others:
<?xml version="1.0"?><Ontologyxmlns="http://www.w3.org/2002/07/owl#"xml:base="http://example.com/ontology"xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:xml="http://www.w3.org/XML/1998/namespace"xmlns:xsd="http://www.w3.org/2001/XMLSchema#"xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"ontologyIRI="http://example.com/ontology"><Prefixname=""IRI="http://example.com/ontology#"/><Prefixname="owl"IRI="http://www.w3.org/2002/07/owl#"/><Prefixname="rdf"IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/><Prefixname="xml"IRI="http://www.w3.org/XML/1998/namespace"/><Prefixname="xsd"IRI="http://www.w3.org/2001/XMLSchema#"/><Prefixname="rdfs"IRI="http://www.w3.org/2000/01/rdf-schema#"/><Declaration><ClassIRI="#Person"/></Declaration><Declaration><ClassIRI="#Woman"/></Declaration><SubClassOf><ClassIRI="#Woman"/><ClassIRI="#Person"/></SubClassOf></Ontology>
Prefix(:=<http://example.com/ontology#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Ontology(<http://example.com/ontology>
Declaration(Class(:Person))
Declaration(Class(:Woman))
SubClassOf(:Woman :Person)
)
Prefix: : <http://example.com/ontology#>
Prefix: owl: <http://www.w3.org/2002/07/owl#>
Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Prefix: xml: <http://www.w3.org/XML/1998/namespace>
Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>
Ontology: <http://example.com/ontology>
Class: Person
Class: Woman
SubClassOf:
Person
AFAIK, one can not parse files in these formats using RDFlib. You can use this online service to convert OWL files between these formats (and RDF formats).
Post a Comment for "While Using Jena (java) Or Rdflib (python), How Should I Find Out Whether To Open The Ontology As 'turtle' Or 'xml'?"