[Developers] MQL for Ruby?
Shawn Simister
narphorium at gmail.com
Sun Mar 15 22:29:47 UTC 2009
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
> <mailto: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 list
>> Developers at freebase.com <mailto:Developers at freebase.com>
>> http://lists.freebase.com/mailman/listinfo/developers
>>
>
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com <mailto:Developers at freebase.com>
> http://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/fdd97900/attachment.htm
More information about the Developers
mailing list