IndicoDataSolutions / IndicoIo-ruby

A simple Ruby Wrapper for the indico set of APIs
MIT License
13 stars 2 forks source link

#predict_text doesn't exist? #53

Closed DGaffney closed 9 years ago

DGaffney commented 9 years ago

I'm interested in using the #predict_text method on the Indico module and I'm getting the following:

2.2.1 :010 > Indico.predict_text(["Best day ever", "Worst day ever"], ["sentiment", "language"])
NoMethodError: undefined method `predict_text' for Indico:Module
        from (irb):10
        from /usr/local/rvm/rubies/ruby-2.2.1/bin/irb:11:in `<main>'

(Version 0.5.1)

sihrc commented 9 years ago

Hi @DGaffney, terribly sorry for the inconvenience. Could you give analyze_text a shot? We made a change very recently. Take a look at the newly updated docs at your convenience.

sihrc commented 9 years ago

@DGaffney are you still having issues?

DGaffney commented 9 years ago

Nope, getting the following stack from the demo on your Github readme:

2.1.4 :007 > Indico.analyze_text(["Best day ever", "Worst day ever"], ["sentiment", "language"])
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
    from /Users/dgaff/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:920:in `connect'
    from /Users/dgaff/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:920:in `block in connect'
    from /Users/dgaff/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
    from /Users/dgaff/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:920:in `connect'
    from /Users/dgaff/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
    from /Users/dgaff/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:852:in `start'
    from /Users/dgaff/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/net/http.rb:1369:in `request'
    from /Users/dgaff/.rvm/gems/ruby-2.1.4/gems/indico-0.5.1/lib/indico/helper.rb:66:in `make_request'
    from /Users/dgaff/.rvm/gems/ruby-2.1.4/gems/indico-0.5.1/lib/indico/helper.rb:38:in `api_handler'
    from /Users/dgaff/.rvm/gems/ruby-2.1.4/gems/indico-0.5.1/lib/indico/multi.rb:39:in `multi'
    from /Users/dgaff/.rvm/gems/ruby-2.1.4/gems/indico-0.5.1/lib/indico.rb:217:in `analyze_text'
    from (irb):7
    from /Users/dgaff/.rvm/rubies/ruby-2.1.4/bin/irb:11:in `<main>’

Getting the SSL error for all calls with my API key, across multiple machines now. I’ve moved on to other things, please let me know if you do get around to fixing this, though. You have an interesting dataset, it would be fun to use it.

On Sep 1, 2015, at 10:33 AM, Chris Lee notifications@github.com wrote:

@DGaffney https://github.com/DGaffney are you still having issues?

— Reply to this email directly or view it on GitHub https://github.com/IndicoDataSolutions/IndicoIo-ruby/issues/53#issuecomment-136742113.

sihrc commented 9 years ago

Assuming you do have the latest version of the library, it looks like there might be a problem with certs on the client side. We'll also investigate on our side right now in case it's not and get back to you as soon as we reach a conclusion. Thanks for your patience!

DGaffney commented 9 years ago

Running through that I get a potentially relevant error message from your API url (apiv2.indico.io, which I found in your gem’s code on git):

Devins-MacBook-Air:pocket_news dgaff$ ruby ssl_fix.rb 
/Users/dgaff/.rvm/rubies/ruby-1.9.3-p550/bin/ruby (1.9.3-p550)
OpenSSL 1.0.1j 15 Oct 2014: /usr/local/etc/openssl
SSL_CERT_DIR=""
SSL_CERT_FILE=""
HEAD https://apiv2.indico.io:443
#<Net::HTTPServiceUnavailable 503 Service Unavailable readbody=true>

On Sep 1, 2015, at 10:56 AM, Chris Lee notifications@github.com wrote:

Assuming you do have the latest version of the library, it looks like there might be a problem with certs http://mislav.uniqpath.com/2013/07/ruby-openssl/ on the client side. We'll also investigate on our side right now in case it's not and get back to you as soon as we reach a conclusion. Thanks for your patience!

— Reply to this email directly or view it on GitHub https://github.com/IndicoDataSolutions/IndicoIo-ruby/issues/53#issuecomment-136751326.

madisonmay commented 9 years ago

I'm pretty certain this is an issue with your certificate bundle (I ran into this myself on OSX). Seems to be a fairly common issue with Ruby 2.0. I would recommend following this gist: https://gist.github.com/mislav/5026283 and seeing if it resolves your issue.

DGaffney commented 9 years ago

I checked that gist, ran through it, didn't have the issues it was telling me about, updated my certs with that haxxx.se url, and ran it against your server, and then ran that ssl fix script mislav wrote:

Devins-MacBook-Air:pocket_news dgaff$ ruby -rnet/https -e "Net::HTTP.get URI('https://apiv2.indico.io')"

Devins-MacBook-Air:pocket_news dgaff$ ruby ssl_fix.rb 
/Users/dgaff/.rvm/rubies/ruby-2.1.4/bin/ruby (2.1.4-p265)
OpenSSL 1.0.1j 15 Oct 2014: /etc/openssl
SSL_CERT_DIR=""
SSL_CERT_FILE=""

