Hi Dave, I did not try model.read (ontPath, "RDF/XML").
I need to create the ontology with the Pellet Reasoner specification, because I need to make some inferences based on the ontology's SWRL rules. Thanks! On Thu, Feb 20, 2014 at 5:24 AM, Dave Reynolds <[email protected]>wrote: > On 20/02/14 02:07, Guilherme Maranhão wrote: > >> Hi Dave, >> >> I've tried all the possible ways to simply create a model and none did >> work. >> >> I've tried your last suggestion and it sends file not found. I've tried >> with both absolute and relative paths. >> > > In that case you need to figure out the right file name. You might want to > start with something simple such as putting the data file in the same place > you are running the code then work up from there. > > > Another way I have tried is as follows: >> >> OntModel model = ModelFactory.createOntologyModel( >> PelletReasonerFactory.THE >> proj_SPEC, null ); >> > > That's creating a model with a Pellet reasoner. If that's what you want > then great. But especially if are having problems getting started then you > might want to start without inference and work up. > > OntModel model > = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); > > > model.read( ontPath, "RDF/XML" ); >> >> ontPath is relative to my project path. >> > > And did that work? > > Dave > > > >> I am very new to Jena, that's why I am having these kind of difficulties. >> >> Thanks again, >> >> Guilherme >> >> >> On Wed, Feb 19, 2014 at 11:18 AM, Dave Reynolds >> <[email protected]>wrote: >> >> On 19/02/14 11:54, Guilherme Maranhão wrote: >>> >>> Dave, >>>> >>>> I've removed line 2 as you've suggested, but stage3Hypertension >>>> continues >>>> null. >>>> >>>> Isn't it the way I am creating the modelMem object? >>>> >>>> ModelMaker modelMaker = ModelFactory.createFileModelMaker(/User/ >>>> guilherme >>>> /ontology/vitalSign.owl); >>>> Model modeltmp = modelMaker.createDefaultModel(); >>>> modelMem = ModelFactory.createOntologyModel(OntModelSpec. >>>> OWL_MEM_MICRO_RULE_INF, modeltmp); >>>> >>>> >>> I don't think modelMaker.createDefaultModel() loads any data, just >>> creates an empty model. But I never use it so can't be sure. >>> >>> Try simply: >>> >>> Model model = RDFDataMgr.loadModel("your-file-name") ; >>> >>> [Hope that's the right syntax, I'm still too used to FileManager.] >>> >>> Dave >>> >>> >>> >>> On Wed, Feb 19, 2014 at 5:38 AM, Dave Reynolds < >>>> [email protected] >>>> >>>>> wrote: >>>>> >>>> >>>> On 19/02/14 03:20, Guilherme Maranhão wrote: >>>> >>>>> >>>>> Hello guys, >>>>> >>>>>> >>>>>> Those are the steps I am using to instantiate an OntClass object: >>>>>> >>>>>> // modelMem is an OntModel object. >>>>>> 1 - Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); >>>>>> 2 - reasoner = reasoner.bindSchema(modelMem); >>>>>> 3 - OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF; >>>>>> 4 - ontModelSpec.setReasoner(reasoner); >>>>>> 5 - OntModel ontModel = ModelFactory.createOntologyModel( >>>>>> ontModelSpec, >>>>>> modelMem); >>>>>> 6 - OntClass stage3Hypertension = ontModel.getOntClass(" >>>>>> http://www.semanticweb.org/ontologies/2013/1/ >>>>>> Ontology1361391792831.owl# >>>>>> Stage3Hypertension >>>>>> "); >>>>>> >>>>>> >>>>>> This is not your underlying problem but you have bound modelMem in >>>>> twice >>>>> - >>>>> you have bound it to the reasoner and then applied that back to the >>>>> same >>>>> model. It would be better to just have: >>>>> >>>>> OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF; >>>>> >>>>> OntModel ontModel = ModelFactory.createOntologyModel(ontModelSpec, >>>>> modelMem); >>>>> >>>>> Though in fact I would recommend OWL_MEM_MICRO_RULE_INF as the best >>>>> default. >>>>> >>>>> >>>>> After line 2, the console prompt shows a lot of warning messages, >>>>> like >>>>> >>>>> this: >>>>>> >>>>>> Fev 19, 2014 12:15:56 AM >>>>>> org.mindswap.pellet.jena.graph.query.GraphQueryHandler findTriple >>>>>> Warning: No query handler found for >>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type >>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#type >>>>>> http://www.w3.org/1999/02/22-rdf-syntax-ns#Property >>>>>> >>>>>> >>>>>> Those are messages from Pellet. Your above code does not include >>>>> Pellet >>>>> so >>>>> either this isn't the code you are running or your "modelMem" in the >>>>> above >>>>> is actually Pellet-backed model. >>>>> >>>>> If the latter then you have a rule reasoner running over a rule >>>>> reasoner >>>>> running over Pellet. Don't know why that would cause outright failures >>>>> but >>>>> certainly not a useful thing to do. >>>>> >>>>> To get help with Pellet you would need to ask the Pellet folks, Pellet >>>>> is >>>>> not part of Jena. >>>>> >>>>> Dave >>>>> >>>>> >>>>> >>>>> >>>> >>> >> >
