RDF::TriG reader/writer

TriG reader/writer for RDF.rb .

Description

This is a Ruby implementation of a TriG reader and writer for RDF.rb.

Features

RDF::TriG parses TriG into statements or quads. It also serializes to TriG.

Install with gem install rdf-trig

Usage

Instantiate a reader from a local file:

repo = RDF::Repository.load("etc/doap.trig", :format => :trig)

Define @base and @prefix definitions, and use for serialization using :base_uri an :prefixes options.

Canonicalize and validate using :canonicalize and :validate options.

Write a repository to a file:

RDF::TriG::Writer.open("etc/test.trig") do |writer|
   writer << repo
end

Note that reading and writing of graphs is also possible, but as graphs have only a single context, it is not particularly interesting for TriG.

Documentation

Full documentation available on Rubydoc.info.

Principle Classes

Interpretations of the spec

It is still not defined what the interpretation of multiple uses of the same graphIri mean. This implementation takes the use of multiple graphs having the same graphIri to be additive, meaning that the statements from each graph are combined together to create a single graph.

Graphs are written with context set to the associated graphIri.

Although RDF::Repository allows any RDF::Value, such as a BNode, literal or variable to be used as a context, TriG only allows the use of an IRI.

Implementation Notes

The reader uses the Turtle parser, which is based on the LL1::Parser with minor updates for the TriG grammar. The writer also is based on the Turtle writer.

Dependencies

Installation

The recommended installation method is via RubyGems. To install the latest official release of the RDF::TriG gem, do:

% [sudo] gem install rdf-trig

Mailing List

Author

Contributing

License

This is free and unencumbered public domain software. For more information, see http://unlicense.org/ or the accompanying UNLICENSE file.