jena-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Reynolds <dave.e.reyno...@gmail.com>
Subject Re: I think I've got some pretty basic confusion with reading into models
Date Thu, 09 Dec 2010 17:46:27 GMT
On Thu, 2010-12-09 at 11:51 -0500, Benson Margulies wrote: 
> Dave,
> 
> Thanks.
> 
> I think that I may have still failed to give you enough information to
> reason about my level of confusion, so I have a few followup
> questions.
> 
> 1.  I think I'm confused about 'Things'. My ontology doesn't mention
> Thing anywhere explicitly. I have owl:Class elements and
> owl:DatatypeProperty elements. When I create an individual with the
> OntModel, is it a thing _ex officio_?

Yes pretty much.

The notion of an "Individual" is something that makes the most sense in
OWL DL.

In RDF and RDFS there are just resources, some of those resources are
also Classes and/or Properties but there's no separation.

In OWL DL there is a strict separation between Classes,
ObjectProperties, DatatypeProperties and Individuals [*].
In OWL DL all resources which are not Classes or Properties are
Individuals. All classes are subclasses of owl:Thing so if you declare
some class C and say:
   i rdf:type C
then it is possible to infer:
   i rdf:type owl:Thing.

> 2. When I set up my OntModel to create my individuals in the first
> place, should I be, somehow, attaching the URI that corresponds to my
> ontolology to it?

Depends what you are trying to do.

To work within strict OWL DL then to use something as a Class you have
to declare it as such either within the model or via an import.

You can achieve that by adding an appropriate import statement to the
OntModel when you create it and letting the OntDocument machinery load
in the ontology (as a sub-model). 

Though given your next point it doesn't sound like you don't want to do
that and strict DL is not your goal.

> 3. I was really _only_ expecting to see the rex: items and not the
> ontology itself. This leads me to ask: If my goal is just to take one
> of these documents and push it into Mulgara, doing no inference on the
> way, should I just be using a plain model and checking my work by
> looking at Resources instead of Individuals? I think that the answer
> is 'yes' based on your email, but I wanted to check.

Not necessarily, though that's certainly OK.

You can perfectly well use OntModels with no inference (see the
OntModelSpec argument in my example) and no imports. The OntModel API
mostly works happily for pure RDF, RDFS and OWL/Full too and has some
useful convenience methods. 

It is just this concept of Individual that is a bit confusing in those
cases.

So you could use the OntModel but fall back on just listing resources
(OntModels extend Models) for those cases, as in my example. Or indeed
use things like OntClass#listInstances  to get instances of specific
classes which I suspect is a more common usage.

> I am very grateful for your assistance in my process of bootstrapping
> myself into this whole areas, where, as you can tell, I am starting
> from a very empty graph.

No worries, the whole stack is certainly pretty complex and confusing
and any API like Jena has some compromises and legacy in it.

Dave

[*] I'm ignoring OWL2's "punning" here.


> 
> --benson
> 
> 
> 
> 
> 
> On Thu, Dec 9, 2010 at 11:04 AM, Dave Reynolds
> <dave.e.reynolds@gmail.com> wrote:
> > Hi Benson,
> >
> > On Thu, 2010-12-09 at 09:11 -0500, Benson Margulies wrote:
> >> Here's a little RDF snippet:
> >>
> >> <rdf:RDF
> >>     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> >>     xmlns:rex="http://www.basistech.com/ontologies/2010/6/rex.owl#"
> >>     xmlns:owl="http://www.w3.org/2002/07/owl#"
> >>     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
> >>     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
> >>   <rex:Location rdf:about="uri:c6c54ebb-a232-48cd-80fa-e4adf9cc5001#3">
> >>     <rex:hasOriginalText rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
> >>     >Pakistan</rex:hasOriginalText>
> >>     <rex:hasNormalizedText
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
> >>     >Pakistan</rex:hasNormalizedText>
> >>     <rex:hasEntityDetectionSource
> >> rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
> >>     >gazetteer:../../../bt_root/rlp/rlp/dicts/en-all-gazetteer-LE.bin</rex:hasEntityDetectionSource>
> >>   </rex:Location>
> >> </rdf:RDF>
> >>
> >> The following rather trivial test fails. I'm sure I'm just befuddled,
> >> could some kind soul rescue me?
> >>
> >>         OntModel model = ModelFactory.createOntologyModel();
> >>         model.read(rdfStream, "", "RDF/XML-ABBREV");
> >>         ExtendedIterator<Individual> individuals = model.listIndividuals();
> >>         int individualCount = 0;
> >>         while (individuals.hasNext()) {
> >>             individualCount++;
> >>         }
> >>         assertTrue("Should have more than two individuals, but got " +
> >> individualCount, individualCount > 0);
> >
> > Actually that's a tricky area :)
> >
> > For OWL then we treat an individual as being anything of type
> > owl:Thing.
> >
> > If you have an OWL-capable reasoner configured for the OntModel then the
> > code can just query for that directly. If you don't then it looks for
> > all resources whose declared type is itself an owl:Class (and not part
> > of the OWL/RDFS "furniture").
> >
> > Since you don't have a declaration of rex:Location anywhere then nothing
> > bites.
> >
> > Since your test comment suggest you are expecting at least 2 then I'm
> > guessing you mean to count rex:Location as well so you are probably just
> > after resources mentioned rather than Individuals in the OWL sense. In
> > that case try:
> >
> >       OntModel model =
> > ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
> >        model.read("file:data/temp2.rdf", "", "RDF/XML-ABBREV");
> >
> >        ExtendedIterator<RDFNode> nodes =
> > model.listObjects().andThen( model.listSubjects() );
> >        int count = 0;
> >        while ( nodes.hasNext() ) {
> >            if (nodes.next().isResource()) count ++;
> >        }
> >
> >
> > Note the explicit OntModelSpec to turn off the default RDFS reasoner
> > which would otherwise complicate things.
> >
> >
> > Actually checking this out revealed a possible bug in this area. RDFS
> > reasoning can infer that rex:Location is a rdfs:Class so if you set the
> > OntModel profile to RDFS then uri:c6c54ebb-a232-48cd-80fa-e4adf9cc5001#3
> > is treated as an individual. The trouble is that a lot of stuff in the
> > background RDFS knowledge are also treated as Individuals (28 of them
> > including things that are rdfs:Class/rdf:Property). While technically
> > correct (because in RDFS all resources are Individuals) I would have
> > expected the OntModel conventions to filter those out. Ian will log a
> > JIRA case the check this out (assuming he can get access to JIRA).
> >
> > Dave
> >
> >
> >




Mime
View raw message