You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Ziqi Zhang <zi...@sheffield.ac.uk> on 2016/08/01 10:56:05 UTC
non-owl class in DBpedia.owl loaded as superclass, causing 'cannot
convert node to OntClass: it does not have rdf:type owl:Class or equivalent'
Hi
I am processing DBpedia.owl
(http://downloads.dbpedia.org/2015-10/dbpedia_2015-10.owl) to read every
class and their superclasses. The java code is as below:
>>>
OntModel base = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
OntModel model= (OntModel) base.read(ontURL);
ExtendedIterator<OntClass> it = model.listNamedClasses();
while (it.hasNext()) { OntClass c = it.next();
ExtendedIterator<OntClass> it = c.listSuperClasses(false);
while(it.hasNext()){ //LINE A OntClass sc = it.next(); ... } }
<<< When the OntClass correspond to the one defined below: >>>
<owl:Class rdf:about="http://dbpedia.org/ontology/Weapon">
<rdfs:label xml:lang="en">weapon</rdfs:label>
<rdfs:subClassOf rdf:resource="http://dbpedia.org/ontology/Device"/>
<rdfs:subClassOf rdf:resource="http://schema.org/Product"/>
<owl:equivalentClass
rdf:resource="http://www.wikidata.org/entity/Q728"/><prov:wasDerivedFrom
rdf:resource="http://mappings.dbpedia.org/index.php/OntologyClass:Weapon"/>
</owl:Class> <<< Line A causes an exception. >>>
org.apache.jena.ontology.ConversionException: Cannot convert node
http://schema.org/Product to OntClass: it does not have rdf:type
owl:Class or equivalent at
org.apache.jena.ontology.impl.OntClassImpl$1.wrap(OntClassImpl.java:82)
at org.apache.jena.enhanced.EnhNode.convertTo(EnhNode.java:152)
at org.apache.jena.enhanced.EnhNode.convertTo(EnhNode.java:31) at
org.apache.jena.enhanced.Polymorphic.asInternal(Polymorphic.java:62)
at org.apache.jena.enhanced.EnhNode.as(EnhNode.java:107) at
org.apache.jena.ontology.impl.OntResourceImpl.lambda$listDirectPropertyValues$30(OntResourceImpl.java:1536)
at
org.apache.jena.util.iterator.Map1Iterator.next(Map1Iterator.java:46)
at
org.apache.jena.util.iterator.WrappedIterator.next(WrappedIterator.java:94)
at
org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:56)
at
org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
at
org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
at
org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
at
org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
<<< I think the problem is that 'http://schema.org/Product' refers to a
class defined in another resource. And this class is not defined in this
owl file. How can this be addressed please? Thanks!
Re: non-owl class in DBpedia.owl loaded as superclass, causing
'cannot convert node to OntClass: it does not have rdf:type owl:Class or
equivalent'
Posted by Dave Reynolds <da...@gmail.com>.
Set non-strict mode.
Dave
On 01/08/16 11:56, Ziqi Zhang wrote:
> Hi
>
> I am processing DBpedia.owl
> (http://downloads.dbpedia.org/2015-10/dbpedia_2015-10.owl) to read every
> class and their superclasses. The java code is as below:
>
>>>>
> OntModel base = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
> OntModel model= (OntModel) base.read(ontURL);
> ExtendedIterator<OntClass> it = model.listNamedClasses();
>
> while (it.hasNext()) { OntClass c = it.next();
> ExtendedIterator<OntClass> it = c.listSuperClasses(false);
> while(it.hasNext()){ //LINE A OntClass sc = it.next(); ... } }
>
> <<< When the OntClass correspond to the one defined below: >>>
> <owl:Class rdf:about="http://dbpedia.org/ontology/Weapon">
> <rdfs:label xml:lang="en">weapon</rdfs:label>
> <rdfs:subClassOf rdf:resource="http://dbpedia.org/ontology/Device"/>
> <rdfs:subClassOf rdf:resource="http://schema.org/Product"/>
> <owl:equivalentClass
> rdf:resource="http://www.wikidata.org/entity/Q728"/><prov:wasDerivedFrom
> rdf:resource="http://mappings.dbpedia.org/index.php/OntologyClass:Weapon"/>
> </owl:Class> <<< Line A causes an exception. >>>
> org.apache.jena.ontology.ConversionException: Cannot convert node
> http://schema.org/Product to OntClass: it does not have rdf:type
> owl:Class or equivalent at
> org.apache.jena.ontology.impl.OntClassImpl$1.wrap(OntClassImpl.java:82)
> at org.apache.jena.enhanced.EnhNode.convertTo(EnhNode.java:152)
> at org.apache.jena.enhanced.EnhNode.convertTo(EnhNode.java:31) at
> org.apache.jena.enhanced.Polymorphic.asInternal(Polymorphic.java:62)
> at org.apache.jena.enhanced.EnhNode.as(EnhNode.java:107) at
> org.apache.jena.ontology.impl.OntResourceImpl.lambda$listDirectPropertyValues$30(OntResourceImpl.java:1536)
> at
> org.apache.jena.util.iterator.Map1Iterator.next(Map1Iterator.java:46)
> at
> org.apache.jena.util.iterator.WrappedIterator.next(WrappedIterator.java:94)
> at
> org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:56)
> at
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> at
> org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
> at
> org.apache.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
> at
> org.apache.jena.util.iterator.FilterIterator.hasNext(FilterIterator.java:55)
> <<< I think the problem is that 'http://schema.org/Product' refers to a
> class defined in another resource. And this class is not defined in this
> owl file. How can this be addressed please? Thanks!
>