Thanks for the explanation. I am going to leave it at that regarding the "Neoplasm mystery". Regarding the difference in OntModel creation speed,I am using the following calls: _modelOnt = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, ds.getDefaultModel()); and _modelOnt = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM, ds.getDefaultModel());
RDFS_MEM executes in < 1 second from the first time I call it. OWL_MEM takes 40 seconds. Based on your suggestion, I just called it a 2nd time and that call is as fast as the RDFS_MEM version (< 1 second). As you stated, it must be the class loader. So each time I am starting my application (e.g. for debugging), I have to wait 40 seconds before I can work with it. Which is OK, just an inconvenience. Again Dave, thank you very much for your help and patience! Regards, Wolfgang -----Original Message----- From: Dave Reynolds <[email protected]> To: users <[email protected]> Sent: Fri, Mar 1, 2013 12:35 pm Subject: Re: OntModel.getOntClass does not return existing classes On 01/03/13 10:50, [email protected] wrote: > Dear Dave, > > thanks for your help! Using OWL_MEM works as expected, just takes longer > to create the OntModel, but it is still acceptable timewise. OWL_MEM, like RDFS_MEM, does not include any reasoning and there should be zero difference in time to create. If you are reporting subjective time when first starting your app then you are probably just seeing the java class loader pulling in a few more classes. However, once your app is running the time to wrap an OntModel with no inference should be very very small and pretty much identical whichever profile you use. > I was trying to use the least expensive OntModelSpec and started with > RDFS_MEM, just to see if it would return OntClasses. And since it did, I > just got stuck in the wrong path ... As I say, there is no difference in expense. > I am still curious, why the OntClass instantiation works for "Neoplasm", > but not for "T1_Stage_Finding". Could you please ellaborate a bit more > on what exactly (might have) happened? Here are some things that I still > find confusing: > > So based on our email exchange:An OntClass does not necessarily need to > be an owl:Class. When using RDFS_MEM, rdfs:Class would be enoughfor an > OntClass instantiation? What I find confusing is that the exception I > got when using RDFS_MEM refers to "owl:Class or similar". This implies > that OntClass always knows about owl:Classand is checking for it even if > I am using RDFS_MEM. So an rdfs:Class should never be enough for an > OntClass? Even if there was an rdfs:Class statement for Neoplasm, it > should not work since it is not equivalent to owl:Class? The OntAPI was created at a time there were lots of different Ontology flavours - there was DAML, there RDFS, there was OWL being developed which in turn had three profiles. These days DAML is gone, OWL is by far the most common. People working in pure RDFS often just work at the RDF level anyway, the OntAPI buys them less. So the error message from OntClass is trying to be helpful since the vast majority of people seem to work with an OWL profile. But it does not imply that something different is being done under the hood. To be an OntClass in an RDFS profile you need a rdf:type rdfs:Class. To be an OntClass in an OWL profile you need a rdf:type owl:Class. Without inference these, I believe, need to be explicit. Ian can correct me if I'm wrong on that. > I take it that RDFS_MEM does not do any additional reasoning, so the > statement that makes the OntClass instantiation succeed for "Neoplasm" > must be readily visible. The Thesaurus.owl file does not contain any > mention of rdfs:Class anywhere. I also attached the result of the Sparql > query "SELECT * WHERE { nci:Neoplasm ?p ?s. }". The result shows that > there are no rdfs:Class triples. Theonly rdfs: triples are rdfs:label > and rdfs:subClassOf. rdfs:subClassOf leads to other owl:Classes. And the > other triples describe properties. I can't explain that. As I said in my message the mystery is why Neoplasm should have worked for you in an RDFS_MEM profile, not why the others didn't. > Is there more to how OntClass > determines if it can convert a resource? Not that I'm aware of but others can answer definitively. Dave > -----Original Message----- > From: Dave Reynolds <[email protected]> > To: users <[email protected]> > Sent: Mon, Feb 25, 2013 6:21 pm > Subject: Re: OntModel.getOntClass does not return existing classes > > On 25/02/13 17:04,[email protected] wrote: >> I am using >> >> _modelOnt = ModelFactory.createOntologyModel(OntModelSpec.RDFS_MEM, >> ds.getDefaultModel()); > > Ah, that explains it! > >> So RDFS inferenceand not OWLbecause I want to keep the loading time to a >> minimum. I tried OWL_MICRO_MEM but that a long time to load. I canceled >> it after 1 hoursince that is not feasiblefor me. > > I can see that you don't want OWL inference. > > But what you specified is an *RDFS* profile, not an OWL profile, with no > inference at all. > > So the OntAPI has been told that classes are of type rdfs:Class and > there's no inference specified to allow it to deduce that something > which is declared as a owl:Class is also an rdfs:Class. > > Use OntModelSpec.OWL_MEM which is an *OWL* profile with no inference. > >> I can get an OntClass from this model for certain concepts using RDFS >> inference, e.g. "Neoplasm", but cannot for others, e.g. >> "T1_Stage_Finding". I attached both definitions, directly copied from >> the thesaurus.owl file. There must be something different in there that >> I don't see. > > My neither but now the mystery is why it doesn't complain about > #Neoplasm rather than why it does complain about #T1_Stage_Finding. > > I wonder if there are other statements about #Neoplasm in your data > which assert it's an rdfs:Class. > >> Ialso created a smaller test ontology with just those concepts and >> properties from the thesaurus that are required to mirror this >> scenario(including parent concepts) and strangely enough, neither of the >> two concepts can be retrieved as OntClass. > > So that's consistent and reinforces the hypothesis that there's other > statements about #Neoplasm elsewhere in your data. > > Dave > > >> >> -Wolfgang >> >> >> -----Original Message----- >> From: Dave Reynolds <[email protected]> >> To: users <[email protected]> >> Sent: Mon, Feb 25, 2013 2:00 pm >> Subject: Re: OntModel.getOntClass does not return existing classes >> >> On 25/02/13 12:03,[email protected] wrote: >>> >>> Hi Dave, >>> >>> I am still having issues coming to terms with what is going on in my project. >> I am using this source code to get a resource by its "code": >>> >>> AnnotationProperty codeProp = >>> _modelOnt.getAnnotationProperty(NS_NCI_HASH >> + "code"); >>> Literal codeLiteral = _modelOnt.createTypedLiteral(code); >>> StmtIterator iter = _modelOnt.listStatements(new >> SimpleSelector(null, codeProp, codeLiteral)); >>> OntClass diseaseClass = null; >>> >>> while(iter.hasNext()){ >>> Statement stmt = iter.next(); >>> PrintStatementIterator(stmt.getSubject().listProperties()); >>> diseaseClass = stmt.getSubject().as(OntClass.class); >>> break; >>> } >>> return diseaseClass; >>> >>> >>> The call to my print method outputs this: >>> >>> [http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#T1_Stage_Finding, >>http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://www.w3.org/2002/07/owl#Class] >>> [http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#T1_Stage_Finding, >>http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#Preferred_Name, "T1 Stage >> Finding"^^http://www.w3.org/2001/XMLSchema#string] >>> [http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#T1_Stage_Finding, >>http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#Semantic_Type, >> "Finding"^^http://www.w3.org/2001/XMLSchema#string] >>> [http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#T1_Stage_Finding, >>http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#DEFINITION, >> "<ncicp:ComplexDefinition >> xmlns:ncicp="http://ncicb.nci.nih.gov/xml/owl/EVS/ComplexProperties.xsd#"><ncicp:def-definition>A >> clinical and/or pathologic primary tumor TNM finding indicating that the > cancer >> is limited to the site of >> growth.</ncicp:def-definition><ncicp:def-source>NCI</ncicp:def-source></ncicp:ComplexDefinition>"^^http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral] >>> >>> The stmt.getSubject().as(OntClass.class) call throws this exception: >>> >>>http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#T1_Stage_Finding to >> OntClass: it does not have rdf:type owl:Class or equivalent >>> >>> >>> The first line from listProperties() states that the resource is an > owl:Class. >> But the exception begs to differ. I am not using any manually created URIs in >> this example and the selector finds a hit for the supplied code (e.g. > "C48720"). >>> >>> What am I missing? >> >> Does look very odd. >> >> Is there any inference involved or is this a plain model? >> >> What OnModelSpec are you using? Clearly if you specified RDFS and had >> no inference then the call would fail, though I assume you are using an >> OWL spec. >> >> Dave >> >> >> >
