/** * Intercepts the current HTTP request and serves an RDF document * if the content negotiation results in a supported RDF format */ public function intercept() { $rdf_format = $this->contentNegotiation->negotiateRdfContentType($_SERVER['HTTP_ACCEPT']); if ($rdf_format != null) { global $wp_query; $graph = $this->rdfBuilder->buildGraph(get_queried_object(), $wp_query); $this->rdfPrinter->printGraph($graph, $rdf_format); exit; } }
if (preg_match('/\\.([a-z]+)/', $row['code']['value'], $m)) { $countryCode = strtoupper($m[1]); $langCode = $row['iso']['value']; $langCodes[$countryCode] = $langCode; } } $langCodes = array('AT' => 'de', 'UK' => 'en', 'BE' => 'nl', 'BG' => 'bg', 'IT' => 'ita', 'RO' => 'ro', 'PL' => 'szl', 'TR' => 'tr', 'GR' => 'el', 'GE' => 'ka', 'BY' => 'be', 'CZ' => 'sk', 'AZ' => 'az', 'MT' => 'mt', 'CY' => 'tr', 'SK' => 'sk', 'BE' => 'de', 'HU' => 'hun', 'LV' => 'lav', 'UA' => 'ukr', 'BA' => 'bs', 'SM' => 'ita'); $file = fopen('eumida.csv', 'r'); $countries = json_decode(file_get_contents('countries.json'), 1); $columnNames = fgetcsv($file); function varify($i) { return preg_replace('/[^0-9a-zA-Z]+/', '_', $i); } $vars = array_map('varify', $columnNames); $Rdf = new RdfBuilder(); register('eum', NS); register('aiiso', $curieous->uri('aiiso:')); $Rdf->create_vocabulary('eum', NS, 'EUMIDA Vocabulary', 'http://keithalexander.co.uk/id/me'); $doctoratesDatasetUri = EUMIDA . 'dataset/doctorates-awarded'; $studentsISCED5DatasetUri = EUMIDA . 'dataset/ISCED5-students-enrolled'; $internationStudentsDatasetUri = EUMIDA . 'dataset/international-ISCED5-students-enrolled'; $studentsISCED6DatasetUri = EUMIDA . 'dataset/ISCED-6-students-enrolled'; $isced6InternationalStudentsDatasetUri = EUMIDA . 'dataset/international-ISCED-6-students-enrolled'; $totalStaffDatasetUri = EUMIDA . 'dataset/total-staff'; $Rdf->thing($doctoratesDatasetUri)->a('qb:DataSet')->label('Numbers of Doctorates Awarded by Higher Education Institutions', 'en'); $Rdf->thing($studentsISCED5DatasetUri)->a('qb:DataSet')->label('Numbers of ISCED 5 Students Enrolled in European Higher Education Institutions', 'en'); $Rdf->thing($internationStudentsDatasetUri)->a('qb:DataSet')->label('Numbers of International ISCED 5 Students at European Higher Education Institutions', 'en'); $Rdf->thing($studentsISCED6DatasetUri)->a('qb:DataSet')->label('Numbers of ISCED 6 Students Enrolled in European Higher Education Institutions', 'en'); $Rdf->thing($isced6InternationalStudentsDatasetUri)->a('qb:DataSet')->label('Numbers of International ISCED 6 Students at European Higher Education Institutions', 'en'); $Rdf->thing($totalStaffDatasetUri)->a('qb:DataSet')->label('Numbers of Members of Staff at European Higher Education Institutions', 'en');
<?php ini_set('max_execution_time', 999999999999); define('MORIARTY_ARC_DIR', 'arc/'); require_once 'moriarty/simplegraph.class.php'; require 'curieous/rdfbuilder.class.php'; define('NS', 'http://ecb.publicdata.eu/'); $rdf = new RdfBuilder(); $rdf->create_vocabulary('ecbstats', NS . 'schema/', 'European Central Bank Statistics RDF Vocabulary', 'http://keithalexander.co.uk/id/me'); register('ecbstats', NS . 'schema/'); $output = array(); $concepts = array(); $codeLists = array(); $keyFamilies = array(); $reader = new XMLReader(); $reader->open('xml-schema/KeyFamily.xml'); while ($reader->read()) { set_time_limit(10000); switch ($reader->nodeType) { case XMLREADER::ELEMENT: if ($reader->localName == "Concept") { $node = $reader->expand(); $agencyID = $node->getAttribute('agencyID'); $id = $node->getAttribute('id'); $Name = $node->getELementsByTagName('Name')->item(0)->textContent; $rdf->thing_from_identifier(NS . 'schema/', $id)->a('qb:DimensionProperty')->label($Name, 'en')->has('rdfs:isDefinedBy')->r(NS . 'schema/')->is('ov:defines')->of(NS . 'schema/')->has('dct:creator')->r(NS . 'agency/' . $agencyID); echo $rdf->dump_ntriples(); } else { if ($reader->localName == "Dimension") { // $node = $reader->expand(); // $concepts[$node->getAttribute('conceptAgency')][$node->getAttribute('conceptRef')]['codeLists'][]=$node->getAttribute('codelist');
<?php require 'inc.php'; require 'curieous/rdfbuilder.class.php'; $datasets = json_decode(file_get_contents('datasets_with_sample_series.json'), 1); $rdf = new RdfBuilder(); foreach ($datasets as $dataset => $serieskey) { $url = 'http://sdw.ecb.europa.eu/quickviewexport.do?trans=&SERIES_KEY=' . $serieskey . '&type=csv'; // $url = 'http://sdw.ecb.europa.eu/export.do?SERIES_KEY='.$serieskey.'&exportType=csv'; $csv = fopen($url, 'r'); $row = fgetcsv($csv); $datasetfield = array_shift(explode(';', $row[0])); $datasetName = trim(array_pop(explode(':', $datasetfield))); $rdf->thing($dataset)->label($datasetName, 'en'); } echo $rdf->dump_ntriples();
foreach ($kf as $id => $props) { $dimensions = $props['dimension_list']; $dimension_key = $dimensions[$no]; $cl_id = $props['dimensions'][$dimension_key]; if (isset($codes[$cl_id]['codes'][$sk_code])) { // log_message("{$sk_code} is in $cl_id for {$dimension_key}"); $matching[$id] = $props; } } return $matching; } $metadata = json_decode(file_get_contents('keyfamily.json'), 1); register('ecbstats', NS . 'schema/'); $rdf = new RdfBuilder(); $rdf->create_vocabulary('ecbstats', NS . 'schema/', 'European Central Bank Statistics RDF Vocabulary', 'http://keithalexander.co.uk/id/me'); $conceptRdf = new RdfBuilder(); function csv_row_to_rdf($row) { global $metadata; global $rdf; global $conceptRdf; global $datasetUris; global $dateRdf; list($breadcrumb_trail, $series_key, $title, $fromDate, $toDate) = $row; $key_components = explode('.', $series_key); $matching_key_families = find_keyfamily_for_series_key($key_components); $matching_kf_ids = array_keys($matching_key_families); $no_of_matches = count($matching_kf_ids); if ($no_of_matches > 1) { log_message("more than one matching key family for series key " . $series_key); return false;
public function testBuildGraphForBlogWithPosts() { $builder = new RdfBuilder(new MockedLocalWebIdService()); $firstPost = new \WP_Post(); $firstPost->ID = 1; $firstPost->post_type = 'post'; $firstPost->post_title = 'My first blog post'; $firstPost->post_modified = '2013-04-17 20:16:41'; $firstPost->post_date = '2013-03-17 19:16:41'; $firstPost->post_content = 'The posts content'; $firstPost->post_author = 2; $secondPost = new \WP_Post(); $secondPost->ID = 2; $secondPost->post_type = 'post'; $secondPost->post_title = 'My second blog post'; $posts = array($firstPost, $secondPost); $graph = $builder->buildGraph(null, new \WP_Query($posts)); $blogUri = 'http://example.com#it'; $blog = $graph->resource($blogUri); $containedPosts = $blog->allResources('sioc:container_of'); $this->assertEquals(2, count($containedPosts), 'Blog should have 2 posts'); $containedPost = array_shift($containedPosts); $this->assertEquals('http://example.com/1#it', $containedPost->getUri()); $this->assertEquals('sioct:BlogPost', $containedPost->type()); $this->assertProperty($containedPost, 'dc:title', 'My first blog post'); $createdPost2 = array_shift($containedPosts); $this->assertEquals('http://example.com/2#it', $createdPost2->getUri()); $this->assertEquals('sioct:BlogPost', $createdPost2->type()); $this->assertProperty($createdPost2, 'dc:title', 'My second blog post'); }