GitHub user mschroeder-github opened a pull request:
https://github.com/apache/jena/pull/299
Turtle Star
Turtle parser extention for Turtle* as suggested in [Foundations of an
Alternative Approach to Reification in
RDF](https://arxiv.org/pdf/1406.3399.pdf) (Section 3.3).
I copied the javacc grammar definition from `turtle.jj` and add the changes
to `turtle-star.jj`.
Javacc generates all the classes in package
`org.apache.jena.n3.turtlestar.parser`.
The `RDFReaderFImpl` is extended with the `TurtleStarReader` reader, so one
can read Turtle* with the following code:
```java
public static void parse() throws MalformedURLException {
Model m = ModelFactory.createDefaultModel();
m.read(new File("test.ttl").toURI().toURL().toString(), "TTL*");
StringWriter sw = new StringWriter();
m.write(sw, "TTL");
System.out.println(sw.toString());
}
```
In short, the Turtle* syntax
```
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix : <http://example.com/> .
<< :bob foaf:age 23 >> dct:creator <http://example.com/crawlers#c1> ;
dct:source
<http://example.net/homepage-listing.html> .
```
results in the following RDF model:
```
:bob foaf:age 23 .
[] a <http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement> ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#object>
23 ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate>
foaf:age ;
<http://www.w3.org/1999/02/22-rdf-syntax-ns#subject>
:bob ;
dct:creator <http://example.com/crawlers#c1> ;
dct:source <http://example.net/homepage-listing.html> .
```
A more complex example is:
```
:sven :claims << :markus :says << :sven a :Person >> >> .
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/mschroeder-github/jena turtle_star
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/jena/pull/299.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #299
----
commit e63811a74da613f5d66232c8ad8a78caa2db6d7e
Author: Markus Schroeder <[email protected]>
Date: 2017-10-27T07:32:40Z
turtle parser generation by javacc fixed
commit 01520ea3d63744ed962402629bc2dea98807b1aa
Author: Markus Schroeder <[email protected]>
Date: 2017-10-27T08:24:32Z
turtle star parser copied from turtle parser
commit 6a72f45be68adf522e39c10bfd6373a3800656ca
Author: Markus Schroeder <[email protected]>
Date: 2017-10-27T14:49:29Z
turtle star syntax
commit 8e63b4784181eea93383cece7be0f6919e760eea
Author: Markus Schroeder <[email protected]>
Date: 2017-10-28T05:20:16Z
undo changes on the pom.xml
----
---