From 25b4ca85cf535629a7e1cdce02999084e5bc2535 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 6 May 2020 14:21:39 -0700 Subject: start refactoring files into module --- extra/wikidata/wikidata.sparql | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 extra/wikidata/wikidata.sparql (limited to 'extra/wikidata') diff --git a/extra/wikidata/wikidata.sparql b/extra/wikidata/wikidata.sparql new file mode 100644 index 0000000..3f7e2f9 --- /dev/null +++ b/extra/wikidata/wikidata.sparql @@ -0,0 +1,35 @@ +# this query fetches basic metadata for about 45k journal from wikidata +# run at: https://query.wikidata.org/ +# +# NOTE: the publisher label somtimes falls through to a QID or "t"-prefixed +# number if the publisher name isn't actually known + +# would rather have direct QID instead of URL, but this seems to slow things down too much (query times out) +#SELECT (REPLACE(STR(?item),".*Q","Q") AS ?wikidata_qid) (SAMPLE(?issn) AS ?issn) (SAMPLE(?title) AS ?title) (SAMPLE(?publisherLabel) AS ?publisher_name) (SAMPLE(?websiteurl) AS ?websiteurl) (str(YEAR(SAMPLE(?inception))) AS ?start_year) + +SELECT ?item (SAMPLE(?issn) AS ?issn) (SAMPLE(?title) AS ?title) (SAMPLE(?publisherLabel) AS ?publisher_name) (SAMPLE(?websiteurl) AS ?websiteurl) (str(YEAR(SAMPLE(?inception))) AS ?start_year) +WHERE +{ + # any instance of... + { ?item wdt:P31 wd:Q5633421 } # "scientific journal" + UNION { ?item wdt:P31 wd:Q773668 } # "open access journal" + UNION { ?item wdt:P31 wd:Q737498 } # "academic journal" + UNION { ?item wdt:P31 wd:Q49850 } # "journal" + UNION { ?item wdt:P31 wd:Q51135530 } # "humanities journal" + + # must have an ISSN + ?item wdt:P1476 ?title + + # may have title, website, publisher, inception date + OPTIONAL{?item wdt:P236 ?issn} + OPTIONAL{?item wdt:P856 ?websiteurl} + OPTIONAL{?item wdt:P123 ?publisher} + OPTIONAL{?item wdt:P571 ?inception} + + # "label service" to turn publisher entity into name + SERVICE wikibase:label { bd:serviceParam wikibase:language "en,pt,es,de,fr,ja". + ?publisher rdfs:label ?publisherLabel. } +} GROUP BY ?item + +# could include all known ISSNs instead of just one with: +# (GROUP_CONCAT(DISTINCT ?issn; SEPARATOR=";") AS ?issns) -- cgit v1.2.3