1

How I can select one of rdf possible labels to send it to the Federated Search?

I have a rdf record who has several links to another databases:

<owl:sameAs rdf:resource="http://cantic.bnc.cat/registres/CUCId/a10035400"/>
<owl:sameAs rdf:resource="http://viaf.org/viaf/61502721"/>
<owl:sameAs rdf:resource="http://dbpedia.org/resource/Delfi_Abella"/>
<owl:sameAs rdf:resource="http://id.loc.gov/authorities/names/nr2005020137"/>
<owl:sameAs rdf:resource="http://d-nb.info/gnd/158288475"/>

I just get the dbpedia link to ask in dbpedia some information using It.

I create this federated search but It not works:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbo:<http://dbpedia.org/ontology/>

SELECT *
WHERE {
  ?autid rdaGr2:dateOfBirth "1991" .
  ?autid owl:sameAs ?dbpediaid 
  FILTER regex(?dbpediaid,'dbpedia','i') .
  SERVICE <http://dbpedia.org/sparql>
  {
    ?dbpediaid dbo:birthPlace ?naixement
  }
}

What I'm doing wrong?

If I use the single search:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbo:<http://dbpedia.org/ontology/>

SELECT *
WHERE {
  ?autid rdaGr2:dateOfBirth "1991" .
  ?autid owl:sameAs ?dbpediaid 
  FILTER regex(?dbpediaid,'dbpedia','i') .
}

I get the autid and the dbpedia link.

autid                                                           dbpediaid
http://arties.cbuc.cat/openccuc/a10985256/  http://dbpedia.org/resource/Emma_Roberts

How I can tell to the SERVIE just use It.

Regards


Update (originally posted as an answer)

Maybe I'm asking badly the question:

I try to do two different sparql in just one. Using the results from the first part of question (Filter aplied) i try to ask into DBPEDIA to get the results I need.

From the first part without any Filter

PREFIX foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX void: <http://rdfs.org/ns/void#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbo:<http://dbpedia.org/ontology/>

SELECT *
WHERE {
  ?autid rdaGr2:dateOfBirth "1991" .
  ?autid owl:sameAs ?dbpediaid 
 }

I get this results:

http://arties.cbuc.cat/openccuc/a10603050/  http://cantic.bnc.cat/registres/CUCId/a10603050
http://arties.cbuc.cat/openccuc/a10603050/  http://viaf.org/viaf/169463957
http://arties.cbuc.cat/openccuc/a10667283/  http://cantic.bnc.cat/registres/CUCId/a10667283
http://arties.cbuc.cat/openccuc/a10667283/  http://viaf.org/viaf/303916880
http://arties.cbuc.cat/openccuc/a10895814/  http://cantic.bnc.cat/registres/CUCId/a10895814
http://arties.cbuc.cat/openccuc/a10895814/  http://viaf.org/viaf/107201286
http://arties.cbuc.cat/openccuc/a10895814/  http://d-nb.info/gnd/140511695
http://arties.cbuc.cat/openccuc/a10895814/  http://id.loc.gov/authorities/names/no2010103795
http://arties.cbuc.cat/openccuc/a10985256/  http://cantic.bnc.cat/registres/CUCId/a10985256
http://arties.cbuc.cat/openccuc/a10985256/  http://viaf.org/viaf/85925873
http://arties.cbuc.cat/openccuc/a10985256/  http://id.loc.gov/authorities/names/no2005021393
http://arties.cbuc.cat/openccuc/a10985256/  http://d-nb.info/gnd/141167203
http://arties.cbuc.cat/openccuc/a10985256/  http://dbpedia.org/resource/Emma_Roberts
http://arties.cbuc.cat/openccuc/a11019682/  http://cantic.bnc.cat/registres/CUCId/a11019682
http://arties.cbuc.cat/openccuc/a11019682/  http://viaf.org/viaf/157747131
http://arties.cbuc.cat/openccuc/a11045553/  http://cantic.bnc.cat/registres/CUCId/a11045553
http://arties.cbuc.cat/openccuc/a11045553/  http://viaf.org/viaf/126161085

I apply the filter

PREFIX foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX void: <http://rdfs.org/ns/void#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbo:<http://dbpedia.org/ontology/>

SELECT *
WHERE {
  ?autid rdaGr2:dateOfBirth "1991" .
  ?autid owl:sameAs ?dbpediaid 
  FILTER regex(?dbpediaid,'dbpedia','i') .
}

to jut get one result:

http://arties.cbuc.cat/openccuc/a10985256/  http://dbpedia.org/resource/Emma_Roberts

And I want to send It to the Service to the DBPEDIA but just send this URL: http://dbpedia.org/resource/Emma_Roberts

Not all the URL I get from the first part:

