Class: Sentra::ProcessingClient
- Inherits:
-
Object
- Object
- Sentra::ProcessingClient
- Defined in:
- lib/sentra/sents.rb
Instance Method Summary collapse
-
#initialize ⇒ ProcessingClient
constructor
A new instance of ProcessingClient.
- #prepare_article(content, url, title, domain = 'GENERAL') ⇒ Object
- #process_result(statistics) ⇒ Object
- #send ⇒ Object
Constructor Details
#initialize ⇒ ProcessingClient
Returns a new instance of ProcessingClient.
3 4 5 6 7 |
# File 'lib/sentra/sents.rb', line 3 def initialize @tweet = OprData::Article.new p "initializing" end |
Instance Method Details
#prepare_article(content, url, title, domain = 'GENERAL') ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/sentra/sents.rb', line 8 def prepare_article content, url, title,domain='GENERAL' calendar = Util::Calendar.getInstance(); @tweet.setUrl(Net::URL.new(url)); @tweet.setDate(calendar.getTime) @tweet.setTitle(title) @tweet.setChannel(domain) @tweet.setContent(content) end |
#process_result(statistics) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/sentra/sents.rb', line 28 def process_result statistics response = {} response['negative'] = statistics[0].getValue.to_f / statistics[3].getValue.to_f response['positive'] = statistics[1].getValue.to_f / statistics[3].getValue.to_f response['neutral'] = statistics[2].getValue.to_f / statistics[3].getValue.to_f response['details'] = {} response end |
#send ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sentra/sents.rb', line 16 def send p 'sending' queue = SemanticService::UnixSocketClient.new() queue.writeArticle(@tweet) p 'receiving' result = queue.readArticle() p 'read done' result.getMetadata('twitter').getFacts() end |