当前位置: 首页>>代码示例>>PHP>>正文


PHP EasyRdf_Namespace类代码示例

本文整理汇总了PHP中EasyRdf_Namespace的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Namespace类的具体用法?PHP EasyRdf_Namespace怎么用?PHP EasyRdf_Namespace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EasyRdf_Namespace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:29,代码来源:Ocre.php

示例2: 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;
 }
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:11,代码来源:DbPediaRulerRdf.php

示例3: 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.");
     }
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:34,代码来源:JSONLDFormatter.php

示例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);
    }
}
开发者ID:aw3s0me,项目名称:RDF_Parser,代码行数:7,代码来源:convert.php

示例5: query

 /** Make a query to the SPARQL endpoint
  *
  * SELECT and ASK queries will return an object of type
  * EasyRdf_Sparql_Result.
  *
  * CONSTRUCT and DESCRIBE queries will return an object
  * of type EasyRdf_Graph.
  *
  * @param string $query The query string to be executed
  * @return object EasyRdf_Sparql_Result|EasyRdf_Graph Result of the query.
  */
 public function query($query)
 {
     # Add namespaces to the queryString
     $prefixes = '';
     foreach (EasyRdf_Namespace::namespaces() as $prefix => $uri) {
         if (strpos($query, "{$prefix}:") !== false and strpos($query, "PREFIX {$prefix}:") === false) {
             $prefixes .= "PREFIX {$prefix}: <{$uri}>\n";
         }
     }
     $client = EasyRdf_Http::getDefaultHttpClient();
     $client->resetParameters();
     $client->setUri($this->_uri);
     $client->setMethod('GET');
     $accept = EasyRdf_Format::getHttpAcceptHeader(array('application/sparql-results+json' => 1.0, 'application/sparql-results+xml' => 0.8));
     $client->setHeaders('Accept', $accept);
     $client->setParameterGet('query', $prefixes . $query);
     $response = $client->request();
     if ($response->isSuccessful()) {
         $type = $response->getHeader('Content-Type');
         if (strpos($type, 'application/sparql-results') === 0) {
             return new EasyRdf_Sparql_Result($response->getBody(), $type);
         } else {
             return new EasyRdf_Graph($this->_uri, $response->getBody(), $type);
         }
     } else {
         throw new EasyRdf_Exception("HTTP request for SPARQL query failed: " . $response->getBody());
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:39,代码来源:Client.php

示例6: 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;
 }
开发者ID:netsensei,项目名称:core,代码行数:37,代码来源:DcatController.php

示例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;
 }
开发者ID:emiberea,项目名称:wade-phos-server,代码行数:34,代码来源:DefaultController.php

示例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#');
 }
开发者ID:vanherba,项目名称:linda,代码行数:8,代码来源:ListsController.php

示例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");
}
开发者ID:symbolicdata,项目名称:web,代码行数:58,代码来源:People.php

示例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;
 }
开发者ID:adi69,项目名称:ONCLARITE,代码行数:10,代码来源:Onclarite_model.php

示例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()));
 }
开发者ID:nfouka,项目名称:tempate_sf2_crud,代码行数:12,代码来源:DefaultController.php

示例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'));
 }
开发者ID:takin,项目名称:workshop-semantic-web,代码行数:13,代码来源:JsonTest.php

示例13: 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;
}
开发者ID:symbolicdata,项目名称:web,代码行数:14,代码来源:Dissertations.php

示例14: 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;
}
开发者ID:symbolicdata,项目名称:web,代码行数:14,代码来源:Systems.php

示例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");
}
开发者ID:symbolicdata,项目名称:web,代码行数:49,代码来源:News.php


注:本文中的EasyRdf_Namespace类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。