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

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

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

sweetrdf/simple-rdf

Composer 安装命令:

composer require sweetrdf/simple-rdf

包简介

As simple as possible rdfInterface implementation

README 文档

README

Latest Stable Version Build status Coverage Status License

An RDF library for PHP implementing the https://github.com/sweetrdf/rdfInterface interface.

The aim was to provide as simple, short and clear implementation as possible. Performance wasn't really important (see the Performance chapter below).

It can be used as a baseline for testing performance of other libraries as well for testing interoperability of the rdfInterface implementations (e.g. making sure they work correctly with rdfInterface\Term objects created by other library).

Installation

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

Automatically generated documentation

https://sweetrdf.github.io/simpleRdf/namespaces/simplerdf.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 simpleRdf\DataFactory as DF;

$graph = new simpleRdf\Dataset();
$parser = new quickRdfIo\TriGParser(new simpleRdf\DataFactory());
$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);

Performance

The simpleRdf\Dataset class shouldn't be used to deal with larger amounts of quads.

Adding a quad has computational complexity of O(N) where N is the number of quads in the dataset. It means adding n quads has computational complexity of O(n!) (read - it quickly gets out of hand with larger n).

Just a sample results:

quads count execution time [s] relative quads count relative execution time
125 0.018090 1 1.0
250 0.059559 2 3.3
500 0.210958 4 11.7
1000 0.849956 8 47.0
2000 2.941319 16 162.6
4000 10.697164 32 591.3
8000 45.792556 64 2531.4

You get the idea, don't you?

Other operations are also not performant, e.g. all searches and in-place deletions have complexity of O(N) and all methods returning a new copy of the dataset have complexity of O(N) + O(n!) (where N is number of quads in the dataset and n the number of quads in the returned dataset).

If you are looking for a performant implementation, please take a look at the quickRdf.

sweetrdf/simple-rdf 适用场景与选型建议

sweetrdf/simple-rdf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.46k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 sweetrdf/simple-rdf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sweetrdf/simple-rdf 我们能提供哪些服务?
定制开发 / 二次开发

基于 sweetrdf/simple-rdf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-14