From: Adam F. <a....@dc...> - 2009-08-26 14:06:49
|
[17/08/09 17:01] Adam Funk wrote: > [13/08/09 16:52] Adam Funk wrote: >> [12/08/09 13:53] Evren Sirin wrote: >> >>> You are right, there's no way to do that. You either can remove the >>> range restriction or type the literal. >> I'm trying to figure out how to do this. I suspect the following: ... > I've also tried adding the "any type" to the properties' ranges (see > below), but I'm still getting the range errors. I'm not in a position > to tell the input ontology creators that they are providing bad data > (and I don't know what tool they've used to create my input OWL files), > so I'd like to be able to treat all data properties as strings and parse > them myself if necessary. I've tried combinations of all or part of the following and am getting quite desperate. OWLDataType anythingType = owlDataFactory.getOWLDataType(XSDVocabulary.ANY_TYPE.getURI()); OWLDataType stringType = owlDataFactory.getOWLDataType(XSDVocabulary.STRING.getURI()); ... private void removeInputRangeRestriction(OWLDataProperty property) { Set<OWLDataRange> ranges = Collections.unmodifiableSet(property.getRanges(input)); OWLAxiom axiom0 = owlDataFactory.getOWLDataPropertyRangeAxiom(property, anythingType); OWLAxiom axiom1 = owlDataFactory.getOWLDataPropertyRangeAxiom(property, stringType); owlManager.addAxiom(input, axiom0); owlManager.addAxiom(input, axiom1); for (OWLDataRange range : ranges) { OWLAxiom axiomR = owlDataFactory.getOWLDataPropertyRangeAxiom(property, range); RemoveAxiom remover = new RemoveAxiom(input, axiomR); changeVisitor.visit(remover); } OWLAxiom axiom2 = owlDataFactory.getOWLDataPropertyRangeAxiom(property, anythingType); OWLAxiom axiom3 = owlDataFactory.getOWLDataPropertyRangeAxiom(property, stringType); owlManager.addAxiom(input, axiom2); owlManager.addAxiom(input, axiom3); } One of the properties that is causing trouble looks like this in the input OWL file: <owl:DatatypeProperty rdf:ID="hasCodeAgrovoc"> <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#int"/> ... <hasCodeAgrovoc>8171</hasCodeAgrovoc> (I can see why the reasoner doesn't like that) and like this in the "loosened" version of the input OWL file (produced by saving the ontology to a debugging file after running the removeInputRangeRestriction method on the troublesome properties: <DataPropertyRange> <DataProperty URI="&agrovoc;hasCodeAgrovoc"/> <Datatype URI="&xsd;anyType"/> </DataPropertyRange> <DataPropertyRange> <DataProperty URI="&agrovoc;hasCodeAgrovoc"/> <Datatype URI="&xsd;int"/> </DataPropertyRange> <DataPropertyRange> <DataProperty URI="&agrovoc;hasCodeAgrovoc"/> <Datatype URI="&xsd;string"/> </DataPropertyRange> ... <DataPropertyAssertion> <DataProperty URI="&agrovoc;hasCodeAgrovoc"/> <Individual URI="&agrovoc;i_ar_8171"/> <Constant>8171</Constant> </DataPropertyAssertion> So the "DataPropertyRange(hasCodeAgrovoc int)" axiom is not really being deleted from the ontology, but the "DataPropertyRange(hasCodeAgrovoc anyType)" and "DataPropertyRange(hasCodeAgrovoc string)" axiom are being added; in any case, the reasoner is still throwing this exception. Exception in thread "main" org.mindswap.pellet.exceptions.InconsistentOntologyException: Cannot do reasoning with inconsistent ontologies! Reason for inconsistency: Plain literal "8171" does not belong to datatype http://www.w3.org/2001/XMLSchema#int. Literal value may be missing the rdf:datatype attribute. What do I have to do to make the input acceptable? Thanks, Adam |