query-459128999faf22a86ed90a328e278e87

rq turtle/ttl

This query takes a list of article in Wikipedia, analyse the gender of all entities cited in the article and count the share of males, females and non binary.

The goal is to measure gender diversity inside wikipedia articles

Feedback and comments are welcome on my talk page User:PAC2

SELECT ?article (SUM(?female) AS ?count_females) (SUM(?male) AS ?count_males) (SUM(?nonbinary) AS ?count_nonbinary) (SUM(?intersexual) AS ?count_intersexual) (COUNT(*) AS ?count) (ROUND(100 * ?count_females / ?count) AS ?share_females) (ROUND(100 * ?count_males / ?count) AS ?share_males) (ROUND(100 * ?count_nonbinary / ?count) AS ?share_nonbinary) (ROUND(100 * ?count_intersexual / ?count) AS ?share_intersexual) { VALUES ?article { "Anthropology" "Philosophy" "Economics" "Sociology" "Demography" } SERVICE wikibase:mwapi { bd:serviceParam wikibase:endpoint "en.wikipedia.org"; wikibase:api "Generator"; mwapi:generator "links"; mwapi:titles ?article;. ?item wikibase:apiOutputItem mwapi:item. } FILTER BOUND (?item) ?item wdt:P31 wd:Q5 . ?item wdt:P21 ?gender . BIND(IF(?gender IN(wd:Q6581097, wd:Q2449503), 1, 0) AS ?male ) BIND(IF(?gender IN(wd:Q6581072, wd:Q1052281), 1, 0 ) AS ?female) BIND(IF(?gender = wd:Q48270, 1, 0) AS ?nonbinary) BIND(IF(?gender = wd:Q1097630, 1,0) AS ?intersexual) } GROUP BY ?article

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# This query takes a list of article in Wikipedia, analyse the gender of all entities cited in the article and count the share of males, females and non binary.
# The goal is to measure gender diversity inside wikipedia articles
# Feedback and comments are welcome on my talk page User:PAC2
SELECT ?article
(SUM(?female) AS ?count_females) 
(SUM(?male) AS ?count_males)
(SUM(?nonbinary) AS ?count_nonbinary) 
(SUM(?intersexual) AS ?count_intersexual) 
(COUNT(*) AS ?count) 
(ROUND(100 * ?count_females / ?count) AS  ?share_females) 
(ROUND(100 * ?count_males / ?count) AS  ?share_males) 
(ROUND(100 * ?count_nonbinary / ?count) AS  ?share_nonbinary)
(ROUND(100 * ?count_intersexual / ?count) AS ?share_intersexual)
{
  VALUES ?article {
  "Anthropology"
  "Philosophy"
  "Economics"
  "Sociology"
  "Demography"
  }
  SERVICE wikibase:mwapi {
     bd:serviceParam wikibase:endpoint "en.wikipedia.org";
                     wikibase:api "Generator";
                     mwapi:generator "links";
                     mwapi:titles ?article;.
     ?item wikibase:apiOutputItem mwapi:item.
  } 
  FILTER BOUND (?item)
  ?item wdt:P31 wd:Q5 . 
  ?item wdt:P21 ?gender . 
  BIND(IF(?gender IN(wd:Q6581097, wd:Q2449503), 1, 0) AS ?male ) 
  BIND(IF(?gender IN(wd:Q6581072, wd:Q1052281), 1, 0 ) AS ?female)
  BIND(IF(?gender = wd:Q48270, 1, 0) AS ?nonbinary) 
  BIND(IF(?gender = wd:Q1097630, 1,0) AS ?intersexual)
}
GROUP BY ?article

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?article"):::projected v12("?count"):::projected v8("?count_females"):::projected v11("?count_intersexual"):::projected v9("?count_males"):::projected v10("?count_nonbinary"):::projected v5("?female"):::projected v3("?gender") v7("?intersexual"):::projected v1("?item") v4("?male"):::projected v6("?nonbinary"):::projected v13("?share_females") v16("?share_intersexual") v14("?share_males") v15("?share_nonbinary") c11(["mwapi:item"]):::iri c4(["en.wikipedia.org"]):::literal c2(["bd:serviceParam"]):::iri c13(["wd:Q5"]):::iri c8(["links"]):::literal c6(["Generator"]):::literal f0[["bound(?item)"]] f0 --> v1 bind1[/VALUES ?article/] bind1-->v2 bind10(["Anthropology"]) bind10 --> bind1 bind11(["Philosophy"]) bind11 --> bind1 bind12(["Economics"]) bind12 --> bind1 bind13(["Sociology"]) bind13 --> bind1 bind14(["Demography"]) bind14 --> bind1 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c2 --"mwapi:endpoint"--> c4 c2 --"mwapi:api"--> c6 c2 --"mwapi:generator"--> c8 c2 --"mwapi:titles"--> v2 v1 --"mwapi:apiOutputItem"--> c11 end v1 --"wdt:P31"--> c13 v1 --"wdt:P21"--> v3 list0c2(["wd:Q2449503"]):::iri list0c1(["wd:Q6581097"]):::iri list0c1 --o bind2 list0c2 --o bind2 bind2[/"if( in ,'1^^xsd:integer','0^^xsd:integer')"/] v3 --o bind2 bind2 --as--o v4 list1c2(["wd:Q1052281"]):::iri list1c1(["wd:Q6581072"]):::iri list1c1 --o bind3 list1c2 --o bind3 bind3[/"if( in ,'1^^xsd:integer','0^^xsd:integer')"/] v3 --o bind3 bind3 --as--o v5 bind4[/"if(?gender = 'wd:Q48270','1^^xsd:integer','0^^xsd:integer')"/] v3 --o bind4 bind4 --as--o v6 bind5[/"if(?gender = 'wd:Q1097630','1^^xsd:integer','0^^xsd:integer')"/] v3 --o bind5 bind5 --as--o v7 bind11[/"sum(?female)"/] v5 --o bind11 bind11 --as--o v8 bind12[/"sum(?male)"/] v4 --o bind12 bind12 --as--o v9 bind13[/"sum(?nonbinary)"/] v6 --o bind13 bind13 --as--o v10 bind14[/"sum(?intersexual)"/] v7 --o bind14 bind14 --as--o v11 bind15[/"count(*)"/] bind15 --as--o v12 bind16[/"numeric-round('100^^xsd:integer' * ?count_females / ?count)"/] v8 --o bind16 v12 --o bind16 bind16 --as--o v13 bind17[/"numeric-round('100^^xsd:integer' * ?count_males / ?count)"/] v9 --o bind17 v12 --o bind17 bind17 --as--o v14 bind18[/"numeric-round('100^^xsd:integer' * ?count_nonbinary / ?count)"/] v10 --o bind18 v12 --o bind18 bind18 --as--o v15 bind19[/"numeric-round('100^^xsd:integer' * ?count_intersexual / ?count)"/] v11 --o bind19 v12 --o bind19 bind19 --as--o v16