From 3688b147c6902e8651597aea51a428e6526bd1e7 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Thu, 15 Jun 2023 14:34:49 +0100 Subject: [PATCH 1/9] Add WikiProject aspect --- scholia/app/templates/wikiproject.html | 24 +++++++++++++++++++ .../app/templates/wikiproject_types.sparql | 13 ++++++++++ scholia/app/views.py | 18 ++++++++++++++ scholia/query.py | 2 ++ 4 files changed, 57 insertions(+) create mode 100644 scholia/app/templates/wikiproject.html create mode 100644 scholia/app/templates/wikiproject_types.sparql diff --git a/scholia/app/templates/wikiproject.html b/scholia/app/templates/wikiproject.html new file mode 100644 index 000000000..1e05baf0a --- /dev/null +++ b/scholia/app/templates/wikiproject.html @@ -0,0 +1,24 @@ +{% extends "base.html" %} + +{% set aspect = 'wikiproject' %} + +{% block in_ready %} + +{{ sparql_to_table("types") }} + +{% endblock %} + + + +{% block page_content %} + +

WikiProject

+ +
+ +

Types maintained by this WikiProject

+ +
+ + +{% endblock %} \ No newline at end of file diff --git a/scholia/app/templates/wikiproject_types.sparql b/scholia/app/templates/wikiproject_types.sparql new file mode 100644 index 000000000..3e8594bc5 --- /dev/null +++ b/scholia/app/templates/wikiproject_types.sparql @@ -0,0 +1,13 @@ +SELECT ?type ?typeLabel ?count WITH { + SELECT DISTINCT ?type (COUNT(?item) AS ?count) WHERE { + ?item wdt:P6104 wd:{{ q }}; + (wdt:P31|wdt:P279) ?type. + } + GROUP BY ?type ?count + ORDER BY DESC (?count) +} AS %result +WHERE { + INCLUDE %result + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,da,de,es,fr,it,sv,uk,zh". } +} +ORDER BY DESC (?count) \ No newline at end of file diff --git a/scholia/app/views.py b/scholia/app/views.py index 2915dfda3..6dc099424 100644 --- a/scholia/app/views.py +++ b/scholia/app/views.py @@ -2465,6 +2465,24 @@ def show_about(): return render_template('about.html') +@main.route('/wikiproject/' + q_pattern) +def show_wikiproject(q): + """Return rendered HTML page for specific WikiProject. + + Parameters + ---------- + q : str + Wikidata item identifier + + Returns + ------- + html : str + Rendered HTML page for specific WikiProject. + + """ + return render_template('wikiproject.html', q=q) + + @main.route('/favicon.ico') def show_favicon(): """Detect and redirect for the favicon.ico.""" diff --git a/scholia/query.py b/scholia/query.py index 75a84d7fb..63497c8a4 100644 --- a/scholia/query.py +++ b/scholia/query.py @@ -1292,6 +1292,8 @@ def q_to_class(q): 'Q22325163', # macromolecular complex ]): class_ = 'complex' + elif ('Q16695773' in classes): # human + class_ = 'wikiproject' else: query = 'select ?class where {{ wd:{q} wdt:P279+ ?class }}'.format( q=escape_string(q)) From 44de82e6091f5a84d65b470edfa07d7391f9c0ea Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Thu, 15 Jun 2023 15:07:57 +0100 Subject: [PATCH 2/9] Add types on focus list --- scholia/app/templates/wikiproject.html | 52 +++++++++++-------- .../app/templates/wikiproject_focus.sparql | 13 +++++ ...s.sparql => wikiproject_maintained.sparql} | 24 ++++----- 3 files changed, 54 insertions(+), 35 deletions(-) create mode 100644 scholia/app/templates/wikiproject_focus.sparql rename scholia/app/templates/{wikiproject_types.sparql => wikiproject_maintained.sparql} (97%) diff --git a/scholia/app/templates/wikiproject.html b/scholia/app/templates/wikiproject.html index 1e05baf0a..8373cf404 100644 --- a/scholia/app/templates/wikiproject.html +++ b/scholia/app/templates/wikiproject.html @@ -1,24 +1,30 @@ -{% extends "base.html" %} - -{% set aspect = 'wikiproject' %} - -{% block in_ready %} - -{{ sparql_to_table("types") }} - -{% endblock %} - - - -{% block page_content %} - -

WikiProject

- -
- -

Types maintained by this WikiProject

- -
- - +{% extends "base.html" %} + +{% set aspect = 'wikiproject' %} + +{% block in_ready %} + +{{ sparql_to_table("maintained") }} + +{{ sparql_to_table("focus") }} + +{% endblock %} + + + +{% block page_content %} + +

WikiProject

+ +
+ +

Types maintained by this WikiProject

+ +
+ +

Types on focus list of this WikiProject

+ +
+ + {% endblock %} \ No newline at end of file diff --git a/scholia/app/templates/wikiproject_focus.sparql b/scholia/app/templates/wikiproject_focus.sparql new file mode 100644 index 000000000..7e564bea9 --- /dev/null +++ b/scholia/app/templates/wikiproject_focus.sparql @@ -0,0 +1,13 @@ +SELECT ?type ?typeLabel ?count WITH { + SELECT DISTINCT ?type (COUNT(?item) AS ?count) WHERE { + ?item wdt:P5008 wd:{{ q }}; + (wdt:P31|wdt:P279) ?type. + } + GROUP BY ?type ?count + ORDER BY DESC (?count) +} AS %result +WHERE { + INCLUDE %result + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,da,de,es,fr,it,sv,uk,zh". } +} +ORDER BY DESC (?count) \ No newline at end of file diff --git a/scholia/app/templates/wikiproject_types.sparql b/scholia/app/templates/wikiproject_maintained.sparql similarity index 97% rename from scholia/app/templates/wikiproject_types.sparql rename to scholia/app/templates/wikiproject_maintained.sparql index 3e8594bc5..2afb622f0 100644 --- a/scholia/app/templates/wikiproject_types.sparql +++ b/scholia/app/templates/wikiproject_maintained.sparql @@ -1,13 +1,13 @@ -SELECT ?type ?typeLabel ?count WITH { - SELECT DISTINCT ?type (COUNT(?item) AS ?count) WHERE { - ?item wdt:P6104 wd:{{ q }}; - (wdt:P31|wdt:P279) ?type. - } - GROUP BY ?type ?count - ORDER BY DESC (?count) -} AS %result -WHERE { - INCLUDE %result - SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,da,de,es,fr,it,sv,uk,zh". } -} +SELECT ?type ?typeLabel ?count WITH { + SELECT DISTINCT ?type (COUNT(?item) AS ?count) WHERE { + ?item wdt:P6104 wd:{{ q }}; + (wdt:P31|wdt:P279) ?type. + } + GROUP BY ?type ?count + ORDER BY DESC (?count) +} AS %result +WHERE { + INCLUDE %result + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,da,de,es,fr,it,sv,uk,zh". } +} ORDER BY DESC (?count) \ No newline at end of file From 0b1ec915604639d3a25131716aa2a4825cac28fe Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Thu, 15 Jun 2023 15:11:39 +0100 Subject: [PATCH 3/9] Adjust language --- scholia/app/templates/wikiproject.html | 4 ++-- scholia/query.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scholia/app/templates/wikiproject.html b/scholia/app/templates/wikiproject.html index 8373cf404..9ed0ea0ef 100644 --- a/scholia/app/templates/wikiproject.html +++ b/scholia/app/templates/wikiproject.html @@ -18,11 +18,11 @@

WikiProject

-

Types maintained by this WikiProject

+

Types of items maintained by this WikiProject

-

Types on focus list of this WikiProject

+

Types of items on focus list of this WikiProject

diff --git a/scholia/query.py b/scholia/query.py index 63497c8a4..a50eded6a 100644 --- a/scholia/query.py +++ b/scholia/query.py @@ -1292,7 +1292,7 @@ def q_to_class(q): 'Q22325163', # macromolecular complex ]): class_ = 'complex' - elif ('Q16695773' in classes): # human + elif ('Q16695773' in classes): # wikiproject class_ = 'wikiproject' else: query = 'select ?class where {{ wd:{q} wdt:P279+ ?class }}'.format( From 82a29dbb186ed6c8b69b31261c521c4c8b874eb5 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Tue, 27 Jun 2023 19:50:53 +0100 Subject: [PATCH 4/9] Add panels for P921 main subject of Wikiproject --- scholia/app/templates/wikiproject.html | 76 ++++++++++++++++++- .../wikiproject_author-awards.sparql | 29 +++++++ .../app/templates/wikiproject_authors.sparql | 32 ++++++++ .../app/templates/wikiproject_context.sparql | 54 +++++++++++++ ...ikiproject_earliest-published-works.sparql | 33 ++++++++ .../wikiproject_organization-map.sparql | 34 +++++++++ .../wikiproject_publications-per-year.sparql | 54 +++++++++++++ ...ikiproject_recently-published-works.sparql | 32 ++++++++ .../app/templates/wikiproject_topics.sparql | 26 +++++++ .../app/templates/wikiproject_venues.sparql | 22 ++++++ scholia/app/views.py | 5 +- scholia/query.py | 46 +++++++++++ 12 files changed, 440 insertions(+), 3 deletions(-) create mode 100644 scholia/app/templates/wikiproject_author-awards.sparql create mode 100644 scholia/app/templates/wikiproject_authors.sparql create mode 100644 scholia/app/templates/wikiproject_context.sparql create mode 100644 scholia/app/templates/wikiproject_earliest-published-works.sparql create mode 100644 scholia/app/templates/wikiproject_organization-map.sparql create mode 100644 scholia/app/templates/wikiproject_publications-per-year.sparql create mode 100644 scholia/app/templates/wikiproject_recently-published-works.sparql create mode 100644 scholia/app/templates/wikiproject_topics.sparql create mode 100644 scholia/app/templates/wikiproject_venues.sparql diff --git a/scholia/app/templates/wikiproject.html b/scholia/app/templates/wikiproject.html index 9ed0ea0ef..66a44001b 100644 --- a/scholia/app/templates/wikiproject.html +++ b/scholia/app/templates/wikiproject.html @@ -5,9 +5,34 @@ {% block in_ready %} {{ sparql_to_table("maintained") }} - {{ sparql_to_table("focus") }} +{{ sparql_to_iframe('context') }} +{{ sparql_to_table('recently-published-works') }} +{{ sparql_to_iframe('publications-per-year') }} +{{ sparql_to_table('earliest-published-works') }} +{{ sparql_to_table('authors') }} +{{ sparql_to_table('author-awards') }} +{{ sparql_to_table('topics') }} +{{ sparql_to_table('venues') }} +{{ sparql_to_iframe('organization-map') }} + + +var url = 'https://www.wikidata.org/w/api.php?action=wbgetentities&ids=' + + '{{ main_subject }}' + + '&format=json&callback=?'; + +$.getJSON(url, function (data) { + var item = data.entities["{{ main_subject }}"]; + if ('en' in item.labels) { + $("#main-subject").append(': ' + item.labels.en.value + ''); + $("#main-subject").append(' ({{ main_subject }})'); + } else { + $("#main-subject").append(': {{ main_subject }}'); + $("#main-subject").append(' (Topic)'); + } +}); + {% endblock %} @@ -26,5 +51,54 @@

Types of items on focus list of this WikiProject

+

Main subject

+ +

The topic in context

+ +
+ +
+ +

Recently published works on the topic RSS icon

+ +
+ +

Publications per year

+ +
+ +
+ +

Earliest published works on the topic

+ +
+ +

Authors publishing about the topic

+ +
+ +

Awards received by authors who published on the topic

+ +
+ +

Co-occurring topics

+ +
+ +

Venues and series publishing works about the topic

+ +
+ +

Map of organizations associated with works about the topic

+ +The colours indicate how many publications on the topic are associated with organizations in the given location, as +detailed in the legend (top right). + +
+ +
{% endblock %} \ No newline at end of file diff --git a/scholia/app/templates/wikiproject_author-awards.sparql b/scholia/app/templates/wikiproject_author-awards.sparql new file mode 100644 index 000000000..6cef8b53e --- /dev/null +++ b/scholia/app/templates/wikiproject_author-awards.sparql @@ -0,0 +1,29 @@ +PREFIX target: + +SELECT ?count +?award ?awardLabel (CONCAT("/award/", SUBSTR(STR(?award), 32)) AS ?awardUrl) +?recipients ?recipientsUrl +WITH { + SELECT (COUNT(?researcher) AS ?count) ?award + (GROUP_CONCAT(DISTINCT ?researcher_label; separator=", ") AS ?recipients) + (CONCAT("../authors/", GROUP_CONCAT(DISTINCT SUBSTR(STR(?researcher), 32); separator=",")) AS ?recipientsUrl) + WHERE { + { + SELECT DISTINCT ?researcher ?award WHERE { + hint:Query hint:optimizer "None" . + ?work wdt:P921 target: . + ?work wdt:P50 ?researcher . + ?researcher wdt:P166 ?award . + } + LIMIT 100 + } + ?researcher rdfs:label ?researcher_label . FILTER (LANG(?researcher_label) = 'en') + } + GROUP BY ?award +} AS %result +WHERE { + INCLUDE %result + ?award rdfs:label ?awardLabel . FILTER (LANG(?awardLabel) = 'en') +} +GROUP BY ?count ?award ?awardLabel ?recipients ?recipientsUrl +ORDER BY DESC(?count) diff --git a/scholia/app/templates/wikiproject_authors.sparql b/scholia/app/templates/wikiproject_authors.sparql new file mode 100644 index 000000000..8f5df44be --- /dev/null +++ b/scholia/app/templates/wikiproject_authors.sparql @@ -0,0 +1,32 @@ +#defaultView:Table + +PREFIX target: + +SELECT + ?count + ?author ?authorLabel ?authorDescription (CONCAT("/author/", SUBSTR(STR(?author), 32)) AS ?authorUrl) + (COALESCE(?orcid_, CONCAT("orcid-search/quick-search/?searchQuery=", ?authorLabel)) AS ?orcid) +WITH { + SELECT + ?author + (count(?work) as ?count) + WHERE { + { ?work wdt:P921/wdt:P31*/wdt:P279* target: . } + UNION + { ?work wdt:P921/wdt:P361+ target: . } + UNION + { ?work wdt:P921/wdt:P1269+ target: . } + ?work wdt:P50 ?author . + } + GROUP BY ?author + ORDER BY DESC(?count) + LIMIT 200 +} AS %result +WHERE { + INCLUDE %result + + # Include optional ORCID iD + OPTIONAL { ?author wdt:P496 ?orcid_ . } + SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh" . } +} +ORDER BY DESC(?count) diff --git a/scholia/app/templates/wikiproject_context.sparql b/scholia/app/templates/wikiproject_context.sparql new file mode 100644 index 000000000..2da08f857 --- /dev/null +++ b/scholia/app/templates/wikiproject_context.sparql @@ -0,0 +1,54 @@ +PREFIX target: +#defaultView:Graph +SELECT ?node ?nodeLabel ?nodeImage ?childNode ?childNodeLabel ?childNodeImage ?rgb +WITH { + SELECT DISTINCT ?property WHERE { + ?property a wikibase:Property; + wdt:P31 wd:Q18610173 ; + wdt:P31 wd:Q26940804 . + } +} AS %properties +WITH { + SELECT DISTINCT ?node ?childNode WHERE { + BIND(target: AS ?node) + ?node ?p ?i. + ?childNode ?x ?p. + ?childNode rdf:type wikibase:Property. + FILTER(STRSTARTS(STR(?i), "http://www.wikidata.org/entity/Q")) + FILTER(STRSTARTS(STR(?childNode), "http://www.wikidata.org/entity/P")) + } + LIMIT 5000 +} AS %nodes +WITH { + SELECT DISTINCT ?childNode ?node ?rgb WHERE { + BIND("EFFBD8" AS ?rgb) + target: ?p ?childNode. + ?node ?x ?p. + ?node rdf:type wikibase:Property. + FILTER(STRSTARTS(STR(?childNode), "http://www.wikidata.org/entity/Q")) + } + LIMIT 5000 +} AS %childNodes +WHERE { + { + INCLUDE %nodes + } + UNION + { + INCLUDE %childNodes + } + + OPTIONAL { + INCLUDE %properties + ?property wikibase:directClaim ?nodeclaim. + ?node ?nodeclaim ?nodeImage. + } + + OPTIONAL { + INCLUDE %properties + ?property wikibase:directClaim ?childNodeclaim. + ?childNode ?childNodeclaim ?childNodeImage. + } + + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } +} diff --git a/scholia/app/templates/wikiproject_earliest-published-works.sparql b/scholia/app/templates/wikiproject_earliest-published-works.sparql new file mode 100644 index 000000000..edcc5efdb --- /dev/null +++ b/scholia/app/templates/wikiproject_earliest-published-works.sparql @@ -0,0 +1,33 @@ +PREFIX target: + +SELECT ?date ?work ?workLabel (CONCAT("/work/", SUBSTR(STR(?work), 32)) AS ?workUrl) +?topicsUrl ?topics +WITH { + SELECT DISTINCT ?work WHERE { + ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) target: . + } +} AS %works +WITH { + SELECT (MAX(?dates) as ?datetime) ?work (GROUP_CONCAT(DISTINCT ?topic_label; separator=" // ") AS ?topics) + (CONCAT("../topics/", GROUP_CONCAT(DISTINCT SUBSTR(STR(?topic), 32); separator=",")) AS ?topicsUrl) + WHERE { + INCLUDE %works + ?work wdt:P921 ?topic . + ?work wdt:P577 ?dates . + FILTER (!isBLANK(?dates)) . + ?topic rdfs:label ?topic_label . FILTER (lang(?topic_label) = 'en') + } + GROUP BY ?work +} AS %result +WHERE { + INCLUDE %result + + # There is a problem with BC dates + # BIND(xsd:date(?datetime) AS ?date) + BIND(REPLACE(STR(?datetime), 'T.*', '') AS ?date) + + SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh". } +} +GROUP BY ?date ?work ?workLabel ?topicsUrl ?topics +ORDER BY ASC(?date) +LIMIT 500 diff --git a/scholia/app/templates/wikiproject_organization-map.sparql b/scholia/app/templates/wikiproject_organization-map.sparql new file mode 100644 index 000000000..826d25e3b --- /dev/null +++ b/scholia/app/templates/wikiproject_organization-map.sparql @@ -0,0 +1,34 @@ +#defaultView:Map + +PREFIX target: + +SELECT ?organization ?organizationLabel ?geo ?count ?layer +WITH { + SELECT DISTINCT ?work WHERE { + # Works on the topic + ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) target: . + } + LIMIT 20000 +} AS %works +WITH { + SELECT DISTINCT ?organization ?geo (COUNT(DISTINCT ?work) AS ?count) WHERE { + INCLUDE %works + # Authors who have published works on the topic + ?work wdt:P50 ?author . + ?author ( wdt:P108 | wdt:P463 | wdt:P1416 ) / wdt:P361* ?organization . + # Use the headquarters location by default but keep the coordinate location as a fallback + OPTIONAL{?organization p:P159/pq:P625 ?hq_geo} + OPTIONAL{?organization wdt:P625 ?coord_geo} + BIND(IF(BOUND(?hq_geo), ?hq_geo, ?coord_geo) AS ?geo) . + FILTER(BOUND(?geo)) . + } + GROUP BY ?organization ?geo + ORDER BY DESC (?count) + LIMIT 2000 +} AS %organizations +WHERE { + INCLUDE %organizations + BIND(IF( (?count < 1), "No results", IF((?count < 2), "1 result", IF((?count < 11), "1 < results ≤ 10", IF((?count < 101), "10 < results ≤ 100", IF((?count < 1001), "100 < results ≤ 1000", IF((?count < 10001), "1000 < results ≤ 10000", "10000 or more results") ) ) ) )) AS ?layer ) + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } + } +ORDER BY DESC (?count) diff --git a/scholia/app/templates/wikiproject_publications-per-year.sparql b/scholia/app/templates/wikiproject_publications-per-year.sparql new file mode 100644 index 000000000..7b977660c --- /dev/null +++ b/scholia/app/templates/wikiproject_publications-per-year.sparql @@ -0,0 +1,54 @@ +#defaultView:BarChart + +PREFIX target: + +SELECT + (STR(?year_) AS ?year) + (COUNT(?work) AS ?number_of_publications) + + # Work type used to color the bar chart + ?type +WITH { + # Find works with the topic. Also report the year + SELECT + ?work (MIN(?years) AS ?year_) (1 AS ?dummy) (SAMPLE(?article_type_) AS ?article_type) + WHERE { + ?work wdt:P921 / (wdt:P31*/wdt:P279* | wdt:P361+ | wdt:P1269+) target: . + ?work wdt:P577 ?dates . + BIND(YEAR(?dates) AS ?years) . + + ?work wdt:P31 ?article_type_ . + } + GROUP BY ?work +} AS %works +WITH { + SELECT ?year_ WHERE { + # default values = 0 + ?year_item wdt:P31 wd:Q577 . + ?year_item wdt:P585 ?date . + BIND(YEAR(?date) AS ?year_) + } +} AS %default_counts +WITH { + # Find earliest publication year + SELECT (MIN(?year_) AS ?earliest_year) WHERE { + INCLUDE %works + } + GROUP BY ?dummy +} AS %earliest +WHERE { + { + INCLUDE %works + ?article_type rdfs:label ?type . FILTER (LANG(?type) = "en") + } + UNION + { + INCLUDE %default_counts + BIND("_" AS ?type) + } + INCLUDE %earliest + BIND(YEAR(NOW()) AS ?this_year) + FILTER (?year_ >= ?earliest_year && ?year_ <= ?this_year && ?year_ >= YEAR("1900-01-01"^^xsd:dateTime)) +} +GROUP BY ?year_ ?type +ORDER BY ?year diff --git a/scholia/app/templates/wikiproject_recently-published-works.sparql b/scholia/app/templates/wikiproject_recently-published-works.sparql new file mode 100644 index 000000000..f4ce8f356 --- /dev/null +++ b/scholia/app/templates/wikiproject_recently-published-works.sparql @@ -0,0 +1,32 @@ +PREFIX target: + +SELECT ?date ?work ?workLabel (CONCAT("/work/", SUBSTR(STR(?work), 32)) AS ?workUrl) + ?topicsUrl ?topics +WITH { + SELECT DISTINCT ?work WHERE { + ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) target: . + } +} AS %works +WITH { + SELECT (MAX(?dates) as ?datetime) ?work (GROUP_CONCAT(DISTINCT ?topic_label; separator=" // ") AS ?topics) + (CONCAT("../topics/", GROUP_CONCAT(DISTINCT SUBSTR(STR(?topic), 32); separator=",")) AS ?topicsUrl) + WHERE { + INCLUDE %works + ?work wdt:P921 ?topic . + OPTIONAL { ?work wdt:P577 ?dates . } + ?topic rdfs:label ?topic_label . FILTER (lang(?topic_label) = 'en') + } + GROUP BY ?work +} AS %result +WHERE { + INCLUDE %result + + # There is a problem with BC dates + # BIND(xsd:date(?datetime) AS ?date) + BIND(REPLACE(STR(?datetime), 'T.*', '') AS ?date) + + SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh". } +} +GROUP BY ?date ?work ?workLabel ?topicsUrl ?topics +ORDER BY DESC(?date) +LIMIT 500 diff --git a/scholia/app/templates/wikiproject_topics.sparql b/scholia/app/templates/wikiproject_topics.sparql new file mode 100644 index 000000000..46f4e76a9 --- /dev/null +++ b/scholia/app/templates/wikiproject_topics.sparql @@ -0,0 +1,26 @@ +#defaultView:Table + +PREFIX target: + +SELECT ?count (CONCAT("/topics/{{ q }},", SUBSTR(STR(?topic), 32)) AS ?countUrl) + ?topic ?topicLabel (CONCAT("/topic/", SUBSTR(STR(?topic), 32)) AS ?topicUrl) + ?example_work ?example_workLabel (CONCAT("/work/", SUBSTR(STR(?example_work), 32)) AS ?example_workUrl) +WITH { + SELECT (COUNT(?work) AS ?count) ?topic (SAMPLE(?work) AS ?example_work) WHERE { + # Find works for the specific queried topic + ?work wdt:P921/( wdt:P31*/wdt:P279* | wdt:P361+ | wdt:P1269+) target: . + + # Find co-occuring topics + ?work wdt:P921 ?topic . + + # Avoid listing the queried topic + FILTER (target: != ?topic) + } + GROUP BY ?topic +} AS %result +WHERE { + # Label the results + INCLUDE %result + SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh" . } +} +ORDER BY DESC(?count) diff --git a/scholia/app/templates/wikiproject_venues.sparql b/scholia/app/templates/wikiproject_venues.sparql new file mode 100644 index 000000000..128248ffb --- /dev/null +++ b/scholia/app/templates/wikiproject_venues.sparql @@ -0,0 +1,22 @@ +#defaultView:Table + +PREFIX target: + +SELECT ?count ?short_name +?venue ?venueLabel (CONCAT("/venue/", SUBSTR(STR(?venue), 32)) AS ?venueUrl) +WITH { + SELECT (count(?work) as ?count) ?venue (SAMPLE(?short_name_) AS ?short_name) WHERE { + { ?work wdt:P921/wdt:P31*/wdt:P279* target: . } + union { ?work wdt:P921/wdt:P361+ target: . } + union { ?work wdt:P921/wdt:P1269+ target: . } + ?work wdt:P1433/wdt:P179* ?venue . + OPTIONAL { ?venue wdt:P1813 ?short_name_ . } + } + GROUP BY ?venue +} AS %result +WHERE { + INCLUDE %result + SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh" . } +} +ORDER BY DESC(?count) +LIMIT 200 diff --git a/scholia/app/views.py b/scholia/app/views.py index 6dc099424..0d9ba01ee 100644 --- a/scholia/app/views.py +++ b/scholia/app/views.py @@ -16,7 +16,7 @@ from ..arxiv import get_metadata as get_arxiv_metadata from ..query import (arxiv_to_qs, cas_to_qs, atomic_symbol_to_qs, doi_to_qs, doi_prefix_to_qs, github_to_qs, biorxiv_to_qs, - chemrxiv_to_qs, + chemrxiv_to_qs, get_prop_value, identifier_to_qs, inchikey_to_qs, issn_to_qs, orcid_to_qs, viaf_to_qs, q_to_class, q_to_dois, random_author, twitter_to_qs, cordis_to_qs, mesh_to_qs, pubmed_to_qs, @@ -2480,7 +2480,8 @@ def show_wikiproject(q): Rendered HTML page for specific WikiProject. """ - return render_template('wikiproject.html', q=q) + main_subject = get_prop_value(q, "P921") + return render_template('wikiproject.html', q=q, main_subject=main_subject) @main.route('/favicon.ico') diff --git a/scholia/query.py b/scholia/query.py index a50eded6a..28e181faa 100644 --- a/scholia/query.py +++ b/scholia/query.py @@ -295,6 +295,52 @@ def identifier_to_qs(property, identifier): for item in data['results']['bindings']] +def get_prop_value(q, prop): + """Given Q and P, return value (which is a Wikidata item) + + Parameters + ---------- + q : str + Given QID + prop : str + Property + + Returns + ------- + v : str + qid of value + + Notes + ----- + The Wikidata Query Service is queries to resolve the given identifier. If + an error happens an empty string is returned. + + Examples + -------- + >>> q = "Q20895241" # E Willighagen + >>> property = "P1026" # academic thesis + >>> v = get_prop_value(q, property) + >>> v == ["Q25713029"] + True + + """ + query = 'SELECT ?value {{ wd:{q} wdt:{prop} ?value }}'.format( + q=q, + prop=prop, + ) + print(query) + + url = 'https://query.wikidata.org/sparql' + params = {'query': query, 'format': 'json'} + try: + response = requests.get(url, params=params, headers=HEADERS) + data = response.json() + print(data) + except Exception: + return [] + return data['results']['bindings'][0]['value']['value'][31:] + + def count_authorships(): """Count the number of authorships. From a0fdc7fc4468511b1ff7a503af23cd643cbe2118 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Tue, 27 Jun 2023 20:01:46 +0100 Subject: [PATCH 5/9] Handle no prop value and no main subject --- scholia/app/templates/wikiproject.html | 5 +++++ scholia/query.py | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/scholia/app/templates/wikiproject.html b/scholia/app/templates/wikiproject.html index 66a44001b..91f54e5e5 100644 --- a/scholia/app/templates/wikiproject.html +++ b/scholia/app/templates/wikiproject.html @@ -7,6 +7,7 @@ {{ sparql_to_table("maintained") }} {{ sparql_to_table("focus") }} +{% if main_subject %} {{ sparql_to_iframe('context') }} {{ sparql_to_table('recently-published-works') }} {{ sparql_to_iframe('publications-per-year') }} @@ -16,6 +17,7 @@ {{ sparql_to_table('topics') }} {{ sparql_to_table('venues') }} {{ sparql_to_iframe('organization-map') }} +{% endif %} var url = 'https://www.wikidata.org/w/api.php?action=wbgetentities&ids=' + @@ -51,6 +53,8 @@

Types of items on focus list of this WikiProject

+{% if main_subject %} +

Main subject

The topic in context

@@ -100,5 +104,6 @@

Map of organizations associated with works about the t +{% endif %} {% endblock %} \ No newline at end of file diff --git a/scholia/query.py b/scholia/query.py index 28e181faa..323fc8ca2 100644 --- a/scholia/query.py +++ b/scholia/query.py @@ -320,7 +320,7 @@ def get_prop_value(q, prop): >>> q = "Q20895241" # E Willighagen >>> property = "P1026" # academic thesis >>> v = get_prop_value(q, property) - >>> v == ["Q25713029"] + >>> v == "Q25713029" True """ @@ -335,10 +335,12 @@ def get_prop_value(q, prop): try: response = requests.get(url, params=params, headers=HEADERS) data = response.json() - print(data) except Exception: return [] - return data['results']['bindings'][0]['value']['value'][31:] + if (len(data['results']['bindings']) > 0): + return data['results']['bindings'][0]['value']['value'][31:] + else: + return "" def count_authorships(): From a032000a43c1a2ab493e60de455a01b7be59fed4 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Wed, 28 Jun 2023 07:26:25 +0100 Subject: [PATCH 6/9] Remove use of main subject, tidy, add auto_lang --- scholia/app/templates/wikiproject.html | 45 ++++++------------- .../wikiproject_author-awards.sparql | 6 ++- .../app/templates/wikiproject_authors.sparql | 12 +++-- .../app/templates/wikiproject_context.sparql | 2 +- ...ikiproject_earliest-published-works.sparql | 8 ++-- .../wikiproject_organization-map.sparql | 7 ++- .../wikiproject_publications-per-year.sparql | 6 ++- ...ikiproject_recently-published-works.sparql | 8 ++-- .../app/templates/wikiproject_topics.sparql | 8 ++-- .../app/templates/wikiproject_venues.sparql | 9 ++-- scholia/app/views.py | 3 +- scholia/query.py | 7 ++- 12 files changed, 56 insertions(+), 65 deletions(-) diff --git a/scholia/app/templates/wikiproject.html b/scholia/app/templates/wikiproject.html index 91f54e5e5..bf4fa0ef9 100644 --- a/scholia/app/templates/wikiproject.html +++ b/scholia/app/templates/wikiproject.html @@ -7,7 +7,6 @@ {{ sparql_to_table("maintained") }} {{ sparql_to_table("focus") }} -{% if main_subject %} {{ sparql_to_iframe('context') }} {{ sparql_to_table('recently-published-works') }} {{ sparql_to_iframe('publications-per-year') }} @@ -17,23 +16,6 @@ {{ sparql_to_table('topics') }} {{ sparql_to_table('venues') }} {{ sparql_to_iframe('organization-map') }} -{% endif %} - - -var url = 'https://www.wikidata.org/w/api.php?action=wbgetentities&ids=' + - '{{ main_subject }}' + - '&format=json&callback=?'; - -$.getJSON(url, function (data) { - var item = data.entities["{{ main_subject }}"]; - if ('en' in item.labels) { - $("#main-subject").append(': ' + item.labels.en.value + ''); - $("#main-subject").append(' ({{ main_subject }})'); - } else { - $("#main-subject").append(': {{ main_subject }}'); - $("#main-subject").append(' (Topic)'); - } -}); {% endblock %} @@ -53,17 +35,15 @@

