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


PHP ARC2::getSimpleIndex方法代码示例

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


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

示例1: 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

示例2: sparql


//.........这里部分代码省略.........
        $s3qlN['from'] = 'namespaces';
        $s3qlN['format'] = 'php';
        $ns = query_user_dictionaries($s3qlN, $db, $user_id);
        $ns = unserialize($ns);
        if ($timer) {
            $timer->setMarker('Dictionary links retrieved');
        }
    }
    ##Convert the result into an RDF file
    $data_triples = array();
    if (is_array($rdf_results)) {
        foreach ($rdf_results as $letter => $results2rdfize) {
            $dont_skip_core_name = false;
            $dont_skip_serialized = true;
            if (ereg('S', $letter)) {
                $dont_skip_serialized = false;
            }
            if (ereg('C|R|P', $letter)) {
                $dont_skip_core_name = true;
            }
            foreach ($results2rdfize as $k => $data) {
                $tmp_triples = rdf_encode($data, $letter, 'array', $s3ql['db'], $ns, $collected_data, $dont_skip_serialized, $dont_skip_core_name);
                if (is_array($tmp_triples)) {
                    $data_triples = array_merge($data_triples, $tmp_triples);
                }
            }
        }
    }
    if (!empty($data_triples)) {
        $tmp['ns'] = $prefixes;
        /*
        #this one for turtle
        $parser = ARC2::getComponent('TurtleParser', $a);
        $index = ARC2::getSimpleIndex($triples, false) ; # false -> non-flat version 
        $rdf_doc = $parser->toTurtle($index,$prefixes);
        */
        $parser = ARC2::getComponent('RDFXMLParser', $tmp);
        $index = ARC2::getSimpleIndex($data_triples, false);
        /* false -> non-flat version */
        $rdf_doc = $parser->toRDFXML($index, $prefixes);
        $filename = S3DB_SERVER_ROOT . '/tmp/' . random_string(15) . '.rdf';
        $rr = fopen($filename, 'a+');
        fwrite($rr, $rdf_doc);
        fclose($rr);
        if ($timer) {
            $timer->setMarker(count($data_triples) . ' triples written to file ' . $filename);
        }
        ##The better strategy would be to let the client cpu resolve the query; return the graphs with the rdf so that a sparql on the client can handle it
        if ($return_file_name) {
            if (filesize($filename) > 0) {
                return array(true, $filename);
            } else {
                return array(false);
            }
            exit;
        }
        if ($redirect) {
            ##And now use an external service ( I gave up with ARC) to parse the query
            $url2search = str_replace(S3DB_SERVER_ROOT, S3DB_URI_BASE, $filename);
            ##Giving up on ARC, surrender to sparql.com
            $remote_endpoint = "http://sparql.org/sparql?query=";
            $bq = ereg_replace("FROM <.*>", "FROM <" . $url2search . ">", $bq);
            $bq = urlencode($bq);
            $remote_endpoint .= $bq . '&default-graph-uri=&stylesheet=/xml-to-html.xsl';
            return array(true, $remote_endpoint);
        }
开发者ID:helenadeus,项目名称:s3db.map,代码行数:67,代码来源:sparql_read.php

示例3: getSimpleIndex

 function getSimpleIndex($flatten_objects = 1, $vals = '')
 {
     return ARC2::getSimpleIndex($this->getTriples(), $flatten_objects, $vals);
 }
开发者ID:harbulot,项目名称:foafme,代码行数:4,代码来源:ARC2_RDFParser.php

示例4: toIndex

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

示例5: getUpdatedIndex

 function getUpdatedIndex($old_index, $q)
 {
     if (!preg_match('/^\\s*(INSERT|DELETE)\\s*(INTO|FROM)?\\s*(.*)$/is', $q, $m)) {
         return 0;
     }
     $qt = strtolower($m[1]);
     $g = $this->getTargetGraph();
     /* inject a target graph, if necessary */
     if (!$m[2]) {
         $q = strtoupper($qt) . ($qt == 'insert' ? ' INTO ' : ' FROM') . ' <' . $g . '> ' . $m[3];
     }
     /* parse the query */
     $this->writeLog($q);
     ARC2::inc('SPARQLPlusParser');
     $p =& new ARC2_SPARQLPlusParser($this->a, $this);
     $p->parse($q);
     $infos = $p->getQueryInfos();
     /* errors? */
     if ($errors = $this->getErrors()) {
         $this->setHeader('http', 'HTTP/1.1 400 Bad Request');
         $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8');
         $this->result = join("\n", $errors);
         return 0;
     }
     $q_index = ARC2::getSimpleIndex($infos['query']['construct_triples'], 0);
     if ($qt == 'insert') {
         return ARC2::getMergedIndex($old_index, $q_index);
     } elseif ($qt == 'delete') {
         return ARC2::getCleanedIndex($old_index, $q_index);
     }
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:31,代码来源:ARC2_DataWikiPlugin.php

示例6: extractTripleIndex

 /**
  * Get generated triple index from the ARC2 parser and store in object variable
  */
 private function extractTripleIndex() {
     $this->m_tripleindex = ARC2::getSimpleIndex( $this->m_triples, false );
     $this->m_tripleindexflat = ARC2::getSimpleIndex( $this->m_triples, true );
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:7,代码来源:SMWBatchWriter.php

示例7: make_rdf_model

function make_rdf_model($triples)
{
    $parser = ARC2::getComponent('RDFXMLParser');
    $index = ARC2::getSimpleIndex($triples, false);
    /* false -> non-flat version */
    $rdf_doc = $parser->toRDFXML($index);
    $filename = S3DB_SERVER_ROOT . '/tmp/' . md5(rand(10000, 200000));
    $rr = fopen($filename, 'a+');
    fwrite($rr, $rdf_doc);
    fclose($rr);
    return $filename;
}
开发者ID:helenadeus,项目名称:s3db.map,代码行数:12,代码来源:sparql_read6.php

示例8: elseif

    /* false -> non-flat version */
    $rdf_doc = $parser->toTurtle($index, $ns);
} elseif ($format == 'json' || $format == 'rdf-json') {
    ini_set("include_path", S3DB_SERVER_ROOT . "/pearlib/arc" . PATH_SEPARATOR . ini_get("include_path"));
    include_once "ARC2.php";
    $a['ns'] = $ns;
    $parser = ARC2::getComponent('RDFJSONSerializer', $a);
    $index = ARC2::getSimpleIndex($triples, false);
    $rdf_doc = $parser->toRDFJSON($index, $ns);
} else {
    $format = 'n3';
    ini_set("include_path", S3DB_SERVER_ROOT . "/pearlib/arc" . PATH_SEPARATOR . ini_get("include_path"));
    include_once "ARC2.php";
    $a['ns'] = $ns;
    $parser = ARC2::getComponent('NTriplesSerializer', $a);
    $index = ARC2::getSimpleIndex($triples, false);
    /* false -> non-flat version */
    $rdf_doc = $parser->toNTriples($index, $ns);
}
fwrite($fid, $rdf_doc);
fclose($fid);
chmod($FinalFfilename, 0777);
##Prepare to output
$linkname = random_string('10') . '.' . $format;
$filelink = $GLOBALS['URI'] . '/extras/' . $linkname;
if (!copy($FinalFfilename, S3DB_SERVER_ROOT . '/extras/' . $linkname)) {
    echo "Could not copy the file. This could be because Apache does not have 'write' permission on the s3db folder or the /extras/.";
    exit;
}
if (in_array('link', array_keys($inputs))) {
    echo $filelink;
开发者ID:helenadeus,项目名称:s3db.map,代码行数:31,代码来源:rdfexport.php

示例9: parse_results_xml

 /**
  * Parse the results of a search on the contentbox.
  * @param string uri the URI used to obtain the search
  * @param string xml the xml returned from a search request
  * @return ResourceList
  */
 function parse_results_xml($uri, $xml)
 {
     // fix up unprefixed rdf:resource in rss 1.0 otherwise ARC gets confused
     $xml = preg_replace("~rdf:li resource=~", "rdf:li rdf:resource=", $xml);
     $parser_args = array("bnode_prefix" => "genid", "base" => $this->uri);
     $resources = new ResourceList();
     $resources->items = array();
     $parser = ARC2::getRDFXMLParser($parser_args);
     $parser->parse($this->uri, $xml);
     $triples = $parser->getTriples();
     $index = ARC2::getSimpleIndex($triples, true);
     $resources->title = $index[$uri][RSS_TITLE][0];
     $resources->description = $index[$uri][RSS_DESCRIPTION][0];
     $resources->start_index = $index[$uri][OS_STARTINDEX][0];
     $resources->items_per_page = $index[$uri][OS_ITEMSPERPAGE][0];
     $resources->total_results = $index[$uri][OS_TOTALRESULTS][0];
     $items_resource = $index[$uri][RSS_ITEMS][0];
     foreach ($index[$items_resource] as $items_property => $items_property_value) {
         if (strpos($items_property, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#_') === 0) {
             $resources->items[] = $index[$items_property_value[0]];
         }
     }
     return $resources;
 }
开发者ID:risis-eu,项目名称:RISIS_LinkedDataAPI,代码行数:30,代码来源:contentbox.class.php

示例10: getIndexFromData

 public function getIndexFromData($data)
 {
     $parser = ARC2::getRDFParser();
     $parser->parseData($data);
     return ARC2::getSimpleIndex($parser->getTriples(), false);
 }
开发者ID:gitter-badger,项目名称:wordlift-plugin,代码行数:6,代码来源:TriplesUtils.php

示例11: rdf_encode_old


//.........这里部分代码省略.........
                $nsV = "";
                $termV = "";
                $nsP = "";
                $termP = "";
                list($nsP, $termP) = explode(":", $property);
                list($nsV, $termV) = explode(":", $value);
                if (!empty($value)) {
                    if (@in_array($property, @array_keys($GLOBALS['propertyURI'][$letter]))) {
                        $p = $GLOBALS['propertyURI'][$letter][$property];
                        if (in_array($property, array_keys($GLOBALS['pointer']))) {
                            $o = $D . '/' . letter($GLOBALS['pointer'][$property]) . $value;
                            $otype = 'uri';
                        } elseif (in_array($property, $GLOBALS['COREids'])) {
                            $o = $D . '/' . letter($property) . $value;
                            $otype = 'uri';
                        } elseif ($property == 'value' && RuleHasObjectId($ID, $db)) {
                            $o = $D . '/I' . $value;
                            $otype = 'uri';
                        } else {
                            $o = $value;
                            $otype = 'literal';
                        }
                        $triple['s'] = $s;
                        $triple['p'] = $p;
                        $triple['o'] = $o;
                        $triple['s_type'] = 'uri';
                        $triple['o_type'] = $otype;
                        $triples[] = $triple;
                    } elseif ($nsP && $termP) {
                        #replace nsP by the corresponding namespace and build a triple
                        if ($usedNS[$nsP] != "") {
                            $triple['s'] = $s;
                            $triple['s_type'] = 'uri';
                            $triple['p'] = str_replace($nsP . ":", eregi("#\$", $usedNS[$nsP]) ? $usedNS[$nsP] : $usedNS[$nsP] . "#", $property);
                        }
                        if ($nsV && $termV) {
                            if ($usedNS[$nsV] != "") {
                                $triple['o'] = str_replace($nsV . ':', eregi("#\$", $usedNS[$nsV]) ? $usedNS[$nsV] : $usedNS[$nsV] . "#", $value);
                                $triple['o_type'] = 'uri';
                            }
                        } else {
                            $triple['o'] = $value;
                            if (ereg('^http', $value)) {
                                $triple['o_type'] = 'uri';
                            } else {
                                $triple['o_type'] = 'literal';
                            }
                        }
                        if ($triple) {
                            $triples[] = $triple;
                        }
                    }
                }
            }
            if ($letter == 'S') {
                ##Outputalso a statment for the unserialized statement where subject is item_id, pred is rule, object is value
                if (RuleHasObjectId($ID, $db)) {
                    $obj = $D . '/I' . $data[$ind]['value'];
                    $objType = 'uri';
                } else {
                    $obj = $data[$ind]['value'];
                    $objType = 'literal';
                }
                $triple['s'] = $D . '/I' . $data[$ind]['item_id'];
                $triple['p'] = $D . '/R' . $data[$ind]['rule_id'];
                $triple['o'] = $obj;
                $triple['s_type'] = 'uri';
                $triple['o_type'] = $objType;
                $triples[] = $triple;
            }
            #And for every element that is part of the core, output a statement that mentions where in the ontology they belong
            $triple['s'] = $D . '/' . $letter . $ID;
            $triple['p'] = $usedNS['rdf'] . "type";
            $triple['o'] = $usedNS['s3db'] . $GLOBALS['N3Names'][$GLOBALS['s3codes'][$letter]];
            $triple['s_type'] = 'uri';
            $triple['o_type'] = 'uri';
            $triples[] = $triple;
        }
    }
    if ($format == 'rdf') {
        $a['ns'] = $usedNS;
        $parser = ARC2::getComponent('RDFXMLParser', $a);
        $index = ARC2::getSimpleIndex($triples, false);
        /* false -> non-flat version */
        $rdf_doc = $parser->toRDFXML($index, $usedNS);
    } elseif ($format == 'turtle') {
        $a['ns'] = $usedNS;
        $parser = ARC2::getComponent('TurtleParser', $a);
        $index = ARC2::getSimpleIndex($triples, false);
        /* false -> non-flat version */
        $rdf_doc = $parser->toTurtle($index, $usedNS);
    } elseif ($format == 'n3') {
        $a['ns'] = $usedNS;
        $parser = ARC2::getComponent('NTriplesSerializer', $a);
        $index = ARC2::getSimpleIndex($triples, false);
        /* false -> non-flat version */
        $rdf_doc = $parser->toNTriples($index, $usedNS);
    }
    return $rdf_doc;
}
开发者ID:helenadeus,项目名称:s3db.map,代码行数:101,代码来源:callback.php


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