0

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

  • neither is `https://dbpedia.org/page/Weather_forecasting` the URL of the DBpedia SPARQL endpoint nor is `foaf:date` any property in DBpedia - did you just randomly declare this property? I mean, did you check your link what property is used to declare a date? – UninformedUser May 16 '22 at 15:25
  • also, your query is neither complete not syntactically correct as shown here ... – UninformedUser May 16 '22 at 15:26
  • Property dbp:date declare the value, for example, 2005-04-29 (xsd:date) – Anastasia R May 16 '22 at 17:04
  • that is correct, but `dbp:date` is **not** `foaf:date` as you're using in your query. It also doesn't make sense to use the prefix `foaf:` for two different namespaces in your query, you should use an own prefix for your custom namespace. – UninformedUser May 16 '22 at 17:39
  • that pattern will also never work: `?date foaf:date ?date ` - or when is the subject and object of a triple a date at the same time. – UninformedUser May 16 '22 at 17:43
  • also illegal syntax: `WHERE foaf: ?excursion .` – UninformedUser May 16 '22 at 17:44
  • okey, first of all I write this and it is working PREFIX rdf: PREFIX owl: PREFIX rdfs: PREFIX xsd: PREFIX : SELECT ?excursion WHERE { ?excursion rdf:type [ rdfs:subClassOf* :Name_of_the_tourTS] . } – Anastasia R May 16 '22 at 18:10
  • Then I add dbp service and it still doesn not work and I do not see any errors in Protege: PREFIX rdf: PREFIX owl: PREFIX rdfs: PREFIX xsd: PREFIX : SELECT ?excursion ?date ?value WHERE { ?excursion rdf:type [ rdfs:subClassOf* :Name_of_the_tourTS] . SERVICE { ?date ?dbp:date . ?value ?xsd:date . } } – Anastasia R May 16 '22 at 18:21
  • as I said before, `SERVICE ` is wrong - the DBpedia SPARQL endpoint URL is not the HTML page of a particular DBpedia website. The endpoint URL is `https://dbpedia.org/sparql` - also, the DBpedia entity resource URI for Wether_forecasting is `http://dbpedia.org/resource/Weather_forecasting` – UninformedUser May 16 '22 at 19:16
  • Okay, and should I use prefix for dbpedia? Because now I have an error (undefined prefix ) – Anastasia R May 16 '22 at 19:35
  • yes, you have to add the prefix declaration for the `dbp:` prefix or just use the full URI instead – UninformedUser May 17 '22 at 05:54
  • I have default Protege prefixes: PREFIX rdf: PREFIX owl: PREFIX rdfs: PREFIX xsd: then I have added prefix for my ontology: PREFIX boldino: and prefix for dbpedia: PREFIX dbp: Is it correct? No errors, but still don't work ;C – Anastasia R May 17 '22 at 08:53
  • PREFIX rdf: PREFIX owl: PREFIX rdfs: PREFIX xsd: PREFIX boldino: PREFIX dbp: SELECT DISTINCT ?excursion ?date ?value WHERE { ?excursion rdf:type [ rdfs:subClassOf* boldino:Name_of_the_tourTS] . SERVICE { ?date dbp:date ?date . ?value xsd:date ?value . } } LIMIT 5 – Anastasia R May 17 '22 at 08:56
  • no, you're missing fundamental things of RDF and SPARQL. I mean, hover the `dbo:date` link on the website and you'll see the URI. Also `?date dbp:date ?date` does not make sense: 1) why should a date literal be in subject and object position of a triple? And then, what is ` ?value xsd:date ?value . ` ? I don't get what you're trying to do with this – UninformedUser May 17 '22 at 09:33
  • PREFIX dbp: create prefix in this way? – Anastasia R May 17 '22 at 10:41
  • I thought ?date dbp:date ?date is like date sub class of dbp:date and variable date should get it – Anastasia R May 17 '22 at 10:44
  • Do you know where can I find triple that include date in https://dbpedia.org/page/Weather_forecasting? – Anastasia R May 17 '22 at 10:46
  • no ... you still don't understand the concept of prefixes ... it should be `PREFIX dbp: ` and then use `dbp:date` - it shouldn't be so difficult to understand the concept of prefixes, namespaces and URIs. – UninformedUser May 17 '22 at 12:41
  • - also `?date` is just a literal of datatype `xsd:date`. Something else has a date, in your case the resource `http://dbpedia.org/resource/Weather_forecasting` has the date asserted. – UninformedUser May 17 '22 at 12:41
  • Should I use FROM or WHERE { graph {?date a } ? – Anastasia R May 17 '22 at 14:29
  • no ... you should read an RDF tutorial first I think. and then come back to SPARQL - the `SERVICE` has to be the DBpedia SPARQL endpoint, and this contains all the RDF triples, also the date of the resource Weather_forcasting. I don't get why you think now `?date a ` is the way to go? Are you randomly creating those things? Why should a date be of type `Weather_forecasting`? the keyword `a` is an alias for `rdf:type` which in fact connects individuals to its type resp. class. – UninformedUser May 18 '22 at 05:33
  • Is it correct? SERVICE – Anastasia R May 18 '22 at 09:12
  • do I need to have # at the end? PREFIX dbp: or not? – Anastasia R May 18 '22 at 09:12
  • I tnink the problem is here { ?date dbp:date ?date . ?value xsd:date ?value . – Anastasia R May 18 '22 at 09:13
  • Schould I use it in this way? {?sub ?obc . } or {?sub prefix:relationship between classes obj .} or somth else? – Anastasia R May 18 '22 at 09:16
  • I tried many examples drom Internet in my Protege sparql (for example, PREFIX qb: PREFIX sehr: SELECT ?diabetes ?bmi ?cases ?hypertension WHERE { ?dataset a qb:Dataset. ?observation qb:DataSet ?dataset; a qb:Observation; sehr:Daibetes ?diabetes ; sehr:BMI_Abnormal ?bmi ; sehr:Hypertension ?hypertension ; sehr:Cases ?cases . } ) but id does not work maybe I have a problem with Protege? – Anastasia R May 18 '22 at 10:18

0 Answers0