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


PHP ARC2类代码示例

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


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

示例1: extractLinkedData

function extractLinkedData($link, $origin)
{
    global $ep;
    // Wenn es die URL im Graph schon gibt, nichts machen, TODO besser updaten?
    if (graphContainsUrl($link)) {
        $res = new Response(null, "URL {$link} already visited, skip indexing");
        return res;
    } else {
        $parser = ARC2::getTurtleParser();
        //$data = $_POST['turtle'];
        $parser->parse($link);
        $triples = $parser->getTriples();
        // print_r($triples);
        // Wenn keine Tripel gefunden wurden
        if (count($triples) < 1) {
            $res = new Response(null, "URL {$link} contains no triples");
        } else {
            // in Datenbank einfügen
            $ep->insert($triples, $origin);
            //echo "<pre>";
            //print_r($triples);
            //echo "</pre>";
            $res = new Response(null, "URL {$link}: added " . count($triples) . " triples");
        }
        return $res;
    }
}
开发者ID:neumann89,项目名称:FUB-xml-project6-2013,代码行数:27,代码来源:linkeddataendpoint.php

示例2: parse

 function parse($q, $src = '', $iso_fallback = 'ignore')
 {
     $this->setDefaultPrefixes();
     $this->base = $src ? $this->calcBase($src) : ARC2::getRequestURI();
     $this->r = array('base' => '', 'vars' => array(), 'prefixes' => array());
     $this->unparsed_code = $q;
     list($r, $v) = $this->xQuery($q);
     if ($r) {
         $this->r['query'] = $r;
         $this->unparsed_code = trim($v);
     } elseif (!$this->getErrors() && !$this->unparsed_code) {
         $this->addError('Query not properly closed');
     }
     $this->r['prefixes'] = $this->prefixes;
     $this->r['base'] = $this->base;
     /* remove trailing comments */
     while (preg_match('/^\\s*(\\#[^\\xd\\xa]*)(.*)$/si', $this->unparsed_code, $m)) {
         $this->unparsed_code = $m[2];
     }
     if ($this->unparsed_code && !$this->getErrors()) {
         $rest = preg_replace('/[\\x0a|\\x0d]/i', ' ', substr($this->unparsed_code, 0, 30));
         $msg = trim($rest) ? 'Could not properly handle "' . $rest . '"' : 'Syntax error, probably an incomplete pattern';
         $this->addError($msg);
     }
 }
开发者ID:paskalkris,项目名称:rdfrep-php,代码行数:25,代码来源:ARC2_SPARQLParser.php

示例3: execute

 /**
  * Perform the load.
  *
  * @param EasyRdf_Graph $chunk
  * @return void
  */
 public function execute(&$chunk)
 {
     if (!$chunk->isEmpty()) {
         // Don't use EasyRdf's ntriple serializer, as something might be wrong with its unicode byte characters
         // After serializing with semsol/arc and easyrdf, the output looks the same (with unicode characters), but after a
         // binary utf-8 conversion (see $this->serialize()) the outcome is very different, leaving easyrdf's encoding completely different
         // from the original utf-8 characters, and the semsol/arc encoding correct as the original.
         $ttl = $chunk->serialise('turtle');
         $arc_parser = \ARC2::getTurtleParser();
         $ser = \ARC2::getNTriplesSerializer();
         $arc_parser->parse('', $ttl);
         $triples = $ser->getSerializedTriples($arc_parser->getTriples());
         preg_match_all("/(<.*\\.)/", $triples, $matches);
         if ($matches[0]) {
             $this->buffer = array_merge($this->buffer, $matches[0]);
         }
         $triple_count = count($matches[0]);
         $this->log("Added {$triple_count} triples to the load buffer.");
         while (count($this->buffer) >= $this->loader->buffer_size) {
             // Log the time it takes to load the triples into the store
             $start = microtime(true);
             $buffer_size = $this->loader->buffer_size;
             $triples_to_send = array_slice($this->buffer, 0, $buffer_size);
             $this->addTriples($triples_to_send);
             $this->buffer = array_slice($this->buffer, $buffer_size);
             $duration = round((microtime(true) - $start) * 1000, 2);
             $this->log("Took {$buffer_size} triples from the load buffer, loading them took {$duration} ms.");
         }
     }
 }
开发者ID:Tjoosten,项目名称:input,代码行数:36,代码来源:Sparql.php

