Class: Analyser

Inherits:
Object
  • Object
show all
Defined in:
lib/engine/analyser.rb

Instance Method Summary collapse

Constructor Details

#initializeAnalyser

Returns a new instance of Analyser.



6
7
8
9
# File 'lib/engine/analyser.rb', line 6

def initialize
  @positive = Corpus.new
  @negative = Corpus.new
end

Instance Method Details

#analyse(sentence) ⇒ Object



23
24
25
# File 'lib/engine/analyser.rb', line 23

def analyse sentence
  Classifier.new(@positive, @negative).classify(sentence)
end

#train_negative(path) ⇒ Object



17
18
19
20
21
# File 'lib/engine/analyser.rb', line 17

def train_negative path
  puts 'Training analyser with -ve sentiment'
  @negative.load_from_directory path
  puts '-ve sentiment training complete'
end

#train_positive(path) ⇒ Object



11
12
13
14
15
# File 'lib/engine/analyser.rb', line 11

def train_positive path
  puts 'Training analyser with +ve sentiment'
  @positive.load_from_directory path
  puts '+ve sentiment training complete'
end