Wikidata:WikiProject Terrorism/Queries

From Wikidata
Jump to navigation Jump to search

Home

 

Properties

 

Todo

 

Queries

 

SPARQL queries :

All terrorist organizations[edit]

SELECT DISTINCT
  (SAMPLE(?item) as ?item)
  (SAMPLE(COALESCE(?en_label, ?any_label)) as ?name)
  (SAMPLE(?inception) as ?inception)
  (SAMPLE(?end) as ?end)
  (SAMPLE(?organization) as ?organization)
  (SAMPLE(?allegiance) as ?allegiance)
  (SAMPLE(?image) as ?image)
  (SAMPLE(?class) as ?class)
WHERE {
  ?class wdt:P279* wd:Q17127659.
  ?item p:P31/ps:P31 ?class. # Occupation: terrorist organization and its potential sub-classes.
  OPTIONAL {?item rdfs:label ?en_label. FILTER(LANG(?en_label) = "en")} OPTIONAL {?item rdfs:label ?any_label}
  OPTIONAL {?item wdt:P571 ?inception}
  OPTIONAL {?item wdt:P582 ?end}
  OPTIONAL {?item wdt:P463 ?organization}
  OPTIONAL {?item wdt:P945 ?allegiance}
  OPTIONAL {?item wdt:P18 ?image}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?item ORDER BY DESC(?inception)
Try it!

All terror attacks[edit]

SELECT DISTINCT
  (SAMPLE(?item) as ?item)
  (SAMPLE(?class_en_label) as ?class)
  (SAMPLE(COALESCE(?armament_en_label, ?armament_any_label)) as ?armament)
  (SAMPLE(?date) as ?date)
  (SAMPLE(?injured) as ?injured)
  (SAMPLE(?deaths) as ?deaths)
  (SAMPLE(?participant_en_label) as ?participant)
  (SAMPLE(?target_en_label) as ?target)
  (SAMPLE(?coordinates) as ?coordinates)
  (SAMPLE(?location_en_label) as ?location)
  (SAMPLE(?country_en_label) as ?country)
  (SAMPLE(?image) as ?image)
  (SAMPLE(COALESCE(?en_label, ?any_label)) as ?name)
  #(SAMPLE(COALESCE(?en_description, ?item_description)) as ?description)
WHERE {
  ?item p:P31/ps:P31/wdt:P279* wd:Q5710433. # Terrorist attack and all of its sub-classes
  ?item p:P31/ps:P31 ?class. OPTIONAL {?class rdfs:label ?class_en_label. FILTER(LANG(?class_en_label) = "en")}
  OPTIONAL {?item wdt:P585 ?date}
  OPTIONAL {?item wdt:P1339 ?injured}
  OPTIONAL {?item wdt:P1120 ?deaths}
  OPTIONAL {?item wdt:P710 ?participant. ?participant rdfs:label ?participant_en_label. FILTER(LANG(?participant_en_label) = "en")}
  OPTIONAL {?item wdt:P533 ?target. ?target rdfs:label ?target_en_label. FILTER(LANG(?target_en_label) = "en")}
  OPTIONAL {?item wdt:P625 ?coordinates}
  OPTIONAL {?item wdt:P276 ?location. ?location rdfs:label ?location_en_label. FILTER(LANG(?location_en_label) = "en")}
  OPTIONAL {?item wdt:P17 ?country. ?country rdfs:label ?country_en_label. FILTER(LANG(?country_en_label) = "en")}
  OPTIONAL {?item wdt:P18 ?image.}
  OPTIONAL {?item wdt:P520 ?armament. ?armament rdfs:label ?armament_en_label. FILTER(LANG(?armament_en_label) = "en").}
  OPTIONAL {?item rdfs:label ?en_label. FILTER(LANG(?en_label) = "en")} OPTIONAL {?item rdfs:label ?any_label}
  OPTIONAL {?item wdt:P4089 ?GDT_id.}
  #OPTIONAL {?item schema:description ?en_description. FILTER(LANG(?en_description) = "en"). ?item schema:description ?item_description}
}
GROUP BY ?item ORDER BY DESC(?date)
Try it!

All terror attacks in France[edit]

SELECT DISTINCT ?subj ?subjLabel ?subjDescription ?date ?blesses ?morts ?paysLabel ?GDT_id WHERE {
  {
    ?subj wdt:P31 wd:Q5710433.
  } UNION {
  	?subj wdt:P31 wd:Q18493502.
  } UNION {
  	?subj wdt:P31 wd:Q1371150.
  } UNION {
  	?subj wdt:P31 wd:Q897797.
  } UNION {
  	?subj wdt:P31 wd:Q25917186.
  } UNION {
  	?subj wdt:P31 wd:Q21480300.
  } UNION {
  	?subj wdt:P31 wd:Q217327.
  } UNION {
  	?subj wdt:P31 wd:Q891854.
  } UNION {
  	?subj wdt:P31 wd:Q750215.
  } UNION {
  	?subj wdt:P31 wd:Q18711682.
  } UNION {
  	?subj wdt:P31 wd:Q384080.
  } UNION {
  	?subj wdt:P31 wd:Q28945444.
  } UNION {
        ?subj wdt:P31 wd:Q81672.
  } UNION {
        ?subj wdt:P31 wd:Q53706.
  }
  ?subj wdt:P17 wd:Q142.
  OPTIONAL { ?subj wdt:P585 ?date. }
  OPTIONAL { ?subj wdt:P17 ?pays. }
  OPTIONAL { ?subj wdt:P1339 ?blesses. }
  OPTIONAL { ?subj wdt:P1120 ?morts. }
  OPTIONAL { ?subj wdt:P4089 ?GDT_id.}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "fr". }
}
ORDER BY ?date
LIMIT 1000
Try it!

All terrorists[edit]

SELECT ?item ?itemLabel ?birth ?death ?organizationLabel ?allegianceLabel ?image ?occupationLabel WHERE {
  ?occupation wdt:P279* wd:Q14886050.
  ?item wdt:P106 ?occupation. # Occupation: terrorist and its potential sub-classes.
  OPTIONAL {?item wdt:P569 ?birth}
  OPTIONAL {?item wdt:P570 ?death}
  OPTIONAL {?item wdt:P463 ?organization}
  OPTIONAL {?item wdt:P945 ?allegiance}
  OPTIONAL {?item wdt:P18 ?image}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY DESC(?birth)
Try it!