1

EasyRDFを使用して (Turtle シリアライゼーションで) RDF コンテンツを解析するにはどうすればよいですか? たとえば、次のようなものです。

$rdf  = '<subject>  <predicate>  "object0"@en .' ;
$rdf .= "\n" ;
$rdf .= '<subject>  <predicate>  "object1"@en .' ;
$array = turtle_decode(rdf) ;
if ($array["subject"]["predicate"][0]["value"]=="object0")
4

1 に答える 1

1

PHP と EasyRDF の使用:

<?php
require 'vendor/autoload.php';

$data  = '<http://rdf.freebase.com/ns/g.11vjz1ynm> <http://rdf.freebase.com/ns/measurement_unit.dated_percentage.date> "2001-02"^^<http://www.w3.org/2001/XMLSchema#gYearMonth>  .' .PHP_EOL;
$data .= '<http://rdf.freebase.com/ns/g.11vjz1ynm>  <http://rdf.freebase.com/ns/measurement_unit.dated_percentage.source> <http://rdf.freebase.com/ns/g.11x1gf2m6>  .' .PHP_EOL;
$data .= '<http://rdf.freebase.com/ns/g.11vjz1ynm>  <http://rdf.freebase.com/ns/type.object.type> <http://rdf.freebase.com/ns/measurement_unit.dated_percentage>  .' .PHP_EOL;
$data .= '<http://rdf.freebase.com/ns/g.11vjz1ynm>  <http://rdf.freebase.com/ns/measurement_unit.dated_percentage.rate> 4.5 .' .PHP_EOL;
$data .= '<http://rdf.freebase.com/ns/g.11vjz1ynm>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://rdf.freebase.com/ns/measurement_unit.dated_percentage>  .' .PHP_EOL;

$graph = new EasyRdf_Graph();
$graph->parse($data,'turtle');
$array = $graph->toRdfPhp();
unset($graph);

print_r($array);
于 2015-07-01T17:46:38.913 に答える