Skip to content

Commit

Permalink
Add co-occurring wikiproject panel
Browse files Browse the repository at this point in the history
  • Loading branch information
carlinmack committed Jul 1, 2023
1 parent 59db86c commit 1a3e2d6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions scholia/app/templates/wikiproject.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

{{ sparql_to_table("maintained") }}
{{ sparql_to_table("focus") }}
{{ sparql_to_table('co-occurring-wikiprojects') }}

{{ sparql_to_iframe('context') }}
{{ sparql_to_table('recently-published-works') }}
Expand Down Expand Up @@ -41,6 +42,10 @@ <h2 id="context">The topic in context</h2>
<iframe class="embed-responsive-item" id="context-iframe"></iframe>
</div>

<h2 id="co-occurring-wikiprojects">Co-occurring WikiProjects</h2>

<table class="table table-hover" id="co-occurring-wikiprojects-table"></table>

<h2 id="works">Works</h2>

<h3 id="recently-published-works">Recently published works<a
Expand Down
27 changes: 27 additions & 0 deletions scholia/app/templates/wikiproject_co-occurring.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#defaultView:Table

PREFIX target: <http://www.wikidata.org/entity/{{ q }}>

SELECT ?count
?wikiproject ?wikiprojectLabel (CONCAT("/wikiproject/", SUBSTR(STR(?wikiproject), 32)) AS ?wikiprojectUrl)
?example_work ?example_workLabel (CONCAT("/work/", SUBSTR(STR(?example_work), 32)) AS ?example_workUrl)
WITH {
SELECT (COUNT(?work) AS ?count) ?wikiproject (SAMPLE(?work) AS ?example_work) WHERE {
# Find works for the specific queried wikiproject
VALUES ?p { wdt:P6104 wdt:P5008 }
SERVICE bd:sample { ?work ?p target: . bd:serviceParam bd:sample.limit 100000 }

# Find co-occuring wikiprojects
?work ?p ?wikiproject .

# Avoid listing the queried wikiproject
FILTER (target: != ?wikiproject)
}
GROUP BY ?wikiproject
} AS %result
WHERE {
# Label the results
INCLUDE %result
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
}
ORDER BY DESC(?count)
1 change: 0 additions & 1 deletion scholia/app/templates/wikiproject_topics.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ WITH {
SELECT (COUNT(?work) AS ?count) ?topic (SAMPLE(?work) AS ?example_work) WHERE {
# Find works for the specific queried topic
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
Expand Down

0 comments on commit 1a3e2d6

Please sign in to comment.