4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/alchemy_connect.rb', line 4
def self.get_sentiment()
alchemyapi = AlchemyAPI.new
response = alchemyapi.sentiment("text", )
if response["status"] == "OK"
puts '## Response Object ##'
puts JSON.pretty_generate(response)
puts ""
puts '## Document Sentiment ##'
puts "type: " + response["docSentiment"]["type"]
if response["docSentiment"].key?("score")
puts "score: " + response["docSentiment"]["score"]
end
else
puts "Error in sentiment analysis call: " + response["statusInfo"]
end
end
|