Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fnielsen/scholia
Browse files Browse the repository at this point in the history
  • Loading branch information
fnielsen committed Apr 16, 2019
2 parents 6479fd1 + 16c4990 commit 589c069
Show file tree
Hide file tree
Showing 33 changed files with 1,119 additions and 143 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Source code an issue tracker

Scholia development is hosted at https://github.com/fnielsen/scholia.

Technolgy stack
Technology stack
---------------

Scholia is mainly based on
Expand All @@ -16,7 +16,7 @@ Scholia is mainly based on
- JavaScript with `jQuery <https://jquery.com/>`__ and
`wikidata-sdk <https://github.com/maxlath/wikidata-sdk>`__
- SPARQL to query the `Wikidata Query
Service <http://query.wikidata,org/>`__
Service <http://query.wikidata.org/>`__

Getting started
---------------
Expand Down
4 changes: 2 additions & 2 deletions scholia/app/templates/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ <h2 id="Locations">Locations</h2>

<h2>Citation statistics</h2>

<h3>Highly cited works</h3>
<h3>Most cited works</h3>

Works of the author ordered according to number of citations received.

Expand All @@ -303,6 +303,6 @@ <h3>Citing authors</h3>

<table class="table table-hover" id="citing-authors"></table>

Missing citing authors here? Then go to <a href="{{ url_for('app.show_author_empty') }}{{ q }}/missing">missing</a> page.
Missing citing authors here? Then go to the <a href="{{ url_for('app.show_author_empty') }}{{ q }}/missing">missing</a> page.

{% endblock %}
35 changes: 34 additions & 1 deletion scholia/app/templates/author_missing.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,31 @@
{% block scripts %}
{{super()}}

<script type="text/javascript">
<script type="text/javascript">
missingAuthorResolvingSparql = `
SELECT
(COUNT(?work) AS ?count)
?author_name
(CONCAT(
'https://tools.wmflabs.org/author-disambiguator/?doit=Look+for+author&name=',
ENCODE_FOR_URI(?author_name)) AS ?author_resolver_url)
WHERE {
{
SELECT DISTINCT ?author_name {
wd:{{ q }} skos:altLabel | rdfs:label ?author_name_ .
# The SELECT-DISTINCT-BIND trick here is due to Stanislav Kralin
# https://stackoverflow.com/questions/53933564
BIND (STR(?author_name_) AS ?author_name)
}
}
OPTIONAL { ?work wdt:P2093 ?author_name . }
}
GROUP BY ?author_name
ORDER BY DESC(?count)
`

