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


PHP URI::toNTriples方法代码示例

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


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

示例1: getRDFTriples

 /**
  * sub,pred,obj, must be an array, either:
  * [action] = "fix"
  * [value]  = "http://dbpedia.org/resource/subject"
  * or a sparql variable ?o like:
  * [action] = "variable"
  * [value]  = "o"
  * * or use $this->subject:
  * [action] = "classattribute"
  * [value]  = null
  * */
 public function getRDFTriples($query, $subject, $predicate, $object, $filterlanguage = true)
 {
     if ($subject['action'] == 'fix') {
         $s = new URI($subject['value'], false);
     } else {
         if ($subject['action'] == 'classattribute') {
             $s = $this->subject;
         }
     }
     if ($predicate['action'] == 'fix') {
         $p = new URI($predicate['value'], false);
     }
     if ($object['action'] == 'fix') {
         try {
             $o = new URI($object['value'], false);
         } catch (Exception $e) {
             $this->log(WARN, 'object = fix only for uris currently');
             return array();
         }
     }
     $result = array();
     $pass = false;
     if ($this->use == 'odbc') {
         Timer::start(get_class($this) . ':odbc_request');
         $jarr = $this->odbc->execAsJson($query, 'SPARQLToRDFTriple');
         Timer::stop(get_class($this) . ':odbc_request');
     } else {
         Timer::start(get_class($this) . ':http_request');
         $json = $this->sparqlEndpoint->executeQuery($query, 'SPARQLToRDFTriple');
         $jarr = json_decode($json, true);
         if (isset($jarr['results'])) {
             $jarr = $jarr['results'];
         }
         Timer::stop(get_class($this) . ':http_request');
     }
     //print_r($result);
     if (isset($jarr['bindings'])) {
         $bindings = $jarr['bindings'];
         foreach ($bindings as $one) {
             try {
                 switch ($subject['action']) {
                     case 'fix':
                         //$s is already set
                         break;
                     case 'variable':
                         $s = new URI($one[$subject['value']]['value']);
                         break;
                     case 'classattribute':
                         //$s is already set
                         break;
                 }
                 switch ($predicate['action']) {
                     case 'fix':
                         //$p is already set
                         break;
                     case 'variable':
                         $p = new URI($one[$predicate['value']]['value']);
                         break;
                 }
                 switch ($object['action']) {
                     case 'fix':
                         //$o is already set
                         break;
                     case 'variable':
                         $unknown = $one[$object['value']];
                         $o = $this->toObject($unknown, $filterlanguage);
                         if ($o === false) {
                             continue;
                         }
                         break;
                 }
                 $this->log(DEBUG, "*******************");
                 $this->log(DEBUG, $s->toNTriples());
                 $this->log(DEBUG, $p->toNTriples());
                 $this->log(DEBUG, $o->toNTriples());
                 $result[] = new RDFtriple($s, $p, $o);
                 //$this->log(DEBUG, $t->getObject()->toNTriples());
             } catch (Exception $ex) {
                 $this->log(WARN, 'found invalid URI: ' . $ex->getMessage());
             }
         }
     } else {
         $this->log(WARN, $json);
     }
     return $result;
 }
开发者ID:nsystem1,项目名称:ZeeJong,代码行数:97,代码来源:SPARQLToRDFTriple.php


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