tag:blogger.com,1999:blog-9025880770474050744.post-86809063288081970162008-02-23T12:35:00.000-08:002008-02-23T12:48:06.761-08:00Ruby API for accessing Freebase/Metaweb structured dataI had a good talk with some of the Metaweb developers last year and started playing with their Python APIs for accessing structured data. I wanted to be able to use this structured data source in a planned Ruby project and was very pleased to see Christopher Eppstein's new project that provides an ActiveRecord style API on top of <a href="http://www.freebase.com" target="new">Freebase</a>. Here is the web page for <a href="http://rubyforge.org/projects/freebaseapi/" target="new">Christopher's Freebase API project</a>. Assuming that you do a "gem install freebase", using this API is easy; some examples:<pre>require 'rubygems'<br />require "freebase"<br />require 'pp'<br /><br />an_asteroid = Freebase::Types::Astronomy::Asteroid.find(:first)<br />#pp "an_asteroid:", an_asteroid<br />puts "name of asteroid=#{an_asteroid.name}"<br />puts "spectral type=#{an_asteroid.spectral_type[0].name}"<br /><br />#all_asteroids = Freebase::Types::Astronomy::Asteroid.find(:all)<br />#pp "all_asteroids:", all_asteroids<br /><br />a_company = Freebase::Types::Business::Company.find(:first)<br />#pp "a_company:", a_company<br />puts "name=#{a_company.name}"<br />puts "parent company name=#{a_company.parent_company[0].name}"</pre>You will want to use this API interactively: use the Freebase web site to find type hierarchies that you are interested in, fetch the first object matching a type hierarchy (e.g., Types -> Astronomy -> Asteroid) and pretty print the fetched object to see what data fields are available.Mark Watson, author and consultanthttp://www.blogger.com/profile/05514730816583918651mark.watson@gmail.com