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
# 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

#sendObject



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.('twitter').getFacts()

end