Exemplo n.º 1
0
 function test_qname_to_uri_returns_null_if_no_match()
 {
     $g = new SimpleGraph();
     $g->set_namespace_mapping('ex', 'http://example.org/');
     $this->assertEquals(null, $g->qname_to_uri('bar:foo'));
 }
Exemplo n.º 2
0
# 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));
        }
        if (preg_match("/^[A-Z][A-Z]\$/", $k2)) {
            // add country
            $country_name = $ee->lookupCountry($k2);
            $country_code = $k2;
            $country_uri = $data_base_uri . "country/" . $ee->uri_safe($country_code);
            $graph->add_resource_triple($country_uri, $graph->qname_to_uri("rdf:type"), $schema_base_uri . "Country");
            $graph->add_literal_triple($country_uri, $graph->qname_to_uri("rdfs:label"), $country_name);
            $graph->add_literal_triple($country_uri, $graph->qname_to_uri("dct:identifier"), $country_code);
            // add results per country
            foreach ($val as $party => $count) {
                if ($party == 'seatCount') {
                    // total count for the political group