Skip to content

Commit e518a5f

Browse files
committed
Merge branch 'qlever' of https://github.com/ad-freiburg/scholia into qlever
2 parents c2ec36a + 130d9be commit e518a5f

15 files changed

+219
-203
lines changed

README.apache-config.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
Currently runs on <https://qlever.scholia.wiki> and
44
<https://wikidata-query-gui.scholia.wiki> with the following
5-
Apache configurations:
5+
Apache configurations.
6+
7+
## qlever.scholia.wiki
68

79
```apache
810
<VirtualHost *:443>
@@ -30,6 +32,8 @@ Apache configurations:
3032
</VirtualHost>
3133
```
3234

35+
## wikidata-query-gui.scholia.wiki
36+
3337
```apache
3438
<VirtualHost *:443>
3539
ServerName wikidata-query-gui.scholia.wiki

scholia/app/static/scholia.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ function sparqlToDataTablePost2(url, editURL, sparql, element, filename, options
265265
var paging = (typeof options.paging === 'undefined') ? true : options.paging;
266266
var sDom = (typeof options.sDom === 'undefined') ? 'lfrtip' : options.sDom;
267267
var sparqlEndpointName = (typeof options.sparqlEndpointName === 'undefined')
268-
? window.jsConfig.sparqlEndpointName : options.sparqlEndpointName;
268+
? window.jsConfig.sparqlEndpointName : options.sparqlEndpointName;
269269

270270
$(element).html("<div class='loader'><div></div><div></div><div></div></div>");
271271

@@ -304,7 +304,7 @@ function sparqlToDataTablePost2(url, editURL, sparql, element, filename, options
304304
'<caption><span style="float:left; font-size:smaller;"><a href="' + editURL +
305305
encodeURIComponent(sparql) +
306306
'">' + sparqlEndpointName + '</a></span>' +
307-
'<span style="float:right; font-size:smaller;"><a href="https://github.com/WDscholia/scholia/blob/main/scholia/app/templates/' +
307+
'<span style="float:right; font-size:smaller;"><a href="https://github.com/ad-freiburg/scholia/blob/qlever/scholia/app/templates/' +
308308
filename + '">' +
309309
filename.replace("_", ": ") +
310310
'</a></span></caption>'
@@ -377,7 +377,7 @@ function sparqlToDataTable2(url, editURL, sparql, element, filename, options = {
377377
const datatableFooter =
378378
'<caption><span style="float:left; font-size:smaller;"><a href="' + editURL +
379379
encodeURIComponent(sparql) + '">' + sparqlEndpointName + '</a></span>' +
380-
'<span style="float:right; font-size:smaller;"><a href="https://github.com/WDscholia/scholia/blob/main/scholia/app/templates/' +
380+
'<span style="float:right; font-size:smaller;"><a href="https://github.com/ad-freiburg/scholia/blob/qlever/scholia/app/templates/' +
381381
filename +
382382
'">' +
383383
filename.replace('_', ': ') +
@@ -493,9 +493,9 @@ function sparqlToDataTable2(url, editURL, sparql, element, filename, options = {
493493
$('#' + loaderID).remove(); // remove loader
494494
let error_message = "";
495495
try {
496-
error_message = "QLever execption: " + JSON.parse(jqXHR.responseText).exception;
496+
error_message = "QLever execption: " + JSON.parse(jqXHR.responseText).exception;
497497
} catch (e) {
498-
error_message = "getJSON query failed: " + textStatus + " " + errorThrown;
498+
error_message = "getJSON query failed: " + textStatus + " " + errorThrown;
499499
}
500500
$(element).prepend("<p style='color:red;'>" + escapeHTML(error_message) + "</p>");
501501
const reloadButton = document.getElementById(element.slice(1) + '-reload');
@@ -525,6 +525,13 @@ function sparqlToIframe2(url, editURL, embedURL, sparql, element, filename) {
525525

526526
if (!embedURL) embedURL = "https://query.wikidata.org/embed.html#";
527527

528+
// overwrite the central URLs of SPARQL specific URLs are found
529+
configFromSPARQL = extractConfig(sparql);
530+
if (configFromSPARQL["url"]) url = configFromSPARQL["url"];
531+
if (configFromSPARQL["editURL"]) editURL = configFromSPARQL["editURL"];
532+
if (configFromSPARQL["embedURL"]) embedURL = configFromSPARQL["embedURL"];
533+
if (configFromSPARQL["endpointName"]) sparqlEndpointName = configFromSPARQL["endpointName"];
534+
528535
const wikidata_sparql = url + "?query=" + encodeURIComponent(sparql);
529536
const wikidata_query = editURL + encodeURIComponent(sparql);
530537
var url = embedURL + encodeURIComponent(sparql);
@@ -569,7 +576,7 @@ function sparqlToIframe2(url, editURL, embedURL, sparql, element, filename) {
569576
}
570577
$iframe.parent().after(
571578
'<span style="float:right; font-size:smaller">' +
572-
'<a href="https://github.com/WDscholia/scholia/blob/main/scholia/app/templates/' + filename + '">' +
579+
'<a href="https://github.com/ad-freiburg/scholia/blob/qlever/scholia/app/templates/' + filename + '">' +
573580
filename.replace("_", ": ") +
574581
'</a>' +
575582
'</span>'
@@ -806,9 +813,12 @@ function askQuery(panel, askQuery, callback) {
806813

807814

808815
function askQuery2(endpointUrl, panel, askQuery, callback) {
809-
if (!endpointUrl) endpointUrl = "https://query.wikidata.org/sparql";
810-
811-
var settings = {
816+
if (!endpointUrl) endpointUrl = "https://query.wikidata.org/sparql";
817+
// overwrite the central URLs of SPARQL specific URLs are found
818+
configFromSPARQL = extractConfig(askQuery);
819+
if (configFromSPARQL["url"]) endpointUrl = configFromSPARQL["url"];
820+
821+
var settings = {
812822
headers: { Accept: 'application/sparql-results+json' },
813823
data: { query: askQuery },
814824
};
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
22
# title: list known allotropes
3-
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>
43
PREFIX p: <http://www.wikidata.org/prop/>
54
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
65
PREFIX ps: <http://www.wikidata.org/prop/statement/>
76
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
87
PREFIX wd: <http://www.wikidata.org/entity/>
98
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
109
PREFIX wikibase: <http://wikiba.se/ontology#>
11-
SELECT DISTINCT ?allotrope ?allotropeLabel ?density ?densityUnit ?densityUnitLabel {
10+
SELECT DISTINCT ?allotrope ?allotropeLabel (SAMPLE(?density_) AS ?density) ?densityUnit ?densityUnitLabel {
1211
{
13-
SELECT ?allotrope (SAMPLE(?densityStats) AS ?densityStat) WHERE {
14-
?allotrope wdt:P31 | wdt:P279 ?allotropeType .
15-
?allotropeType p:P279 ?allotropeSpecsStatement .
16-
?allotropeSpecsStatement ps:P279 wd:Q21198401 ;
17-
pq:P642 target: .
18-
OPTIONAL {
19-
?allotrope p:P2054 ?densityStats .
20-
}
12+
SELECT DISTINCT ?allotrope ?allotropeLabel WHERE {
13+
?allotropeType wdt:P279 wd:Q21198401 ;
14+
wdt:P279 wd:Q623 .
15+
{ ?allotropeType ^wdt:P279* ?allotrope }
16+
UNION
17+
{ ?allotropeType ^wdt:P279* ?allotrope ; ^wdt:P2054 [] }
18+
{{ sparql_helpers.labels(["?allotrope"], languages) }}
2119
}
22-
GROUP BY ?allotrope
2320
}
2421
OPTIONAL {
2522
?allotrope p:P2054 ?densityStat .
2623
?densityStat psv:P2054 ?densityValNode .
27-
?densityValNode wikibase:quantityAmount ?density ;
24+
?densityValNode wikibase:quantityAmount ?density_ ;
2825
wikibase:quantityUnit ?densityUnit .
26+
{{ sparql_helpers.labels(["?densityUnit"], languages) }}
2927
}
30-
{{ sparql_helpers.labels(["?allotrope", "?densityUnit"], languages) }}
31-
}
32-
ORDER BY ASC(?allotropeLabel)
28+
} GROUP BY ?allotrope ?allotropeLabel ?densityUnit ?densityUnitLabel
29+
ORDER BY DESC(?density) ASC(?allotropeLabel)

scholia/app/templates/chemical_found-in-taxon.sparql

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@ PREFIX ps: <http://www.wikidata.org/prop/statement/>
77
PREFIX wd: <http://www.wikidata.org/entity/>
88
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
99
SELECT DISTINCT ?taxon ?taxonLabel (CONCAT("/taxon/", SUBSTR(STR(?taxon),32)) AS ?taxonUrl) ?source ?sourceLabel (CONCAT("/work/", SUBSTR(STR(?source),32)) AS ?sourceUrl) ?doi WHERE {
10-
wd:{{ q }} p:P703 ?taxonStatement .
11-
?taxonStatement ps:P703 wd:{{ q }} .
12-
OPTIONAL {
13-
?taxonStatement prov:wasDerivedFrom/pr:P248 ?source .
14-
OPTIONAL {
15-
?source wdt:P356 ?doi .
16-
}
10+
{
11+
SELECT DISTINCT ?taxon (SAMPLE (?source_) AS ?source) (SAMPLE (?doi_) AS ?doi) WHERE {
12+
{
13+
wd:{{ q }} p:P703 ?taxonStatement .
14+
?taxonStatement ps:P703 ?taxon .
15+
} UNION {
16+
wd:{{ q }} p:P703 ?taxonStatement .
17+
?taxonStatement ps:P703 ?taxon .
18+
?taxonStatement prov:wasDerivedFrom/pr:P248 ?source_ .
19+
} UNION {
20+
wd:{{ q }} p:P703 ?taxonStatement .
21+
?taxonStatement ps:P703 ?taxon .
22+
?taxonStatement prov:wasDerivedFrom/pr:P248 ?source_ .
23+
?source_ wdt:P356 ?doi_ .
24+
}
25+
} GROUP BY ?taxon
1726
}
1827
{{ sparql_helpers.labels(["?taxon"], languages) }}
1928
{{ sparql_helpers.labels_unbound(["?source"], languages) }}

scholia/app/templates/chemical_physchem-properties.sparql

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,47 @@ PREFIX wikibase: <http://wikiba.se/ontology#>
1212
SELECT DISTINCT ?propEntity ?propEntityLabel ?value ?units ?unitsLabel ?qualifiers ?source ?sourceLabel ?doi WHERE {
1313
{
1414
SELECT DISTINCT ?propEntity ?value ?units ?source ?doi (GROUP_CONCAT(?qualifierStr; SEPARATOR=", ") AS ?qualifiers) WHERE {
15-
target: ?propp ?statement .
16-
?statement a wikibase:BestRank ;
17-
?proppsv [
18-
wikibase:quantityAmount ?value ; wikibase:quantityUnit ?units
19-
] .
20-
OPTIONAL {
21-
?statement prov:wasDerivedFrom/pr:P248 ?source .
22-
OPTIONAL {
23-
?source wdt:P356 ?doi .
24-
}
25-
}
26-
?property wikibase:claim ?propp ;
15+
{
16+
SELECT DISTINCT ?propEntity ?statement ?value ?units (SAMPLE (?source_) AS ?source) (SAMPLE( ?doi_) AS ?doi) WHERE {
17+
{
18+
target: ?propp ?statement .
19+
?statement a wikibase:BestRank ; ?proppsv [ wikibase:quantityAmount ?value ; wikibase:quantityUnit ?units ] .
20+
} UNION {
21+
target: ?propp ?statement .
22+
?statement a wikibase:BestRank ; ?proppsv [ wikibase:quantityAmount ?value ; wikibase:quantityUnit ?units ] .
23+
?statement prov:wasDerivedFrom/pr:P248 ?source_ .
24+
} UNION {
25+
target: ?propp ?statement .
26+
?statement a wikibase:BestRank ; ?proppsv [ wikibase:quantityAmount ?value ; wikibase:quantityUnit ?units ] .
27+
?statement prov:wasDerivedFrom/pr:P248 ?source_ .
28+
?source_ wdt:P356 ?doi_ .
29+
}
30+
?property wikibase:claim ?propp ;
2731
wikibase:statementValue ?proppsv ;
2832
wdt:P1629 ?propEntity ;
2933
wdt:P31 wd:Q21077852 .
30-
OPTIONAL {
31-
{
32-
?qualifierProp wikibase:qualifier ?qualifier ;
34+
} GROUP BY ?propEntity ?value ?units ?statement
35+
}
36+
OPTIONAL {
37+
?property wikibase:claim ?propp ;
38+
wdt:P1629 ?propEntity .
39+
{
40+
target: ?propp ?statement .
41+
?statement ?qualifier ?qualifierVal .
42+
?qualifier a owl:DatatypeProperty .
43+
?qualifierProp wikibase:qualifier ?qualifier ;
3344
rdfs:label ?qProplabel ; FILTER (LANG(?qProplabel) = "en") .
34-
?qualifier a owl:DatatypeProperty .
35-
?statement ?qualifier ?qualifierVal .
36-
BIND (CONCAT(STR(?qProplabel), ": ", STR(?qualifierVal)) AS ?qualifierStr)
37-
}
38-
UNION {
39-
?qualifierProp wikibase:qualifier ?qualifier ;
45+
BIND (CONCAT(STR(?qProplabel), ": ", STR(?qualifierVal)) AS ?qualifierStr)
46+
} UNION {
47+
target: ?propp ?statement .
48+
?statement ?qualifier ?qualifierVal .
49+
?qualifier a owl:ObjectProperty .
50+
?qualifierVal rdfs:label ?qVallabel ; FILTER (LANG(?qVallabel) = "en") .
51+
?qualifierProp wikibase:qualifier ?qualifier ;
4052
rdfs:label ?qProplabel ; FILTER (LANG(?qProplabel) = "en") .
41-
?qualifier a owl:ObjectProperty .
42-
?statement ?qualifier ?qualifierVal .
43-
?qualifierVal rdfs:label ?qVallabel ; FILTER (LANG(?qVallabel) = "en") .
44-
BIND (CONCAT(STR(?qProplabel), ": ", STR(?qVallabel)) AS ?qualifierStr)
45-
}
46-
}
53+
BIND (CONCAT(STR(?qProplabel), ": ", STR(?qVallabel)) AS ?qualifierStr)
54+
}
55+
}
4756
}
4857
GROUP BY ?propEntity ?value ?units ?source ?doi
4958
}

scholia/app/templates/cito-index_articles-by-year.sparql

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,32 @@ PREFIX wd: <http://www.wikidata.org/entity/>
88
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
99
SELECT DISTINCT ?year (COUNT(?work) AS ?number_of_publications) ?role WHERE {
1010
{
11-
SELECT ?work (MIN(?years) AS ?year) ?type_ ?venue WHERE {
12-
?work wdt:P577 ?dates ;
13-
p:P2860 ?citesStatement .
14-
?citesStatement pq:P3712/wdt:P31 wd:Q96471816 .
15-
BIND (STR(YEAR(?dates)) AS ?years) .
16-
OPTIONAL {
17-
?work wdt:P31 wd:Q109229154 .
11+
SELECT DISTINCT ?work (MIN(?years) AS ?year) ?type_ ?role WHERE {
12+
{
13+
wd:Q96471816 ^wdt:P31 / ^pq:P3712 ?citesStatement .
14+
?citesStatement ^p:P2860 ?work .
15+
?work wdt:P31 wd:Q109229154 ;
16+
wdt:P1433 ?venue_ .
17+
?venue_ rdfs:label ?venue . FILTER (LANG(?venue) = "en" || LANG(?venue) = "mul")
18+
MINUS { ?venue_ wdt:P31 wd:Q1143604 }
1819
BIND ("explicit" AS ?type_)
19-
?work wdt:P1433 ?venue_ .
20-
?venue_ rdfs:label ?venue . FILTER (LANG(?venue) = "en" || LANG(?venue) = "mul")
21-
MINUS {
22-
?venue_ wdt:P31 wd:Q1143604
23-
}
24-
}
25-
OPTIONAL {
20+
} UNION {
21+
wd:Q96471816 ^wdt:P31 / ^pq:P3712 ?citesStatement .
22+
?citesStatement ^p:P2860 ?work .
23+
?citesStatement prov:wasDerivedFrom ?reference .
24+
?reference pr:P12545 ?referenceURL .
2625
BIND ("nanopub" AS ?type_)
2726
BIND ("Nanopublication" AS ?venue)
28-
?citesStatement prov:wasDerivedFrom ?reference .
29-
?reference pr:P854 | pr:P12545 ?referenceURL .
30-
FILTER (STRSTARTS(STR(?referenceURL),"https://w3id.org/np/") || STRSTARTS(STR(?referenceURL),"http://purl.org/np/"))
27+
} UNION {
28+
wd:Q96471816 ^wdt:P31 / ^pq:P3712 ?citesStatement .
29+
?citesStatement ^p:P2860 ?work .
30+
MINUS { ?work wdt:P31 wd:Q109229154 }
31+
MINUS { ?citesStatement prov:wasDerivedFrom / pr:P12545 [] }
32+
BIND ("other source" AS ?venue)
3133
}
32-
}
33-
GROUP BY ?work ?type_ ?venue
34+
BIND (COALESCE(IF(BOUND(?type_),?venue,'other source')) AS ?role)
35+
?work wdt:P577 ?dates .
36+
BIND (STR(YEAR(?dates)) AS ?years) .
37+
} GROUP BY ?work ?type_ ?role
3438
}
35-
BIND (COALESCE(IF(BOUND(?type_),?venue,'other source')) AS ?role)
36-
}
37-
GROUP BY ?year ?role
38-
ORDER BY ?year
39+
} GROUP BY ?year ?role

scholia/app/templates/complex_articles-by-year.sparql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ SELECT (STR(?year_) AS ?year) (COUNT(?work) AS ?number_of_publications)
4444
}
4545
GROUP BY ?dummy
4646
}
47-
BIND (YEAR(NOW()
48-
) AS ?this_year ) FILTER ( ?year_ >= ?earliest_year && ?year_ <= ?this_year && ?year_ >= YEAR ( "1900-01-01" ^^ xsd:dateTime ) )}
47+
BIND (YEAR(NOW() ) AS ?this_year )
48+
FILTER ( ?year_ >= ?earliest_year && ?year_ <= ?this_year && ?year_ >= YEAR ( "1900-01-01" ^^ xsd:date ) )
49+
}
4950
GROUP BY ?year_ ?type
5051
ORDER BY ?year

scholia/app/templates/dataset_identifiers.sparql

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,13 @@
11
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
2-
PREFIX target: <http://www.wikidata.org/entity/{{ q }}>
3-
PREFIX bd: <http://www.bigdata.com/rdf#>
42
PREFIX wd: <http://www.wikidata.org/entity/>
53
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
64
PREFIX wikibase: <http://wikiba.se/ontology#>
75
SELECT ?Identifier ?IdentifierLabel ?id (SAMPLE(?idUrls) AS ?idUrl) ?IdentifierDescription {
8-
{
9-
SELECT * WHERE {
10-
{
11-
SELECT ?Identifier ?id ?formatterurl WHERE {
12-
target: ?IDdir ?id .
13-
?Identifier wikibase:directClaim ?IDdir ;
14-
wdt:P31/wdt:P279* wd:Q19847637 .
15-
OPTIONAL {
16-
?Identifier wdt:P1630 ?formatterurl .
17-
}
18-
}
19-
LIMIT 500
20-
}
21-
FILTER (?Identifier = wd:P234)
22-
BIND (IRI(REPLACE(?formatterurl, '\\\\$1', ENCODE_FOR_URI(STR(?id)))) AS ?idUrls) .
23-
}
24-
}
25-
UNION {
26-
SELECT * WHERE {
27-
{
28-
SELECT ?Identifier ?id ?formatterurl WHERE {
29-
target: ?IDdir ?id .
30-
?Identifier wikibase:directClaim ?IDdir ;
31-
wdt:P31/wdt:P279* wd:Q19847637 .
32-
OPTIONAL {
33-
?Identifier wdt:P1630 ?formatterurl .
34-
}
35-
}
36-
LIMIT 500
37-
}
38-
FILTER (?Identifier != wd:P234)
39-
BIND (IRI(REPLACE(?formatterurl, '\\\\$1', STR(?id))) AS ?idUrls) .
40-
}
41-
}
6+
wd:{{ q }} ?IDdir ?id .
7+
?Identifier wikibase:directClaim ?IDdir ;
8+
wdt:P31/wdt:P279* wd:Q19847637 .
9+
OPTIONAL { ?Identifier wdt:P1630 ?formatterurl . }
10+
BIND (IRI(REPLACE(?formatterurl, '\\\\$1', STR(?id))) AS ?idUrls) .
4211
{{ sparql_helpers.labels(["?Identifier"], languages) }}
4312
{{ sparql_helpers.descriptions(["?Identifier"], languages) }}
4413
}

0 commit comments

Comments
 (0)