- From: Miguel <miguel.ceriani@gmail.com>
- Date: Wed, 08 Jul 2015 15:49:29 +0000
- To: Olivier Rossel <olivier.rossel@gmail.com>, public-sparql-dev@w3.org
- Message-ID: <CALWU=RsqW-nNhQ-C0ddfzwTGbjbjjGMJ4bf27ncjzdcnQrCA0g@mail.gmail.com>
Hi Olivier, EDIT: I have read just now the reply from Jeremy that is along the same lines of mine; I am sending mine anyway to complement his reply as I made some tests with dbpedia live. I have some good news and some bad news for you. Good news is that you can express that query in SPARQL using negation (FILTER NOT EXISTS), bad news is that the results from DBPedia won't be what you probably expect. In SPARQL you don't have a direct way to say "take all the types s.t., for each one of them and any object of the actor property, that object belong to that type". But you can do that in an indirect way using double negation: SELECT DISTINCT ?typeOfActor WHERE { [] <http://dbpedia.org/property/actor> ?actor. ?actor a ?typeOfActor. FILTER NOT EXISTS{ [] <http://dbpedia.org/property/actor> ?otherActor. FILTER NOT EXISTS { ?otherActor a ?typeOfActor. } } } While I am very proud of this query (and I hope it is right, but should be...), sadly it does not give any result. As a fact, strange as it may seem, in DBPedia there is no type common to all the objects of the property <http://dbpedia.org/property/actor>. You can look for the most popular types with a query like this: SELECT ?typeOfActor (COUNT(*) AS ?typeCount) WHERE { SELECT DISTINCT ?actor ?typeOfActor WHERE { [] <http://dbpedia.org/property/actor> ?actor. ?actor a ?typeOfActor. } } GROUP BY ?typeOfActor ORDER BY DESC (?typeCount) LIMIT 100 Among the most popular ones, <http://dbpedia.org/ontology/Person> could be a good candidate because it is part of the dbpedia ontology and you can expect an actor is always a person. But if you run the following query you can find a lot of exceptions: SELECT DISTINCT ?actor WHERE { [] <http://dbpedia.org/property/actor> ?actor. FILTER NOT EXISTS{ ?actor a <http://dbpedia.org/ontology/Person>. } } LIMIT 100 Most of the results, as a fact, represent persons but are not typed as such. In a lot of cases they are plain literals with the name of the actor. Miguel Il giorno mer 8 lug 2015 alle ore 16:45 Olivier Rossel < olivier.rossel@gmail.com> ha scritto: > Hi all. > > I wonder how I can get an intersection in SPARQL. > > Here is the use case: > In DBPedia, there is a predicate called <http://dbpedia.org/property/actor > >. > > In this triple pattern: > ?s <http://dbpedia.org/property/actor> ?actor . ?actor a ?typeOfActor > > ?typeOfActor can be: > > http://www.w3.org/2002/07/owl#Thing > http://schema.org/Person > http://xmlns.com/foaf/0.1/Person > http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#Agent > http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#NaturalPerson > http://wikidata.dbpedia.org/resource/Q215627 > http://wikidata.dbpedia.org/resource/Q5 > http://dbpedia.org/ontology/Agent > http://dbpedia.org/ontology/Person > http://dbpedia.org/class/yago/Actor109765278 > http://dbpedia.org/class/yago/ActorsFromLiverpool > http://dbpedia.org/class/yago/Adult109605289 > http://dbpedia.org/class/yago/CausalAgent100007347 > http://dbpedia.org/class/yago/Educator110045713 > http://dbpedia.org/class/yago/Entertainer109616922 > http://dbpedia.org/class/yago/LivingThing100004258 > http://dbpedia.org/class/yago/Object100002684 > http://dbpedia.org/class/yago/Organism100004475 > http://dbpedia.org/class/yago/Performer110415638 > http://dbpedia.org/class/yago/Person100007846 > http://dbpedia.org/class/yago/Professional110480253 > http://dbpedia.org/class/yago/Teacher110694258 > http://dbpedia.org/class/yago/Whole100003553 > http://dbpedia.org/class/yago/YagoLegalActorGeo > > My need is to retrieve only the ?typeOfActor that are common to all > the ?actor(s). > > I still have no clue how to do that in SPARQL. > > Any help would be very welcome. > > (and any strategy to do that in SPARQL 1.0 would be interesting too) > >
Received on Wednesday, 8 July 2015 15:50:09 UTC