dajobe / raptor

Redland Raptor RDF syntax library
https://librdf.org/raptor/
Other
157 stars 62 forks source link

mKR serializer for Raptor #15

Closed rhmccullough closed 10 years ago

rhmccullough commented 10 years ago

New files for mKR writer, serializer, tests. Minimal changes to other programs to add a new language. I have some questions re: Turtle serializer handling of @base and rdf:nil.

dajobe commented 10 years ago

the README.md should not be at the top level. Maybe in the tests area. If it's just about this pull request, delete the file and put in the PR description

dajobe commented 10 years ago

How different is the mkr work compared to turtle. Is a whole new serializer / writer needed or could the turtle one do it with some flags?

dajobe commented 10 years ago

Is mkr really generating 30,000 line results? e.g. test-14.mkr that seems huge

rhmccullough commented 10 years ago

Dave,

I'll try to cover all 4 emails in this reply.

1) It is possible the turtle serializer could do mKR's work with flags. The basic rules are: "." => ";" "( x y z )" => "[ x, y, z ]" and "( )" => "[ ]" "[ ... ]" => "{ ... }" subject => . is subject ; predicate object1, object2, ... ; => . has predicate = [ object1, object2, ... ] ; except rdf:type object1, object2, ... ; => . isu object1, object2, ... ; rdfs:subClassOf object1, object2, ... ; => . iss object1, object2, ... ; rdfs:subPropertyOf object1, object2, ... ; => . iss object1, object2, ... ;

The basic philosophy is: "." stands for current concept, and is short enough to make mKR as readable as Turtle. Everything is a complete sentence, and all the more advanced features can be expressed in more complicated sentences. FYI: mKR uses "isa" to mean either "isu" or "iss".

2) re Makefile.am etc. I'm a real novice with the automake tools. I'll do it anyway you want.

3) re 30,000 line mKR file. That's for real. It's a translation of your 10,000 line Turtle file. I suggest deleting test-16.ttl and test-16.mkr

4) re test-08.ttl Turtle serializer changes "( )" to "rdf:nil". That seems contrary to the spirit of Turtle. I put a 3 line patch in raptor_mkr_emit_resource() that could put out "( )" instead.

5) listing4-3.ttl from "Linked Data" book has @base declaration. I do not know what is supposed to be done with it. Turtle serializer outputs no @base declaration. My hack of Turtle serializer outputs @base with local file name replacing original URI.

6) re building with github files I have not been able to do a successful build -- missing dependency & .am files. For now, I can only build by copying github files into the files I downloaded from librdf.org.

I'll start work on the changes you suggested. How do I keep my changes from affecting you?

dajobe commented 10 years ago
  1. If the delta is small then it seems a good idea to me to reuse the turtle writer/serializer and add flags for the if(mkr) parts
  2. & 6. The INSTALL.html file in the distribution describes how to build from GIT, what automake tools you need etc. If you look at the Raptor CI (continuous integration) runs at http://ci.aelius.com/job/raptor/641/console for example, you can see how a build from GIT is automated.
  3. The test-08.ttl serializer thing sounds like a separate issue, you could make a small PR (pull request) for that alone.
  4. The turtle serializer writing @base is done in raptor_turtle_writer_base() and only if the write_base_uri argument to raptor_new_turtle_writer() is true.

Your changes should be applied and the existing tests must all pass. Also I'd like a configure option to enable/disable mKR; defaulting to disable, and the new code made conditional with something like #ifdef RAPTOR_MKR. You can use an automake conditional for that; see configure.ac

rhmccullough commented 10 years ago

Re-implemented mKR serializer using raptor_serialize_turtle.c & raptor_turtle_writer.c. I reverted all the changes in rhmccullough/raptor master. All the latest changes are in the mkr-serializer branch of rhmccullough/raptor. I use context->emit_mkr = 1 for mKR and = 0 for Turtle. Since writer does not use context, I added emit_mkr argument to _prefix and _base procedures. I have been using tests/mkr/Makefile.mkr for testing, since your latest build aborts in scripts (can't find raptor2.h).

dajobe commented 10 years ago

Since you've reverted everything, I'll close this PR and you can make a new one from the mkr-serializer branch.