tonality_analyser 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,11 +64,11 @@ module TonalityAnalyser
|
|
64
64
|
neg_proba = analysis(text, :neg)
|
65
65
|
pos_proba >= neg_proba ? :pos : :neg
|
66
66
|
end
|
67
|
-
def load_traning_corpus!
|
68
|
-
TONALITIES.each { |tonality| load_traning_corpus_for(tonality) }
|
67
|
+
def load_traning_corpus!(dir)
|
68
|
+
TONALITIES.each { |tonality| load_traning_corpus_for(dir, tonality) }
|
69
69
|
end
|
70
|
-
def load_traning_corpus_for(tonality)
|
71
|
-
File.open("
|
70
|
+
def load_traning_corpus_for(dir, tonality)
|
71
|
+
File.open("#{dir}/#{tonality}.txt", 'r') do |f|
|
72
72
|
f.each_line { |line| train(line, tonality) }
|
73
73
|
f.close
|
74
74
|
end
|
@@ -5,7 +5,7 @@ describe TonalityAnalyser::Engine do
|
|
5
5
|
# Woouuu Wouuuu les test de la mort :)
|
6
6
|
it 'propose tonality' do
|
7
7
|
e = TonalityAnalyser::Engine.new
|
8
|
-
e.load_traning_corpus!
|
8
|
+
e.load_traning_corpus!('training')
|
9
9
|
e.compute_probabilities!
|
10
10
|
e.tonality('This').should == :neg
|
11
11
|
e.tonality('Unacceptable') == :neg
|