snap sparql to retrieve data property value - sparql

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

Related

How to write Federated SPARQL request in Protege

Can somebody help me please with SPARQL Federated, because I can't understand it syntax.
For example I have my own local ontology (museum domen) and there are some data regarding weather I find this https://dbpedia.org/page/Weather_forecasting.
How can I view information from this ontology (weather and date, for example) and my ontology (excursion and date)?
I tried to create request here https://query.wikidata.org/#SELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20WHERE%20%7B%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%22.%20%7D%0A%20%20%7B%0A%20%20%20%20SELECT%20DISTINCT%20%3Fitem%20WHERE%20%7B%0A%20%20%20%20%20%20%3Fitem%20p%3AP4150%20%3Fstatement0.%0A%20%20%20%20%20%20%3Fstatement0%20%28ps%3AP4150%29%20_%3AanyValueP4150.%0A%20%20%20%20%7D%0A%20%20%20%20LIMIT%20100%0A%20%20%7D%0A%7D but it does not work in Protege.
I tried to create request in Protege:
*** PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX foaf: <http://www.menthor.net/myontology#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?date ?excursion
FROM <https://dbpedia.org/page/Weather_forecasting>
WHERE <http://www.menthor.net/myontology> foaf: ?excursion .
SERVICE <https://dbpedia.org/page/Weather_forecasting/sparql> {
?date foaf:date ?date . ***
but it does not work again
What prefixes should I have? Can I get data from this link https://dbpedia.org/page/Weather_forecasting in Protege?
enter image description here I can get data from my ontology, but do not understand how to use dbpedia data

Usage of rules in SPARQL queries

I would like to use rules in my ontology so that at the moment of the inference I can retrieve some information not explicitly expressed in the triplestore.
I created a basic ontology and I want to add this rule:
Person(?p) ^ hasSibling(?p, ?s) ^ Man(?s) → hasBrother(?p, ?s)
The SPARQL query I would like to perform is
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX prova: <http://www.example.it/prova/>
SELECT ?subject ?object
WHERE { ?subject prova:hasBrother ?object }
Running this does not return anything. Of course, I have created the individuals for each class, but I have not created the instance that involves hasBrother, as this is what I want the intelligence to retrieve by itself.
So, my question is: is it possible to use SPARQL queries to achieve inference described by rules? Or these kind of inferences are only possible with a dedicated query system? In protegè I learn about the SQWRL tab for instance.
I am using the last version of Protegè (5.5.0) and the last version of the SWRL Rules plugin (2.11). I have defined the rule in the SWRL Tab. Then I tried the SQWRL tab to perform the query, but I get a strange error related to "invalid query name", which I don't really understand. Any suggestion about this second point would be helpful.

How to list all properties on a custom Wikibase instance

I am trying to list all properties created in on a wikibase I installed, using docker-compose, based on this install.
Now, want to list all properties that are available in this wikibase, similar to getting that list available through:
<wikibase.url>wiki/Special:ListProperties
I have also extracted that list through SPARQL with the following SPARQL query:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX schema: <http://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT DISTINCT
?property
?propertyType
?propertyLabel
?propertyAltLabel
WHERE {
?property a wikibase:Property ;
rdfs:label ?propertyLabel ;
wikibase:propertyType ?propertyType .
OPTIONAL {?property skos:altLabel ?propertyAltLabel .}
}
Running that SPARQL query is expensive though and I need to run that query often, so I would very much like to get that list of properties to the core wikibase API.
Is that possible?
If you know the namespace number for properties on the target wiki (it’s usually 122 if the wiki has an Item: namespace, or 120 if, like on Wikidata, items are in the main namespace), you can use the core allpages API: https://www.wikidata.org/w/api.php?action=query&list=allpages&apnamespace=120
To also get the labels at the same time, use it as a generator and combine it with the entityterms API (new in 1.35; looks like it’s not documented yet, but see T257658): https://www.wikidata.org/w/api.php?action=query&generator=allpages&gapnamespace=120&prop=entityterms&wbetterms=label

How to display list using SPARQL

I am trying to show the list of Charities from this page - http://dbpedia.org/page/Category:Charitable_organizations
The list is in is dct:subject of property, I have made a query but it doesn't work.
QUERY
WHERE {
?s dbo:type dbr:Charitable_organization .
}
I do kind of know how to use SPARQL with DBPEDIA but am unsure how to use the dct:subject part and display the `dbr:'
Using the site- http://dbpedia.org/sparql to execute queries. So any help on how I can show the list of charities from that website? Thanks for reading.
Your query should be:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX dbr: <http://dbpedia.org/resource/>
## Added ##
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT *
WHERE {
?s dbo:type dbr:Charitable_organization .
}
Links
Live Results Page Link.
Live Query Definition Link.

fuseki doesn't select from dbpedia on my computer

I have fuseki running on my computer. version 1.1.1. but it when I enter a query to select from dbpedia it doesnt return anything. The query made is suppose to return http://dbpedia.org/class/yago/Guitarist110151760 as ?artistKind and http://semanticweb.org/laura/ontologies/2014/9/untitled-ontology-26#Guitar as ?instrument.
I made the ontology in protege and used a restriction that Guitarist110151760 playsInstrument Guitar.
PREFIX instru: <http://www.semanticweb.org/laura/ontologies/2014/9/untitled-ontology-26#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/resource/>
select ?artistKind ?instrument
FROM <http://www.semanticweb.org/laura/ontologies/2014/9/untitled-ontology-26#>
WHERE
{
?artistKind instru:playsInstrument ?instrument.
SERVICE <http://dbpedia.org/sparql> {
dbpedia:Eric_Clapton rdf:type ?artistKind . }
}
Use website http://dbpedia.org/sparql to perform successful queries on dbpedia ontology because jena fusiki is used to perform queries on local ontologies inside hard disk (by loading owl files)