-
I am new to using SPARQL Anything and am using it to CONSTRUCT triples from CSV. My CONSTRUCT query looks like this: PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX for: <https://dkglab.github.io/ns/for/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
CONSTRUCT {
?site a geo:Feature ;
skos:prefLabel ?site_name ;
geo:hasGeometry [ geo:asWKT ?wkt ] ;
for:hasArtifactType ?p ;
.
}
WHERE {
SERVICE <x-sparql-anything:> {
fx:properties fx:csv.headers "true" .
?row xyz:HLLG%20%23 ?hllg_number .
?row xyz:Site%20Name ?site_name .
?row xyz:Longitude ?longitude .
?row xyz:Latitude ?latitude .
?row ?p "1" .
BIND(IRI(CONCAT(STR(for:), "site/", ?hllg_number)) as ?site)
BIND(CONCAT("POINT(", ?longitude, " ", ?latitude, ")") as ?wkt)
}
} This works as expected, but produces duplicate triples in the output, e.g.: <https://dkglab.github.io/ns/for/site/3702>
a geo:Feature ;
geo:hasGeometry [ geo:asWKT "POINT(1.144602 41.115171)" ] ;
geo:hasGeometry [ geo:asWKT "POINT(1.144602 41.115171)" ] ;
geo:hasGeometry [ geo:asWKT "POINT(1.144602 41.115171)" ] ;
geo:hasGeometry [ geo:asWKT "POINT(1.144602 41.115171)" ] ;
geo:hasGeometry [ geo:asWKT "POINT(1.144602 41.115171)" ] ;
skos:prefLabel "La Canaleta" ;
for:hasArtifactType xyz:ARSA , xyz:TSH , xyz:TS_any , xyz:TS_early , xyz:TSG . As duplication of triples is meaningless in RDF, I’m surprised to see this rather than simply: <https://dkglab.github.io/ns/for/site/3702>
a geo:Feature ;
geo:hasGeometry [ geo:asWKT "POINT(1.144602 41.115171)" ] ;
skos:prefLabel "La Canaleta" ;
for:hasArtifactType xyz:ARSA , xyz:TSH , xyz:TS_any , xyz:TS_early , xyz:TSG . The latter is how |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @rybesh -- welcome! We assume triples produced by SA to be distinct because of how the CONSTRUCT operator works -- we are using Jena as-is for that. In your example, the triples are all referring to different blank nodes: geo:hasGeometry [ geo:asWKT ?wkt ] ; The CONSTRUCT operator will generate a new BNode for each match. One way to solve this problem is to change your query and skolemise the blank noe (use a URI instead) and make sure it is generated using relrevant keys (for example, the string POINT(1.144602 41.115171)) FYI, SPARQL Anything has a shortcut to build entity URIs (see also discussion here #106): fx:entity. |
Beta Was this translation helpful? Give feedback.
Hi @rybesh -- welcome!
We assume triples produced by SA to be distinct because of how the CONSTRUCT operator works -- we are using Jena as-is for that. In your example, the triples are all referring to different blank nodes:
geo:hasGeometry [ geo:asWKT ?wkt ] ;
The CONSTRUCT operator will generate a new BNode for each match. One way to solve this problem is to change your query and skolemise the blank noe (use a URI instead) and make sure it is generated using relrevant keys (for example, the string POINT(1.144602 41.115171))
FYI, SPARQL Anything has a shortcut to build entity URIs (see also discussion here #106): fx:entity.