query-a5fc0e33e327dc99f5ffaa8d04d0b08f
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
- https://query.wikidata.org/sparql
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)