[Developers] MQL for Ruby?

Shawn Simister narphorium at gmail.com
Sun Mar 15 23:13:02 UTC 2009


Interesting. I don't have echoe installed and the sample runs fine but I 
do have hoe installed so I guess that's the difference. I'll make a note 
of that for next time.

David Dennis wrote:
> 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 
> <mailto: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 <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 <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/02352cfa/attachment.htm 


More information about the Developers mailing list