承接 sweetrdf/quick-rdf 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sweetrdf/quick-rdf

最新稳定版本:2.0.6

Composer 安装命令:

composer require sweetrdf/quick-rdf

包简介

Yet another RDF library

README 文档

README

Latest Stable Version Build status Coverage Status License

An RDF library for PHP providing implementation of https://github.com/sweetrdf/rdfInterface terms and dataset.

Implemented to be fast and memory efficient.

This is achieved by using a global terms hash table with only a single copy of equal rdfInterface terms being stored in memory at a given time. It allows to save quite some memory in dense graphs and provides a lightning fast terms comparison (equal if and only if it's the same object). It also provides a very efficient implementation of Dataset set operations using PHP's SplObjectStorage.

The Dataset implementation maintains indexes allowing quick quads search (indexing can be turned off if needed as it significantly slows down a dataset creation).

Installation

  • Obtain the Composer
  • Run composer require sweetrdf/quick-rdf
  • Run composer require sweetrdf/quick-rdf-io to install parsers and serializers.

Automatically generated documentation

https://sweetrdf.github.io/quickRdf/namespaces/quickrdf.html

It's very incomplete but better than nothing.
RdfInterface documentation is included which explains the most important design decisions.

Usage

(you can also take a look at generic rdfInterface examples)

include 'vendor/autoload.php';

use quickRdf\DataFactory as DF;

$graph = new quickRdf\Dataset();
$parser = new quickRdfIo\TriGParser();
$stream = fopen('pathToTurtleFile', 'r');
$graph->add($parser->parseStream($stream));
fclose($stream);

// count edges in the graph
echo count($graph);

// go trough all edges in the graph
foreach ($graph as $i) {
  echo "$i\n";
}

// find all graph edges with a given subject
echo $graph->copy(DF::quadTemplate(DF::namedNode('http://mySubject')));

// find all graph edges with a given predicate
echo $graph->copy(DF::quadTemplate(null, DF::namedNode('http://myPredicate')));

// find all graph edges with a given object
echo $graph->copy(DF::quadTemplate(null, null, DF::literal('value', 'en')));

// replace an edge in the graph
$edge = DF::quad(DF::namedNode('http://edgeSubject'), DF::namedNode('http://edgePredicate'), DF::namedNode('http://edgeObject'));
$graph[$edge] = $edge->withObject(DF::namedNode('http://anotherObject'));

// find intersection with other graph
$graph->copy($otherGraph); // immutable
$graph->delete($otherGraph); // in-place

// compute union with other graph
$graph->union($otherGraph); // immutable
$graph->add($otherGraph); // in-place

// compute set difference with other graph
$graph->copyExcept($otherGraph); // immutable
$graph->delete($otherGraph); // in-place

$serializer = new quickRdfIo\TurtleSerializer();
$stream = fopen('pathToOutputTurtleFile', 'w');
$serializer->serializeStream($stream, $graph);
fclose($stream);

统计信息

  • 总下载量: 10.94k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 7
  • 推荐数: 4

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-16