LoginSignup
7

More than 5 years have passed since last update.

日本の野球選手の出身高校を列挙するクエリの例

Last updated at Posted at 2015-07-14

PREFIX dbp-owl: <http://dbpedia.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dbpprop-ja: <http://ja.dbpedia.org/property/>
PREFIX dbp-category: <http://ja.dbpedia.org/resource/Category:>
PREFIX dbp-template: <http://ja.dbpedia.org/resource/Template:>

select distinct ?label ?team_label
where {

    #対象は日本人の野球選手
    {
        ?person dcterms:subject dbp-category:日本の野球選手 .
    } union {
        ?person dcterms:subject dbp-category:MLBの日本人選手 .
    } union {
        ?person dcterms:subject dbp-category:在日外国人の野球選手 .
    } union {
        ?person dcterms:subject dbp-category:日系人の野球選手 .
    }


    ?person rdfs:label ?label ;
        dbp-owl:team ?team.
    # リダイレクトページの可能性を疑う
    {
        ?team dbp-owl:wikiPageRedirects ?redirects .
        ?redirects dbpprop-ja:wikiPageUsesTemplate dbp-template:日本の高等学校 ;
            rdfs:label ?team_label .
    } union {
        ?team dbpprop-ja:wikiPageUsesTemplate dbp-template:日本の高等学校 ;
            rdfs:label ?team_label .
    }
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7