W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > August 2011

Re: Problem loading OWL ontology with RDF.rb

From: Gregg Kellogg <gregg@kellogg-assoc.com>
Date: Tue, 9 Aug 2011 15:00:51 -0400
To: Franco Rondini <rondinif@yahoo.it>
CC: "public-rdf-ruby@w3.org" <public-rdf-ruby@w3.org>, Marcel Otto <marcelotto@gmx.de>
Message-ID: <3E441DED-7A01-430B-8D2D-1490EE572B24@kellogg-assoc.com>
On Aug 9, 2011, at 11:49 AM, Franco Rondini wrote:

excuse me if the problem may seem trivial but I'm still not able to load a Graph from a owl file directly stored on the local filesystem. Can you help me to point the right direction?

### attempt N.1
from /Users/ronda/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
ruby-1.9.2-p290 :038 > uri = RDF::URI.new(:scheme => 'file', :path => 'owl.owl', :host => '/Users/ronda/Downloads')
 => #<RDF::URI:0x80fc6004(file:///Users/ronda/Downloads/owl.owl)>
ruby-1.9.2-p290 :039 > g2 = RDF::Graph.load( uri )
Errno::ENOENT: No such file or directory - file:///Users/ronda/Downloads/owl.owl

The RDF::URI.new syntax you use here would seem to be for Addressable::URI, not RDF::URI. RDF::URI.new takes a String, or #to_s.

### attempt N.2
ruby-1.9.2-p290 :029 > g3 = RDF::Graph.load("/Users/ronda/Downloads/owl.owl")
Ronda filename:/Users/ronda/Downloads/owl.owlRDF::FormatError: unknown RDF format: {:base_uri=>#<RDF::URI:0x82c96ae4(/Users/ronda/Downloads/owl.owl)>, :file_name=>"/Users/ronda/Downloads/owl.owl"}

RDF::Graph.load takes hints from the path name, file extension and mime-type. In this case, it can't associate the file extension ".owl" with an appropriate reader. You can tell it what reader to use using :format, or set the :mime_type explicitly. Try the following:

g3 = RDF::Graph.load("/Users/rohnda/Downloads/owl.owl", :format => :rdfxml)

In a separate project, I have an RDF::All::Reader, which will sniff the input and choose one or more readers to use based upon the detected types. At some point, we'll roll that into the linkeddata gem.

RDF::Graph.load() takes options like RDF::Reader.for() and RDF::Reader.new().

orks fine from http
ruby-1.9.2-p290 :004 > g = RDF::Graph.load( RDF::OWL )
 => #<RDF::Graph:0x81469084(http://www.w3.org/2002/07/owl#)>
ruby-1.9.2-p290 :005 > g.count  # => 450

Yes, this is because they're returning an appropriate mime-type when you download file file, note the application/rdf+xml in the content-type below.

the file used for the tests is obtaineid this way:
[ 02:55:46 ] > cd ~/Downloads/
[ ronda@MacBook-di-Franco-Rondini.local<mailto:ronda@MacBook-di-Franco-Rondini.local> ~/Downloads ]
[ 08:37:31 ] > wget http://www.w3.org/2002/07/owl
--2011-08-09 20:37:49--  http://www.w3.org/2002/07/owl
Resolving www.w3.org<http://www.w3.org/>... 128.30.52.37
Connecting to www.w3.org<http://www.w3.org>|128.30.52.37|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 31861 (31K) [application/rdf+xml]
Saving to: `owl.1'

100%[==================================================================================================================>] 31,861      45.7K/s   in 0.7s

2011-08-09 20:37:51 (45.7 KB/s) - `owl.1' saved [31861/31861]

[ ronda@MacBook-di-Franco-Rondini.local<mailto:ronda@MacBook-di-Franco-Rondini.local> ~/Downloads ]
[ 08:38:31 ] > mv owl.1 owl.owl
[ ronda@MacBook-di-Franco-Rondini.local<mailto:ronda@MacBook-di-Franco-Rondini.local> ~/Downloads ]
[ 08:38:47 ] > less owl.owl
in the editor it looks good to me.
thanks and greetings
Franco

Il giorno 08/ago/2011, alle ore 22.45, Marcel Otto ha scritto:

Works fine now. Also the dump seems ok to me.

Thank you very much for the rapid fix
Marcel

Am 08.08.2011 22:01, schrieb Gregg Kellogg:
A simple matter of RTFM, to get Nokogiri to decode entities.

Updated gem to version 0.3.4, update with "(sudo) gem update rdf-rdfxml" you should now see the following:

require 'linked data'
g = RDF::Graph.load( RDF::OWL )
g.count  # => 450

Also, try the following:

g.dump(:ttl, :standard_prefixes => true)

Gregg


On Aug 8, 2011, at 10:14 AM, Marcel Otto wrote:

g = RDF::Graph.load( RDF::OWL )
Received on Tuesday, 9 August 2011 19:02:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 9 August 2011 19:02:30 GMT