lvaudor / glitter

an R package which writes SPARQL queries
https://lvaudor.github.io/glitter
43 stars 4 forks source link

glitter for named graphs #98

Open nleguillarme opened 1 year ago

nleguillarme commented 1 year ago

Hi,

I am wondering if glitter can be used to build queries

  1. that specify the dataset to be used for matching using the FROM and FROM NAMED clauses
  2. that use the GRAPH keyword to match patterns against named graphs

If not, it would be great to see these get included in the package.

lvaudor commented 1 year ago

Hi! Thanks for your feedback. Hmm let us have a think here with @maelle... We have not worked with named graphs yet I guess we need practical examples to get a grasp of how we could use them... A few explanations can be found here maybe:(https://levelup.gitconnected.com/working-with-rdf-database-named-graphs-a5ddab447e91)

lvaudor commented 1 year ago

@nleguillarme would you be able to provide a (SPARQL) query example that you'd be trying to reproduce here?

nleguillarme commented 1 year ago

Hi @lvaudor For instance, if I look for observation records of some traits for species "Armillaria gallica" in my triplestore, and want the iri of the named graph containing the observation triples, I would write the following query:

SELECT DISTINCT ?observation ?g
WHERE {
  VALUES ?sciName {"Armillaria gallica"}
  ?taxon rdfs:label ?sciName.
  GRAPH ?g {
    ?observation obo:OBI_0000293 ?organism.
    ?organism sesame:directType ?taxon.
  }
}
lvaudor commented 1 year ago

Thanks @nleguillarme ! So, it's a local triplestore? I guess, if so, you'd also have a question along the lines of the Issue support for additional backends? #10 ?

nleguillarme commented 1 year ago

Exactly, it's a private instance of GraphDB we set up one one of our servers. I use glitter to encapsulate SPARQL queries in R functions, as a user-friendly interface to our triplestore.

lvaudor commented 1 year ago

Great! Thanks for the feedback @nleguillarme We'll see what we can do about searching specific graphs. For now we do not use private triplestores and so had not run yet into the question of sub-graphs so far... Am I right guessing that each of your graphs would correspond to specific geographic sites?

lvaudor commented 1 year ago

So, @maelle, I guess one example which we could try and reproduce (well, if we find a way) is this (to run on dbpedia's endpoint)

SELECT ?person ?name ?birthPlace ?deathPlace
WHERE
{
  GRAPH <http://dbpedia.org>
  {
    ?person a dbo:Person ;
            rdfs:label ?name .
    FILTER (LANG(?name) = 'en')
  }
  GRAPH <http://dbpedia.org/fr>
  {
    ?person dbo:birthPlace ?birthPlace .
    OPTIONAL {?person dbo:deathPlace ?deathPlace}
  }
}
FROM NAMED <http://dbpedia.org>, <http://dbpedia.org/fr>

It queries the graph with places' names in English, or in French... (well, haven't checked it yet, full disclosure: it's ChatGPT's code )

nleguillarme commented 1 year ago

Well actually, in my use case (semantic data integration), named graphs are used to track the original data source, so 1 graph = 1 data source.

maelle commented 1 year ago

@lvaudor what glitter interface would you envision for this?

maelle commented 1 year ago

related: #144 (FROM)