2

I would like to make a SPARQL query using MAKG (Microsoft Academic Knowledge Graph) (https://makg.org/) and DBPedia datasets (using SERVICE keyword) on Apache Jena Fuseki.

Before that, I want to test some simpler queries for just MAKG such as:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX magc: <https://makg.org/class/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX fabio: <http://purl.org/spar/fabio/>
PREFIX prism: <http://prismstandard.org/namespaces/basic/2.0/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT distinct ?paperTitle ?paperPubDate
WHERE {
        ?paper rdf:type magc:Paper .
        ?paper prism:keyword "hydrogen"^^xsd:string .
        ?paper fabio:hasDiscipline ?field .
        ?paper dcterms:title ?paperTitle .
        ?paper prism:publicationDate ?paperPubDate .
}
LIMIT 100

It retrieves papers with a keyword equals to "hydrogen".

Using MAKG endpoint https://makg.org/sparql, it's working well (result). But if I test the same query on Apache Jena Fuseki, it retrieves no row.

SELECT ?paperTitle ?paperPubDate WHERE {
  SERVICE <https://makg.org/sparql> {
    ?paper rdf:type magc:Paper .
    ?paper prism:keyword "hydrogen"^^xsd:string .
    ?paper fabio:hasDiscipline ?field .
    ?paper dcterms:title ?paperTitle .
    ?paper prism:publicationDate ?paperPubDate .
  }
}
LIMIT 100

In general, it seems like it's not working when I want to query by a specific string.

Do you have any hints?

Thank you in advance.

1 Answers1

3

The makg.org server is Virtuoso which uses RDF 1.0 for data so "hydrogen"^^xsd:string != "hydrogen".

Apache Jena Fuseki uses RDF 1.1 where "hydrogen"^^xsd:string is the same as "hydrogen" .

The problem is that the query sent is sending "hydrogen" because it is reconstructing the query service-part into a string using RDF 1.1 abbreviations.

The way round this using Fuseki is to use a filter.

?paper prism:keyword ?X . FILTER(str(?X) = "hydrogen")

Strictly str() isn't needed (SPARQL defines "=" as string-value, not same-term) but makg.org does need it.


In addition, the LIMIT needs to go to makg.org server by putting it inside the SERVICE:

PREFIX ...

SELECT ?paperTitle ?paperPubDate WHERE {
  SERVICE <https://makg.org/sparql> {
    SELECT * {
      ?paper rdf:type magc:Paper .
      ?paper prism:keyword "hydrogen"^^xsd:string .
      ?paper fabio:hasDiscipline ?field .
      ?paper dcterms:title ?paperTitle .
      ?paper prism:publicationDate ?paperPubDate .
    } LIMIT 100
  }
}
AndyS
  • 16,345
  • 17
  • 21