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


PHP ARC2::getRDFParser方法代码示例

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


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

示例1: __construct

 public function __construct($a = '')
 {
     parent::__construct();
     $this->a = $a;
     /* parse the before and after graphs if necessary*/
     foreach (array('before', 'after', 'before_rdfxml', 'after_rdfxml') as $rdf) {
         if (!empty($a[$rdf])) {
             if (is_string($a[$rdf])) {
                 /** @var \ARC2_RDFParser $parser */
                 $parser = \ARC2::getRDFParser();
                 $parser->parse(false, $a[$rdf]);
                 $a[$rdf] = $parser->getSimpleIndex(0);
             } else {
                 if (is_array($a[$rdf]) and isset($a[$rdf][0]) and isset($a[$rdf][0]['s'])) {
                     //triples array
                     /** @var \ARC2_RDFSerializer $ser */
                     $ser = \ARC2::getTurtleSerializer();
                     /** @var string $turtle */
                     $turtle = $ser->getSerializedTriples($a[$rdf]);
                     /** @var \ARC2_RDFParser $parser */
                     $parser = \ARC2::getTurtleParser();
                     $parser->parse(false, $turtle);
                     $a[$rdf] = $parser->getSimpleIndex(0);
                 }
             }
             $nrdf = str_replace('_rdfxml', '', $rdf);
             $this->{$nrdf} = $a[$rdf];
         }
     }
     $this->__init();
 }
开发者ID:talis,项目名称:tripod-php,代码行数:31,代码来源:ChangeSet.class.php

示例2: get_openlink_acct

function get_openlink_acct($acct)
{
    $parser = ARC2::getRDFParser();
    $parser->parse($acct);
    $triples = $parser->getTriples();
    foreach ($triples as $row) {
        if (strcmp($row[p], "http://xmlns.com/foaf/0.1/accountServiceHomepage") == 0) {
            return convert_to_rss($row[o]);
        }
    }
}
开发者ID:akbarhossain,项目名称:openid4me,代码行数:11,代码来源:libActivity.php

示例3: __construct

 function __construct($a = array())
 {
     $this->a = $a;
     /* parse the before and after graphs if necessary*/
     foreach (array('before', 'after') as $rdf) {
         if (!is_array($a[$rdf]) and !empty($a[$rdf])) {
             $parser = ARC2::getRDFParser();
             $parser->parse(false, $a[$rdf]);
             $a[$rdf] = $parser->getSimpleIndex(0);
         }
         $this->{$rdf} = $a[$rdf] ? $a[$rdf] : array();
     }
 }
开发者ID:jhigman,项目名称:TalisRdfEditor,代码行数:13,代码来源:changesetbatch.class.php

示例4: _run_query

 function _run_query($query)
 {
     $response = $this->sparqlservice->graph($query);
     if ($response->is_success()) {
         require_once MORIARTY_ARC_DIR . '/ARC2.php';
         $parser = ARC2::getRDFParser();
         $parser->parse(false, $response->body);
         $changeset = $this->revert_changes($parser->getSimpleIndex(0));
         $ser = ARC2::getRDFXMLSerializer();
         $response->body = $ser->getSerializedIndex($changeset);
     }
     return $response;
 }
开发者ID:risis-eu,项目名称:RISIS_LinkedDataAPI,代码行数:13,代码来源:rollback.class.php

示例5: arc_ntriples2php

function arc_ntriples2php($datafile)
{
    ini_set("include_path", S3DB_SERVER_ROOT . '/pearlib/arc' . PATH_SEPARATOR . ini_get("include_path"));
    if (in_array("ARC2.php", get_included_files())) {
    }
    include_once "ARC2.php";
    $parser = ARC2::getRDFParser();
    $parser->parse($datafile);
    $triples = $parser->getTriples();
    if (!$triples) {
        $parser->parse('file://' . $datafile);
        $triples = $parser->getTriples();
    }
    return $triples;
}
开发者ID:helenadeus,项目名称:s3db.map,代码行数:15,代码来源:rdfheader.inc.php

示例6: retrieveLabel

