本文整理汇总了PHP中EasyRdf_Graph类的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Graph类的具体用法?PHP EasyRdf_Graph怎么用?PHP EasyRdf_Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EasyRdf_Graph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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 = '[email protected]';
$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
示例3: convert_to_rdf
function convert_to_rdf($path)
{
//get processed array
$uris = get_uris();
$result = process_spreadsheet($path);
init_vocabularies();
global $voc_keys;
$root = new EasyRdf_Graph();
$courses = $root->newBNode('rdf:Seq');
//create container
//iterate through array and create nodes
foreach ($result as $key => $value) {
$resource_uri = $uris[$key];
$temp_cours = new EasyRdf_Resource($resource_uri, $root);
$courses->append($temp_cours);
foreach ($value as $propName => $propValue) {
if ($propName == null || $propName == "" || $propName == "id") {
continue;
}
$predicate_url = $voc_keys[$propName];
//add to resource predicate with property. probably addLiteral method
$temp_cours->addLiteral($predicate_url, $propValue);
}
}
return $root->serialise("rdfxml");
}
开发者ID:aw3s0me,项目名称:RDF_Parser,代码行数:26,代码来源:convert.php
示例4: 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
示例5: getJSONVersionOfSchema
/**
* Retrieve the latest RDFA version of schema.org and converts it to JSON-LD.
*
* Note: caches the file in data and retrieves it from there as long as it exists.
*/
private function getJSONVersionOfSchema()
{
// Set cachefile
$cacheFile = dirname(dirname(__DIR__)) . '/data/schemaorg.cache';
if (!file_exists($cacheFile)) {
// Create dir
if (!file_exists(dirname($cacheFile))) {
mkdir(dirname($cacheFile), 0777, true);
}
// Load RDFA Schema
$graph = new \EasyRdf_Graph(self::RDFA_SCHEMA);
$graph->load(self::RDFA_SCHEMA, 'rdfa');
// Lookup the output format
$format = \EasyRdf_Format::getFormat('jsonld');
// Serialise to the new output format
$output = $graph->serialise($format);
if (!is_scalar($output)) {
$output = var_export($output, true);
}
$this->schema = \ML\JsonLD\JsonLD::compact($graph->serialise($format), 'http://schema.org/');
// Write cache file
file_put_contents($cacheFile, serialize($this->schema));
} else {
$this->schema = unserialize(file_get_contents($cacheFile));
}
}
开发者ID:lengthofrope,项目名称:create-jsonld,代码行数:31,代码来源:Build.php
示例6: getTriples
protected function getTriples($file)
{
if (!file_exists($file)) {
throw new Exception($file . ' not found');
}
// validate the file to import
$parser = new tao_models_classes_Parser($file, array('extension' => 'rdf'));
$parser->validate();
if (!$parser->isValid()) {
throw new common_Exception('Invalid RDF file ' . $file);
}
$modelDefinition = new EasyRdf_Graph();
$modelDefinition->parseFile($file);
/*
$graph = $modelDefinition->toRdfPhp();
$resources = $modelDefinition->resources();
*/
$format = EasyRdf_Format::getFormat('php');
$data = $modelDefinition->serialise($format);
$triples = array();
foreach ($data as $subjectUri => $propertiesValues) {
foreach ($propertiesValues as $prop => $values) {
foreach ($values as $k => $v) {
$triples[] = array('s' => $subjectUri, 'p' => $prop, 'o' => $v['value'], 'l' => isset($v['lang']) ? $v['lang'] : '');
}
}
}
return $triples;
}
开发者ID:oat-sa,项目名称:extension-tao-devtools,代码行数:29,代码来源:class.RdfDiff.php
示例7: actionEasyRDF
public function actionEasyRDF()
{
$this->layout = "test";
$foaf = new EasyRdf_Graph("http://njh.me/foaf.rdf");
$foaf->load();
$me = $foaf->primaryTopic();
echo "My name is: " . $me->get('foaf:name') . "\n";
}
开发者ID:acorbi,项目名称:pixelhumain,代码行数:8,代码来源:TestController.php
示例8: get
/** Fetch a named graph from the graph store
*
* The URI can either be a full absolute URI or
* a URI relative to the URI of the graph store.
*
* @param string $uriRef The URI of graph desired
* @return object EasyRdf_Graph The graph requested
*/
public function get($uriRef)
{
$graphUri = $this->_parsedUri->resolve($uriRef)->toString();
$dataUrl = $this->urlForGraph($graphUri);
$graph = new EasyRdf_Graph($graphUri);
$graph->load($dataUrl);
return $graph;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:16,代码来源:GraphStore.php
示例9: testParseQuery
public function testParseQuery()
{
$graph = new EasyRdf_Graph();
$graph->parse(readFixture('query/construct.ttl'), 'turtle');
$query = $graph->resource('test:construct');
$this->assertClass('EasySpinRdf_Query_Construct', $query);
$this->assertStringEquals("CONSTRUCT { ?this test:grandParent ?grandParent } WHERE { ?parent test:child ?this. ?grandParent test:child ?parent }", $query->getSparql());
}
开发者ID:conjecto,项目名称:easyspinrdf,代码行数:8,代码来源:ConstructTest.php
示例10: serialise
/**
* Method to serialise an EasyRdf_Graph to RDF/JSON
*
* http://n2.talis.com/wiki/RDF_JSON_Specification
* docs/appendix-a-rdf-formats-json.md
*
* @param EasyRdf_Graph $graph An EasyRdf_Graph object.
* @param string $format The name of the format to convert to.
* @param array $options
* @throws EasyRdf_Exception
* @return string The RDF in the new desired format.
*/
public function serialise($graph, $format, array $options = array())
{
$nodes = array();
// cache for id-to-node association
foreach ($graph->toRdfPhp() as $resource => $properties) {
echo $resource;
}
}
开发者ID:shawfactor,项目名称:lh-rdf,代码行数:20,代码来源:JsonLd.php
示例11: get
/** Fetch a named graph from the graph store
*
* The URI can either be a full absolute URI or
* a URI relative to the URI of the graph store.
*
* @param string $uriRef The URI of graph desired
* @return object EasyRdf_Graph The graph requested
*/
public function get($uriRef)
{
$graphUri = EasyRdf_Utils::resolveUriReference($this->_uri, $uriRef);
$dataUrl = $this->urlForGraph($graphUri);
$graph = new EasyRdf_Graph($graphUri);
$graph->load($dataUrl);
return $graph;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:16,代码来源:GraphStore.php
示例12: preRun
protected function preRun()
{
$data = parent::getData();
$resourceUri = JURI::base() . "index.php?com_content&view=article&id=" . $data["articleID"];
$annotation = new EasyRdf_Graph($resourceUri);
foreach ($data["entityIDs"] as $entityID) {
$annotation->addResource($resourceUri, "sioc:about", "http://www.mni.thm.de/user/" . $entityID);
}
parent::setData($annotation->serialise("rdfxml"));
}
开发者ID:sumutcan,项目名称:lib_sj_engines,代码行数:10,代码来源:Store.php
示例13: testParseWebId
public function testParseWebId()
{
$graph = new EasyRdf_Graph();
$graph->parseFile(fixturePath('webid.ttl'), 'turtle');
$me = $graph->resource('http://www.example.com/myfoaf#me');
$modulus = $me->get('cert:key')->get('cert:modulus');
$this->assertStringEquals('CB24ED85D64D794B69C701C186ACC059501E856000F661C93204D8380E07191C' . '5C8B368D2AC32A428ACB970398664368DC2A867320220F755E99CA2EECDAE62E' . '8D15FB58E1B76AE59CB7ACE8838394D59E7250B449176E51A494951A1C366C62' . '17D8768D682DDE78DD4D55E613F8839CF275D4C8403743E7862601F3C49A6366' . 'E12BB8F498262C3C77DE19BCE40B32F89AE62C3780F5B6275BE337E2B3153AE2' . 'BA72A9975AE71AB724649497066B660FCF774B7543D980952D2E8586200EDA41' . '58B014E75465D91ECF93EFC7AC170C11FC7246FC6DED79C37780000AC4E079F6' . '71FD4F207AD770809E0E2D7B0EF5493BEFE73544D8E1BE3DDDB52455C61391A1', $modulus);
$this->assertInternalType('string', $modulus->getValue());
$this->assertSame(NULL, $modulus->getLang());
$this->assertSame('xsd:hexBinary', $modulus->getDatatype());
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:11,代码来源:HexBinaryTest.php
示例14: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$relations = [];
$schemaOrg = new \EasyRdf_Graph();
$schemaOrg->load(TypesGeneratorConfiguration::SCHEMA_ORG_RDFA_URL, 'rdfa');
$relations[] = $schemaOrg;
$goodRelations = [new \SimpleXMLElement(TypesGeneratorConfiguration::GOOD_RELATIONS_OWL_URL, 0, true)];
$goodRelationsBridge = new GoodRelationsBridge($goodRelations);
$cardinalitiesExtractor = new CardinalitiesExtractor($relations, $goodRelationsBridge);
$result = $cardinalitiesExtractor->extract();
$output->writeln(json_encode($result, JSON_PRETTY_PRINT));
}
开发者ID:api-platform,项目名称:schema-generator,代码行数:15,代码来源:ExtractCardinalitiesCommand.php
示例15: 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
示例16: 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
示例17: statement2rdf
/**
* @ignore
*/
private static function statement2rdf(PDOStatement $statement)
{
$graph = new EasyRdf_Graph();
while ($r = $statement->fetch()) {
if (isset($r['l_language']) && !empty($r['l_language'])) {
$graph->addLiteral($r['subject'], $r['predicate'], $r['object'], $r['l_language']);
} elseif (common_Utils::isUri($r['object'])) {
$graph->add($r['subject'], $r['predicate'], $r['object']);
} else {
$graph->addLiteral($r['subject'], $r['predicate'], $r['object']);
}
}
$format = EasyRdf_Format::getFormat('rdfxml');
return $graph->serialise($format);
}
开发者ID:nagyist,项目名称:generis,代码行数:18,代码来源:class.ModelExporter.php
示例18: toFile
public static function toFile($filePath, $triples)
{
$graph = new \EasyRdf_Graph();
foreach ($triples as $triple) {
if (!empty($triple->lg)) {
$graph->addLiteral($triple->subject, $triple->predicate, $triple->object, $triple->lg);
} elseif (\common_Utils::isUri($triple->object)) {
$graph->add($triple->subject, $triple->predicate, $triple->object);
} else {
$graph->addLiteral($triple->subject, $triple->predicate, $triple->object);
}
}
$format = \EasyRdf_Format::getFormat('rdfxml');
return file_put_contents($filePath, $graph->serialise($format));
}
开发者ID:nagyist,项目名称:generis,代码行数:15,代码来源:FileModel.php
示例19: getData
/** Get data from the endpoint
* @access protected
* @return string
*/
protected function getData()
{
$key = md5($this->_uri);
if (!$this->_cache->test($key)) {
$graph = new EasyRdf_Graph(self::URI . $this->_uri . self::SUFFIX);
$graph->load();
$data = $graph->resource(self::URI . $this->_uri);
$this->_cache->save($data);
} else {
$data = $this->_cache->load($key);
}
EasyRdf_Namespace::set('dcterms', 'http://purl.org/dc/terms/');
EasyRdf_Namespace::set('pleiades', 'http://pleiades.stoa.org/places/vocab#');
return $data;
}
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:19,代码来源:PleiadesMintRdf.php
示例20: getData
/** Get the graph to parse
* @access protected
* @returns object
*/
protected function getData()
{
$key = md5($this->_uri);
if (!$this->_cache->test($key)) {
$graph = new EasyRdf_Graph($this->_uri);
$graph->load();
$data = $graph->resource($this->_uri);
$this->_cache->save($data);
} else {
$data = $this->_cache->load($key);
}
EasyRdf_Namespace::set('dbpediaowl', 'http://dbpedia.org/ontology/');
EasyRdf_Namespace::set('dbpprop', 'http://dbpedia.org/property/');
EasyRdf_Namespace::set('dbpedia', 'http://dbpedia.org/resource/');
return $data;
}
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:20,代码来源:DbPediaMintRdf.php
注:本文中的EasyRdf_Graph类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论