Andy, Thanks. Two followups:
1) Since I just want all the tuples, is there any advantage of DESCRIBE over CONSTRUCT? 2) What would I read to learn about BIND? I don't think I saw it in the overview. --benson On Mon, Dec 27, 2010 at 11:47 AM, Andy Seaborne <[email protected]> wrote: > > > On 27/12/10 03:15, Benson Margulies wrote: >> >> Goal here: (a) all triples with a subject which has a >> 'hasNormalizedText' of "Kerr" and also (b) all triples with a subject >> which 'is owl:sameAs' one of the subjects from (a). Inference is not >> turned on, so I have to (?) do this myself. I seem to be stuck on how >> to get the rest of the triples for the subjects that pass the sameAs >> test. > > It will depend on which way round the owl:sameAs is written so you will need > to two cases for subject/object and object/subject. > > CONSTRUCT{ ?s ?p ?o } > WHERE > { > GRAPH x-arq:UnionGraph { > > # Items of interest. > ?entity rex:hasNormalizedText "Kerr" . > #sets ?s by direct reference. > { BIND(?entity AS ?s} } > UNION > # sets ?s by forward owl:sameAs > { ?s owl:sameAs ?entity } > UNION > # sets ?s by backward owl:sameAs > { ?entity owl:sameAs ?s } > # All triples of the subject > ?s ?p ?o . > } > > > But it's weak in that only zero or one step of owl:sameAs is done. > > Using property paths for any number of owl:sameAs in either direction should > work: > > CONSTRUCT { ?s ?p ?o } > { > GRAPH x-arq:UnionGraph { > ?entity rex:hasNormalizedText "Kerr" . > ?entity (owl:sameAs|^owl:sameAs)* ?s > ?s ?p ?o . > } > } > > > Andy > >> >> PREFIX rex:<http://www.basistech.com/ontologies/2010/6/rex.owl#> >> PREFIX owl:<http://www.w3.org/2002/07/owl#> >> PREFIX x-arq:<urn:x-arq:> >> >> CONSTRUCT { >> # all tuples with the selected entity as a subject >> ?entity ?pred ?val . >> ?corefEntity owl:sameAs ?entity . >> } >> WHERE >> { >> GRAPH x-arq:UnionGraph { >> ?entity rex:hasNormalizedText "Kerr" . >> OPTIONAL { ?entity ?pred ?val } >> OPTIONAL { ?corefEntity owl:sameAs ?entity } >> } >> } >
