Skip to content

Commit

Permalink
README.md update
Browse files Browse the repository at this point in the history
  • Loading branch information
zozlak committed May 17, 2022
1 parent dc6bf76 commit f11273d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
[![Coverage Status](https://coveralls.io/repos/github/sweetrdf/quickRdfIo/badge.svg?branch=master)](https://coveralls.io/github/sweetrdf/quickRdfIo?branch=master)
[![License](https://poser.pugx.org/sweetrdf/quick-rdf-io/license)](https://packagist.org/packages/sweetrdf/quick-rdf-io)

Collection of parsers and serializers implementing the https://github.com/sweetrdf/rdfInterface interface.
Collection of RDF parsers and serializers implementing the https://github.com/sweetrdf/rdfInterface interface.

Originally developed for the [quickRdf](https://github.com/sweetrdf/quickRdf) library.

Quite quick and dirty at the moment.
## Supported serializations

| serialization | read/write | class | implementation |
|---------------|------------|--------------------------------|----------------------|
| n-triples | rw | NQuadsParser, NQuadsSerializer | own |
| n-triples* | rw | NQuadsParser, NQuadsSerializer | own |
| n-quads | rw | NQuadsParser, NQuadsSerializer | own |
| n-quads* | rw | NQuadsParser, NQuadsSerializer | own |
| rdf-xml | rw | RdfXmlParser, RdfXmlSerializer | own |
| turtle | rw | TriGParser, TurtleSerializer | pietercolpaert\hardf |
| TriG | r | TriGParser | pietercolpaert\hardf |

## Installation

Expand All @@ -28,20 +38,20 @@ It's very incomplete but better than nothing.\
```php
include 'vendor/autoload.php';

// parse turle/ntriples/nquad/ntriples* file
$dataFactory = new DataFactory();
// parse turle/n-triples/n-quads/n-triples*/n-quads* file
$dataFactory = new quickRdf\DataFactory();
$parser = new quickRdfIo\TriGParser($dataFactory);
$stream = fopen('pathToTurtleFile', 'r');
foreach($parser->parseStream($stream) as $quad) {
echo "$quad\n";
}
fclose($stream);

// convert to nquads/ntriples/ntriples*
// convert to n-quads/n-triples/n-triples*/n-quads*
$instream = fopen('pathToTurtleFile', 'r');
$iterator = $parser->parseStream($instream);
$serializer = new quickRdfIo\NQuadsSerializer();
$outstream = fopen('pathToOutputTurtleFile', 'w');
$outstream = fopen('pathToOutputNQuadsFile', 'w');
$serializer->serializeStream($stream, $iterator);
fclose($outstream);
fclose($instream);
Expand Down

0 comments on commit f11273d

Please sign in to comment.