Types of items on focus list of this WikiProject

-{% if main_subject %} - -

Main subject

- -

The topic in context

+

The topic in context

-

Recently published works on the topic Works

+ +

Recently published worksRSS icon

@@ -75,27 +55,31 @@

Publications per year

-

Earliest published works on the topic

+

Earliest published works

-

Authors publishing about the topic

+

Authors

+ +

Related authors

-

Awards received by authors who published on the topic

+

Awards received by authors

-

Co-occurring topics

+

Topics

+ +

From random sample

-

Venues and series publishing works about the topic

+

Related venues and series

-

Map of organizations associated with works about the topic

+

Map of organizations associated with related works

The colours indicate how many publications on the topic are associated with organizations in the given location, as detailed in the legend (top right). @@ -104,6 +88,5 @@

Map of organizations associated with works about the t -{% endif %} {% endblock %} \ No newline at end of file diff --git a/scholia/app/templates/wikiproject_author-awards.sparql b/scholia/app/templates/wikiproject_author-awards.sparql index 6cef8b53e..f793d204f 100644 --- a/scholia/app/templates/wikiproject_author-awards.sparql +++ b/scholia/app/templates/wikiproject_author-awards.sparql @@ -1,4 +1,4 @@ -PREFIX target: +PREFIX target: SELECT ?count ?award ?awardLabel (CONCAT("/award/", SUBSTR(STR(?award), 32)) AS ?awardUrl) @@ -11,7 +11,9 @@ WITH { { SELECT DISTINCT ?researcher ?award WHERE { hint:Query hint:optimizer "None" . - ?work wdt:P921 target: . + { ?work wdt:P6104 target: .} + union + { ?work wdt:P5008 target: .} ?work wdt:P50 ?researcher . ?researcher wdt:P166 ?award . } diff --git a/scholia/app/templates/wikiproject_authors.sparql b/scholia/app/templates/wikiproject_authors.sparql index 8f5df44be..c0a700d82 100644 --- a/scholia/app/templates/wikiproject_authors.sparql +++ b/scholia/app/templates/wikiproject_authors.sparql @@ -1,6 +1,6 @@ #defaultView:Table -PREFIX target: +PREFIX target: SELECT ?count @@ -11,11 +11,9 @@ WITH { ?author (count(?work) as ?count) WHERE { - { ?work wdt:P921/wdt:P31*/wdt:P279* target: . } - UNION - { ?work wdt:P921/wdt:P361+ target: . } - UNION - { ?work wdt:P921/wdt:P1269+ target: . } + { ?work wdt:P6104 target: .} + union + { ?work wdt:P5008 target: .} ?work wdt:P50 ?author . } GROUP BY ?author @@ -27,6 +25,6 @@ WHERE { # Include optional ORCID iD OPTIONAL { ?author wdt:P496 ?orcid_ . } - SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh" . } + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } } ORDER BY DESC(?count) diff --git a/scholia/app/templates/wikiproject_context.sparql b/scholia/app/templates/wikiproject_context.sparql index 2da08f857..00fa623b8 100644 --- a/scholia/app/templates/wikiproject_context.sparql +++ b/scholia/app/templates/wikiproject_context.sparql @@ -1,4 +1,4 @@ -PREFIX target: +PREFIX target: #defaultView:Graph SELECT ?node ?nodeLabel ?nodeImage ?childNode ?childNodeLabel ?childNodeImage ?rgb WITH { diff --git a/scholia/app/templates/wikiproject_earliest-published-works.sparql b/scholia/app/templates/wikiproject_earliest-published-works.sparql index edcc5efdb..b130562d5 100644 --- a/scholia/app/templates/wikiproject_earliest-published-works.sparql +++ b/scholia/app/templates/wikiproject_earliest-published-works.sparql @@ -1,10 +1,12 @@ -PREFIX target: +PREFIX target: SELECT ?date ?work ?workLabel (CONCAT("/work/", SUBSTR(STR(?work), 32)) AS ?workUrl) ?topicsUrl ?topics WITH { SELECT DISTINCT ?work WHERE { - ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) target: . + { ?work wdt:P6104 target: .} + union + { ?work wdt:P5008 target: .} } } AS %works WITH { @@ -26,7 +28,7 @@ WHERE { # BIND(xsd:date(?datetime) AS ?date) BIND(REPLACE(STR(?datetime), 'T.*', '') AS ?date) - SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh". } + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } } GROUP BY ?date ?work ?workLabel ?topicsUrl ?topics ORDER BY ASC(?date) diff --git a/scholia/app/templates/wikiproject_organization-map.sparql b/scholia/app/templates/wikiproject_organization-map.sparql index 826d25e3b..b86d07c5b 100644 --- a/scholia/app/templates/wikiproject_organization-map.sparql +++ b/scholia/app/templates/wikiproject_organization-map.sparql @@ -1,12 +1,15 @@ #defaultView:Map -PREFIX target: +PREFIX target: SELECT ?organization ?organizationLabel ?geo ?count ?layer WITH { SELECT DISTINCT ?work WHERE { # Works on the topic - ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) target: . + { ?work wdt:P6104 target: .} + union + { ?work wdt:P5008 target: .} + ?work wdt:P50 []. } LIMIT 20000 } AS %works diff --git a/scholia/app/templates/wikiproject_publications-per-year.sparql b/scholia/app/templates/wikiproject_publications-per-year.sparql index 7b977660c..fa6513a36 100644 --- a/scholia/app/templates/wikiproject_publications-per-year.sparql +++ b/scholia/app/templates/wikiproject_publications-per-year.sparql @@ -1,6 +1,6 @@ #defaultView:BarChart -PREFIX target: +PREFIX target: SELECT (STR(?year_) AS ?year) @@ -13,7 +13,9 @@ WITH { SELECT ?work (MIN(?years) AS ?year_) (1 AS ?dummy) (SAMPLE(?article_type_) AS ?article_type) WHERE { - ?work wdt:P921 / (wdt:P31*/wdt:P279* | wdt:P361+ | wdt:P1269+) target: . + { ?work wdt:P6104 target: .} + union + { ?work wdt:P5008 target: .} ?work wdt:P577 ?dates . BIND(YEAR(?dates) AS ?years) . diff --git a/scholia/app/templates/wikiproject_recently-published-works.sparql b/scholia/app/templates/wikiproject_recently-published-works.sparql index f4ce8f356..d2120f49c 100644 --- a/scholia/app/templates/wikiproject_recently-published-works.sparql +++ b/scholia/app/templates/wikiproject_recently-published-works.sparql @@ -1,10 +1,12 @@ -PREFIX target: +PREFIX target: SELECT ?date ?work ?workLabel (CONCAT("/work/", SUBSTR(STR(?work), 32)) AS ?workUrl) ?topicsUrl ?topics WITH { SELECT DISTINCT ?work WHERE { - ?work wdt:P921 / (wdt:P361+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) target: . + { ?work wdt:P6104 target: .} + union + { ?work wdt:P5008 target: .} } } AS %works WITH { @@ -25,7 +27,7 @@ WHERE { # BIND(xsd:date(?datetime) AS ?date) BIND(REPLACE(STR(?datetime), 'T.*', '') AS ?date) - SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh". } + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } GROUP BY ?date ?work ?workLabel ?topicsUrl ?topics ORDER BY DESC(?date) diff --git a/scholia/app/templates/wikiproject_topics.sparql b/scholia/app/templates/wikiproject_topics.sparql index 46f4e76a9..c046db33f 100644 --- a/scholia/app/templates/wikiproject_topics.sparql +++ b/scholia/app/templates/wikiproject_topics.sparql @@ -1,6 +1,6 @@ #defaultView:Table -PREFIX target: +PREFIX target: SELECT ?count (CONCAT("/topics/{{ q }},", SUBSTR(STR(?topic), 32)) AS ?countUrl) ?topic ?topicLabel (CONCAT("/topic/", SUBSTR(STR(?topic), 32)) AS ?topicUrl) @@ -8,7 +8,9 @@ SELECT ?count (CONCAT("/topics/{{ q }},", SUBSTR(STR(?topic), 32)) AS ?countUrl) WITH { SELECT (COUNT(?work) AS ?count) ?topic (SAMPLE(?work) AS ?example_work) WHERE { # Find works for the specific queried topic - ?work wdt:P921/( wdt:P31*/wdt:P279* | wdt:P361+ | wdt:P1269+) target: . + VALUES ?p { wdt:P6104 wdt:P5008 } + # Find works for the specific queried topic + SERVICE bd:sample { ?work ?p target: . bd:serviceParam bd:sample.limit 10000 } # Find co-occuring topics ?work wdt:P921 ?topic . @@ -21,6 +23,6 @@ WITH { WHERE { # Label the results INCLUDE %result - SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh" . } + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } } ORDER BY DESC(?count) diff --git a/scholia/app/templates/wikiproject_venues.sparql b/scholia/app/templates/wikiproject_venues.sparql index 128248ffb..5b082cf7e 100644 --- a/scholia/app/templates/wikiproject_venues.sparql +++ b/scholia/app/templates/wikiproject_venues.sparql @@ -1,14 +1,13 @@ #defaultView:Table -PREFIX target: +PREFIX target: SELECT ?count ?short_name ?venue ?venueLabel (CONCAT("/venue/", SUBSTR(STR(?venue), 32)) AS ?venueUrl) WITH { SELECT (count(?work) as ?count) ?venue (SAMPLE(?short_name_) AS ?short_name) WHERE { - { ?work wdt:P921/wdt:P31*/wdt:P279* target: . } - union { ?work wdt:P921/wdt:P361+ target: . } - union { ?work wdt:P921/wdt:P1269+ target: . } + { ?work wdt:P6104 target: . } + union { ?work wdt:P5008 target: . } ?work wdt:P1433/wdt:P179* ?venue . OPTIONAL { ?venue wdt:P1813 ?short_name_ . } } @@ -16,7 +15,7 @@ WITH { } AS %result WHERE { INCLUDE %result - SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh" . } + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . } } ORDER BY DESC(?count) LIMIT 200 diff --git a/scholia/app/views.py b/scholia/app/views.py index 0d9ba01ee..79f2c2592 100644 --- a/scholia/app/views.py +++ b/scholia/app/views.py @@ -2480,8 +2480,7 @@ def show_wikiproject(q): Rendered HTML page for specific WikiProject. """ - main_subject = get_prop_value(q, "P921") - return render_template('wikiproject.html', q=q, main_subject=main_subject) + return render_template('wikiproject.html', q=q) @main.route('/favicon.ico') diff --git a/scholia/query.py b/scholia/query.py index 323fc8ca2..1b4e1c42f 100644 --- a/scholia/query.py +++ b/scholia/query.py @@ -267,7 +267,7 @@ def identifier_to_qs(property, identifier): Notes ----- - The Wikidata Query Service is queries to resolve the given identifier. If + The Wikidata Query Service is queried to resolve the given identifier. If an error happens an empty list is returned. Examples @@ -296,7 +296,7 @@ def identifier_to_qs(property, identifier): def get_prop_value(q, prop): - """Given Q and P, return value (which is a Wikidata item) + """Given Q and P, return value (which is a Wikidata item). Parameters ---------- @@ -312,7 +312,7 @@ def get_prop_value(q, prop): Notes ----- - The Wikidata Query Service is queries to resolve the given identifier. If + The Wikidata Query Service is queried to resolve the given identifier. If an error happens an empty string is returned. Examples @@ -328,7 +328,6 @@ def get_prop_value(q, prop): q=q, prop=prop, ) - print(query) url = 'https://query.wikidata.org/sparql' params = {'query': query, 'format': 'json'} From a4ce70cd7fcb2ce79dc5053de6979faf9fc75e4c Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Wed, 28 Jun 2023 07:32:23 +0100 Subject: [PATCH 7/9] Remove unused get_prop_val import --- scholia/app/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scholia/app/views.py b/scholia/app/views.py index 79f2c2592..6dc099424 100644 --- a/scholia/app/views.py +++ b/scholia/app/views.py @@ -16,7 +16,7 @@ from ..arxiv import get_metadata as get_arxiv_metadata from ..query import (arxiv_to_qs, cas_to_qs, atomic_symbol_to_qs, doi_to_qs, doi_prefix_to_qs, github_to_qs, biorxiv_to_qs, - chemrxiv_to_qs, get_prop_value, + chemrxiv_to_qs, identifier_to_qs, inchikey_to_qs, issn_to_qs, orcid_to_qs, viaf_to_qs, q_to_class, q_to_dois, random_author, twitter_to_qs, cordis_to_qs, mesh_to_qs, pubmed_to_qs, From b5954bcf411b5a792c9571f915f32de3ec15d12e Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Fri, 30 Jun 2023 11:58:06 +0100 Subject: [PATCH 8/9] Remove get_prop_val() --- scholia/query.py | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/scholia/query.py b/scholia/query.py index 1b4e1c42f..dce09294e 100644 --- a/scholia/query.py +++ b/scholia/query.py @@ -295,53 +295,6 @@ def identifier_to_qs(property, identifier): for item in data['results']['bindings']] -def get_prop_value(q, prop): - """Given Q and P, return value (which is a Wikidata item). - - Parameters - ---------- - q : str - Given QID - prop : str - Property - - Returns - ------- - v : str - qid of value - - Notes - ----- - The Wikidata Query Service is queried to resolve the given identifier. If - an error happens an empty string is returned. - - Examples - -------- - >>> q = "Q20895241" # E Willighagen - >>> property = "P1026" # academic thesis - >>> v = get_prop_value(q, property) - >>> v == "Q25713029" - True - - """ - query = 'SELECT ?value {{ wd:{q} wdt:{prop} ?value }}'.format( - q=q, - prop=prop, - ) - - url = 'https://query.wikidata.org/sparql' - params = {'query': query, 'format': 'json'} - try: - response = requests.get(url, params=params, headers=HEADERS) - data = response.json() - except Exception: - return [] - if (len(data['results']['bindings']) > 0): - return data['results']['bindings'][0]['value']['value'][31:] - else: - return "" - - def count_authorships(): """Count the number of authorships. From e2d8a7c69f1e5b99d02aee217f5cf78b56808c57 Mon Sep 17 00:00:00 2001 From: Carlin MacKenzie Date: Fri, 30 Jun 2023 12:03:07 +0100 Subject: [PATCH 9/9] dummy commit, PR won't update --- scholia/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scholia/query.py b/scholia/query.py index dce09294e..20c2e6979 100644 --- a/scholia/query.py +++ b/scholia/query.py @@ -1271,7 +1271,7 @@ def q_to_class(q): 'Q46855', # hackathon 'Q625994', # conference 'Q2020153', # scientific conference - 'Q40444998', # akademic workshop + 'Q40444998', # academic workshop ]): class_ = 'event' elif set(classes).intersection([