I have just setup Virtuoso and I have loaded an OWL file (created with Protege software) present on my local machine in to Virtuoso using the following code:
SQL> DB.DBA.RDF_LOAD_RDFXML_MT (file_to_string_output ('antibiotics.owl'), '', 'http://myexample.com');
Now, my question is how do I access the URI myexample.com ? How do I create a SPARQL endpoint in Virtuoso so that I can query it?
No need to create a sparql endpoint, since it's already there.
Check the inserted RDF data on your Virtuoso instance sparql endpoint http://cname:port/sparql (usually: http://localhost:8890/sparql). To do some test queries, use the web interface of Virtuoso (the conductor) http://localhost:8890/conductor and go to the 'Linked Data' tab.
Enter a query like:
SELECT ?s ?p ?o
FROM <http://myexample.com>
WHERE {?s ?p ?o}
LIMIT 1000
to get started.
You can also query directly from the vsql command line by adding 'SPARQL ' in front of your sparql query.
To get results in a specific format directly via html get request:
http://localhost:8890/sparql?query=(YourQueryUriEncodedWithout())&format=json
For a more detailed answer, consult the documentation here:
http://docs.openlinksw.com/virtuoso/rdfsparql.html
Points of interest:
16.2.3.15. SPARQL Endpoint with JSON/P Output Option: Curl Example
16.2.5. SPARQL Inline in SQL
If you still want your own endpoint:
16.2.3.4.6. Creating and Using a SPARQL-WebID based Endpoint
Best regards...
Related
I am trying to get alternative names of given names in WikiData with the following simple query:
PREFIX ps: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
CONSTRUCT {?s rdfs:label ?o}
WHERE { ?s ps:P31 wd:Q202444. ?s rdfs:label ?o}
LIMIT 1000
Initially, the query was much more complex, but I was getting time-outs on the public WikiData SPARQL endpoint. I decided to use Linked Data Fragments to offload some filtering from the server to the client.
$comunica-sparql "https://query.wikidata.org/bigdata/ldf" -f query > given_names.n3
Could not retrieve https://query.wikidata.org/bigdata/ldf?subject=http%3A%2F%2Fwww.wikidata.org%2Fentity%2FQ21147790&predicate=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23label&page=3 (500: unknown error)
(where query is a file with the SPARQL query shown above). Unfortunately, the client tries to get output from the 3rd page, I am getting the error. Following the link in fact returns HTTP 500 error with
The link points to the 3rd page. It works if you try to go to the second page.
Is this a bug or a limitation of a service?
This is definitely a bug; the server does not fulfill the Triple Pattern Fragments specification if pagination does not work.
I am trying to learn SPARQL and I am trying to query a local ttl file which is my downloads
The path is : C:/Users/abc/Downloads/human-instructions-english-wikihow/en_0_rdf_result.ttl
SELECT ?s ?p ?o
FROM <C:/Users/abc/Downloads/human-instructions-english-wikihow/en_0_rdf_result.ttl>
WHERE {?s ?p ?o}
LIMIT 1000
So I am trying to execute a very simple query like this but it does not return any output.
I understand we have to put a SPARQL endpoint or something with 'http' in FROM but this file is on my Downloads and I cant seem to figure out what would be the endpoint.
Please, help me with this. Thanks.
(If you haven't already, you need to install the Virtuoso Sponger Middleware module, cartridges_dav.vad, for your version of Virtuoso Enterprise/Commercial Edition or Open Source Edition.)
First, you need to add this line to the top of your SPARQL query --
define get:soft "replace"
That "define pragma" is a SPARQL extension, which tells Virtuoso to resolve remote URLs it encounters in the rest of the query.
Then, you need to use a full URI for the target file. This may be a file: scheme URI, IFF --
the URI is properly constructed
the target file is accessible through the filesystem where Virtuoso is running
the directory holding the target file is included in the DirsAllowed parameter in the virtuoso.ini file
Also see How to import JSON-LD into Virtuoso.
In the GraphDB documentation, I see that "the dataset’s default graph contains the merge of the database’s default graph AND all the database named graphs." This means that "if a statement ex:x ex:y ex:z exists in the database in the graph ex:g" then a query such as SELECT * { ?s ?p ?o } will return the triple ex:x ex:y ex:z
I am wondering if there is a setting which can be triggered either via the web interface or via the RDF4J/OpenRDF API which will disable this behavior in a specified GraphDB repository. That is, for the purposes of my project I would prefer to have triples which are stored in named graphs to only appear in results which specifically query that named graph.
I have not seen anything like this searching through the documentation or on the settings available on the web interface, but maybe somebody here knows something I don't.
EDIT: I am not looking for a SPARQL solution to this problem. I know that I can query just the default graph using SPARQL, but I want to be able to use the query SELECT * { ?s ?p ?o } and only see results which are in the default graph by default.
GraphDB/RDF4J have a different interpretation than Jena how to query the default graph. The only easy way to query only explicit statements in the default graph is to use the special graph sesame:nil. The SPARQL-based solution is to write:
PREFIX sesame: <http://www.openrdf.org/schema/sesame#>
SELECT ?s ?p ?o
FROM sesame:nil
WHERE {
?s ?p ?o .
} LIMIT 100
I don't think there is any easy non-SPARQL based solution like changing a configuration option or even use this special graph over the SPARQL Graph Store protocol.
I've problem to suppress one objectProperty in graph on my fuseki server.
I tried to use many way to delete my objectProperty without results.
I tried to use s-delete to suppress:
./s-delete http://localhost:3030/ds 'DELETE {?s <http://www.semanticweb.org/ds/dependsOfExchange> ?o}'
or
./s-delete http://localhost:3030/ds 'DELETE {GRAPH ?g {?s <http://www.semanticweb.org/ds/dependsOfExchange> ?o} WHERE{?s <http://www.semanticweb.org/ds/dependsOfExchange> ?o}}'
I tried to find some information about how to use correctly s-delete to suppress objectproperty or dataproperty in data stored in my fuseki server, but I haven't found anything useful. And there is no update or suppress tools accessible by the browser.
Thanks in advance.
s-delete executes part of the SPARQL Graph Store Protocol which operaes on whole graphs only. It is an HTTP delete on a named graph.
To modify part of a graph, you need SPARQL Update, and so use s-update.
The delete command, using the DELETE WHERE short form might be:
DELETE WHERE {?s <http://www.semanticweb.org/ds/dependsOfExchange> ?o}
or the GRAPH version.
Hi I'm trying to learn how to query DBpedia using SPARQL. I can't find any website/source that shows me how do this and I'm finding it difficult to learn how to use all the properties (like the ones available at http://mappings.dbpedia.org/index.php?title=Special%3AAllPages&from=&to=&namespace=202 ). Any good source I can learn from?
So for example if I want to check if the wikipedia page http://en.wikipedia.org/wiki/Inception is a movie (property film) or not, how do I do that?
The wikipedia URL http://en.wikipedia.org/wiki/Inception maps to the dbpedia URI http://dbpedia.org/resource/Inception. Dbpedia has a SPARQL endpoint at: http://dbpedia.org/sparql, which you may use to run queries either programmatically or via the html interface.
To check if http://dbpedia.org/page/Inception is a "movie", you have many options. To give you an idea:
If you know the URI of "movie" in dbpedia (it is http://schema.org/Movie), then run an ASK query to check against that type. ASK will return true/false based on whether the pattern in the where clause is valid against the data:
ASK where {
<http://dbpedia.org/resource/Inception> a <http://schema.org/Movie>
}
If you don't know the URI of "movie" then you have a number of options. For example:
Execute an ASK query with a filter on whether the resource has a type that contains the word "movie" somewhere in its uri (or its associated rdfs:label, or both). You would use a regular expression for this:
ASK where {
<http://dbpedia.org/resource/Inception> a ?type .
FILTER regex(str(?type), "^.*movie", "i")
}
Same idea, but return all matches and post-process the results (programmatically I pressume) to see if they match your request:
select distinct ?type where {
<http://dbpedia.org/resource/Inception> a ?type .
FILTER regex(str(?type), "^.*movie", "i")
}
Return all the types of the resource without applying a filter and post-process to see if they match your request:
select distinct ?type where {
<http://dbpedia.org/resource/Inception> a ?type
}
Many options. The SPARQL spec is you number one resource.
First I suggest you start reading up on what exactly SPARQL is. There are tons of really good tutorials such as: this.
If you want to write SPARQL queries on dbpedia, there are various endpoints that you can use. They don't always accept all features that are supported by SPARQL, but if you don't want to go through the trouble of installing one locally, they can be a relatively reliable test environment. The queries that I am going to write below, have been tested on Virtuoso endpoint.
Let's say you want to find all the movies in dbpedia. You first need to know what is the URI for a movie type in dbpedia. If you open Inception in dbpedia, you can see that the type dbpedia-owl:Film is associated to it. So if you want to get the first 100 movies, you just need to call:
select distinct *
where {
?s ?o dbpedia-owl:Film
} LIMIT 100
If you want o know more about each of these movies, you just need to expand your queries by expanding the triples.
select distinct *
where {
?s ?p dbpedia-owl:Film.
?s ?x ?y.
} LIMIT 100