Skip to content

Commit

Permalink
Finish 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Apr 19, 2019
2 parents 07e5c73 + ba77d8f commit 548b4c6
Show file tree
Hide file tree
Showing 168 changed files with 5,653 additions and 1,013 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
@@ -1,15 +1,17 @@
language: ruby
bundler_args: --without debug
script: "bundle exec rspec spec"
before_install: "gem update --system"

before_install:
- 'gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems)'
- 'gem update bundler --conservative'
env:
- CI=true
rvm:
- 2.2
- 2.2.2
- 2.3
- 2.4
- 2.5
- 2.6
- jruby-9
- rbx-3
cache: bundler
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Expand Up @@ -6,7 +6,7 @@ Community contributions are essential for keeping Ruby RDF great. We want to kee

This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.

* create or respond to an issue on the [Github Repository](http://github.com/ruby-rdf/rdf-n3/issues)
* create or respond to an issue on the [Github Repository](https://github.com/ruby-rdf/rdf-n3/issues)
* Fork and clone the repo:
`git clone git@github.com:your-username/rdf-n3.git`
* Install bundle:
Expand All @@ -30,7 +30,7 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage devel
of thumb, additions larger than about 15 lines of code), we need an
explicit [public domain dedication][PDD] on record from you.

[YARD]: http://yardoc.org/
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[YARD]: https://yardoc.org/
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[pr]: https://github.com/ruby-rdf/rdf-n3/compare/
14 changes: 9 additions & 5 deletions Gemfile
Expand Up @@ -2,13 +2,17 @@ source "https://rubygems.org"

gemspec

gem "rdf", github: "ruby-rdf/rdf", branch: "develop"
gem "rdf", git: "https://github.com/ruby-rdf/rdf", branch: "develop"

group :development do
gem "rdf-spec", github: "ruby-rdf/rdf-spec", branch: "develop"
gem "rdf-isomorphic", github: "ruby-rdf/rdf-isomorphic", branch: "develop"
gem "rdf-xsd", github: "ruby-rdf/rdf-xsd", branch: "develop"
gem "json-ld", github: "ruby-rdf/json-ld", branch: "develop"
gem "rdf-spec", git: "https://github.com/ruby-rdf/rdf-spec", branch: "develop"
gem "rdf-isomorphic", git: "https://github.com/ruby-rdf/rdf-isomorphic", branch: "develop"
gem "rdf-trig", git: "https://github.com/ruby-rdf/rdf-trig", branch: "develop"
gem 'rdf-vocab', git: "https://github.com/ruby-rdf/rdf-vocab", branch: "develop"
gem "rdf-xsd", git: "https://github.com/ruby-rdf/rdf-xsd", branch: "develop"
gem "json-ld", git: "https://github.com/ruby-rdf/json-ld", branch: "develop"
gem 'sparql', git: "https://github.com/ruby-rdf/sparql", branch: "develop"
gem 'sxp', git: "https://github.com/dryruby/sxp.rb", branch: "develop"
end

group :debug do
Expand Down
146 changes: 95 additions & 51 deletions README.md
@@ -1,11 +1,11 @@
# RDF::N3 reader/writer
# RDF::N3 reader/writer and reasoner
Notation-3 reader/writer for [RDF.rb][RDF.rb] .

[![Gem Version](https://badge.fury.io/rb/rdf-n3.png)](http://badge.fury.io/rb/rdf-n3)
[![Build Status](https://travis-ci.org/ruby-rdf/rdf-n3.png?branch=master)](http://travis-ci.org/ruby-rdf/rdf-n3)
[![Gem Version](https://badge.fury.io/rb/rdf-n3.png)](https://badge.fury.io/rb/rdf-n3)
[![Build Status](https://travis-ci.org/ruby-rdf/rdf-n3.png?branch=master)](https://travis-ci.org/ruby-rdf/rdf-n3)

## Description
RDF::N3 is an Notation-3 parser for Ruby using the [RDF.rb][RDF.rb] library suite.
RDF::N3 is an Notation-3 parser for Ruby using the [RDF.rb][RDF.rb] library suite. Also implements N3 Entailment.

Reader inspired from TimBL predictiveParser and Python librdf implementation.

Expand All @@ -14,14 +14,12 @@ Support for Turtle mime-types and specific format support has been deprecated fr
as Turtle is now implemented using [RDF::Turtle][RDF::Turtle].

## Features
RDF::N3 parses [Notation-3][N3], [Turtle][Turtle] and [N-Triples][N-Triples] into statements or triples. It also serializes to Turtle.
RDF::N3 parses [Notation-3][N3], [Turtle][Turtle] and [N-Triples][N-Triples] into statements or quads. It also performs reasoning and serializes to N3.

Install with `gem install rdf-n3`

## Limitations
* Full support of Unicode input requires Ruby version 2.0 or greater.
* Support for Variables in Formulae dependent on underlying repository. Existential variables are quantified to RDF::Node instances, Universals to RDF::Query::Variable, with the URI of the variable target used as the variable name.
* No support for N3 Reification. If there were, it would be through a :reify option to the reader.
* Support for Variables in Formulae. Existential variables are quantified to RDF::Node instances, Universals to RDF::Query::Variable, with the URI of the variable target used as the variable name.

## Usage
Instantiate a reader from a local file:
Expand All @@ -40,23 +38,53 @@ Write a graph to a file:
writer << graph
end

### Formulae
### Reasoning
Experimental N3 reasoning is supported. Instantiate a reasoner from a dataset:

RDF::N3::Reasoner.new do |reasoner|
RDF::N3::Reader.open("etc/foaf.n3") {|reader| reasoner << reader}

reader.each_statement do |statement|
puts statement.inspect
end
end

Reasoning is performed by turning a repository containing formula and predicate operators into an executable set of operators (similar to the executable SPARQL Algebra). Reasoning adds statements to the base dataset, marked with `:inferred` (e.g. `statement.inferred?`). Predicate operators are defined from the following vocabularies:

* RDF List vocabulary <http://www.w3.org/2000/10/swap/list#>
* list:append (not implemented yet - See {RDF::N3::Algebra::ListAppend})
* list:in (not implemented yet - See {RDF::N3::Algebra::ListIn})
* list:last (not implemented yet - See {RDF::N3::Algebra::ListLast})
* list:member (not implemented yet - See {RDF::N3::Algebra::ListMember})
* RDF Log vocabulary <http://www.w3.org/2000/10/swap/log#>
* log:conclusion (not implemented yet - See {RDF::N3::Algebra::LogConclusion})
* log:conjunction (not implemented yet - See {RDF::N3::Algebra::LogConjunction})
* log:equalTo (See {not implemented yet - RDF::N3::Algebra::LogEqualTo})
* log:implies (See {RDF::N3::Algebra::LogImplies})
* log:includes (not implemented yet - See {RDF::N3::Algebra::LogIncludes})
* log:notEqualTo (not implemented yet - See {RDF::N3::Algebra::LogNotEqualTo})
* log:notIncludes (not implemented yet - See {RDF::N3::Algebra::LogNotIncludes})
* log:outputString (not implemented yet - See {RDF::N3::Algebra::LogOutputString})

N3 Formulae are introduced with the { statement-list } syntax. A given formula is assigned an RDF::Node instance, which is also used as the graph_name for RDF::Statement instances provided to RDF::N3::Reader#each_statement. For example, the following N3 generates the associated statements:

{ [ x:firstname "Ora" ] dc:wrote [ dc:title "Moby Dick" ] } a n3:falsehood .
@prefix x: <http://example.org/x-ns/#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix dc: <http://purl.org/dc/elements/1.1/#> .

{ [ x:firstname "Ora" ] dc:wrote [ dc:title "Moby Dick" ] } a log:falsehood .

results in
when turned into an RDF Repository results in the following quads

_:form <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/10/swap/log#falsehood> .
_:moby <http://purl.org/dc/elements/1.1/#title> "Moby Dick" _:form .
_:ora <http://purl.org/dc/elements/1.1/#wrote> _:moby _:form .
_:ora <http://example.org/x-ns/#firstname> "Ora" _:form .

f = RDF::Node.new
s = RDF::Node.new
o = RDF::Node.new
RDF::Statement(f, rdf:type n3:falsehood)
RDF::Statement(s, x:firstname, "Ora", graph_name: f)
RDF::Statement(s, dc:wrote, o, graph_name: f)
RDF::Statement(o, dc:title, "Moby Dick", graph_name: f)
Reasoning uses a Notation3 Algebra, similar to [SPARQL S-Expressions](). This implementation considers formulae to be patterns, which may be asserted on statements made in the default graph, possibly loaded from a separate file. The logical relationships are reduced to algebraic operators.

### Variables
N3 Variables are introduced with @forAll, @forEach, or ?x. Variables reference URIs described in formulae, typically defined in the default vocabulary (e.g., ":x"). Existential variables are replaced with an allocated RDF::Node instance. Universal variables are replaced with a RDF::Query::Variable instance. For example, the following N3 generates the associated statements:
N3 Variables are introduced with @forAll, @forSome, or ?x. Variables reference URIs described in formulae, typically defined in the default vocabulary (e.g., ":x"). Existential variables are replaced with an allocated RDF::Node instance. Universal variables are replaced with a RDF::Query::Variable instance. For example, the following N3 generates the associated statements:

@forAll <#h>. @forSome <#g>. <#g> <#loves> <#h> .

Expand All @@ -66,6 +94,8 @@ results in:
g = RDF::Node.new()
RDF::Statement(f, <#loves>, h)

Note that the behavior of both existential and universal variables is not entirely in keeping with the [Team Submission][], and neither work quite like SPARQL variables. When used in the antecedent part of an implication, universal variables should behave much like SPARQL variables. This area is subject to a fair amount of change.

## Implementation Notes
The parser is driven through a rules table contained in lib/rdf/n3/reader/meta.rb. This includes
branch rules to indicate productions to be taken based on a current production. Terminals are denoted
Expand All @@ -79,48 +109,60 @@ http://www.w3.org/2000/10/swap/grammar/n3.n3 (along with bnf-rules.n3) using cwm

[n3-selectors.n3][file:lib/rdf/n3/reader/n3-selectors.rb] is itself used to generate meta.rb using script/build_meta.

## TODO
* Generate Formulae and solutions using BGP and SPARQL CONSTRUCT mechanisms
* Create equivalent to `--think` to iterate on solutions.

## Dependencies
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 3.0)
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.0, >= 3.0.10)

## Documentation
Full documentation available on [RubyDoc.info](http://rubydoc.info/github/ruby-rdf/rdf-n3/frames)
Full documentation available on [RubyDoc.info](https://rubydoc.info/github/ruby-rdf/rdf-n3)

### Principle Classes
* {RDF::N3}
* {RDF::N3::Format}
* {RDF::N3::Reader}
* {RDF::N3::Reasoner}
* {RDF::N3::Writer}
* {RDF::N3::Algebra}
* {RDF::N3::Algebra::Formula}
* {RDF::N3::Algebra::ListAppend}
* {RDF::N3::Algebra::ListIn}
* {RDF::N3::Algebra::ListLast}
* {RDF::N3::Algebra::ListMember}
* {RDF::N3::Algebra::LogConclusion}
* {RDF::N3::Algebra::LogConjunction}
* {RDF::N3::Algebra::LogEqualTo}
* {RDF::N3::Algebra::LogImplies}
* {RDF::N3::Algebra::LogIncludes}
* {RDF::N3::Algebra::LogNotEqualTo}
* {RDF::N3::Algebra::LogNotIncludes}
* {RDF::N3::Algebra::LogOutputString}

### Additional vocabularies
* {RDF::LOG}
* {RDF::REI}

### Patches
* `Array`
* `RDF::List`
* {RDF::N3::Log}
* {RDF::N3::Rei}
* {RDF::N3::Crypto}
* {RDF::N3::List}
* {RDF::N3::Math}
* {RDF::N3::Str}
* {RDF::N3::Time}

## Resources
* [RDF.rb][RDF.rb]
* [Distiller](http://rdf.greggkellogg.net/distiller)
* [Documentation](http://rubydoc.info/github/ruby-rdf/rdf-n3/master/frames)
* [Documentation](https://rubydoc.info/github/ruby-rdf/rdf-n3/)
* [History](file:file.History.html)
* [Notation-3][N3]
* [N3 Primer](http://www.w3.org/2000/10/swap/Primer.html)
* [N3 Reification](http://www.w3.org/DesignIssues/Reify.html)
* [N3 Primer](https://www.w3.org/2000/10/swap/Primer.html)
* [N3 Reification](https://www.w3.org/DesignIssues/Reify.html)
* [Turtle][Turtle]
* [W3C SWAP Test suite](http://www.w3.org/2000/10/swap/test/README.html)
* [W3C Turtle Test suite](http://www.w3.org/2001/sw/DataAccess/df1/tests/README.txt)
* [W3C SWAP Test suite](https://www.w3.org/2000/10/swap/test/README.html)
* [W3C Turtle Test suite](https://www.w3.org/2001/sw/DataAccess/df1/tests/README.txt)
* [N-Triples][N-Triples]

## Author
* [Gregg Kellogg](http://github.com/gkellogg) - <http://greggkellogg.net/>
* [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>

## Contributors
* [Nicholas Humfrey](http://github.com/njh) - <http://njh.me/>
* [Nicholas Humfrey](https://github.com/njh) - <https://njh.me/>

## Contributing
This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
Expand All @@ -140,19 +182,21 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
## License

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

## Feedback
* <gregg@greggkellogg.net>
* <http://rubygems.org/gem/rdf-n3>
* <http://github.com/ruby-rdf/rdf-n3>
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>

[RDF.rb]: http://ruby-rdf.github.com/rdf
[RDF::Turtle]: http://ruby-rdf.github.com/rdf-turtle/
[N3]: http://www.w3.org/DesignIssues/Notation3.html "Notation-3"
[Turtle]: http://www.w3.org/TR/turtle/
[N-Triples]: http://www.w3.org/TR/n-triples/
[YARD]: http://yardoc.org/
[YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
* <https://rubygems.org/gem/rdf-n3>
* <https://github.com/ruby-rdf/rdf-n3>
* <https://lists.w3.org/Archives/Public/public-rdf-ruby/>

[RDF.rb]: https://ruby-rdf.github.com/rdf
[RDF::Turtle]: https://ruby-rdf.github.com/rdf-turtle/
[N3]: https://www.w3.org/DesignIssues/Notation3.html "Notation-3"
[Team Submission]: https://www.w3.org/TeamSubmission/n3/
[Turtle]: https://www.w3.org/TR/turtle/
[N-Triples]: https://www.w3.org/TR/n-triples/
[YARD]: https://yardoc.org/
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[SPARQL S-Expressions]: https://jena.apache.org/documentation/notes/sse.html
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.0.1
3.1.0
6 changes: 3 additions & 3 deletions etc/doap.n3
Expand Up @@ -9,18 +9,18 @@

<> a doap:Project ;
doap:name "RDF::N3" ;
doap:homepage <http://github.com/ruby-rdf/rdf-n3> ;
doap:homepage <https://github.com/ruby-rdf/rdf-n3> ;
doap:license <http://creativecommons.org/licenses/publicdomain/> ;
doap:shortdesc "N3 reader/writer for Ruby."@en ;
doap:description "RDF::N3 is an Notation-3 reader/writer for the RDF.rb library suite."@en ;
doap:description "RDF::N3 is an Notation-3 reader/writer and reasoner for the RDF.rb library suite."@en ;
doap:created "2010-06-03"^^xsd:date;
doap:programming-language "Ruby" ;
doap:implements <http://www.w3.org/DesignIssues/Notation3.html> ;
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
<http://dbpedia.org/resource/Ruby_(programming_language)> ;
doap:download-page <http://rubygems.org/gems/rdf-n3> ;
doap:mailing-list <http://lists.w3.org/Archives/Public/public-rdf-ruby/> ;
doap:bug-database <http://github.com/ruby-rdf/rdf-n3/issues> ;
doap:bug-database <https://github.com/ruby-rdf/rdf-n3/issues> ;
doap:blog <http://greggkellogg.net/> ;
doap:developer <http://greggkellogg.net/foaf#me> ;
doap:helper <http://njh.me/> ;
Expand Down
6 changes: 3 additions & 3 deletions etc/doap.nt
@@ -1,8 +1,8 @@
<http://rubygems.org/gems/rdf-n3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#name> "RDF::N3" .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#homepage> <http://github.com/ruby-rdf/rdf-n3> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#homepage> <https://github.com/ruby-rdf/rdf-n3> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#shortdesc> "N3 reader/writer for Ruby."@en .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#shortdesc> "N3 reader/writer reader/writer and reasoner for Ruby."@en .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#description> "RDF::N3 is an Notation-3 reader/writer for the RDF.rb library suite."@en .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#created> "2010-06-03"^^<http://www.w3.org/2001/XMLSchema#date> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#programming-language> "Ruby" .
Expand All @@ -11,7 +11,7 @@
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#category> <http://dbpedia.org/resource/Ruby_(programming_language)> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#download-page> <http://rubygems.org/gems/rdf-n3> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#mailing-list> <http://lists.w3.org/Archives/Public/public-rdf-ruby/> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#bug-database> <http://github.com/ruby-rdf/rdf-n3/issues> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#bug-database> <https://github.com/ruby-rdf/rdf-n3/issues> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#blog> <http://greggkellogg.net/> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#developer> <http://greggkellogg.net/foaf#me> .
<http://rubygems.org/gems/rdf-n3> <http://usefulinc.com/ns/doap#helper> <http://njh.me/> .
Expand Down

0 comments on commit 548b4c6

Please sign in to comment.