Sparql: Use DBpedia together with PeriodicTable.owl

30 Views Asked by At

I use the periodicTable.owl from http://www.daml.org/2003/01/periodictable/. Each chemical element has a name e.g. "helium". I am now trying to gather more information about an element from dbpedia via the rdfs:label.

I tried this as an example:

PREFIX table: <http://www.daml.org/2003/01/periodictable/PeriodicTable#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbo: <http://dbpedia.org/ontology/> 

SELECT ?element ?abstract
WHERE
     {
        ?element rdf:type table:Element .
        ?element table:name ?name .
        ?dbr rdfs:label ?name .
        OPTIONAL{?dbr dbo:abstract ?abstract} .
     }

So the idea is to connect each of the elements in the periodictable to the corresponding dbpedia resource via the rdfs:label property and return the abstract if there is one like here: https://dbpedia.org/page/Helium

This does not work. Any suggestions why?

1

There are 1 best solutions below

1
Stefan - brox IT-Solutions On

In http://www.daml.org/2003/01/periodictable/PeriodicTable.owl, the names are literals with the datatype xsd:string. In DBpedia (at least in this case), the labels are literals with the datatype rdf:langString + a language tag.

These three labels have the same lexical form, but they are different literals (see Literal Equality):

ex:Someting rdfs:label "Foo" . # xsd:string
ex:Someting rdfs:label "Foo"@en . # rdf:langString + language tag "en"
ex:Someting rdfs:label "Foo"@fr . # rdf:langString + language tag "fr"

To compare their lexical forms, you can use SPARQL’s str() in a FILTER:

# untested query

SELECT ?element ?abstract
WHERE {

  ?element_daml
    a table:Element ;
    table:name ?name_daml .

  OPTIONAL { 

    ?element_dbpedia 
      rdfs:label ?name_dbpedia .
      dbo:abstract ?abstract . 

    FILTER( ?name_daml = str(?name_dbpedia) ) .

  }

}

Notes:

  • You might get better performance by using a subquery.
  • You might want to add a triple pattern to restrict which DBpedia entities are searched.
  • If you want to compare the labels case-insensitive, you can use LCASE/UCASE.