http://cantic.bnc.cat/registres/CUCId/a10603050
http://viaf.org/viaf/169463957
http://cantic.bnc.cat/registres/CUCId/a10667283
http://viaf.org/viaf/303916880
http://cantic.bnc.cat/registres/CUCId/a10895814
http://viaf.org/viaf/107201286
http://d-nb.info/gnd/140511695
http://id.loc.gov/authorities/names/no2010103795
http://cantic.bnc.cat/registres/CUCId/a10985256
http://viaf.org/viaf/85925873
http://id.loc.gov/authorities/names/no2005021393
http://d-nb.info/gnd/141167203
http://dbpedia.org/resource/Emma_Roberts

Because some of them are not related to the Dbpedia and then the DBPEDIA send me an error like this:

Virtuoso RDFZZ Error DB.DBA.SPARQL_REXEC('http://dbpedia.org/sparql', ...) returned Content-Type 'text/plain' status 'HTTP/1.1 400 Bad Request
'
Virtuoso 37000 Error SP030: SPARQL compiler, line 3: syntax error at '_' before ':'

SPARQL query:
define sql:big-data-const 0  SELECT ?naixement
 WHERE  {  <http://dbpedia.org/resource/Emma_Roberts> <http://dbpedia.org/ontology/birthPlace> ?naixement .
     FILTER (_::default-20-7 =  <http://arties.cbuc.es:8990/CCUCAF>) }

SPARQL query:
define sql:big-data-const 0 
#output-format:text/html
define sql:signal-void-variables 1 define get:soft "soft" define input:default-graph-uri <http://arties.cbuc.es:8990/CCUCAF> PREFIX foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX void: <http://rdfs.org/ns/void#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbo:<http://dbpedia.org/ontology/>

SELECT ?naixement
WHERE {
  ?autid rdaGr2:dateOfBirth "1991" .
  ?autid owl:sameAs ?dbpediaid 
  filter regex( str(?dbpediaid),'dbpedia','i')

  SERVICE <http://dbpedia.org/sparql>
  {
    ?dbpediaid dbo:birthPlace ?naixement
  }
Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58

1 Answers1

1

FILTER regex(?dbpediaid,'dbpedia','i') should probably fail, since ?dbpediaid isn't a string; but a URI. Instead, you should be doing FILTER regex(str(?dbpediaid),'dbpedia','i'). The fact that your second query returns some results, though, makes it seem like the URI is implicitly being converted to a string. That might be an extension of the particular implementation you're using, though.

However, when I use Apache Jena to execute the following query, I get empty results:

prefix dbpedia: <http://dbpedia.org/resource/>
prefix dbpedia-owl: <http://dbpedia.org/ontology/>

select * where {
  bind( dbpedia:Emma_Roberts as ?dbpediaid )
  filter regex( ?dbpediaid,'dbpedia','i')

  service <http://dbpedia.org/sparql> {
    ?dbpediaid dbpedia-owl:birthPlace ?naixement
  }
}
-------------------------
| dbpediaid | naixement |
=========================
-------------------------

If I make the change to using str(?dbpediaid), I get results:

prefix dbpedia: <http://dbpedia.org/resource/>
prefix dbpedia-owl: <http://dbpedia.org/ontology/>

select * where {
  bind( dbpedia:Emma_Roberts as ?dbpediaid )
  filter regex( str(?dbpediaid),'dbpedia','i')

  service <http://dbpedia.org/sparql> {
    ?dbpediaid dbpedia-owl:birthPlace ?naixement
  }
}
--------------------------------------------------------------------------------------
| dbpediaid            | naixement                                                   |
======================================================================================
| dbpedia:Emma_Roberts | <http://dbpedia.org/resource/Rhinebeck_(village),_New_York> |
--------------------------------------------------------------------------------------

Note that this could be a very expensive query if the query engine does the service part first, as it would retrieve all the dbpedia-owl:birthPlace triples first, bring them back, and then match against the particular one that you care about. There may be different behavior if rather than using bind, like I did above, the value of ?dbpediaid is simply coming from some triple matches.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Sorry but maybe I'm explain badly – jordi Pallares Jul 24 '14 at 07:04
  • @jordiPallares You posted an "answer" that isn't actually an answer, and should have been an edit to the question. I think I understand what you're trying to do: you're trying to query data from one place (not DBpedia) and then use *some* of those values as parameters in a query to DBpedia that's performed by `service { … }`. Is that correct? You then said that **Because some of them are not related to the Dbpedia and then the DBPEDIA send me an error like this: …**. The error message doesn't say that the problem is that the URIs "are not related to DBpedia", but… – Joshua Taylor Jul 24 '14 at 10:55
  • …rather that DBpedia is returning text instead of SPARQL results. The actual text that it's returning is the error message from DBpedia: **Virtuoso 37000 Error SP030: SPARQL compiler, line 3: syntax error at '_' before ':'** referring, I presume, to the line of the query: `FILTER (_::default-20-7 = )`. I expect that it's complaining about `_::default-20-7`, but I'm not sure. If you got such a detailed error message, then you should have posted it in the original question. – Joshua Taylor Jul 24 '14 at 10:59
  • You **did** get a more detailed error than what you put in your original question. You posted it in an answer; that's where i copied it from! – Joshua Taylor Jul 24 '14 at 12:07