function retrieveLabel($url)
{
    $parser = ARC2::getRDFParser();
    $parser->parse($url);
    $index = $parser->getSimpleIndex(0);
    if (is_array($index[$url]["http://www.w3.org/2000/01/rdf-schema#label"])) {
        foreach ($index[$url]["http://www.w3.org/2000/01/rdf-schema#label"] as $sl) {
            if ($sl['lang'] == "en" || $sl['lang'] == "") {
                $label = $sl['value'];
            }
        }
    }
    if (trim($label) != "") {
        return $label;
    }
    if (strrpos($url, "#") !== false) {
        return substr($url, strrpos($url, "#") + 1);
    }
    if (strrpos($url, "/") !== false) {
        return substr($url, strrpos($url, "/") + 1);
    }
    return $url;
}
开发者ID:hannesmuehleisen,项目名称:CCC2011_LOD_workshop,代码行数:23,代码来源:index.php

示例7: handleUpdateRequest

 function handleUpdateRequest($webid, $uri)
 {
     $this->result = '';
     $this->setHeader('http', 'HTTP/1.1 403 Forbidden');
     if ($q = @file_get_contents('php://input')) {
         //	$this->sparulLog($uri, $webid, $q);
         $triples = array();
         $parser = ARC2::getRDFParser($this->a);
         $parser->parse($uri);
         $triples = $parser->getTriples();
         $index = ARC2::getSimpleIndex($triples, 0);
         /* split combined INSERT/DELETE query */
         if (preg_match('/^\\s*(DELETE.*)\\s*(INSERT.*)$/is', $q, $m)) {
             $qs = array($m[1], $m[2]);
         } else {
             $qs = array($q);
         }
         $tmpfname = tempnam("/home/foaf/www/datawiki/rdf", "rdf_");
         foreach ($qs as $q) {
             $index = $this->getUpdatedIndex($index, $q, $uri);
             if (!$this->getErrors()) {
                 $this->setHeader('http', 'HTTP/1.1 200 OK');
                 if ($index) {
                     /* todo: create dirs, if necessary */
                     $fp = fopen($tmpfname, 'w');
                     $doc = $parser->toRDFXML($index);
                     fwrite($fp, $doc);
                     fclose($fp);
                 } else {
                     unlink($tmpfname);
                 }
             }
         }
         return $tmpfname;
     }
 }
开发者ID:harbulot,项目名称:foafme,代码行数:36,代码来源:ARC2_DataWikiPlugin.php

示例8: main

