query-a5fc0e33e327dc99f5ffaa8d04d0b08f

rq turtle/ttl

Several query requests in one https://sengoku.netlify.app/#Not sure if I should post several query request. Since they are related I thought I would just post one. I am trying to finish my site. https://w.wiki/cjqSo, I'm trying to refine the query: Many thanks to the help I've gotten so far. These are my request: Get images(optional) for each participant. Use only 1 coordinate location for each item. Create a column called ‘type’ for ‘battle’, ‘siege’, ‘military campaign’. Get english or Japanese Wikipedia url links Can I get Coordinate location(P625) of location (PP276). I would like to get the Battles, sieges, and campaigns of the Sengoku Period. So what I did was query the 'part of' (P361) | 'time period'(P2348) of the Sengoku Period(Q204023). However, some of the results are people from this period. Is there a way to subtract people from the query or should I just use a UNION of 'instance of' for 'battle', 'siege', and 'military campaign'.I know this is query is long. Hopefully its ok. Thanks in advance. Template:Nonoumasy10:34, 19 September 2020 (UTC)) talk (Nonoumasy--

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?battle ?battleLabel 
  ?type ?typeLabel 
  ?wikipedia_link_en ?wikipedia_link_ja 
  (YEAR(?year) as ?someyear)
  (SAMPLE(?coordinates) as ?some_coordinates)
  (GROUP_CONCAT(DISTINCT ?participantLabel; SEPARATOR = " // ") AS ?participants)
  (SAMPLE(?image) as ?some_image)
WHERE
{
  { ?battle (wdt:P361 | wdt:P2348) wd:Q204023. }
  FILTER NOT EXISTS {  ?battle wdt:P31 wd:Q5 } #exclude people
  # ?battle wdt:P31/wdt:P279* wd:Q645883 .     #only military operations or subtypes 
  OPTIONAL { ?battle wdt:P31 ?type }
  OPTIONAL { ?battle wdt:P710 ?participant. 
              OPTIONAL { ?participant wdt:P18 ?image }

           }
  ?battle (wdt:P585 | wdt:P580) ?year. 
  OPTIONAL { ?battle wdt:P625 ?coordinates0. }
  OPTIONAL { ?battle wdt:P276 / wdt:P625 ?coordinates1. }
  BIND( COALESCE(?coordinates0, ?coordinates1) as ?coordinates)
  OPTIONAL { ?wikipedia_link_en schema:about ?battle ; schema:isPartOf <https://en.wikipedia.org/>. }
  OPTIONAL { ?wikipedia_link_ja schema:about ?battle ; schema:isPartOf <https://ja.wikipedia.org/>. } 
  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,ja".
    ?battle rdfs:label ?battleLabel.
    ?participant rdfs:label ?participantLabel.
    ?type rdfs:label ?typeLabel.
  }
}
GROUP BY ?battle ?battleLabel  ?type ?typeLabel ?wikipedia_link_en ?wikipedia_link_ja ?year ?typeBattle
ORDER BY (?year)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?battle"):::projected v11("?battleLabel"):::projected v8("?coordinates"):::projected v6("?coordinates0") v7("?coordinates1") v5("?image"):::projected v4("?participant") v12("?participantLabel"):::projected v16("?participants") v15("?some_coordinates") v17("?some_image") v14("?someyear") v3("?type"):::projected v13("?typeLabel"):::projected v9("?wikipedia_link_en"):::projected v10("?wikipedia_link_ja"):::projected v1("?year"):::projected a1((" ")) c4(["wd:Q204023"]):::iri c19(["#91;AUTO_LANGUAGE#93;,en,ja"]):::literal c14([https://en.wikipedia.org/]):::iri c17(["bd:serviceParam"]):::iri c2(["wd:Q5"]):::iri c15([https://ja.wikipedia.org/]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"wdt:P31"--> e0c2 e0v1("?battle"):::projected e0c2(["wd:Q5"]):::iri end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> c2 v2 --"wdt:P31"--> c2 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P2348"--> c4 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P361"--> c4 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P31".-> v3 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P710".-> v4 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v4 -."wdt:P18".-> v5 end end subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P580"--> v1 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P585"--> v1 end union1r <== or ==> union1l end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P625".-> v6 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P276".-> a1 a1 --"wdt:P625"--> v7 end bind1[/"?coordinates0?coordinates1"/] v6 --o bind1 v7 --o bind1 bind1 --as--o v8 subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v9 -."schema:about".-> v2 v9 --"schema:isPartOf"--> c14 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v10 -."schema:about".-> v2 v10 --"schema:isPartOf"--> c15 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c17 --"wikibase:language"--> c19 v2 --"rdfs:label"--> v11 v4 --"rdfs:label"--> v12 v3 --"rdfs:label"--> v13 end bind5[/"year-from-dateTime(?year)"/] v1 --o bind5 bind5 --as--o v14 bind6[/"sample(?coordinates)"/] v8 --o bind6 bind6 --as--o v15 bind7[/"?participantLabel"/] v12 --o bind7 bind7 --as--o v16 bind8[/"sample(?image)"/] v5 --o bind8 bind8 --as--o v17