Class: Sentra::ProcessingClient

Inherits:
Object
  • Object
show all
Defined in:
lib/sentra/sents.rb

Instance Method Summary collapse

Constructor Details

#initializeProcessingClient

Returns a new instance of ProcessingClient.



3
4
5
6
7
8
# File 'lib/sentra/sents.rb', line 3

def initialize
  @tweet = OprData::Article.new
  @queue = SemanticService::UnixSocketClient.new()

  p "initializing"
end

Instance Method Details

#prepare_article(content, url, title, domain = 'GENERAL') ⇒ Object



10
11
12
13
14
15
16
17
# 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) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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

#receiveObject



29
30
31
32
33
34
35
# File 'lib/sentra/sents.rb', line 29

def receive
  p 'receiving'
  result = @queue.ReceiveText()
  p 'read done'
  p result.content
  result.('twitter').getFacts()
end

#sendObject



19
20
21
22
23
24
25
26
# File 'lib/sentra/sents.rb', line 19

def send

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


end