Skip to content

Commit

Permalink
Documentation and DOAP improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 25, 2011
1 parent 19e091b commit a8e1f3d
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 52 deletions.
22 changes: 1 addition & 21 deletions History
@@ -1,22 +1,2 @@
### 0.1.0
* Updates for RDF.rb 0.3.4.
* Format detection.

### 0.0.5
* Update turtle and writer specs to use latest version of Turtle specs.
* Use Spira Manifest w/list to order tests.
* Change debug to use blocks to reduce computation overhead when not doing debugging, results in a reasonable performance boost.

### 0.0.4
* Make an un-defined empty prefix an error, rather than treating it as <>.
* Replace remaining uses of SPARQL with RDF::Turtle or RDF::LL1

### 0.0.3
* Completed RDF 1.1 Turtle based on http://www.w3.org/TR/2011/WD-turtle-20110809/
* Reader
* Writer
* Issues:
* IRI lexical representations
* PNAMES not unescaped, should they be?
* Assume undefined empty prefix is synonym for base
* Can a list be used on it's own? Used in Turtle example.
* First release based on 02-Nov-2011 version of [TriG spec](http://dvcs.w3.org/hg/rdf/raw-file/default/trig/index.html)
37 changes: 6 additions & 31 deletions README.markdown
Expand Up @@ -2,7 +2,7 @@
[TriG][] reader/writer for [RDF.rb][RDF.rb] .

## Description
This is a [Ruby][] implementation of a [TriG][] parser for [RDF.rb][].
This is a [Ruby][] implementation of a [TriG][] reader and writer for [RDF.rb][].

## Features
RDF::TriG parses [TriG][Turtle] into statements or quads. It also serializes to TriG.
Expand All @@ -16,7 +16,7 @@ Install with `gem install rdf-trig`
## Usage
Instantiate a reader from a local file:

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

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

Expand All @@ -25,11 +25,11 @@ Canonicalize and validate using `:canonicalize` and `:validate` options.
Write a graph to a file:

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

## Documentation
Full documentation available on [Rubydoc.info][TriG doc]
Full documentation available on [Rubydoc.info][TriG doc].

### Principle Classes
* {RDF::TriG::Format}
Expand Down Expand Up @@ -58,38 +58,13 @@ In some cases, the specification is unclear on certain issues:
library suite is brought up to date.

## Implementation Notes
The reader uses a generic LL1 parser {RDF::LL1::Parser} and lexer {RDF::LL1::Lexer}. The parser takes branch and follow
tables generated from the original [TriG EBNF Grammar][TriG EBNF] described in the [specification][TriG]. Branch and Follow tables are specified in {RDF::TriG::Meta}, which is in turn
generated using etc/gramLL1.

The branch rules indicate productions to be taken based on a current production. Terminals are denoted
through a set of regular expressions used to match each type of terminal, described in {RDF::TriG::Terminals}.

etc/trig.bnf is used to to generate a Notation3 representation of the grammar, a transformed LL1 representation and ultimately {RDF::TriG::Meta}.

Using SWAP utilities, this is done as follows:

python http://www.w3.org/2000/10/swap/grammar/ebnf2turtle.py \
etc/trig.bnf \
trig language \
'http://www.w3.org/ns/formats/TriG#' > |
sed -e 's/^ ".*"$/ g:seq (&)/' > etc/trig.n3
python http://www.w3.org/2000/10/swap/cwm.py etc/trig.n3 \
http://www.w3.org/2000/10/swap/grammar/ebnf2bnf.n3 \
http://www.w3.org/2000/10/swap/grammar/first_follow.n3 \
--think --data > etc/trig-bnf.n3

script/gramLL1 \
--grammar etc/trig-ll1.n3 \
--lang 'http://www.w3.org/ns/formats/TriG#language' \
--output lib/rdf/trig/meta.rb

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

* [Ruby](http://ruby-lang.org/) (>= 1.8.7) or (>= 1.8.1 with [Backports][])
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.3.4)
* [rdf-turtle](http://rubygems.org/gems/rdf-turtle) (>= 0.1.1)

## Installation

Expand Down
52 changes: 52 additions & 0 deletions etc/doap.trig
@@ -0,0 +1,52 @@
@prefix dc: <http://purl.org/dc/terms/> .
@prefix doap: <http://usefulinc.com/ns/doap#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

{
<https://github.com/gkellogg/rdf-trig> a doap:GitRepository;
dc:title "rdf-trig";
doap:browse <https://github.com/gkellogg/rdf-trig> .

_:proj a doap:Project;
dc:created "2011-12-22T09:53:17-08:00"^^xsd:dateTime;
dc:creator <http://greggkellogg.net/foaf#me>;
doap:developer <http://greggkellogg.net/foaf#me>;
doap:documenter <http://greggkellogg.net/foaf#me>;
foaf:maker <http://greggkellogg.net/foaf#me> .
doap:maintainer <http://greggkellogg.net/foaf#me>;
doap:bug-database <https://github.com/gkellogg/rdf-trig/issues>;
doap:description "TriG reader/writer for RDF.rb";
doap:name "rdf-trig";
doap:shortdesc "TriG reader/writer for Ruby."@en;
doap:programming-language "Ruby";
doap:repository <https://github.com/gkellogg/rdf-trig>;
doap:mailing-list <http://lists.w3.org/Archives/Public/public-rdf-ruby/>;
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
<http://dbpedia.org/resource/Ruby_(programming_language)>;
doap:homepage <http://github.com/gkellogg/rdf-trig>;
doap:license <http://creativecommons.org/licenses/publicdomain/>;
doap:wiki <https://github.com/gkellogg/rdf-trig/wiki> .

<http://github.com/gkellogg> a foaf:OnlineAccount;
dc:created "2009-01-13T08:58:46-08:00"^^xsd:dateTime;
doap:homepage <http://github.com/gkellogg>;
foaf:accountName "gkellogg";
foaf:accountServiceHomepage <http://github.com/>;
foaf:name "GitHub";
foaf:page <http://github.com/gkellogg> .
}

<http://greggkellogg.net/foaf#me> {
<http://greggkellogg.net/foaf> a foaf:Person;
foaf:mbox <mailto:gregg@kellogg-assoc.com>;
foaf:mbox_sha1sum "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd";
foaf:name "Gregg Kellogg";
foaf:nick "gkellogg";
foaf:developer _:proj;
foaf:account <http://github.com/gkellogg>;
foaf:based_near "San Rafael, CA";
foaf:depiction <http://www.gravatar.com/avatar/42f948adff3afaa52249d963117af7c8>;
foaf:weblog <http://kellogg-assoc.com> .
}
26 changes: 26 additions & 0 deletions examples/example-1.trig
@@ -0,0 +1,26 @@
# This document encodes three graphs.

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix swp: <http://www.w3.org/2004/03/trix/swp-1/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ex: <http://www.example.org/vocabulary#> .
@prefix : <http://www.example.org/exampleDocument#> .

:G1 { :Monica ex:name "Monica Murphy" .
:Monica ex:homepage <http://www.monicamurphy.org> .
:Monica ex:email <mailto:monica@monicamurphy.org> .
:Monica ex:hasSkill ex:Management }

:G2 { :Monica rdf:type ex:Person .
:Monica ex:hasSkill ex:Programming }

:G3 { :G1 swp:assertedBy _:w1 .
_:w1 swp:authority :Chris .
_:w1 dc:date "2003-10-02"^^xsd:date .
:G2 swp:quotedBy _:w2 .
:G3 swp:assertedBy _:w2 .
_:w2 dc:date "2003-09-03"^^xsd:date .
_:w2 swp:authority :Chris .
:Chris rdf:type ex:Person .
:Chris ex:email <mailto:chris@bizer.de> }

0 comments on commit a8e1f3d

Please sign in to comment.