0

I am trying to fill my rdf with Spanish city names from Dbpedia But... nothing is extracted. I do it with the ARC2 library

<?php

include_once("./vendor/semsol/arc2/ARC2.php");

$config = array(
  /* db */
  'db_name' => 'my_db',
  'db_user' => 'root',
  'db_pwd' => 'root',
/* store name */
   'store_name' => 'construct_store',
 );

$store = ARC2::getStore($config);
if (!$store->isSetUp()) {     
      $store->setUp();
}

$store->query ('LOAD <http://localhost:8080/proyecto1/data/myOnto.rdf>');

$q = '
  PREFIX myOntology:  <http://www.semanticweb.org/myOntology#>
  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
  PREFIX dbpprop: <http://dbpedia.org/property/>
  PREFIX esdbpr: <http://es.dbpedia.org/resource/> 

 CONSTRUCT  {
 ?l myOntology:hasName ?name.
 }
  WHERE (?x rdf:resource <http://dbpedia.org/ontology/PopulatedPlace">
  ?x <http://es.dbpedia.org/ontology/country>  <http://es.dbpedia.org/resource/Spain>  .
   ?name rdfs:label ?label.
 )
 }
 LIMIT 5';

 $r = '';
 if ($rows = $store->query($q, 'rows')) {
   foreach ($rows as $row) {
     $r .= '<li>' . $row['name'] . '</li>';
   }
 }

 echo $r ? '<ul>' . $r . '</ul>' : 'nothing is found';

  ?>

Maybe I am looking incorrectly through the DBPedia ontology or the CONSTRUCT structure in incorrect....

THank you in advance

elka
  • 25
  • 3

1 Answers1

0

What is rdf:resource in your opinion for a property? You should only use properties that really exist, in your case it should be rdf:type.

-> x rdf:type <http://dbpedia.org/ontology/PopulatedPlace">

And what is the quote char in the PopulatedPlace URI used for?

-> x rdf:type <http://dbpedia.org/ontology/PopulatedPlace>

And it's not clear if your local data contains the triples you're asking for. At least from the code I can only see that you load a file and execute the query against that file. By the way, you're mixing up URIs from the English and Spanish DBpedia - is this reflected by your data?

UninformedUser
  • 8,397
  • 1
  • 14
  • 23
  • I found _italic_ **bold** `rdf.resourse ` on the [link] (http://es.dbpedia.org/page/Espa%C3%B1a), and thought yo use it. Maybe, wrongly. The quote I put by a misprint, thanks! – elka Feb 09 '17 at 12:47
  • THe mixture of the English and Spanish data is not reflected because I do not get any result...:( – elka Feb 09 '17 at 12:48
  • In my ontology I have a triple like that "_?l myOntology:hasName ?name_", where _l_ is a place, and _name_ is the name of the place. They are linked with "hasName". – elka Feb 09 '17 at 12:52
  • I don't understand what you're doing. You loaded your own ontology, thus, you can only query that data via SPARQL. – UninformedUser Feb 09 '17 at 14:02
  • I want to exstract some data from dbpedia and put them into my ontology – elka Feb 10 '17 at 08:11
  • Ok, but do you understand that your code just loads your ontology and runs the SPARQL query against that data only? – UninformedUser Feb 10 '17 at 10:54
  • I didnt notice that before, but now, yes, it seems so...So, what I should do is not to load my ontology, but consult fo the dbpedia, and when insert the data I extract to my ontology? – elka Feb 10 '17 at 12:20
  • Ehm yes, of course. How else should the SPARQL query return anything from a remote dataset without knowing the location of the SPARQL service? – UninformedUser Feb 10 '17 at 13:23
  • Ok, thanks a lot. I have made changes and now i set an endpoint to DBPedia, and also changed a query `$query = ' PREFIX ... WHERE { ?city rdf:type dbpedia-owl:City ; rdfs:label ?label ; dbpedia-owl:country . filter ( langMatches(lang(?label), "es") ) } ORDER BY ?label LIMIT 100';` BUt now I am thinkig of how should I put it data into my ontology: should I write some INSERT INTO? Should I do it in some *.php apart or in the same... – elka Feb 13 '17 at 12:40
  • As you said, there are multiple options but I guess the easiest would be to use the ARC2 PHP API. Or if you only need to do it once, some command line utility like `rapper` – UninformedUser Feb 13 '17 at 13:06