示例4: connect

 /**
  * Connexion au store
  * @return bool
  */
 private function connect()
 {
     $this->store = ARC2::getStore($this->config);
     if (!@$this->store->getDBCon()) {
         //On regarde si l'on peut se connecter avec les informations fournies
         $this->errors[] = "Error connexion";
         return false;
     } else {
         if (!$this->store->isSetUp()) {
             //Si les tables du store n'existent pas
             $this->store->setUp();
             //On crée les tables
             if ($erreurs = $this->store->getErrors()) {
                 //Si la création à échouée
                 foreach ($erreurs as $value) {
                     $this->errors[] = $value;
                 }
                 return false;
                 $this->store->closeDBCon();
             } else {
                 //Si on vient de faire la création pour pouvoir faire autre chose on doit se déconnecter et se reconnecter
                 $this->store->closeDBCon();
                 $this->store = ARC2::getStore($this->config);
             }
         }
     }
     return true;
 }
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:32,代码来源:rdf.class.php

示例5: parse

 function parse($path, $data = '')
 {
     $this->state = 0;
     /* reader */
     if (!$this->v('reader')) {
         ARC2::inc('Reader');
         $this->reader =& new ARC2_Reader($this->a, $this);
     }
     $this->reader->setAcceptHeader('Accept: sparql-results+xml; q=0.9, */*; q=0.1');
     $this->reader->activate($path, $data);
     $this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base;
     /* xml parser */
     $this->initXMLParser();
     /* parse */
     $first = true;
     while ($d = $this->reader->readStream()) {
         if (!xml_parse($this->xml_parser, $d, false)) {
             $error_str = xml_error_string(xml_get_error_code($this->xml_parser));
             $line = xml_get_current_line_number($this->xml_parser);
             $this->tmp_error = 'XML error: "' . $error_str . '" at line ' . $line . ' (parsing as ' . $this->getEncoding() . ')';
             return $this->addError($this->tmp_error);
         }
     }
     $this->target_encoding = xml_parser_get_option($this->xml_parser, XML_OPTION_TARGET_ENCODING);
     xml_parser_free($this->xml_parser);
     $this->reader->closeStream();
     return $this->done();
 }
开发者ID:rdmpage,项目名称:bioguid,代码行数:28,代码来源:ARC2_SPOGParser.php

示例6: extractRDF

 function extractRDF()
 {
     $tc = 0;
     $t = '';
     $t_vals = array();
     foreach ($this->nodes as $n) {
         if ($n['tag'] != 'a') {
             continue;
         }
         if (!($href = $this->v('href uri', '', $n['a']))) {
             continue;
         }
         if (!($rels = $this->v('rel m', array(), $n['a']))) {
             continue;
         }
         if (!($vals = array_intersect($this->terms, $rels))) {
             continue;
         }
         $parts = preg_match('/^(.*\\/)([^\\/]+)\\/?$/', $href, $m) ? array('space' => $m[1], 'tag' => rawurldecode($m[2])) : array('space' => '', 'tag' => '');
         if ($tag = $parts['tag']) {
             $t_vals['s_' . $tc] = $this->getContainerResIDByClass($n, $this->containers);
             $t_vals['concept_' . $tc] = $this->createBnodeID() . '_concept';
             $t_vals['tag_' . $tc] = $tag;
             $t_vals['space_' . $tc] = $parts['space'];
             $t .= '?s_' . $tc . ' skos:subject [skos:prefLabel ?tag_' . $tc . ' ; skos:inScheme ?space_' . $tc . '] . ';
             $tc++;
         }
     }
     $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']);
     $this->addTs(ARC2::getTriplesFromIndex($doc));
 }
开发者ID:helenadeus,项目名称:s3db.map,代码行数:31,代码来源:ARC2_RelTagSkosExtractor.php

示例7: __construct

    public function __construct() {
        parent::__construct();
        global $wgDBserver, $wgDBname, $wgDBuser, $wgDBpassword, $smwgARC2StoreConfig;

        /* instantiation */
        $this->arc2store = ARC2::getStore( $smwgARC2StoreConfig );
    }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:7,代码来源:SMW_ARC2Store.php

