forked from marklogic-community/semantic-news-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-dbpedia-data.xqy
34 lines (26 loc) · 943 Bytes
/
load-dbpedia-data.xqy
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
(: This query:
1. finds all the DBpedia sameAs links we just loaded,
2. loads the corresponding RDF data from dbpedia.org.
:)
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
(: If it doesn't finish in 30 minutes, something else is wrong :)
xdmp:set-request-time-limit(1800),
(: STEP 1: find all the DBpedia sameAs links :)
sem:sparql("
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT DISTINCT ?thing
FROM <http://marklogic.com/sem-app/sameAsLinks>
WHERE
{
?entity owl:sameAs ?thing FILTER STRSTARTS(?thing,'http://dbpedia.org/') .
}
")
! map:get(.,"thing")
(: STEP 2: grab the corresponding RDF data from dbpedia.org :)
! replace(.,"/resource/","/data/")
! concat(.,".rdf")
! (try { (xdmp:log(concat("Loading ",.)),
sem:rdf-load(., ("rdfxml","graph=http://marklogic.com/sem-app/dbpedia"))) }
catch($e) {xdmp:log($e)})