Skip to content

Instantly share code, notes, and snippets.

@egonw
Last active November 13, 2022 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egonw/1c8bc99373a24075838ee19976c74856 to your computer and use it in GitHub Desktop.
Save egonw/1c8bc99373a24075838ee19976c74856 to your computer and use it in GitHub Desktop.
# tool: scholia
# / defaultView:Graph
PREFIX target: <http://www.wikidata.org/entity/Q30149558>
SELECT
?citing_work ?citing_workLabel ?grey ?padded_grey ?rgb
?cited_work ?cited_workLabel
WITH {
SELECT (COUNT(*) AS ?count) ?citing_work WHERE {
?citing_work wdt:P1433 wd:Q6294930 ;
p:P2860 [
ps:P2860 ?cited_work ;
pq:P3712 wd:Q96472102
] .
}
GROUP BY ?citing_work
ORDER BY DESC(?count)
LIMIT 40
} AS %citing_works
WITH {
SELECT (COUNT(*) AS ?count_) ?cited_work WHERE {
?citing_work wdt:P1433 wd:Q6294930 ;
p:P2860 [
ps:P2860 ?cited_work ;
pq:P3712 wd:Q96472102
] .
}
GROUP BY ?cited_work
ORDER BY DESC(?count_)
LIMIT 40
} AS %cited_works
WITH {
SELECT (MAX(?count) AS ?max_count) WHERE {
INCLUDE %citing_works
BIND(1 AS ?dummy)
}
GROUP BY ?dummy
} AS %max_count
WHERE {
INCLUDE %citing_works
INCLUDE %max_count
INCLUDE %cited_works
?citing_work wdt:P2860 ?cited_work .
BIND(STR(xsd:integer(40 + 50 * (1 - ?count / ?max_count))) AS ?grey)
BIND(CONCAT(SUBSTR("0", 1, 2 - STRLEN(?grey)), ?grey) AS ?padded_grey)
BIND(CONCAT(?padded_grey, "00", "00") AS ?rgb)
{
?citing_work (p:P50) ?citing_author_statement .
?citing_author_statement pq:P1545 "1" .
?citing_author_statement ps:P50 ?citing_author .
?citing_author rdfs:label ?citing_author_name .
filter(lang(?citing_author_name) = 'en')
}
union
{
?citing_work (p:P2093) ?citing_author_statement .
?citing_author_statement pq:P1545 "1" .
?citing_author_statement ps:P2093 ?citing_author_name .
}
{
?cited_work (p:P50) ?cited_author_statement .
?cited_author_statement pq:P1545 "1" .
?cited_author_statement ps:P50 ?cited_author .
?cited_author rdfs:label ?cited_author_name .
filter(lang(?cited_author_name) = 'en')
}
union
{
?cited_work (p:P2093) ?cited_author_statement .
?cited_author_statement pq:P1545 "1" .
?cited_author_statement ps:P2093 ?cited_author_name .
}
?citing_work wdt:P577 ?citing_date .
?cited_work wdt:P577 ?cited_date .
bind(year(?citing_date) as ?citing_year)
bind(year(?cited_date) as ?cited_year)
bind(concat(?citing_author_name, ", ", str(?citing_year)) as ?citing_workLabel)
bind(concat(?cited_author_name, ", ", str(?cited_year)) as ?cited_workLabel)
}
ORDER BY DESC(?count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment