
query.demo.insert.rq Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of corese-core Show documentation
Show all versions of corese-core Show documentation
Corese is a Semantic Web Factory (triple store and SPARQL endpoint) implementing RDF, RDFS, SPARQL 1.1
Query and Update.
The newest version!
#
# Generate rdf triples from json map format
#
prefix geo:
prefix map:
#load ;
insert {
?uri rdfs:label ?location ;
geo:lat ?lat ;
geo:long ?lon ;
map:description ?desc ;
map:dbpedia ?url ;
map:wikipedia ?wiki ;
?pred ?value
}
where {
#bind ("/user/corby/home/AADemoNew/map/map.json" as ?path)
bind ("%s" as ?path)
bind (xt:json(xt:read(?path)) as ?json)
values ?feature { unnest(xt:path(?json, "/features")) }
bind (xt:path(?feature, "/properties/name") as ?location)
bind (xt:path(?feature, "/properties/description") as ?desc)
bind (xt:path(?feature, "/geometry/coordinates") as ?list)
bind (replace(replace(replace(?location, " ", ""), "-", "_"), "'", "") as ?name)
bind (replace(replace(replace(?location, " ", "_"), "-", "_"), "'", "") as ?urlName)
filter (xt:size(?list) >= 2)
bind (xt:get(?list, 0) as ?lon)
bind (xt:get(?list, 1) as ?lat)
bind (uri(concat(map:, ?name, st:number())) as ?uri)
bind (uri(concat( , ?urlName)) as ?url)
bind (uri(concat( , ?urlName)) as ?wiki)
bind (us:complete(?location, us:clean(?desc)) as ?map)
values (?key ?val) {unnest(?map)}
bind (us:predicate(?key) as ?pred)
bind (us:value(?pred, ?val) as ?value)
}
function us:predicate(name) {
if (name = "type", uri(concat(rdf:, name)),
uri(concat(map:, name)))
}
function us:value(pred, val) {
if (pred = rdf:type, uri(concat(map:, val)),
val)
}
# lieu=Place;com=City
function us:complete(loc, descr) {
let (json = xt:json()) {
xt:set(json, "name", loc);
if (strlen(descr) = 0){return(json)};
for (elem in xt:split(descr, ";")) {
let ((key val) = xt:split(elem, "=")) {
xt:set(json, key, val)
}
} ;
return(json)
}
}
# ((lieu=Place;com=City))
function us:clean(descr) {
strbefore(strafter(descr, "(("), "))")
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy