yago45en / filter.sparql
wikipunk's picture
update script
e0dd3d8
raw
history blame
3.08 kB
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)
}