[Developers] MQL for Ruby?

David Dennis davdennis at gmail.com
Sun Mar 15 22:56:08 UTC 2009


I did include and require 'rubygems'

I'm using Rails.

I ran the sample code without installing echoe and got the below error:
http://whatdoesthiserrormean.com/errors/1240

There are commenters on that site who got the same error I did for HTTParty.

Uninstall echoe and run the sample code again to check.

David

On Sun, Mar 15, 2009 at 6:29 PM, Shawn Simister <narphorium at gmail.com>wrote:

>  You shouldn't need to install the echoe gem to get the sample code
> working. Simply using rubygems or rails (which uses rubygems) should do the
> trick.
>
> If you're running the code from the command line you'll need to do
> something like this:
>
> ruby -rubygems example.rb
>
>
> David Dennis wrote:
>
> THANKS!
>  But please also warn people in the future to run "gem install echoe"
> first.
>
> On Fri, Mar 13, 2009 at 10:14 PM, Shawn Simister <narphorium at gmail.com>wrote:
>
>>  The HTTParty gem is a great way to get started with MQL in Ruby. Here's
>> some sample code to get you started.
>>
>> require 'httparty'
>>
>> class Freebase
>>   include HTTParty
>>   format :json
>>   base_uri 'http://www.freebase.com/api'
>>
>>   def self.read(q)
>>     return get('/service/mqlread?', :query => {:query => '{"query":' + q +
>> '}'})['result']
>>   end
>> end
>>
>> query = '{"id":"/en/peru","capital":null,"type":"/location/country"}'
>> puts Freebase.read(query)['capital']
>>
>> This code will query Freebase to find the capital of Peru and will write
>> the result to the console.
>>
>> Shawn
>>
>> David Dennis wrote:
>>
>>  From looking around it seems like there's no gem set up for this yet.
>>
>>  For some reason even running a basic "open()" from "open-uri" doesn't
>> allow me to retrieve any text when I include a Freebase query url as a
>> parameter.  I can usually retrieve HTML this way (e.g.,
>> http://www.google.com still works).  Why would does it not work for the
>> Freebase query URLs?
>>  I just want to get some text on screen to start with.  Have any other
>> rails people had luck?
>>
>>  Thanks,
>> David
>>
>> ------------------------------
>> _______________________________________________
>> Developers mailing listDevelopers at freebase.comhttp://lists.freebase.com/mailman/listinfo/developers
>>
>>
>>
>> _______________________________________________
>> Developers mailing list
>> Developers at freebase.com
>> http://lists.freebase.com/mailman/listinfo/developers
>>
>>
>  ------------------------------
> _______________________________________________
> Developers mailing listDevelopers at freebase.comhttp://lists.freebase.com/mailman/listinfo/developers
>
>
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freebase.com/pipermail/developers/attachments/20090315/a7b5c107/attachment-0001.htm 


More information about the Developers mailing list