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