class Sentra::ProcessingClient

Public Class Methods

new() click to toggle source
# File lib/sentra/sents.rb, line 3
def initialize
  @tweet = OprData::Article.new
  @queue = SemanticService::UnixSocketClient.new()

  p "initializing"
end

Public Instance Methods

prepare_article(content, url, title, domain='GENERAL') click to toggle source
# File lib/sentra/sents.rb, line 10
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) click to toggle source
# File lib/sentra/sents.rb, line 37
def process_result statistics
  response = {}
  # puts 'here statistics'
  # p statistics
  if statistics[3].getValue.to_f > 0
    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

  else
    response['negative'] = 0
    response['positive'] = 0
    response['neutral'] = 1

  end
  response['details'] = {}
  response
end
receive() click to toggle source
# File lib/sentra/sents.rb, line 29
def receive
  p 'receiving'
  result = @queue.ReceiveText()
  p 'read done'
  p result.content
  result.getMetadata('twitter').getFacts()
end
send() click to toggle source
# File lib/sentra/sents.rb, line 19
def send

  p 'sending'
  p @tweet.content
  @queue.SendText(@tweet)


end