Constructing all Wikidata triples in SPARQL that h

2019-08-20 02:55发布

问题:

I am trying to return a list of triples by using a construct query in the Wikidata SPARQL query service. I want all triples of people who have a GTAA_ID identifier. In addition to this, of all people who have a GTAA_ID, I want all triples containing the person with a GTAA_ID as the subject + all combinations of predicates and objects.

Take the following example: Tom Hanks has a GTAA_ID (identifier). Tom Hanks also has a lot of other statements and identifiers in Wikidata. I want to retrieve everything that has to do with Tom Hanks (as he has a GTAA_ID).

So for example:

Tom Hanks | GTAA_ID    | 106942
Tom Hanks | residence  | Los Angeles
Tom Hanks | residence  | Oakland
Tom Hanks | occupation | film actor
Tom Hanks | occupation | film director

and so on..

The example query Wikidata give (for all triples to do with Asthma) is:

#CONSTRUCT query to get the RDF graph for a Wikidata item (e.g. asthma)
CONSTRUCT {
  wd:Q35869 ?p ?o .
  ?o ?qualifier ?f .
  ?o prov:wasDerivedFrom ?u .
  ?u ?a ?b .
}
WHERE {
  wd:Q35869 ?p ?o .
  OPTIONAL {?o ?qualifier ?f .}
  OPTIONAL {?o prov:wasDerivedFrom ?u .
  ?u ?a ?b .}
}

This returns a list of triples that has to do with the item 'Asthma'. However, what I want to do is return a list of triples where the item is a person with a GTAA_ID.

This is the code which returns all subjects with the corresponding GTAA_ID:

CONSTRUCT {
  ?s ps:1741 ?o .
  }
WHERE {
  ?s ps:P1741 ?o.
  }

and the link to the Wikidata SPARQL Query Service

Many thanks in advance!