function translateLabelsOnPage($xpath_query) { global $nameTranslations; foreach ($this->translate_langs as $lang) { $doc = $this->fetchDocFromUrl($this->translatePageUrlTo($lang)); $xpath = new DomXpath($doc); $graph = new SimpleGraph(); foreach ($xpath->query($xpath_query) as $a) { $nodeId = $this->getNodeIdFromUrl($a->getAttribute('href')); $uri = INST . 'institutions/' . $nodeId; $this->graph->add_literal_triple($uri, RDFS_LABEL, $a->textContent, $lang); $nameTranslations[$uri][$lang] = $a->textContent; } echo trim($graph->to_ntriples()); } }
} else { // seats won by the national parties $obs2 = $data_base_uri . "2009/national_parties/observation/" . $ee->getObservationId(); $graph->add_resource_triple($obs2, $graph->qname_to_uri('rdf:type'), $graph->qname_to_uri('eedef:ElectionResult')); $graph->add_resource_triple($obs2, $graph->qname_to_uri('eedef:year'), 'http://reference.data.gov.uk/id/year/2009'); $graph->add_resource_triple($obs2, $graph->qname_to_uri('eedef:votingCountry'), $country_uri); $graph->add_resource_triple($obs2, $graph->qname_to_uri('eedef:nationalParty'), $ee->getPartyURI($data_base_uri, $party)); $graph->add_literal_triple($obs2, $graph->qname_to_uri('eedef:seatsWon'), $count); $graph->add_literal_triple($obs2, $graph->qname_to_uri('eedef:percentageOfSeatsWon'), $electionPercentageData[$k1][$k2][$party]); $graph->add_resource_triple($obs2, $graph->qname_to_uri('qb:dataset'), $data_base_uri . '2009/political_groups/seats_won'); $graph->add_resource_triple($ee->getPartyURI($data_base_uri, $party), $graph->qname_to_uri('rdf:type'), $graph->qname_to_uri('eedef:NationalParty')); $graph->add_resource_triple($ee->getPartyURI($data_base_uri, $party), $graph->qname_to_uri('rdfs:label'), html_entity_decode($ee->lookupPartyName($party), ENT_QUOTES)); } } } } } echo $graph->to_turtle(); //echo $def->to_turtle(); file_put_contents(PROJECT_ROOT . "rdf/election-results.nt", $graph->to_ntriples()); // TODO // link political groups to national parties. (columns in the original HTML) // do we need slices? // /* * country specific scrapings * * */ // http://www.europarl.europa.eu/parliament/archive/elections2009/en/belgium_en_txt.html //