<?php define('MORIARTY_ARC_DIR', 'arc/'); require 'inc.php'; require 'credentials.inc.php'; require_once 'moriarty/credentials.class.php'; function report($r) { var_dump($r->status_code); if ($r->is_success() === false) { var_dump($r); die; } } $void = new SimpleGraph(); $void->add_turtle(file_get_contents('void.ttl')); $void->add_literal_triple(WHOISWHO, DCT . 'modified', date('c'), false, XSDT . 'dateTime'); $graph = new Graph('http://api.talis.com/stores/euwhoiswho/meta', new Credentials(STORE_USER, STORE_PASS)); $graph->mirror_from_uri(WHOISWHO, $void->to_json()); $graph->submit_ntriples_in_batches_from_file('roles.nt', 500, 'report'); $graph->mirror_from_uri("http://institutions.publicdata.eu/", file_get_contents('institutions.publicdata.eu.ttl')); $graph->submit_ntriples_in_batches_from_file('all.nt', 500, 'report');
function test_add_turtle_does_not_merge_bnodes_with_same_name() { $g = new SimpleGraph(); $g->add_turtle('_:foo <http://example.org/pred> "foo".'); $g->add_turtle('_:foo <http://example.org/pred> "foo".'); $this->assertEquals(2, count($g->get_triples())); $index = $g->get_index(); $this->assertEquals(2, count($index)); // two different subjects }
} function writeLog($msg) { echo $msg . "\n"; } } $ee = new Election_Results("http://www.europarl.europa.eu/parliament/archive/elections2009/en/national_parties_en_txt.html"); $ee->parseSeatsByPartyByStateTables(); print_r($electionCountData); //echo $ee->lookupCountry("BE"); $data_base_uri = "http://data.kasabi.com/dataset/european-election-results/"; $schema_base_uri = "http://data.kasabi.com/dataset/european-election-results/def/"; # build a graph $graph = new SimpleGraph(); //$def = new SimpleGraph() ; $graph->add_turtle(file_get_contents(PROJECT_ROOT . 'defs/eu-dataset-definition.ttl')); $graph->set_namespace_mapping('eedef', $schema_base_uri); $graph->set_namespace_mapping('ee', $data_base_uri); $graph->set_namespace_mapping('qb', 'http://purl.org/linked-data/cube#'); $graph->set_namespace_mapping('dct', 'http://purl.org/dc/terms/'); $electionPercentageData = $ee->getSeatsByPartyByStateTablePercentages(); // seats won counts foreach ($ee->getSeatsByPartyByStateTableCounts() as $k1 => $v) { foreach ($v as $k2 => $val) { if ($k2 == 'PoliticalGroupAbbr') { // add political groups $political_group = $data_base_uri . "political_group/" . $ee->uri_safe($v['PoliticalGroupAbbr']); $graph->add_resource_triple($political_group, $graph->qname_to_uri("rdf:type"), $schema_base_uri . "PoliticalGroup"); $graph->add_literal_triple($political_group, $graph->qname_to_uri("rdfs:label"), html_entity_decode($v['PoliticalGroupName'], ENT_QUOTES)); $graph->add_literal_triple($political_group, $graph->qname_to_uri("dct:identifier"), html_entity_decode($v['PoliticalGroupAbbr'], ENT_QUOTES)); }