HEAD https://apiv2.indico.io:443
#<Net::HTTPServiceUnavailable 503 Service Unavailable readbody=true>

I hit your URL directly and got this as well. I understand that it's a common issue but it really smells like it's not the issue and that instead this 503 error is the problem.

screen shot 2015-09-01 at 12 14 48 pm

sihrc commented 9 years ago

You seem to be making a GET request to our servers, which is not supported. Currently, it's being caught by one of our error handling services which returns the 503 you are experiencing by default. Usually, you would provide an api in the url https://apiv2.indico.io/sentiment and it will attempt to find a server for that api.

In your case, may I suggest trying the request with a POST request with the following url and body:

POST https://apiv2.indico.io/sentiment?key=API_KEY
BODY:
{
     "data": "Sentiment text to run"
}
sihrc commented 9 years ago

screen shot 2015-09-01 at 1 00 10 pm

DGaffney commented 9 years ago

Weird. I haven't made any changes beyond the stated attempts from earlier which didn't yield anything and it is now working:

Devins-MacBook-Air:pocket_news dgaff$ curl -d '{
>      "data": "Sentiment text to run"
> }' 'https://apiv2.indico.io/sentiment?key=9795864f16d213fd76b91fd2d480f571'
{"results": 0.102632503008872}
Devins-MacBook-Air:pocket_news dgaff$ rvm use ruby-2
Using /Users/dgaff/.rvm/gems/ruby-2.1.4
Devins-MacBook-Air:pocket_news dgaff$ bundle exec irb
2.1.4 :001 > load 'environment.rb'
 => true 
2.1.4 :002 > Indico.sentiment("Sentiment text to run")
 => 0.102632503008872 
2.1.4 :003 > Indico.analyze_text(["Best day ever", "Worst day ever"], ["sentiment", "language"])

 => {"language"=>[{"Swedish"=>0.0022464881013042294, "Vietnamese"=>9.887170914498351e-05, "Romanian"=>0.00010661175919993216, "Dutch"=>0.0004540651019748842, "Korean"=>0.002030398193117043, "Danish"=>0.03427050962327267, "Indonesian"=>0.4252087949289627, "Latin"=>2.187847761603399e-05, "Hungarian"=>0.006162182653750597, "Persian (Farsi)"=>0.0001280189549568246, "Lithuanian"=>1.7174663936012685e-06, "French"=>0.004447907162140138, "Norwegian"=>0.02567567402839836, "Russian"=>1.9498339458039835e-05, "Thai"=>0.001814531096080969, "Finnish"=>0.00040773795096733095, "Hebrew"=>0.00011117004732246605, "Bulgarian"=>0.0012394697335993334, "Turkish"=>0.00019816587227943102, "Greek"=>0.0006718492689864853, "Tagalog"=>0.2579796526990078, "English"=>6.637773941088482e-05, "Arabic"=>0.00017611839790642638, "Italian"=>0.0865827368371047, "Portuguese"=>0.01234035585122695, "Chinese"=>0.00017823809834916282, "Czech"=>0.002885117311585762, "Japanese"=>0.002968700348028766, "German"=>0.1280878038945344, "Slovak"=>5.6512012597971665e-08, "Spanish"=>0.00032785780568399226, "Polish"=>0.0028544990520832517, "Esperanto"=>0.00023694498413924753}, {"Swedish"=>0.4924352805804646, "Vietnamese"=>0.028574824174911372, "Romanian"=>0.004185623723173551, "Dutch"=>0.000717033819689362, "Korean"=>0.0030093489153785826, "Danish"=>0.007025280171869988, "Indonesian"=>0.08440475317514011, "Latin"=>6.3586584954475465e-06, "Hungarian"=>0.0011502190555430552, "Persian (Farsi)"=>0.0010381646885128765, "Lithuanian"=>0.00011412332822797365, "French"=>0.001667098294151085, "Norwegian"=>3.287756592031808e-05, "Russian"=>0.02703510969596419, "Thai"=>0.004539642713324699, "Finnish"=>1.7461970114776083e-05, "Spanish"=>0.0001802650418242818, "Bulgarian"=>0.03444115087237797, "Turkish"=>3.362651018138108e-06, "Greek"=>0.004370074503052712, "Tagalog"=>0.19550087861614862, "English"=>0.00029360653028684554, "Arabic"=>0.00023623844077157904, "Italian"=>0.023503714459038007, "Portuguese"=>0.022333271636436114, "Chinese"=>0.0006965151336310375, "Czech"=>0.04074674819624262, "Japanese"=>0.0009679117491250495, "German"=>0.008884609408426256, "Slovak"=>1.6712598842822853e-06, "Hebrew"=>0.001117880506883003, "Polish"=>0.010418042433978408, "Esperanto"=>0.0003508580299930899}], "sentiment"=>[0.9899001220871786, 0.005709885173415242]} 
madisonmay commented 9 years ago

Huh, that's super odd. Regradless, glad to hear things sorted themselves out. Thanks for opening an issue, and feel free to reach out at any point in time and we'll be happy to help however we can!

madisonmay commented 9 years ago

At the very least we'll try to document the issue as best we can, and point folks to some of the same resources we pointed you to on our documentation pages.