- From: Dan Brickley <danbri@danbri.org>
- Date: Tue, 30 Sep 2008 15:27:22 +0200
- To: RDFa <public-rdf-in-xhtml-tf@w3.org>, Patrick.Sinclair@bbc.co.uk, tom@tommorris.org
Hello Ruby people, I'm trying to parse the N-Triples dumps from http://lcsh.info/ in Ruby. This was a good excuse to try the repackaged 'Rena' tools from Tom Morris, Patrick Sinclair and friends. I downloaded a tar.gz from GitHub and tried to make it go. http://github.com/tommorris/rena First - I had to make some edits to rena.gemspec before I could make it build and install a Gem package. Those edits are here: http://pastebin.com/f4c1b3d25 Secondly, I'm trying to parse ntriples or even n3 input (assuming the former is a subset of the latter). I get an error in /Users/danbri/.gem/ruby/1.8/gems/rena-0.0.1/lib/rena/n3parser.rb:28:in `initialize': undefined local variable or method `string' for #<Rena::N3Parser:0x12b59ac> (NameError) code is: puts "Expected #{tf.expected_string.inspect} (#{tf.index})- '#{string[tf.index,10].inspect}'" If I comment out the string bit, it runs (but still fails to parse). Input is http://svn.foaf-project.org/foaftown/2008/lcshplus/_bristol.nt which parses fine with Redland's rapper parser, either with -i ntriples, or -i turtle. Help welcomed. Is this code ready to use? If someone could at least help fix the 'string' error above it might be possible to get more understandable error messages... cheers, Dan My script is just: #!/usr/bin/ruby require 'rena' include Rena filepath='_bristol.nt' n3_string = File.read(filepath) parser = N3Parser.new(n3_string) ntriples = parser.graph.to_ntriples ntriples.gsub!(/_:bn\d+/, '_:node1') ntriples = sort_ntriples(ntriples)
Received on Tuesday, 30 September 2008 13:27:59 UTC