tdt / streamingrdfmapper
一个流式映射器。接受数据块和映射文件,返回RDF三元组。
v1.0.1
2014-04-24 14:08 UTC
Requires
- easyrdf/easyrdf: *
- guzzle/guzzle: ~3.7
- semsol/arc2: >=2.2.3
This package is auto-updated.
Last update: 2024-08-29 03:35:37 UTC
README
此库使用不同的映射语言将PHP数组映射到RDF。
Vertere
Vertere映射语言是这个存储库的起点。代码从 mmmmmrob 中复用。
您可以在 VERTERE.md 文件中找到更多关于Vertere的文档。目前它是唯一支持的语言。
RML
将成为此存储库的将来语言。参见Anastasia Dimou、Miel Vander Sande、Pieter Colpaert在ISWC 2013上发表的关于RML的论文。
您可以在 RML.md 文件中找到更多关于RML的文档。
用法
安装
此存储库符合PSR-0规范,可以使用composer安装
composer install tdt/streamingrdfmapper
不熟悉composer?请在这里了解它 这里
在代码中
$mapping = file_get_contents("http://foo.bar/mapping/file.ttl"); $typeofmapping = "Vertere"; $mapper = new StreamingRDFMapper($mapping, $typeofmapping); $data = foo\bar\getNextDataChunk(); //get data from somewhere: can be a csv file you've extracted, some data you've scraped or XML or JSON file you've flattened and put into an array $getEasyRDFGraph = true; $triplesEasyRDFGraph = $mapper->map($data, $getEasyRDFGraph); $triplesArray = $mapper->map($data, !$getEasyRDFGraph); //print ntriples through easy graph (some overhead, but really good library*) print $triplesEasyRDFGraph->serialize("ntriples"); //print ntriples through array (faster) foreach($triplesArray as $triple){ print implode(" ", $triple); print " . \n"; }
您还可以通过在创建实例后执行此操作来为映射器设置标准的基础URI
$mapper->setBaseUri("http://data.iRail.be/");
- The EasyRDF库