Return-Path: Delivered-To: apmail-incubator-jena-users-archive@minotaur.apache.org Received: (qmail 61351 invoked from network); 9 Dec 2010 16:52:19 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Dec 2010 16:52:19 -0000 Received: (qmail 39456 invoked by uid 500); 9 Dec 2010 16:52:19 -0000 Delivered-To: apmail-incubator-jena-users-archive@incubator.apache.org Received: (qmail 39432 invoked by uid 500); 9 Dec 2010 16:52:19 -0000 Mailing-List: contact jena-users-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jena-users@incubator.apache.org Delivered-To: mailing list jena-users@incubator.apache.org Received: (qmail 39424 invoked by uid 99); 9 Dec 2010 16:52:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Dec 2010 16:52:18 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bimargulies@gmail.com designates 209.85.214.52 as permitted sender) Received: from [209.85.214.52] (HELO mail-bw0-f52.google.com) (209.85.214.52) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Dec 2010 16:52:11 +0000 Received: by bwz4 with SMTP id 4so2885793bwz.25 for ; Thu, 09 Dec 2010 08:51:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=vtGOpvcMAirCzhPhVEW0ZCRglBeflgMqJ/7lGHF98so=; b=FiwhOzstoppMpbb2cPgtCGQ6ZBWXhgSoGZ5U49y35zsy7pTkOudj+0uNUgViSMb2e3 OAJGYvs0/1xCOaiVCxVV/d9pzeHiIaeeeE9tinZO5cLgLDahTjst07dF87mwU7PRMUMN QoBZAXHIcHiWngcrF5ozZtvApjErrgmW0NKlE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=RfNiEOMX0cr0gF1S+b78gV4dAnwS58WwX4YrwPsq8vAf2eQj3g73mIpVW0oPAfApCS IuBSgoS72dzUCBIQyT8so9o6LB+1td6MwKqArofPNXLHpypPJh9jcGuguXCP3eTPfRaS IIO0A2IG4RDUKmA1tSm1jmXD+bcQU959D41fI= MIME-Version: 1.0 Received: by 10.204.118.138 with SMTP id v10mr3594988bkq.94.1291913509882; Thu, 09 Dec 2010 08:51:49 -0800 (PST) Received: by 10.204.45.66 with HTTP; Thu, 9 Dec 2010 08:51:49 -0800 (PST) In-Reply-To: <1291910679.2462.161.camel@dave-desktop> References: <1291910679.2462.161.camel@dave-desktop> Date: Thu, 9 Dec 2010 11:51:49 -0500 Message-ID: Subject: Re: I think I've got some pretty basic confusion with reading into models From: Benson Margulies To: jena-users@incubator.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 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_? 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? 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. 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. --benson On Thu, Dec 9, 2010 at 11:04 AM, Dave Reynolds wrote: > Hi Benson, > > On Thu, 2010-12-09 at 09:11 -0500, Benson Margulies wrote: >> Here's a little RDF snippet: >> >> > =C2=A0 =C2=A0 xmlns:rdf=3D"http://www.w3.org/1999/02/22-rdf-syntax-ns#" >> =C2=A0 =C2=A0 xmlns:rex=3D"http://www.basistech.com/ontologies/2010/6/re= x.owl#" >> =C2=A0 =C2=A0 xmlns:owl=3D"http://www.w3.org/2002/07/owl#" >> =C2=A0 =C2=A0 xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema#" >> =C2=A0 =C2=A0 xmlns:rdfs=3D"http://www.w3.org/2000/01/rdf-schema#"> >> =C2=A0 >> =C2=A0 =C2=A0 > =C2=A0 =C2=A0 >Pakistan >> =C2=A0 =C2=A0 > rdf:datatype=3D"http://www.w3.org/2001/XMLSchema#string" >> =C2=A0 =C2=A0 >Pakistan >> =C2=A0 =C2=A0 > rdf:datatype=3D"http://www.w3.org/2001/XMLSchema#string" >> =C2=A0 =C2=A0 >gazetteer:../../../bt_root/rlp/rlp/dicts/en-all-gazetteer= -LE.bin >> =C2=A0 >> >> >> The following rather trivial test fails. I'm sure I'm just befuddled, >> could some kind soul rescue me? >> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 OntModel model =3D ModelFactory.createOntolo= gyModel(); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 model.read(rdfStream, "", "RDF/XML-ABBREV"); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 ExtendedIterator individuals =3D= model.listIndividuals(); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 int individualCount =3D 0; >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 while (individuals.hasNext()) { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 individualCount++; >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 } >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 assertTrue("Should have more than two indivi= duals, 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: > > =C2=A0 =C2=A0 =C2=A0 OntModel model =3D > ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM); > =C2=A0 =C2=A0 =C2=A0 =C2=A0model.read("file:data/temp2.rdf", "", "RDF/XML= -ABBREV"); > > =C2=A0 =C2=A0 =C2=A0 =C2=A0ExtendedIterator nodes =3D > model.listObjects().andThen( model.listSubjects() ); > =C2=A0 =C2=A0 =C2=A0 =C2=A0int count =3D 0; > =C2=A0 =C2=A0 =C2=A0 =C2=A0while ( nodes.hasNext() ) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (nodes.next().isResource()) c= ount ++; > =C2=A0 =C2=A0 =C2=A0 =C2=A0} > > > 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 > > >