On 05/03/13 16:16, Joshua TAYLOR wrote:
On Tue, Mar 5, 2013 at 10:59 AM, Dave Reynolds
<dave.e.reyno...@gmail.com> wrote:
On 05/03/13 14:11, Joshua TAYLOR wrote:

On Tue, Mar 5, 2013 at 3:20 AM, Vegard Vaage <vegard.va...@tv2.no> wrote:

I'm trying to verify instance data against an ontology using Jenas OWL
reasoner. Right now I'm just trying to verify that the input literals are of
the correct types and ranges, but later on I'll need more advanced
verification against the ontology.
I've been following the Jena OWL Reasoner example and come up with this:

Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
Resource resource = IndividualMapper.mapResource(dataModel, data, uri);
InfModel infModel = ModelFactory.createInfModel(reasoner, schema,
dataModel);
Resource clazz = infModel.getResource(uri);
if (infModel.contains(resource, RDF.type, clazz)) {
          return true;
}
return false;

But no matter how I define instance data I always get true as a return
value. The ontology is basically a single class using owl:restriction on a
datatypeProperty:

   <owl:DatatypeProperty rdf:about="http://snipped/#Id";>
          <rdf:type rdf:resource="&owl;FunctionalProperty"/>
      </owl:DatatypeProperty>

<owl:Class rdf:about="http://snipped/#MyClass";>
          <rdfs:label xml:lang="en">MyClass</rdfs:label>
          <rdfs:subClassOf>
              <owl:Restriction>
                  <owl:onProperty rdf:resource="http://snipped/#Id"/>
                  <owl:someValuesFrom rdf:resource="&xsd;long"/>
              </owl:Restriction>
          </rdfs:subClassOf>
</owl:Class>

What am I doing wrong? See below for source code for the non-Jena stuff:


What sort of instance data are you providing?
What result are you expecting that you aren't seeing?
What result aren't you expecting that you are seeing?

What exactly do you mean by validation?  You said that you're trying
to check that the "input literals are of the correct type and ranges".
   However, it looks like check that you're performing is to see whether
individuals have a particular RDF type.  Based on your ontology, I
don't see any way to infer that something is a member of MyClass
except through explicit assertion, although there are ways that you
could infer that something *isn't* a MyClass, e.g., if it has a value
for Id that's not a long.


Actually not even then. Vegard's restriction on MyClass is
owl:someValuesFrom which won't work for several reasons.

First, the the open world assumption means that if there isn't such a value
then there is no inconsistency (the data is incomplete but not
inconsistent).

Well, I'd been hoping we could elicit a few more details from the OP,
so that we could figure out whether some kind of validation would be
possible for his case.  Since his "Id" property was declared to be
functional, a reasoner could recognize that once an individual has an
Id with a *non* xsd:long value, that it *can't* be a member of
MyClass. Since he was talking about checking the datatypes of property
values, but his code was checking the class membership of individuals,
I expected that we'd probably get to testing both for MyClass and for
[not MyClass] (i.e., to see if something happened that would *prevent*
something from being a MyClass.

Second, that's OWL2 and Jena only supports OWL1.

I might be missing something, but which part of this falls into OWL2?
It looks like OWL1 [1] has both someValuesFrom [2] and
functionalProperty [3].

Oops. Sorry, you are right. I was thinking of qualified cardinality restrictions, someValuesFrom is fine.

Dave

Reply via email to