Currently I am trying to create OWLClass from a string in Turtle syntax by first creating Jena OntModel and visiting each statement within the class. Is there a better way to create OWL Class using OWL API from Turtle syntax? Below is the string which I am trying to parse.
@prefix p0: <http://rdf.test.com/dl_reasoning/> .
@prefix p1: <http://rdf.test.com/ns/test_rm#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
p0:safetyGoal_1 a rdfs:Class , p1:SafetyGoal ;
rdfs:subClassOf p1:SafetyGoal ;
p1:fulfilledBy p0:fsr_fuel , p0:fsr_coo .
p0:safetyGoal_3 a rdfs:Class , p1:SafetyGoalVersion ;
rdfs:subClassOf p1:SafetyGoal ;
p0:safetyGoal_2 a rdfs:Class , p1:SafetyGoalVersion ;
rdfs:subClassOf p1:SafetyGoal ;
p1:fulfilledBy p0:fsr_fuel ;
p1:fulfills p0:fsr_coo .
The string you're trying to parse does not contain just classes - it contains axioms as well. In order to be a full ontology, it only lacks an ontology declaration. It should be possible to parse this straight to an ontology - which would be anonymous - by parsing it with one of the Turtle parsers in OWLAPI.
Have you tried parsing this to an OWLOntology
?
String in = "...";
StringDocumentSource input = new StringDocumentSource(in);
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology o = m.loadOntologtFromOntologyDocument(input);
Listing the axioms or iterating through the signature of the ontology should provide you with enough structure to move forward in your work.
Side note: these two lines seem to be missing a dot:
p0:safetyGoal_3 a rdfs:Class , p1:SafetyGoalVersion ;
rdfs:subClassOf p1:SafetyGoal ;
There should be a full stop to allow parsing:
p0:safetyGoal_3 a rdfs:Class , p1:SafetyGoalVersion ;
rdfs:subClassOf p1:SafetyGoal .