How can I activate GeoSparql in Graphdb? - sparql

I looked into the documentation and it is written that we should add
INSERT DATA { _:s geoSparql:enabled "true" . } to the setting in Graphdb to be able to query OpenStreetMap. But I don't understand how or where should I do this.
Here is the instruction: https://graphdb.ontotext.com/documentation/9.4/free/geosparql-support.html#usage
Could you please help me? Thanks.
Update: I added my query here. It works in sophox.org but not in the graphdb.
PREFIX osmt: <https://wiki.openstreetmap.org/wiki/Key:>
PREFIX osmm: <https://www.openstreetmap.org/meta/>
PREFIX geoSparql: <http://www.ontotext.com/plugins/geosparql#>
SELECT * {
?uni osmt:amenity "university";
osmt:addr:country "FR".
}

I added SERVICE <https://sophox.org/sparql> after the first curly bracket and it is working perfectly now.
PREFIX osmt: <https://wiki.openstreetmap.org/wiki/Key:>
PREFIX osmm: <https://www.openstreetmap.org/meta/>
PREFIX geoSparql: <http://www.ontotext.com/plugins/geosparql#>
SELECT * {<https://sophox.org/sparql> {
?uni osmt:amenity "university";
osmt:addr:country "FR".
}}

Related

GraphDB: use similarity search with embedded repository

I have been using GraphDB's (version 9.2) similarity search from the workbench. Now I also want to use this feature for an embedded repository using graphdb-free-runtime 9.2.1. However I have no clue how this feature can be used from the APIs provided by the runtime. My questions are:
In http://graphdb.ontotext.com/documentation/standard/semantic-similarity-searches.html it is mentioned that similarity search is a plugin. However I could not find any such plugin within the runtime. Do I have to load it from some external resource? Where?
Is there any documentation or example how to create a similarity index programmatically?
Would it be an option to run the workbench as some kind of server and access the similarity search via REST API? However the REST API documentation at http://graphdb.ontotext.com/documentation/9.0/free/using-the-workbench-rest-api.html does not mention any API for similarity searches. Am I missing something?
Any hints or pointers are welcome.
You could add similarity plugin runtime, setting following "graphdb.extra.plugins" property to directory where similarity-plugin (you could find such into GDB instance -> dist/lib/plugins) is located , or:
-Dgraphdb.extra.plugins=directory
System.setProperty("graphdb.extra.plugins", "directory");
You may create index programmatically using SPARQL or:
to create similarity text index "allNews" execute following update:
PREFIX : <http://www.ontotext.com/graphdb/similarity/>
PREFIX inst: <http://www.ontotext.com/graphdb/similarity/instance/>
PREFIX pred: <http://www.ontotext.com/graphdb/similarity/psi/>
insert {
inst:allNews :createIndex "-termweight idf" ;
:analyzer "org.apache.lucene.analysis.en.EnglishAnalyzer" ;
:documentID ?documentID .
?documentID :documentText ?documentText .
} where {
SELECT ?documentID ?documentText {
?documentID ?p ?documentText .
filter(isLiteral(?documentText))
}
}
to delete index "allNews" execute following update:
PREFIX :<http://www.ontotext.com/graphdb/similarity/>
PREFIX inst:<http://www.ontotext.com/graphdb/similarity/instance/>
insert { inst:allNews :deleteIndex '' } where {}
to rebuild index "allNews":
PREFIX :<http://www.ontotext.com/graphdb/similarity/>
PREFIX inst:<http://www.ontotext.com/graphdb/similarity/instance/>
insert { inst:allNews :rebuildIndex '' } where {}
followed by the create query!
to list all created indexes, execute following query:
PREFIX :<http://www.ontotext.com/graphdb/similarity/>
PREFIX inst:<http://www.ontotext.com/graphdb/similarity/instance/>
select ?index ?status ?type
where {
?index :status ?status .
?index :type ?type .
}

GeoSPARQL within query

I'm struggling with the GeoSPARQL functions. I have two points defined in my ontology. Using this query I get them in my results:
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?what ?met
WHERE {
?what geo:hasGeometry ?met .
FILTER geof:within( ?met ,"ENVELOPE(51.900991, 51.913594, 4.502206, 4.476328)"^^geo:wktLiteral ) .
}
http://www.example.org/POI#Headquater
http://www.example.org/POI#MiddenVanDeBrug
The question is why http://www.example.org/POI#ErasmusBrug is not part of the search result. Should it be possible to search for polygons within an envelop?
Which GeoSPARQL functions are available in Stardog? Any good example resource?
The ontology I use can be found here
The Stardog documentation for GeoSPARQL can be found here. For more specific support, please come visit us at Stardog Community.
I found out that there is an error in the log file of Stardog upon importing the data:
WARN 2017-12-14 08:31:30,989 [XNIO-1 task-24] com.complexible.stardog.spatial.io.StatementSourceGeospatialSource:parse(95): Failed to parse unknown/malformed shape POLYGON((4.476027 51.91137, 4.497099 51.911291, 4.497142 51.905307, 4.75813 51.905201, 4.476027 51.91137 )). Skipping this record
What could be wrong with this polygon?