function main($uri)
{
    global $config;
    // Triple store
    global $store_config;
    global $store;
    $uri = urldecode($uri);
    $ntriples = get_canonical_uri($uri);
    //echo $ntriples; exit();
    if ($ntriples == 0) {
        // Fetch URI
        echo '<html>';
        echo '<body>';
        echo 'Sorry, don\'t have this URI <b>' . $uri . '</b>, trying to fetch it...';
        $uri_to_fetch = $uri;
        if (preg_match('/^urn:lsid:/', $uri_to_fetch)) {
            $uri_to_fetch = 'http://bioguid.info/' . $uri_to_fetch;
        }
        echo $uri_to_fetch;
        // can we get it, if so redirect...
        $query = "LOAD <" . $uri_to_fetch . ">";
        $r = $store->query($query);
        /*echo $query;
        		
        		echo '<pre>';
        		print_r($r);
        		echo '</pre>';
        		exit(); */
        if ($r['result']['t_count'] > 0) {
            // Got it, redirect to web page for this URI
            echo '<script type="text/javascript">';
            echo 'document.location="' . $config['web_root'] . 'uri/' . $uri . '";';
            echo '</script>';
        } else {
            // Bugger...
            echo "Badness happened";
        }
        echo '</body>';
        echo '</html>';
    } else {
        // Display info about this object (having issues with CONSTRUCT not returning language codes!?)
        $sparql = "\nCONSTRUCT\n{\n\t<{$uri}> ?o ?p\n}\n\nWHERE \n{ \n\t<{$uri}> ?o ?p\n}\n";
        $sparql = "DESCRIBE <{$uri}>";
        //echo $sparql . "\n";
        // get object
        $r = $store->query($sparql);
        $index = $r['result'];
        $parser = ARC2::getRDFParser();
        $rdfxml_doc = $parser->toRDFXML($index);
        //echo $rdfxml_doc;
        // What type if this?
        $dom = new DOMDocument();
        $dom->loadXML($rdfxml_doc);
        $xpath = new DOMXPath($dom);
        $xpath->registerNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
        $xpath->registerNamespace("dcterms", "http://purl.org/dc/terms/");
        $type = array();
        $xsl_filename = '';
        $html = '';
        $topic_title = '';
        //------------------------------------------------------------------------------------------
        // Get type(s) of objects
        $name = '';
        $nodeCollection = $xpath->query('//rdf:type/@rdf:resource');
        foreach ($nodeCollection as $node) {
            $type[] = $node->firstChild->nodeValue;
        }
        //------------------------------------------------------------------------------------------
        // Post process objects...
        // Publication add sequences...
        // possibe relations are isReferencedBy (stated in GenBank record) and references
        // which is stated in publication if we have links via PubMed.
        if (in_array('http://purl.org/ontology/bibo/Article', $type)) {
            $topic_title = get_title($uri);
            // Sequences
            $xml = query_sequences_from_publication($uri);
            append_xml($dom, $xml);
            // Taxa
            // Geography
            $xml = query_localities_from_publication($uri);
            append_xml($dom, $xml);
        }
        // Journal
        if (in_array('http://purl.org/ontology/bibo/Journal', $type)) {
            $topic_title = get_title($uri);
            $xml = query_articles_from_journal($uri);
            append_xml($dom, $xml);
        }
        // Collection
        if (in_array('http://rs.tdwg.org/ontology/voc/Collection#Collection', $type)) {
            $topic_title = get_title($uri);
            $xml = query_specimens_from_collection($uri);
            append_xml($dom, $xml);
        }
        // GenBank: Add specimen if we have it...
        if (in_array('http://purl.uniprot.org/core/Molecule', $type)) {
            $topic_title = get_title($uri);
            $specimen_uri = '';
            $nodeCollection = $xpath->query('//dcterms:relation/@rdf:resource');
            foreach ($nodeCollection as $node) {
//.........这里部分代码省略.........
开发者ID:rdmpage,项目名称:bioguid,代码行数:101,代码来源:get.php

示例9: to_rdf

 function to_rdf($url, $document, $output, $store = '')
 {
     $parser = ARC2::getRDFParser($this->a);
     $parser->parse($url, $document);
     $triples = $parser->getTriples();
     if ($this->use_store == 1 && $store == '') {
         $this->store_rdf($url, $parser->toTurtle($triples));
     }
     switch ($output) {
         case 'ntriples':
             $file = $this->rand_filename('nt');
             header("Content-type: text/plain");
             header("Content-Disposition: inline; filename=" . $file);
             $result = $parser->toNTriples($triples);
             break;
         case 'turtle':
             $file = $this->rand_filename('ttl');
             header("Content-type: text/turtle");
             header("Content-Disposition: inline; filename=" . $file);
             $result = $parser->toTurtle($triples);
             break;
         case 'rdfjson':
             $file = $this->rand_filename('json');
             header("Content-type: application/json");
             header("Content-Disposition: inline; filename=" . $file);
             $result = $parser->toRDFJSON($triples);
             break;
         case 'rdf':
             $file = $this->rand_filename('rdf');
             header("Content-type: application/rdf+xml");
             header("Content-Disposition: inline; filename=" . $file);
             $result = $parser->toRDFXML($triples);
             break;
         case 'html':
             $file = $this->rand_filename('html');
             header("Content-type: text/html");
             header("Content-Disposition: inline; filename=" . $file);
             $result = $parser->toHTML($triples);
             break;
         case 'rdfa':
             $file = $this->rand_filename('html');
             header("Content-type: text/html");
             header("Content-Disposition: inline; filename=" . $file);
             $result = $this->toRDFa($triples);
             break;
     }
     return $result;
 }
开发者ID:WebOrganics,项目名称:TransFormr,代码行数:48,代码来源:ARC2_RDFTranformrPlugin.php

示例10: getRDFParser

 /**
  * Get an RDF parser.
  * @return ARC2_RDFParser The RDF parser.
  */
 public function getRDFParser()
 {
     /** @var ARC2_RDFParser $parser */
     $parser = ARC2::getRDFParser();
     return $parser;
 }
开发者ID:gitter-badger,项目名称:wordlift-plugin,代码行数:10,代码来源:TripleStoreService.php

示例11: serialize

 /**
  * Serialize an index into either RDF-XML or RDF-JSON
  */
 public function serialize($index, $prefix = '', $format = 'xml')
 {
     if (!empty($prefix)) {
         $this->ns['scalar'] = $prefix;
     }
     switch (strtolower($format)) {
         case 'json':
             $parser = @ARC2::getRDFParser();
             $doc = @$parser->toRDFJSON($index);
             break;
         case 'turtle':
             $parser = @ARC2::getRDFParser();
             $doc = @$parser->toTurtle($index, $this->ns);
             break;
         default:
             // xml
             $conf = array('ns' => $this->ns, 'serializer_prettyprint_container' => true);
             // , 'serializer_type_nodes' => true
             $ser = @ARC2::getRDFXMLSerializer($conf);
             $doc = @$ser->getSerializedIndex($index);
     }
     return $doc;
 }
开发者ID:paulshannon,项目名称:scalar,代码行数:26,代码来源:RDF_Store.php

示例12: toTriples

 function toTriples($v)
 {
     if (is_array($v)) {
         if (isset($v[0]) && isset($v[0]['s'])) {
             return $v;
         }
         return ARC2::getTriplesFromIndex($v);
     }
     $parser = ARC2::getRDFParser($this->a);
     if ($v && !preg_match('/\\s/', $v)) {
         /* assume graph URI */
         $parser->parse($v);
     } else {
         $parser->parse('', $v);
     }
     return $parser->getTriples();
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:17,代码来源:ARC2_Class.php

示例13: listActivity

 /**
  * listActivity
  *
  * tries to get feeds by checking various ways to relate feeds with foaf
  * profiles.
  *
  * @see http://wiki.foaf-project.org/w/PersonWeblogRssDocumentationIssue
  *
  * @since 0.1
  *
  * @param array $check array with strings of predicates which should be checked
  * @param int $items number of returned activity items
  *
  * @return array with activity items
  */
 public function listActivity(array $check = array(), $numberItems = null)
 {
     // $ARC2TO = $this;
     if (!isset($cacheTimeActivity)) {
         $cacheTimeActivity = $this->cacheTimeActivity;
     }
     if (!is_array($check) || count($check) == 0) {
         $check = array('seeAlso', 'made', 'weblog', 'account', 'homepage');
     }
     if ($numberItems == null) {
         $numberItems = 50;
     }
     $numberItems = intval($numberItems);
     // get all rdfs:seeAlso
     $rdfs_seeAlso = array();
     if (array_search('seeAlso', $check) !== false) {
         $rdfs_seeAlso = $this->_nld_rdfs_seeAlso;
     }
     // get all foaf:made
     $foaf_made = array();
     if (array_search('made', $check) !== false) {
         $foaf_made = $this->_nld_foaf_made;
     }
     // get all foaf:weblog in foaf:Document
     $weblog_seeAlso = array();
     if (array_search('weblog', $check) !== false) {
         $foaf_weblog = $this->_nld_foaf_weblog;
         foreach ($foaf_weblog as $weblog) {
             if (is_object($weblog) && $weblog->_nld_rdfs_seeAlso) {
                 $weblog_seeAlso = array_merge($weblog_seeAlso, $weblog->_nld_rdfs_seeAlso);
             }
             unset($weblog);
         }
         unset($foaf_weblog);
     }
     // get all foaf:homepage in foaf:Document
     $homepage_seeAlso = array();
     if (array_search('homepage', $check) !== false) {
         $foaf_homepage = $this->_nld_foaf_homepage;
         foreach ($foaf_homepage as $homepage) {
             if (is_object($homepage) && $homepage->_nld_rdfs_seeAlso) {
                 $homepage_seeAlso = array_merge($homepage_seeAlso, $homepage->_nld_rdfs_seeAlso);
             }
             unset($homepage);
         }
         unset($foaf_homepage);
     }
     // get all foaf:holdsAccount in foaf:OnlineAccount
     $account_seeAlso = array();
     if (array_search('account', $check) !== false) {
         $foaf_holdsAccount = $this->_nld_foaf_holdsAccount;
         foreach ($foaf_holdsAccount as $holdsAccount) {
             if (is_object($holdsAccount) && $holdsAccount->_nld_rdfs_seeAlso) {
                 $account_seeAlso = array_merge($account_seeAlso, $holdsAccount->_nld_rdfs_seeAlso);
             }
             unset($holdsAccount);
         }
         unset($foaf_holdsAccount);
     }
     // check for type, must be rss:channel
     $possibleFeeds = array_unique(array_merge($rdfs_seeAlso, $foaf_made, $weblog_seeAlso, $account_seeAlso, $homepage_seeAlso));
     unset($rdfs_seeAlso, $foaf_made, $weblog_seeAlso, $account_seeAlso, $homepage_seeAlso);
     $confirmedFeeds = array();
     foreach ($possibleFeeds as $feed) {
         if (is_object($feed) && is_array($feed->_nld_rdf_type) && isset($feed->_nld_rdf_type[0]) && $feed->_nld_rdf_type[0] == 'http://purl.org/rss/1.0/channel') {
             $confirmedFeeds[$feed->uri] = $feed->getLiteral(array('rdfs_label', 'dc_title'));
         }
     }
     unset($possibleFeeds);
     $activity = array('feeds' => $confirmedFeeds, 'stream' => array());
     // load feeds and read items
     $i = 0;
     $sortByDate = array();
     $uniqueUris = array();
     foreach ($confirmedFeeds as $feed => $feedTitle) {
         $feedIndex = null;
         if (false === ($feedIndex = $this->getCache(array('name' => $feed, 'space' => $this->cache_space_prefix . 'Activity', 'time' => $cacheTimeActivity)))) {
             // parse feed
             $feedParser = ARC2::getRDFParser(array('reader_timeout' => $this->requestsTimeout, 'http_user_agent_header' => $this->user_agent_string, 'keep_time_limit' => true));
             $feedParser->parse($feed, null, 0, $this->requestsTimeout);
             if (is_object($feedParser)) {
                 $feedIndex = $feedParser->getSimpleIndex(0);
                 // save cache
                 $this->saveCache(array('data' => $feedIndex, 'name' => $feed, 'space' => $this->cache_space_prefix . 'Activity', 'time' => true));
             }
//.........这里部分代码省略.........
开发者ID:haschek,项目名称:RDF-Template-Object,代码行数:101,代码来源:rdfto.arc2.php

示例14: loadData

 function loadData($data)
 {
     require_once 'arc/ARC2.php';
     $parser = \ARC2::getRDFParser();
     $parser->parse('', $data);
     return $this->load($parser->getSimpleIndex(0));
 }
开发者ID:kwijibo,项目名称:raffles,代码行数:7,代码来源:rafflesstore.php

示例15: serializeRdf

 public static function serializeRdf($data, $extension = 'rdf')
 {
     global $conf;
     global $lodspk;
     $ser;
     $dPointer;
     $docs = Utils::travelTree($data);
     require_once $conf['home'] . 'lib/arc2/ARC2.php';
     $parser = ARC2::getRDFParser();
     $triples = array();
     foreach ($docs as $d) {
         $parser->parse($conf['basedir'], $d);
         $t = $parser->getTriples();
         $triples = array_merge($triples, $t);
     }
     if ($lodspk['mirror_external_uris']) {
         global $uri;
         global $localUri;
         $t = array();
         $t['s'] = $localUri;
         $t['s_type'] = 'uri';
         $t['p'] = "http://www.w3.org/2002/07/owl#sameAs";
         $t['o'] = $uri;
         $t['o_type'] = 'uri';
         array_push($triples, $t);
         $t['p'] = "http://www.w3.org/2000/10/swap/pim/contact#preferredURI";
         array_push($triples, $t);
     }
     switch ($extension) {
         case 'ttl':
             $ser = ARC2::getTurtleSerializer();
             break;
         case 'nt':
             $ser = ARC2::getNTriplesSerializer();
             break;
         case 'json':
             $ser = ARC2::getRDFJSONSerializer();
             break;
         case 'rdf':
             $ser = ARC2::getRDFXMLSerializer();
             break;
         case 'html':
             return array("content" => $triples, "serialized" => false);
             break;
         default:
             $ser = null;
     }
     if ($ser != null) {
         $doc = $ser->getSerializedTriples($triples);
     } else {
         $doc = var_export($data, true);
     }
     return array("content" => $doc, "serialized" => true);
 }
开发者ID:OpenDataServices,项目名称:lodspeakr,代码行数:54,代码来源:Utils.php


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