function test_match_compare_string_with_boolean() { $g = new SimpleGraph(); $g->set_namespace_mapping('ex', 'http://example.org/'); $g->add_literal_triple('http://example.org/subj', 'http://example.org/pred', 'obj'); $g->add_literal_triple('http://example.org/subj2', 'http://example.org/pred', ''); $gp = new GraphPath('*[literal-value(ex:pred) = true()]'); $this->assertPathSelects($gp, $g); }
function test_uri_to_qname_returns_null_if_uri_not_representable_as_qname() { $g = new SimpleGraph(); $g->set_namespace_mapping('ex', 'http://example.org/'); $this->assertEquals(null, $g->uri_to_qname('http://example.org/foo/')); }
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)); } if (preg_match("/^[A-Z][A-Z]\$/", $k2)) {