First of all, great job! Here's my initial impression - I'll have to
take some time to try it out properly, though.
> Since the stand-alone scardf was missing the ability to round-trip RDF
> without being able to read N-Triples, I had a go at making a parser
> for that.
Don't know if you saw the swap-scala project. Dan Connolly made a
model and multiple parsers in Scala. Here's his N-Triples parser, for
reference:
> I thought using Scala's parser combinators would be overkill for
> something as trivial as N-Triples. There is that Scanner class in
> Java, also... What I have here is perhaps going overboard with low-
> level, character at a time streaming, mutable state abuse. I think I
> was trying to go for performance, inline everything, and not create
> any new objects unnecessarily.
I have some personal experience with combinator parsing in 2.7. Most
recently I've been parsing 20+ GB log files and found them to be quite
fast, easy on the memory, and great for rapid development.
But N-Triples has a trivial syntax and so your approach is probably
better in the long term. I'll try it out and let you know what I
think.
> But it seems to work. Just haven't finished the support for language
> tags yet - I haven't seen many of those.
You're an American, right? Well, they are kind of a big deal outside
of the US ;)
> A question: How do you build this?
> When I type mvn compile, the only thing that gets built is
> net.croz.scardf.query.NTripleHelper.class
*~* (or whatever is the emoticon for blushing)
You can type "mvn scala:compile". Or just download the latest version
of the POM file.
> I just made it an sbt project, and it seems to build fine - I'm more
> familiar with sbt anyways.
Never got around to learn how to use sbt. Maybe you could contribute
your sbt file/script/whatchamacallit?
Hrvoje
Probably. I haven't looked at it in detail. There are no new updates
since February, and Connolly left W3C in June. Code is MIT-licensed,
so there shouldn't be
a problem to adopt parts of his code.
> Speaking of testing, I made a round-trip test for the serialization...
> Nothing blows up if I run mvn test, so I think it works?
Umph, not quite. Pure org.scardf has an incomplete implementation of
the is-isomorphic-to method (=~). Currently, if it returns true that
doesn't mean the graphs are isomorphic for sure (false does mean
they're not). I've been working on a full RDF isomorphism algorithm in
Scala but I've never finished it.
The workaround is to use Jena. If both A and B are JenaGraphs, then
A=~B will delegate to Jena's isIsomorphicWith method, which is tried
and true. So I do a conversion like this:
val g = new jena.JenaGraph ++ Doe.graph
And your mustVerify test now really works!
I tried to make a ScalaCheck test for it, but I got stuck. I'll try to
make additional tests, ScalaCheck or not. Also, it would be good to
add blank lines and comment lines so that it becomes an
almost-complete implementation. It got me thinking - it could be used
as a low-tech bridge between frameworks.
> The N-Triples BNF does say all lines must end with an eoln, so I added
> one.
OK, great.
>> Never got around to learn how to use sbt. Maybe you could contribute
>> your sbt file/script/whatchamacallit?
>
> Sure, I've got all these changes on github,
> https://github.com/LeifW/scardf
> The sbt config is in the /project directory, with /project/
> build.properties containing the project name and version number, and /
> project/build/ScardfProject.scala having the dependencies.
I will check it out.
> You wouldn't happen to know anything about setting up a maven / ivy
> repo for this, would you?
No, not really. Are you talking about setting up a private Maven
repository to put up scardf, or to publish Scardf on a well-known
repository, or something else?
cheers,
Hrvoje
Just so you know, I've just added blank lines and comments to the parser.
http://code.google.com/p/scardf/source/detail?r=202