Is DBPedia data contains the latest data? Is there another way to retrieve data - sparql

I am new to DBPedia. I was trying to fetch data (Infobox details) from Wikipedia using SPARQL from DBPedia in C#. Using the below code:
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("http://dbpedia.org/sparql"), "http://dbpedia.org");
string query = "PREFIX dbo: <http://dbpedia.org/ontology/>" +
"PREFIX db: <http://dbpedia.org/resource/>" +
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" +
"PREFIX dbp: <http://dbpedia.org/property/>" +
"SELECT ?numberOfEmployees WHERE {<http://dbpedia.org/resource/SomeOrganizationName> " +
"dbp:numberOfEmployees ?numberOfEmployees"}";
SparqlResultSet res = endpoint.QueryWithResultSet(query);
The data is not matching for some fields. Is there another way to retrieve data from DBPedia? I found https://live.dbpedia.org/sparql which I thought will be giving away fresh data but it does not return anything.

I'm not sure if DBPedia is getting updated these days, WikiData https://www.wikidata.org/wiki/Wikidata:Main_Page
might be a better resource to use

Related

snap sparql to retrieve data property value

I had a new problem now when using snap sparql.
oke, i had 2 class, that is resep_makanan which is food name , bahan_makanan which is food source.
and i linked those 2 classes using data_property memiliki_bahan and at each food source i linked with annotation property data_memiliki_bahan.
when using standard SPARQL
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX :<http://www.semanticweb.org/astrid/ontologies/2019/5/mpasiv2#>
SELECT ?resep_makanan ?bahan_makanan ?value
WHERE {
?bahan_makanan :data_memiliki_bahan ?memiliki_bahan.
?resep_makanan ?memiliki_bahan ?value.
FILTER regex(str(?resep_makanan),"pure_alpukat")
}
i get what i want, but when im using snap sparql with exact same code, it didnt work, how should i write it using snap sparql?
in snap sparql i get this error :
please click here to see the error message

How to construct RDF using Data Cube Vocabulary with SPARQL

I have CSV data set and I want to construct RDF using Data Cube Vocabulary.
Now I have triplifier, which constructs "regular" RDF with tarql:
PREFIX data1: <http://data1/#>
PREFIX data2: <http://data2/#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbo: <http://dbpedia.org/ontology/#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
CONSTRUCT {
?URI a data1:Data1;
variale:name ?name;
variable:something ?something;
}
FROM <file:data2.csv>
WHERE {
BIND (URI(CONCAT('http://data1/', ?someValue)) AS ?URI)
BIND (STRLANG(?someName, "en") AS ?name)
BIND (xsd:string(?anotherValue) AS ?value)
}
OFFSET 1
I can find some explanations about how result RDF with Data Cube should look like, but I've found no examples about constructing it.
Here is the dataset I'm trying to process.
SPARQL can produce tabular data from RDF data using SELECT queries, or RDF data from RDF data using CONSTRUCT queries, but SPARQL is not suitable for converting CSV tabular data into RDF.

How to get all available classes in a .owl file, using SPARQL query?

I need to retrieve all classes available in a camera.owl file (https://github.com/quoll/mulgara/blob/master/data/camera.owl). Here is my query and I feel something wrong in it but hard to figure it out.
String queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"
+ "PREFIX owl: <http://www.w3.org/2002/07/owl#>"
+ "PREFIX : <http://www.xfront.com/owl/ontologies/camera/#>"
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"SELECT DISTINCT ?class WHERE { ?s a ?class . }";
You "feel something wrong"...that's not helpful in computer science or even any science. You should really describe what is not working next time, e.g. "doesn't return anything" or "leads to an exception" or "doesn't return what I'd expect" or ...
Your query does what you want but only for those classes that have instances. And this ontology doesn't contain any instance data.
Alternatively, you can query for all resource of type owl:Class, i.e. you work on the schema level (Note, this does only work if there are OWL classes, thus, for RDFS it wouldn't work):
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT ?class WHERE { ?class a owl:Class }

How to get the arithmetic result of a comment in TopBraid Composer?

In TopBraid Composer, I save all my SPARQL queries as Comments in separate instances. I want to calculate their value and I want that value in a separate instance. For example, my SPARQL queries is 2 * 3 and when I run it, the result is 6. Here my comment contain "2 * 3".
What I want is the result "6" to be displayed in a separate instance. I will use the value of that instance in some other calculation, say "6 (of this) * 4" = 24. Please let me know if there is any way to deal with it.
It will save us from writing and arranging so many inner queries. All we would need is write simple queries and connect them through this method and the final query will get us the result. Thank you so much.
SPARQL is pretty good about casting to basic XML schema types, so you can simply cast these to xs:integer - as an example:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xs: <http://www.w3.org/2001/XMLSchema#>
SELECT ?product
WHERE {
<x> rdfs:comment ?c1 .
<y> rdfs:comment ?c2 .
BIND (xs:integer(?c1) * xs:integer(?c2) AS ?product)
}

PROTÉGÉ SPARQL QUERY TAB: cannot query for ontology-specific classes

I am using SPARQL Query tab in Protege 5 to query an OWL ontology I have been constructing. I succeded in many kinds of queries, but when I use some specific class of my ontology inside the very same queries (that are apparently well formed) they return no results. Following, two of the problematic queries - assuming "Event" as one of the concepts of the ontology (http://www.semanticweb.org/ontologies/2014/5/MyOnto#Event):
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX onto: <http://www.semanticweb.org/ontologies/2014/5/MyOnto#>
SELECT ?a WHERE { ?a rdfs:subClassOf onto:Event }
and, with the same prefixes
SELECT ?a WHERE { ?a rdfs:range onto:Event }
Both return no results. However, if I substitute "onto:Event" for, let's say, ?b, both return a long list of results - inclunding Event as a match for ?b.
Is it something I'm misusing or forgetting (although I've seen this pattern in several links on internet with people claiming to have got results) or is it a limitation of SPARQL or some issue of the Protege tab?
The problem is that, in fact, although the URI of the ontology is:
<http://www.semanticweb.org/ontologies/2014/5/MyOnto#>
in the OWL document, the prefix used before class names is the IRI:
<http://www.semanticweb.org/ontologies/2014/2/untitled-ontology-662#>
Thus, replacing the old onto: by
PREFIX onto: <http://www.semanticweb.org/ontologies/2014/2/untitled-ontology-662#>
solves the issue.
(Thanks to #Csongor from Protégé Project mail list, who found the answer.)
P.S.: It's also worthy to note that it can't be taken for granted that all the terms in the ontology will be <current_ontology_URI#term> - e.g. if one includes some terms in the ontology and then changes ontology URI, these terms will be identified as <previous_ontology_URI#term> and the new ones as <current_ontology_URI#term> (which was exactly the cause of the problem above).
I had the same problem, whenever using an ontology specific class there were no results although there should have been. My ontology (pizza.owl) was loaded from a local file.
I found that it is required to add the file name in the PREFIX.
PREFIX : <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
After that I got the information that I expected.