forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompanies_donation.rq
69 lines (68 loc) · 2.62 KB
/
companies_donation.rq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Number of PM20 companies per wiki language (used to match company names)
# and percentage of already matched entries
#
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX frapo: <http://purl.org/cerif/frapo/>
PREFIX hint: <http://www.bigdata.com/queryHints#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
#
select ?wikiLang ?catalog ('M-n-m' as ?catalogLabel)
(str(count(distinct ?id)) as ?pm20CompanyCount) (str(sum(?directlyLinked)) as ?directLinks)
(concat(str(round(sum(?directlyLinked) / count(distinct ?id)*1000)/10), ' %') as ?percentageDone)
(str(sum(?new)) as ?itemsCreated)
(concat(str(round(sum(?new) / count(distinct ?id)*1000)/10), ' %') as ?percentageCreated)
where {
hint:Query hint:optimizer "None" .
#
# existing Mix-n-match catalogs
values ( ?wikiLang ?catalogId ) {
( 'nl' '4397' )
( 'en' '4414' )
( 'fr' '4521' )
( 'de' '4492' )
( 'und' '4542' )
}
# base set of entries from PM20
service <https://zbw.eu/beta/sparql/pm20/query> {
# query restricts result to folders with documents
?pm20 a zbwext:CompanyFolder ;
dct:identifier ?id ;
zbwext:adjustedLabel ?name ;
frapo:hasCountryCode ?country ;
zbwext:totalDocCount ?docCount .
#
# this is the filter for defining the separate mnm catalogs (parts)
bind(
if(?country in ('NL', 'ID', 'AO'), 'nl',
if(?country in ('GB', 'US', 'CA', 'AU', 'ZA', 'IE', 'MY', 'ZW'), 'en',
if(?country in ('FR', 'VN', 'BE', 'CD', 'LU', 'DZ'), 'fr',
if(?country in ('DE', 'AT', 'CH', 'HU', 'TZ', 'PL', 'CZ', 'WS'), 'de',
'und')))) as ?wikiLang)
}
# mark already directly linked entries
optional {
?statement ps:P4293 ?id .
?wd p:P4293 ?statement .
optional {
?statement pq:P4390 ?relType .
}
# don't take into account related matches (mapping relation type)
filter(!bound(?relType) || ?relType!=wd:Q39894604)
}
bind(if(bound(?wd), 1, 0) as ?directlyLinked)
#
# check if the item was created after start of the PM20 companies' linking phase
# at 2021-04-26, first new item Q106647030
bind(xsd:integer(strafter(str(?wd), concat(str(wd:), 'Q'))) as ?qidNum)
bind(if(?qidNum >= 106647030, 1, 0) as ?new)
#
bind(uri(concat('https://mix-n-match.toolforge.org/#/catalog/', ?catalogId)) as ?catalog)
}
group by ?wikiLang ?catalog
order by ?wikiLang