Path queries in Wikidata endpoint?

Consider the following snippet
ASK WHERE { wd:Q734774 wdt:P31 wd:Q3918. }
This works fine in Wikidata. I want to use some of the path syntax in the this snippet. Specifically I want to limit the number of the times "wdt:P31" used in the path. According to the guidelines this should be the right syntax:
ASK WHERE { wd:Q734774 wdt:P31{,3} wd:Q3918. }
But it's giving me weird error messages. Any ideas?
The final version of SPARQL 1.1 Property Paths lets you do this with the following query --
ASK WHERE
{ wd:Q734774
wdt:P31? / wdt:P31? / wdt:P31?
wd:Q3918
}
For clarity, I've put the full Property Path Predicate (wdt:P31? / wdt:P31? / wdt:P31?) on a separate line between Subject (wd:Q734774) and Object (wd:Q3918). The trailing ? asks for one-or-zero instances of the wdt:P31 predicate, and the / asks for a sequence, so this full path asks for a sequence of zero-or-one-or-two-or-three instances.

How to add dot '.' in the name of individuals in Sparql?

Is it possible to have a . (dot) in the qname of individuals or RDF resources in general?
Something like this?
SELECT ?tableName ?fieldName
WHERE { ?fieldName hrdata:relatedField hrdata:ps_ti0002.EMPLID. }
The dot in ps_ti0002.EMPLID is problematic.
your code is right and should work. It is possible to use dot in the individual's name.
I think you should check your data property (relatedField), maybe is not clarified right.
#Narges Kasaeizadeh
Unfortunately, I still can't comment - but I think your answer is wrong and a dot is not allowed in prefixed URIs/IRIs as you can try out using the validator suggested by #AndyS .
The . is allowed in SPARQL and the SPARQLer Query Validator demonstrates. However, there are a couple of suggestions to help you get this working. First is to have a space after the qname, i.e.:
WHERE { ?fieldName hrdata:relatedField hrdata:ps_ti0002.EMPLID . }
Another is to use the fully qualified URI. Suppose the namespace for hrdata is http://example.org/hrdata/, the the following query should work:
SELECT ?tableName ?fieldName
WHERE { ?fieldName hrdata:relatedField <http://example.org/hrdata/ps_ti0002.EMPLID> . }

SPARQL-Query results invalid?

I run a Virtuoso Server and missed a number of results when making a SPARQL-Select request. I tracked it down and find a really strange behaviour, that I cannot explain.
But to start from the beginning.
The endpoint I query can be found at http://creativeartefact.org/sparql
I) Check for a specific triple:
ASK WHERE {
<http://creativeartefact.org/mbrainzImport/f18e677a-4051-486a-aa64-d9a3bfef90af>
<http://creativeartefact.org/ontology/represents>
<http://creativeartefact.org/mbrainzImport/35ed9f2a-6ce4-44ca-9c7a-967377b0e007>. }
The query returns TRUE
II) Now getting a bit more unspecific:
ASK WHERE {
?s
<http://creativeartefact.org/ontology/represents>
<http://creativeartefact.org/mbrainzImport/35ed9f2a-6ce4-44ca-9c7a-967377b0e007>. }
If the first returns true, the second shall do as well, shouldn't it? But it doesn't. It return FALSE!
If I replace the predicate or the object with a variable, it returns true as expected. Only when setting a variable for the subject, it returns false.
That the data really exists in the triple store can be tested by running the query
SELECT * WHERE {
?s
?p
<http://creativeartefact.org/mbrainzImport/35ed9f2a-6ce4-44ca-9c7a-967377b0e007>. }
You will see, that both results comw with p = http://creativeartefact.org/ontology/represents - which is exactly the predicate I am asking for in the former query.
To make it even more strange, there ARE triples with the aforementioned format, that return the triples:
select * {
?s
<http://creativeartefact.org/ontology/represents>
<http://creativeartefact.org/mbrainzImport/e4003568-5645-4ee1-abd0-2e8156272e59>. }
Any idea, what is happening here?
Thanks in advance,
Frank
The Virtuoso being used is an original 07.00.3203 build from 2013.
I would suggest upgrading to the latest Virtuoso 07.10.3211, open source or commercial, depending on which is in use here, and see if the problem persists ...