PHP code example of tdt / streamingrdfmapper

1. Go to this page and download the library: Download tdt/streamingrdfmapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tdt / streamingrdfmapper example snippets


$mapping = file_get_contents("http://foo.bar/mapping/file.ttl");
$typeofmapping = "Vertere";
$mapper = new StreamingRDFMapper($mapping, $typeofmapping);
$data = foo\bar\getNextDataChunk(); //get data from somewhere: can be a csv file you've extracted, some data you've scraped or XML or JSON file you've flattened and put into an array
$getEasyRDFGraph = true;
$triplesEasyRDFGraph = $mapper->map($data, $getEasyRDFGraph);
$triplesArray = $mapper->map($data, !$getEasyRDFGraph);
//print ntriples through easy graph (some overhead, but really good library*)
print $triplesEasyRDFGraph->serialize("ntriples");
//print ntriples through array (faster)
foreach($triplesArray as $triple){
  print implode(" ", $triple);
  print " . \n";
}


$mapper->setBaseUri("http://data.iRail.be/");