File size: 3,082 Bytes
d585e77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
PREFIX yago: <http://yago-knowledge.org/resource/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX schema: <http://schema.org/>
PREFIX cc: <http://creativecommons.org/ns#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX data: <https://www.wikidata.org/wiki/Special:EntityData/>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX s: <http://www.wikidata.org/entity/statement/>
PREFIX ref: <http://www.wikidata.org/reference/>
PREFIX v: <http://www.wikidata.org/value/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wpq: <http://www.wikidata.org/prop/quant/>
PREFIX wdtn: <http://www.wikidata.org/prop/direct-normalized/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX pqv: <http://www.wikidata.org/prop/qualifier/value/>
PREFIX pqn: <http://www.wikidata.org/prop/qualifier/value-normalized/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prv: <http://www.wikidata.org/prop/reference/value/>
PREFIX prn: <http://www.wikidata.org/prop/reference/value-normalized/>
PREFIX wdno: <http://www.wikidata.org/prop/novalue/>
PREFIX ys: <http://yago-knowledge.org/schema#>

CONSTRUCT {
  ?s ?newp ?o .
}
WHERE {
  ?s ?p ?originalO .
  
  # Transforming the predicates to a new namespace where applicable
  BIND(
       IF(?p IN (
		 schema:administrates,
		 schema:demonym,
		 schema:highestPoint,
		 schema:humanDevelopmentIndex,
		 schema:influencedBy,
		 schema:leader,
		 schema:lowestPoint,
		 schema:motto,
		 schema:neighbors,
		 schema:officialLanguage,
		 schema:ownedBy,
		 schema:populationNumber,
		 schema:unemploymentRate
		 ), URI(REPLACE(STR(?p), "http://schema.org/", "http://yago-knowledge.org/resource/")), ?p)
       AS ?newp
       )

  # Transforming negative xsd:dateTime to xsd:dateTimeStamp
  BIND(
       IF(datatype(?originalO) = xsd:dateTime && STRSTARTS(STR(?originalO), "-"),
	  STRDT(STR(?originalO), xsd:dateTimeStamp),
	  ?originalO)
       AS ?o
       )
  
  # Filtering out non-English literals and xsd:anyURI literals
  FILTER (
	  !(
	    isLiteral(?o) && 
	    (
	     lang(?o) != "" && 
	     !(
               langMatches(lang(?o), "en") && 
               lang(?o) != "en-gb" && 
               lang(?o) != "en-ca"
	       ) || 
	     datatype(?o) = xsd:anyURI || 
	     (?p = rdfs:label && str(?o) = "Generic instance")
	     )
	    )
	  )

  # Excluding specific predicates
  FILTER (?p != schema:sameAs)
  FILTER (?p != owl:sameAs)
}