示例8: extractRDF

 function extractRDF()
 {
     foreach ($this->nodes as $n) {
         if (!($vals = $this->v('class m', array(), $n['a']))) {
             continue;
         }
         if (!in_array('adr', $vals)) {
             continue;
         }
         /* node  */
         $t_vals = array('s' => $this->getResID($n, 'adr'));
         $t = '';
         /* context */
         list($t_vals, $t) = $this->extractContext($n, $t_vals, $t);
         /* properties */
         foreach ($this->terms as $term) {
             $m = 'extract' . $this->camelCase($term);
             if (method_exists($this, $m)) {
                 list($t_vals, $t) = $this->{$m}($n, $t_vals, $t);
             }
         }
         /* result */
         $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']);
         $this->addTs(ARC2::getTriplesFromIndex($doc));
     }
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:26,代码来源:ARC2_AdrFoafExtractor.php

示例9: test_set_comment_add_rdfs_comment_triple

 function test_set_comment_add_rdfs_comment_triple()
 {
     $fpmap = new QueryProfile("http://example.org/store/queryprofiles/1");
     $fpmap->set_comment('my qp is kewl');
     $index = ARC2::getSimpleIndex($fpmap->get_triples(), true);
     $this->assertEquals("my qp is kewl", $index[$fpmap->uri]['http://www.w3.org/2000/01/rdf-schema#comment'][0]);
 }
开发者ID:risis-eu,项目名称:RISIS_LinkedDataAPI,代码行数:7,代码来源:networkresource.test.php

示例10: testSelectSerializeAndDelete

 public function testSelectSerializeAndDelete()
 {
     global $EndPoint4store, $modeDebug, $prefixSparql, $prefixTurtle, $graph1, $graph2;
     $s = new Endpoint($EndPoint4store, false, $modeDebug);
     $this->checkIfInitialState($s);
     $r = $s->set($graph1, $prefixTurtle . "\n@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\t\t\t\t\ta:A b:Name \"Test2\"@en.\n\t\t\t\t\ta:A b:Name \"Test3\"@fr.\n\t\t\t\t\ta:A b:Name \"Test4\".\n\t\t\t\t\ta:A b:date \"2010-03-09T22:30:00Z\"^^xsd:dateTime .\n\t\t\t\t\t");
     $q = $prefixSparql . "\n select * where {GRAPH <" . $graph1 . "> {a:A ?p ?o.}} ";
     $triples = $s->query($q, 'rows');
     $err = $s->getErrors();
     if ($err) {
         print_r($err);
         $this->assertTrue(false);
     }
     for ($i = 0, $i_max = count($triples); $i < $i_max; $i++) {
         $triples[$i]['s'] = "http://example.com/test/a/A";
         $triples[$i]['s type'] = "uri";
     }
     //print_r($triples);
     /* Serializer instantiation */
     $ser = ARC2::getNTriplesSerializer();
     /* Serialize a triples array */
     $docd = $ser->getSerializedTriples($triples, 1);
     $q = "DELETE DATA {  \n\t\t\t\tGRAPH <" . $graph1 . "> {    \n\t\t\t\t{$docd} \n    \t\t}}";
     //print_r($q);
     $res = $s->query($q, 'raw');
     $err = $s->getErrors();
     if ($err) {
         print_r($err);
         $this->assertTrue(false);
     }
     $this->assertTrue($res);
     $this->checkIfInitialState($s);
 }
开发者ID:BorderCloud,项目名称:4store-php,代码行数:33,代码来源:FourStoreFormatTest.php

示例11: testBlockUpdateWithoutGraph

 public function testBlockUpdateWithoutGraph()
 {
     global $prefixSparql, $graph1;
     $q = $prefixSparql . " \n\t\t\tINSERT DATA { \n\t\t\t\ta:A b:Name \"Test2\" . \n    \t\t}";
     $p = ARC2::getSPARQLPlusParser();
     $p->parse($q);
     $infos = $p->getQueryInfos();
     $t1 = ARC2::mtime();
     $err = $p->getErrors();
     if ($err) {
         print_r($err);
         $this->assertTrue(true);
     } else {
         $this->assertTrue(false);
     }
     $q = $prefixSparql . " \n\t\t\tDELETE DATA { \n\t\t\t\ta:A b:Name \"Test2\" . \n    \t\t}";
     $p = ARC2::getSPARQLPlusParser();
     $p->parse($q);
     $infos = $p->getQueryInfos();
     $t1 = ARC2::mtime();
     $err = $p->getErrors();
     if ($err) {
         print_r($err);
         $this->assertTrue(true);
     } else {
         $this->assertTrue(false);
     }
 }
开发者ID:BorderCloud,项目名称:arc2,代码行数:28,代码来源:ARC2_SPARQLParserTest.php

示例12: __construct

 public function __construct($contextURI)
 {
     global $config;
     $this->store = ARC2::getStore($config);
     $this->contextURI = $contextURI;
     $this->query = "\n\nSELECT DISTINCT ?rName ?pURL ?pTitle  ?lvDesc  ?lvScore \nWHERE  {\n\t<{$this->contextURI}> r:hasRubric ?rubric ; \nr:hasRubric ?rubric ; \n\t    r:hasRecording ?rec .\n        ?rubric sioc:name ?rName . \n\t?rec r:hasLineValue ?lv ;\n\t\tr:hasPage ?pURL ; \n\t\t sioc:has_creator ?recCreator . \n\t?lv r:score ?lvScore ;\n\t\tr:description ?lvDesc . \nOPTIONAL {\n\t?pURL dc:title ?pTitle . \n}\t\n}\n\n\t";
 }
开发者ID:patrickmj,项目名称:Rubrick,代码行数:7,代码来源:ContextReporter.php

示例13: testAddGraphToStore

 public function testAddGraphToStore()
 {
     $storeConf = array('db_host' => 'localhost', 'db_name' => 'negtest', 'db_user' => 'negtest', 'db_pwd' => 'negtest');
     $store = ARC2::getStore($storeConf);
     $store->reset();
     if (!$store->isSetUp()) {
         $store->setUp();
     }
     $docNeg = $this->getDOMDocNeg();
     $docNeg->setStore($store);
     $docNeg->process();
     $docNeg->gatherSubnegotiatorGraphs(false);
     $docNeg->addGraphToStore();
     $q = 'SELECT DISTINCT ?s ?p ?o WHERE { ?s ?p ?o }';
     $rs = $store->query($q);
     if (!$store->getErrors()) {
         $rows = $rs['result']['rows'];
         $this->assertEquals('http://example.org/domDoc', $rows[0]['s']);
     }
     $q = 'SELECT DISTINCT ?s ?p ?o WHERE { GRAPH <http://example.org/graphURI> { ?s ?p ?o } }';
     $rs = $store->query($q);
     if (!$store->getErrors()) {
         $rows = $rs['result']['rows'];
         $this->assertEquals('http://example.org/domDoc', $rows[0]['s']);
         $this->assertEquals(2, count($rows));
     }
     $q = 'SELECT DISTINCT ?s ?p ?o WHERE { GRAPH <http://example.org/graphURIX> { ?s ?p ?o } }';
     $rs = $store->query($q);
     if (!$store->getErrors()) {
         $rows = $rs['result']['rows'];
         $this->assertEquals(0, count($rows));
     }
 }
开发者ID:patrickmj,项目名称:Rubrick,代码行数:33,代码来源:DOMDocTest.php

示例14: extractRDF

 function extractRDF()
 {
     $tc = 0;
     $t = '';
     $t_vals = array();
     foreach ($this->nodes as $n) {
         if ($n['tag'] != 'a') {
             continue;
         }
         if (!($href = $this->v('href uri', '', $n['a']))) {
             continue;
         }
         if (!($rels = $this->v('rel m', array(), $n['a']))) {
             continue;
         }
         if (!($vals = array_intersect($this->terms, $rels))) {
             continue;
         }
         if (in_array('category', $this->v('class m', array(), $n['a']))) {
             continue;
         }
         /* hcard/hcalendar categories */
         $parts = preg_match('/^(.*\\/)([^\\/]+)\\/?$/', $href, $m) ? array('space' => $m[1], 'tag' => rawurldecode($m[2])) : array('space' => '', 'tag' => '');
         if ($tag = $parts['tag']) {
             $t_vals['s_' . $tc] = $this->getContainerResIDByClass($n, $this->containers);
             $t_vals['tag_' . $tc] = $tag;
             $t .= '?s_' . $tc . ' dc:subject ?tag_' . $tc . ' . ';
             $tc++;
         }
     }
     $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']);
     $this->addTs(ARC2::getTriplesFromIndex($doc));
 }
开发者ID:helenadeus,项目名称:s3db.map,代码行数:33,代码来源:ARC2_RelTagDcExtractor.php

示例15: testGetFormatWithNTriples

 public function testGetFormatWithNTriples()
 {
     $data = file_get_contents('../data/nt/test.nt');
     $actual = ARC2::getFormat($data);
     $this->assertEquals('ntriples', $actual);
     $actual = ARC2::getFormat($data, '', 'nt');
     $this->assertEquals('ntriples', $actual);
 }
开发者ID:mk-smart,项目名称:datahub-rdf-catalogue,代码行数:8,代码来源:ARC2_getFormatTest.php


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