missingCoauthorItemsSparql = `
SELECT
# Number of works with the coauthor
Expand Down Expand Up @@ -87,6 +111,7 @@


$(document).ready(function() {
sparqlToDataTable(missingAuthorResolvingSparql, "#missing-author-resolving");
sparqlToDataTable(missingCoauthorItemsSparql, "#missing-coauthor-items");
sparqlToDataTable(missingCitingAuthorItemsSparql, "#missing-citing-author-items");
sparqlToDataTable(missingTopicSparql, "#missing-topic");
Expand All @@ -105,6 +130,14 @@ <h1 id="h1">Author</h1>
Missing information with respect to the author.


<h2>Author name strings to be resolved</h2>

The author may be represented as a string rather than a Wikidata item.
Follow the link to use the Author disambiguator tool to try to resolve the author name.

<table class="table table-hover" id="missing-author-resolving"></table>


<h2>Missing coauthor items</h2>

The coauthors listed below may only be represented as strings in Wikidata
Expand Down
2 changes: 1 addition & 1 deletion scholia/app/templates/award.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h2 id="Images of recipients">Images of recipients</h2>
<h2 id="Topics of works by recipients">Topics of works by recipients</h2>

<div class="embed-responsive embed-responsive-4by3">
<iframe class="embed-responsive-item" src="https://query.wikidata.org/embed.html#%23defaultView%3ABubbleChart%0A%23defaultView%3ABubbleChart%0A%23%20Count%20the%20number%20of%20time%20works%20by%20award%20recipients%20have%20set%20a%20main%20topic%0ASELECT%20%3Fcount%20%3Ftopic%20%3FtopicLabel%20%0AWITH%20%7B%0A%20%20SELECT%20%3Ftopic%20%28COUNT%28%3Fwork%29%20AS%20%3Fcount%29%20WHERE%20%7B%0A%20%20%20%20%3Frecipient%20wdt%3AP166%20wd%3A{{ q }}%20.%0A%20%20%20%20%3Fwork%20wdt%3AP50%20%3Frecipient%20.%0A%20%20%20%20%3Fwork%20wdt%3AP921%20%3Ftopic%20.%0A%20%20%7D%0A%20%20GROUP%20BY%20%3Ftopic%0A%7D%20AS%20%25result%0AWHERE%20%7B%0A%20%20INCLUDE%20%25result%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%2Cda%2Cde%2Ces%2Cfr%2Cjp%2Cno%2Cru%2Csv%2Czh%22%20.%20%7D%20%20%0A%7D%0AORDER%20BY%20DESC%28%3Fcount%29"></iframe>
<iframe class="embed-responsive-item" src="https://query.wikidata.org/embed.html#%23defaultView%3ABubbleChart%0A%23%20Count%20the%20number%20of%20time%20works%20by%20award%20recipients%20have%20set%20a%20main%20topic%0ASELECT%20%3Fcount%20%3Ftopic%20%3FtopicLabel%20%0AWITH%20%7B%0A%20%20SELECT%20%3Ftopic%20%28COUNT%28%3Fwork%29%20AS%20%3Fcount%29%20WHERE%20%7B%0A%20%20%20%20%3Frecipient%20wdt%3AP166%20wd%3A{{ q }}%20.%0A%20%20%20%20%3Fwork%20wdt%3AP50%20%3Frecipient%20.%0A%20%20%20%20%3Fwork%20wdt%3AP921%20%3Ftopic%20.%0A%20%20%7D%0A%20%20GROUP%20BY%20%3Ftopic%0A%7D%20AS%20%25result%0AWHERE%20%7B%0A%20%20INCLUDE%20%25result%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%2Cda%2Cde%2Ces%2Cfr%2Cjp%2Cno%2Cru%2Csv%2Czh%22%20.%20%7D%20%20%0A%7D%0AORDER%20BY%20DESC%28%3Fcount%29%0ALIMIT%2050"></iframe>
</div>


Expand Down
63 changes: 63 additions & 0 deletions scholia/app/templates/award_missing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{% extends "base.html" %}


{% block scripts %}
{{super()}}

<script type="text/javascript">
missingCoauthorItemsSparql = `
SELECT
# Number of works with the coauthor
?count
# The coauthor as a string, - rather than as an item
?coauthor
# Build URL to the Author disambiguator tool
(CONCAT(
'https://tools.wmflabs.org/author-disambiguator/?doit=Look+for+author&name=',
ENCODE_FOR_URI(?coauthor)) AS ?resolver_url)
WITH {
SELECT (COUNT(?work) as ?count) ?coauthor WHERE {
?work wdt:P50 ?author .
?author wdt:P166 wd:{{ q }} .
?work wdt:P2093 ?coauthor .
}
GROUP BY ?coauthor
LIMIT 2000
} AS %result
WHERE {
INCLUDE %result
# Label the results
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh". }
}
ORDER BY DESC(?count)
`



$(document).ready(function() {
sparqlToDataTable(missingCoauthorItemsSparql, "#missing-coauthor-items");
});


</script>

{% endblock %}


{% block page_content %}


<h2>Missing coauthor items</h2>

The coauthors listed below may only be represented as strings in Wikidata
with no link to Wikidata items.
Follow the link to use the Author disambiguator tool to try to resolve
the authors.

<table class="table table-hover" id="missing-coauthor-items"></table>



{% endblock %}
8 changes: 8 additions & 0 deletions scholia/app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
UNION
{ [] wdt:P123 wd:{{ q }} . BIND("publisher" AS ?aspect) }
UNION
{ [] wdt:P872 wd:{{ q }} . BIND("printer" AS ?aspect) }
UNION
{ [] wdt:P179 wd:{{ q }} . BIND("series" AS ?aspect) }
UNION
{ [] wdt:P859 wd:{{ q }} . BIND("sponsor" AS ?aspect) }
Expand All @@ -132,6 +134,10 @@
UNION
{ [] wdt:P1433 wd:{{ q }} . BIND("venue" AS ?aspect) }
UNION
{ wd:{{ q }} wdt:P235 [] . BIND("chemical" AS ?aspect) }
UNION
{ [] wdt:P279 | wdt:P31 wd:{{ q }} . BIND("chemical" AS ?aspect) }
UNION
{ wd:{{ q }} wdt:P50 | wdt:P2093 [] . BIND("work" AS ?aspect) }
}
`;
Expand Down Expand Up @@ -213,6 +219,7 @@
<li role="presentation"><a href="{{ url_for('app.show_series_empty') }}">Series</a></li>
<li role="presentation"><a href="{{ url_for('app.show_catalogue_empty') }}">Catalogue</a></li>
<li role="presentation"><a href="{{ url_for('app.show_publisher_empty') }}">Publisher</a></li>
<li role="presentation"><a href="{{ url_for('app.show_printer_empty') }}">Printer</a></li>
</ul>
</div>
</li>
Expand All @@ -224,6 +231,7 @@
<ul class="dropdown-menu">
<li role="presentation"><a href="{{ url_for('app.show_organization_empty') }}">Organization</a></li>
<li role="presentation"><a href="{{ url_for('app.show_publisher_empty') }}">Publisher</a></li>
<li role="presentation"><a href="{{ url_for('app.show_printer_empty') }}">Printer</a></li>
<li role="presentation"><a href="{{ url_for('app.show_sponsor_empty') }}">Sponsor</a></li>
</ul>
</div>
Expand Down
16 changes: 13 additions & 3 deletions scholia/app/templates/chemical.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@
}
} LIMIT 500
} AS %RESULTS {
INCLUDE %RESULTS
BIND(IRI(REPLACE(?formatterurl, '\\\\$1', str(?id))) AS ?idUrls).
{ SELECT * WHERE {
INCLUDE %RESULTS
FILTER (?IDpred = wd:P234)
BIND(IRI(REPLACE(?formatterurl, '\\\\$1', ENCODE_FOR_URI(str(?id)))) AS ?idUrls).
}
} UNION {
SELECT * WHERE {
INCLUDE %RESULTS
FILTER (?IDpred != wd:P234)
BIND(IRI(REPLACE(?formatterurl, '\\\\$1', str(?id))) AS ?idUrls).
}
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} GROUP BY ?IDpred ?IDpredLabel ?id
ORDER BY ASC(?IDpredLabel)
Expand Down Expand Up @@ -90,7 +100,7 @@
}
} AS %works
WITH {
SELECT (MAX(?dates) as ?datetime) ?work (GROUP_CONCAT(DISTINCT ?type_label; separator=", ") AS ?type) (GROUP_CONCAT(?topic_label; separator=" // ") AS ?topics) WHERE {
SELECT (MAX(?dates) as ?datetime) ?work (GROUP_CONCAT(DISTINCT ?type_label; separator=", ") AS ?type) (GROUP_CONCAT(DISTINCT ?topic_label; separator=" // ") AS ?topics) WHERE {
INCLUDE %works
?work wdt:P921 ?topic .
OPTIONAL { ?work wdt:P31 ?type_ . ?type_ rdfs:label ?type_label . FILTER (LANG(?type_label) = 'en') }
Expand Down
2 changes: 1 addition & 1 deletion scholia/app/templates/chemical_class.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}
} AS %works
WITH {
SELECT (MAX(?dates) as ?datetime) ?work (GROUP_CONCAT(DISTINCT ?type_label; separator=", ") AS ?type) (GROUP_CONCAT(?topic_label; separator=" // ") AS ?topics) WHERE {
SELECT (MAX(?dates) as ?datetime) ?work (GROUP_CONCAT(DISTINCT ?type_label; separator=", ") AS ?type) (GROUP_CONCAT(DISTINCT ?topic_label; separator=" // ") AS ?topics) WHERE {
INCLUDE %works
?work wdt:P921 ?topic .
OPTIONAL { ?work wdt:P31 ?type_ . ?type_ rdfs:label ?type_label . FILTER (LANG(?type_label) = 'en') }
Expand Down
6 changes: 3 additions & 3 deletions scholia/app/templates/country_topic.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h1 id="h1">Country-topic</h1>
<div id="intro"></div>


<h2 id="Authors">Authors of the country within the topics</h2>
<h2 id="Authors">Authors of the country who published on the topics</h2>

<table class="table table-hover" id="authors"></table>

Expand All @@ -70,10 +70,10 @@ <h2 id="Co-author graph">Co-author graph</h2>

<h2 id="Co-citation graph">Co-citation graph</h2>

Citations between authors within the country and topic.
Citations between authors of the country who published on the topic.

<div class="embed-responsive embed-responsive-4by3">
<iframe class="embed-responsive-item" src="https://query.wikidata.org/embed.html#%23defaultView%3AGraph%0ASELECT%0A%20%20%3Fauthor1%20%3Fauthor1Label%0A%20%20%3Fauthor2%20%3Fauthor2Label%0AWITH%20%7B%0A%20%20SELECT%0A%20%20%20%20%3Fauthor1%0A%20%20%20%20%3Fauthor2%20%0A%20%20WHERE%20%7B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%3Forganization%20wdt%3AP17%20wd%3A{{ q1 }}%20.%0A%20%20%20%20%20%20%3Fauthor1%20%28%20wdt%3AP108%20%7C%20wdt%3AP1416%20%29%20%3Forganization%20.%0A%20%20%20%20%20%20%3Fauthor2%20%28%20wdt%3AP108%20%7C%20wdt%3AP1416%20%29%20%3Forganization%20.%0A%0A%20%20%20%20%20%20%3Fwork1%20wdt%3AP921%20%2F%20%28wdt%3AP361%2B%20%7C%20wdt%3AP1269%2B%20%7C%20%28wdt%3AP31%2a%20%2F%20wdt%3AP279%2a%29%20%29%20wd%3A{{ q2 }}%20.%0A%0A%20%20%20%20%20%20%3Fwork1%20wdt%3AP50%20%3Fauthor1%20.%0A%20%20%20%20%20%20%3Fwork2%20wdt%3AP50%20%3Fauthor2%20.%0A%0A%20%20%20%20%20%20%3Fwork1%20wdt%3AP2860%20%3Fwork2%20.%0A%20%20%20%20%7D%0A%20%20%20%20UNION%20%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%3Forganization%20wdt%3AP17%20wd%3A{{ q1 }}%20.%0A%20%20%20%20%20%20%3Fauthor1%20%28%20wdt%3AP108%20%7C%20wdt%3AP1416%20%29%20%3Forganization%20.%0A%20%20%20%20%20%20%3Fauthor2%20%28%20wdt%3AP108%20%7C%20wdt%3AP1416%20%29%20%3Forganization%20.%0A%0A%20%20%20%20%20%20%3Fwork2%20wdt%3AP921%20%2F%20%28wdt%3AP361%2B%20%7C%20wdt%3AP1269%2B%20%7C%20%28wdt%3AP31%2a%20%2F%20wdt%3AP279%2a%29%20%29%20wd%3A{{ q2 }}%20.%0A%0A%20%20%20%20%20%20%3Fwork1%20wdt%3AP50%20%3Fauthor1%20.%0A%20%20%20%20%20%20%3Fwork2%20wdt%3AP50%20%3Fauthor2%20.%0A%0A%20%20%20%20%20%20%3Fwork1%20wdt%3AP2860%20%3Fwork2%20.%0A%20%20%20%20%7D%20%20%0A%20%20%20%0A%20%20%20%20FILTER%20%28%3Fauthor1%20%21%3D%20%3Fauthor2%29%0A%20%20%7D%0A%7D%20AS%20%25results%0AWHERE%20%7B%0A%20%20INCLUDE%20%25results%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%2Cda%2Cde%2Ces%2Cfr%2Cjp%2Cnl%2Cno%2Cru%2Csv%2Czh%22.%20%7D%0A%7D%0A"></iframe>
<iframe class="embed-responsive-item" src="https://query.wikidata.org/embed.html#%23defaultView%3AGraph%0ASELECT%0A%20%20%3Fauthor1%20%3Fauthor1Label%0A%20%20%3Fauthor2%20%3Fauthor2Label%0AWITH%20%7B%0A%20%20SELECT%20DISTINCT%20%3Fauthor1%20%3Fwork1%20WHERE%20%7B%0A%20%20%20%20hint%3AQuery%20hint%3Aoptimizer%20%22None%22.%0A%20%20%20%20%3Fauthor1%20%28%20wdt%3AP108%20%7C%20wdt%3AP1416%20%29%20%2F%20wdt%3AP17%20wd%3A{{ q1 }}%20.%0A%20%20%20%20%3Fwork1%20wdt%3AP50%20%3Fauthor1%20.%0A%20%20%20%20%3Fwork1%20wdt%3AP921%20%2F%20%28wdt%3AP361%2B%20%7C%20wdt%3AP1269%2B%20%7C%20%28wdt%3AP31%2a%20%2F%20wdt%3AP279%2a%29%20%29%20wd%3A{{ q2 }}%20.%0A%20%20%7D%0A%7D%20AS%20%25author1%0AWITH%20%7B%0A%20%20SELECT%20DISTINCT%20%3Fauthor2%20%3Fwork2%20WHERE%20%7B%0A%20%20%20%20hint%3AQuery%20hint%3Aoptimizer%20%22None%22.%0A%20%20%20%20%3Fauthor2%20%28%20wdt%3AP108%20%7C%20wdt%3AP1416%20%29%20%2F%20wdt%3AP17%20wd%3A{{ q1 }}%20.%0A%20%20%20%20%3Fwork2%20wdt%3AP50%20%3Fauthor2%20.%0A%20%20%20%20%3Fwork2%20wdt%3AP921%20%2F%20%28wdt%3AP361%2B%20%7C%20wdt%3AP1269%2B%20%7C%20%28wdt%3AP31%2a%20%2F%20wdt%3AP279%2a%29%20%29%20wd%3A{{ q2 }}%20.%0A%20%20%7D%0A%7D%20AS%20%25author2%0AWITH%20%7B%0A%20%20SELECT%0A%20%20%20%20DISTINCT%20%0A%20%20%20%20%3Fauthor1%0A%20%20%20%20%3Fauthor2%20%0A%20%20WHERE%20%7B%0A%20%20%20%20INCLUDE%20%25author1%0A%20%20%20%20INCLUDE%20%25author2%0A%20%20%20%20%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%3Fwork1%20wdt%3AP2860%20%2F%20wdt%3AP50%20%3Fauthor2%20.%0A%20%20%20%20%7D%0A%20%20%20%20UNION%20%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%3Fauthor1%20%5Ewdt%3AP50%20%2F%20wdt%3AP2860%20%3Fwork2%20.%0A%20%20%20%20%7D%20%20%0A%20%20%20%0A%20%20%20%20FILTER%20%28%3Fauthor1%20%21%3D%20%3Fauthor2%29%0A%20%20%7D%0A%7D%20AS%20%25results%0AWHERE%20%7B%0A%20%20INCLUDE%20%25results%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%2Cda%2Cde%2Ces%2Cfr%2Cjp%2Cnl%2Cno%2Cru%2Csv%2Czh%22.%20%7D%0A%7D%0A"></iframe>
</div>


Expand Down
44 changes: 44 additions & 0 deletions scholia/app/templates/event_empty.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,39 @@

<script type="text/javascript">

comingDeadlinesSparql = `
SELECT
?date
?short_name
?event ?eventLabel
?location ?locationLabel
WITH {
SELECT
?datetime ?event
(SAMPLE(?location_) AS ?location)
(SAMPLE(?short_name_) AS ?short_name)
WHERE {
?event p:P793 ?key_event_statement .
?key_event_statement ps:P793 / wdt:P279 wd:Q2404808 ;
pq:P585 ?datetime .
FILTER (NOW() < ?datetime)
OPTIONAL { ?event wdt:P276 ?location_ }
OPTIONAL { ?event wdt:P1813 ?short_name_ }
}
GROUP BY ?datetime ?event
ORDER BY(?datetime)
LIMIT 200
} AS %events
WHERE {
INCLUDE %events
BIND(xsd:date(?datetime) AS ?date)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,da,de,es,fr,jp,nl,no,ru,sv,zh". }
}
ORDER BY(?date)
`


futureEventsSparql = `
SELECT ?time ?short_name ?event ?eventLabel ?location ?locationLabel
WITH {
Expand Down Expand Up @@ -80,6 +113,12 @@


$(document).ready(function() {
sparqlToDataTable(comingDeadlinesSparql, "#coming-deadlines", {
linkPrefixes: {
event: "../event/",
location: "../location/",
}
});
sparqlToDataTable(futureEventsSparql, "#future-events", {
linkPrefixes: {
event: "../event/",
Expand All @@ -102,6 +141,11 @@

<h1>Events</h1>

<h2 id="Coming deadlines">Coming deadlines</h2>

<table class="table table-hover" id="coming-deadlines"></table>


<h2 id="Future events">Future events</h2>

<table class="table table-hover" id="future-events"></table>
Expand Down
Loading

0 comments on commit 589c069

Please sign in to comment.