本文整理汇总了PHP中EasyRdf_Namespace::set方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Namespace::set方法的具体用法?PHP EasyRdf_Namespace::set怎么用?PHP EasyRdf_Namespace::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EasyRdf_Namespace
的用法示例。
在下文中一共展示了EasyRdf_Namespace::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDcat
/**
* Create the DCAT document of the published (non-draft) resources
*
* @param $pieces array of uri pieces
* @return mixed \Data object with a graph of DCAT information
*/
private function createDcat()
{
$ns = $this->dcat->getNamespaces();
foreach ($ns as $prefix => $uri) {
\EasyRdf_Namespace::set($prefix, $uri);
}
// Apply paging when fetching the definitions
list($limit, $offset) = Pager::calculateLimitAndOffset();
$definition_count = $this->definitions->countPublished();
$definitions = $this->definitions->getAllPublished($limit, $offset);
$oldest = $this->definitions->getOldest();
$describedDefinitions = array();
// Add the source type description to the definition
foreach ($definitions as $definition) {
$definition = array_merge($definition, $this->definitions->getFullDescription($definition['collection_uri'] . '/' . $definition['resource_name']));
array_push($describedDefinitions, $definition);
}
$graph = $this->dcat->getDcatDocument($describedDefinitions, $oldest);
// Return the dcat feed in our internal data object
$data_result = new Data();
$data_result->data = $graph;
$data_result->is_semantic = true;
$data_result->paging = Pager::calculatePagingHeaders($limit, $offset, $definition_count);
// Add the semantic configuration for the ARC graph
$data_result->semantic = new \stdClass();
$data_result->semantic->conf = array('ns' => $ns);
$data_result->definition = new \stdClass();
$data_result->definition->resource_name = 'dcat';
$data_result->definition->collection_uri = 'info';
return $data_result;
}
示例2: getInfo
/** Get the data for reuse based off sparql endpoint
* @access public
* @return array $data
* */
public function getInfo($identifier)
{
$key = md5($identifier . 'ocre');
$uri = self::CRRO . $identifier;
if (!$this->getCache()->test($key)) {
EasyRdf_Namespace::set('nm', 'http://nomisma.org/id/');
EasyRdf_Namespace::set('nmo', 'http://nomisma.org/ontology#');
EasyRdf_Namespace::set('skos', 'http://www.w3.org/2004/02/skos/core#');
EasyRdf_Namespace::set('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
$request = new EasyRdf_Http_Client();
$request->setUri($uri);
$response = $request->request()->getStatus();
if ($response == 200) {
$graph = new EasyRdf_Graph($uri);
$graph->load();
$data = $graph->resource($uri);
$this->getCache()->save($data);
} else {
$data = NULL;
}
} else {
$data = $this->getCache()->load($key);
}
return $data;
}
示例3: registerNameSpaces
/** Register the namespaces with EasyRdf
* @access public
* @return \Pas_View_Helper_SparqlEasy
*/
public function registerNameSpaces()
{
foreach ($this->getNameSpaces() as $k => $v) {
EasyRdf_Namespace::set($k, $v);
}
return $this;
}
示例4: init_vocabularies
function init_vocabularies()
{
$voc_prefixes = array("cc" => "http://creativecommons.org/ns#", "mdc" => "http://purl.org/meducator/repurposing", "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "dcterms" => "http://purl.org/dc/terms", "ebucore" => "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore", "nrl" => "http://www.semanticdesktop.org/ontologies/2007/08/15/nrl", "va" => "http://code-research.eu/ontology/visual-analytics", "ex" => "http://example.org");
foreach ($voc_prefixes as $key => $value) {
EasyRdf_Namespace::set($key, $value);
}
}
示例5: setUp
public function setUp()
{
if (PHP_MAJOR_VERSION < 5 or PHP_MAJOR_VERSION == 5 and PHP_MINOR_VERSION < 3) {
$this->markTestSkipped("JSON-LD support requires PHP 5.3+");
}
if (!class_exists('\\ML\\JsonLD\\JsonLD')) {
$this->markTestSkipped('"ml/json-ld" dependency is not installed');
}
$this->graph = new EasyRdf_Graph('http://example.com/');
$this->serialiser = new EasyRdf_Serialiser_JsonLd();
$joe = $this->graph->resource('http://www.example.com/joe#me', 'foaf:Person');
$joe->set('foaf:name', new EasyRdf_Literal('Joe Bloggs', 'en'));
$joe->set('foaf:age', 59);
$joe->set('foaf:homepage', $this->graph->resource('http://foo/bar/me'));
$project = $this->graph->newBNode();
$project->add('foaf:name', 'Project Name');
$joe->add('foaf:project', $project);
EasyRdf_Namespace::set('dc', 'http://purl.org/dc/elements/1.1/');
EasyRdf_Namespace::set('ex', 'http://example.org/vocab#');
EasyRdf_Namespace::set('xsd', 'http://www.w3.org/2001/XMLSchema#');
EasyRdf_Namespace::set('', 'http://foo/bar/');
$chapter = $this->graph->resource('http://example.org/library/the-republic#introduction', 'ex:Chapter');
$chapter->set('dc:description', new EasyRdf_Literal('An introductory chapter on The Republic.'));
$chapter->set('dc:title', new EasyRdf_Literal('The Introduction'));
$book = $this->graph->resource('http://example.org/library/the-republic', 'ex:Book');
$book->set('dc:creator', new EasyRdf_Literal('Plato'));
$book->set('dc:title', new EasyRdf_Literal('The Republic'));
$book->addResource('ex:contains', $chapter);
$library = $this->graph->resource('http://example.org/library', 'ex:Library');
$library->addResource('ex:contains', $book);
}
示例6: getBody
public static function getBody($dataObj)
{
if ($dataObj->is_semantic) {
// Check if a configuration is given
$conf = array();
if (!empty($dataObj->semantic->conf)) {
$conf = $dataObj->semantic->conf;
foreach ($conf['ns'] as $prefix => $uri) {
\EasyRdf_Namespace::set($prefix, $uri);
}
}
// Add the configured ontology prefixes
$ontologies = \App::make('Tdt\\Core\\Repositories\\Interfaces\\OntologyRepositoryInterface');
$context = array();
// Only add the common namespaces
$namespaces = array('hydra', 'rdf', 'rdfs', 'foaf', 'void', 'xsd', 'skos', 'xs');
foreach ($namespaces as $ns) {
$namespace = $ontologies->getByPrefix($ns);
if (!empty($namespace)) {
$context[$ns] = $namespace['uri'];
}
}
$output = $dataObj->data->serialise('jsonld');
// Next, encode the context as JSON
$jsonContext = json_encode($context);
// Compact the JsonLD by using @context -> Needs tweaking can only return the
// URI spaces that are used in the document.
$compacted = JsonLD::compact($output, $jsonContext);
// Print the resulting JSON-LD!
return JsonLD::toString($compacted, true);
} else {
\App::abort(400, "The data is not a semantically linked document, a linked data JSON representation is not possible.");
}
}
示例7: createPersonAction
/**
* @Route("/create-person")
*/
public function createPersonAction()
{
\EasyRdf_Format::registerSerialiser('ntriples', 'EasyRdf_Serialiser_Arc');
\EasyRdf_Format::registerSerialiser('posh', 'EasyRdf_Serialiser_Arc');
\EasyRdf_Format::registerSerialiser('rdfxml', 'EasyRdf_Serialiser_Arc');
\EasyRdf_Format::registerSerialiser('turtle', 'EasyRdf_Serialiser_Arc');
\EasyRdf_Namespace::set('foaf', 'http://xmlns.com/foaf/0.1/');
$uri = 'http://www.example.com/emi#me';
$name = 'Emi Berea';
$emailStr = 'emi.berea@gmail.com';
$homepageStr = 'http://bereae.me/';
$graph = new \EasyRdf_Graph();
# 1st Technique
$me = $graph->resource($uri, 'foaf:Person');
$me->set('foaf:name', $name);
if ($emailStr) {
$email = $graph->resource("mailto:" . $emailStr);
$me->add('foaf:mbox', $email);
}
if ($homepageStr) {
$homepage = $graph->resource($homepageStr);
$me->add('foaf:homepage', $homepage);
}
# Finally output the graph
$data = $graph->serialise('rdfxml');
if (!is_scalar($data)) {
$data = var_export($data, true);
}
var_dump($data);
die;
}
示例8: __construct
public function __construct()
{
// Enable things like: http://linda/lists/frequencies.json?q=trien
// cfr. https://github.com/iRail/hyperRail/blob/master/app/controllers/StationController.php#L44
$this->lists = ["frequencies" => [], "organizationtypes" => [], "uses" => []];
\EasyRdf_Namespace::set('linda', 'http://semweb.mmlab.be/ns/linda#');
\EasyRdf_Namespace::set('odapps', 'http://semweb.mmlab.be/ns/odapps#');
}
示例9: getPeople
function getPeople($name, $affil)
{
EasyRdf_Namespace::set('sd', 'http://symbolicdata.org/Data/Model#');
$query = '
PREFIX sd: <http://symbolicdata.org/Data/Model#>
construct { ?a ?b ?c . }
from <http://symbolicdata.org/Data/People/>
from <http://symbolicdata.org/Data/AuthorIdentification/>
from <http://symbolicdata.org/Data/PersonalProfiles/>
from <http://symbolicdata.org/Data/BenchmarkReferences/>
Where {
?a a foaf:Person ; ?b ?c; foaf:name $n .
optional { ?a sd:affiliation $f . }
filter regex(?n, "' . $name . '","i")
filter regex(?f, "' . $affil . '","i")
}
LIMIT 100';
$sparql = new EasyRdf_Sparql_Client('http://symbolicdata.org:8890/sparql');
$result = $sparql->query($query);
// a CONSTRUCT query returns an EasyRdf_Graph
//echo $result->dump("turtle");
/* generate data structure for output table */
$s = array();
foreach ($result->allOfType("foaf:Person") as $v) {
$a = $v->getUri();
$label = $v->get('foaf:name');
$loc = $v->get('sd:affiliation');
$hp = $v->get('foaf:homepage');
$zb = $v->get('sd:hasZBMathAuthorID');
$mr = $v->get('sd:hasMRAuthorID');
$bs = $v->get('sd:providesDataAt');
$pp = $v->get('sd:hasPersonalProfile');
$out = '<p><dl> <dt><strong><a href="' . $a . '">' . $label . '</a></strong></dt>
';
if (!empty($loc)) {
$out .= '<dd>Affiliation: ' . $loc . '.</dd>';
}
if (!empty($hp)) {
$out .= '<dd>Homepage: <a href="' . $hp . '">' . $hp . '</a></dd>';
}
if (!empty($pp)) {
$out .= '<dd>Personal FOAF Profile: <a href="' . $pp . '">' . $pp . '</a></dd>';
}
if (!empty($zb)) {
$out .= '<dd>ZBMath Author Code: <a href="' . $zb . '">' . $zb . '</a></dd>';
}
if (!empty($mr)) {
$out .= '<dd>MR Author ID: <a href="' . $mr . '">' . $mr . '</a></dd>';
}
if (!empty($bs)) {
$out .= '<dd>Provides Benchmark References at: <a href="' . $bs . '">' . $bs . '</a></dd>';
}
$out .= '</dl></p>';
$s["{$a}"] = $out;
}
ksort($s);
return '<h4>List of entries with foaf:name containing "' . $name . '" and sd:affiliation containing "' . $affil . '"</h4>' . join($s, "\n");
}
示例10: get_action
public function get_action($data)
{
EasyRdf_Namespace::set('o311', 'http://ontology.eil.utoronto.ca/open311.owl#');
$sparql = new EasyRdf_Sparql_Client('http://localhost:8890/sparql');
//SAMPLE QUERY: select * where {?sub o311:hasAddress o311:iiitCC3. ?sub o311:has311Subject o311:Waste. ?sub o311:need311Action ?action. ?sub o311:isHandledBy ?authority. ?authority o311:AgencyName ?name. ?authority o311:Phone ?phone. ?authority o311:Email ?email. ?authority o311:AddressType ?address }';
$str = 'SELECT * WHERE {' . '?sub o311:hasAddress o311:' . $data["where"] . ". " . '?sub o311:has311Subject o311:' . $data["what"] . ". " . '?sub o311:isHandledBy ?authority. ' . '?sub o311:need311Action ?action. ' . '?authority o311:AgencyName ?name.' . '?authority o311:Phone ?phone.' . '?authority o311:Email ?email.' . '?authority o311:AddressType ?address.' . '} ';
echo "<br><i><font color = 'grey'>{$str}</font></i><br>";
$result = $sparql->query($str);
return $result;
}
示例11: indexAction
public function indexAction()
{
$foaf = \EasyRdf_Graph::newAndLoad('http://njh.me/foaf.rdf');
$me = $foaf->primaryTopic();
\EasyRdf_Namespace::set('category', 'http://dbpedia.org/resource/Category:');
\EasyRdf_Namespace::set('dbpedia', 'http://dbpedia.org/resource/');
\EasyRdf_Namespace::set('dbo', 'http://dbpedia.org/ontology/');
\EasyRdf_Namespace::set('dbp', 'http://dbpedia.org/property/');
$sparql = new \EasyRdf_Sparql_Client('http://dbpedia.org/sparql');
$result = $sparql->query('SELECT * WHERE {' . ' ?country rdf:type dbo:Country .' . ' ?country rdfs:label ?label .' . ' ?country dc:subject category:Member_states_of_the_United_Nations .' . ' FILTER ( lang(?label) = "en" )' . '} ORDER BY ?label');
return $this->render('MyAppBlogBundle:Default:index.html.twig', array('name' => $result, 'count' => $result->numRows()));
}
示例12: testSerialiseJson
public function testSerialiseJson()
{
\EasyRdf_Namespace::set('', 'http://foo/bar/');
$joe = $this->graph->resource('http://www.example.com/joe#me', 'foaf:Person');
$joe->set('foaf:name', new EasyRdf_Literal('Joe Bloggs', 'en'));
$joe->set('foaf:homepage', $this->graph->resource('http://foo/bar/me'));
$joe->set('foaf:age', 59);
$project = $this->graph->newBNode();
$project->add('foaf:name', 'Project Name');
$joe->add('foaf:project', $project);
$json = $this->serialiser->serialise($this->graph, 'json');
$this->assertSame('{"http:\\/\\/www.example.com\\/joe#me":{' . '"http:\\/\\/www.w3.org\\/1999\\/02\\/22-rdf-syntax-ns#type":[' . '{"type":"uri","value":"http:\\/\\/xmlns.com\\/foaf\\/0.1\\/Person"}],' . '"http:\\/\\/xmlns.com\\/foaf\\/0.1\\/name":[' . '{"type":"literal","value":"Joe Bloggs","lang":"en"}],' . '"http:\\/\\/xmlns.com\\/foaf\\/0.1\\/homepage":[{"type":"uri","value":"http:\\/\\/foo\\/bar\\/me"}],' . '"http:\\/\\/xmlns.com\\/foaf\\/0.1\\/age":[' . '{"type":"literal","value":"59","datatype":' . '"http:\\/\\/www.w3.org\\/2001\\/XMLSchema#integer"}],' . '"http:\\/\\/xmlns.com\\/foaf\\/0.1\\/project":[' . '{"type":"bnode","value":"_:genid1"}]},"_:genid1":{' . '"http:\\/\\/xmlns.com\\/foaf\\/0.1\\/name":[' . '{"type":"literal","value":"Project Name"}]}}', $this->serialiser->serialise($this->graph, 'json'));
}
示例13: casystems
function casystems()
{
EasyRdf_Namespace::set('sd', 'http://symbolicdata.org/Data/Model#');
EasyRdf_Namespace::set('dct', 'http://purl.org/dc/terms/');
EasyRdf_Namespace::set('owl', 'http://www.w3.org/2002/07/owl#');
$people = new EasyRdf_Graph("http://symbolicdata.org/Data/People/");
$people->parseFile("http://symbolicdata.org/rdf/People.rdf");
//$people->parseFile("/home/graebe/git/SD/web/rdf/People.rdf");
$systems = new EasyRdf_Graph("http://symbolicdata.org/Data/CA-Systems/");
$systems->parseFile("http://symbolicdata.org/rdf/CA-Systems.rdf");
//$systems->parseFile("/home/graebe/git/SD/web/rdf/CA-Systems.rdf");
$out = displaySystems($systems, $people);
return $out;
}
示例14: dissertationen
function dissertationen($atts)
{
EasyRdf_Namespace::set('bibo', 'http://purl.org/ontology/bibo/');
EasyRdf_Namespace::set('sd', 'http://symbolicdata.org/Data/Model#');
EasyRdf_Namespace::set('dct', 'http://purl.org/dc/terms/');
$people = new EasyRdf_Graph("http://symbolicdata.org/Data/People/");
$people->parseFile("http://symbolicdata.org/rdf/People.rdf");
//$people->parseFile("/home/graebe/git/SD/web/rdf/People.rdf");
$out = "\n\n<h2 align=\"center\">Habilitationen</h2>\n\n";
$out .= displayAll(getDissertations('habil'), $people);
$out .= "\n\n<h2 align=\"center\">Promotionen</h2>\n\n";
$out .= displayAll(getDissertations('phd'), $people);
return $out;
}
示例15: getNews
function getNews()
{
EasyRdf_Namespace::set('sd', 'http://symbolicdata.org/Data/Model#');
EasyRdf_Namespace::set('sioc', 'http://rdfs.org/sioc/ns#');
$query1 = '
PREFIX sd: <http://symbolicdata.org/Data/Model#>
construct { ?a ?b ?c . }
from <http://symbolicdata.org/Data/News/>
Where { ?a a sioc:BlogPost ; ?b ?c . }
';
$query2 = '
PREFIX sd: <http://symbolicdata.org/Data/Model#>
construct { ?p foaf:name ?n . }
from <http://symbolicdata.org/Data/News/>
from <http://symbolicdata.org/Data/People/>
Where { ?a a sioc:BlogPost ; dc:publisher ?p .
?p foaf:name ?n . }
';
$sparql = new EasyRdf_Sparql_Client('http://symbolicdata.org:8890/sparql');
$result = $sparql->query($query1);
// a CONSTRUCT query returns an EasyRdf_Graph
//echo $result->dump("turtle");
$people = $sparql->query($query2);
//echo $people->dump("turtle");
/* generate data structure for output table */
$s = array();
foreach ($result->allOfType("sioc:BlogPost") as $v) {
$a = $v->getUri();
$label = $v->get('rdfs:label');
$created = $v->get('dc:created');
$subject = $v->join('dc:subject');
$abstract = $v->get('dc:abstract');
$publisher = $people->get($v->get('dc:publisher'), 'foaf:name');
$link = $v->get('sioc:link');
$linksTo = $v->get('sioc:links_to');
$out = '<p><dl> <dt><strong><a href="' . $a . '">' . $label . '</a></strong></dt>
';
$out .= addLine($created, "Created");
$out .= addLine($subject, "Subject");
$out .= addLine($abstract, "Abstract");
$out .= addLine($publisher, "Publisher");
$out .= addLink($link, "More");
$out .= addLink($linksTo, "Links to");
$out .= '</dl></p>';
$s["{$created_}{$a}"] = $out;
}
krsort($s);
return join($s, "\n");
}