sad_panda 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module SadPanda
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe EmotionBank do
4
+
5
+ let(:output) {EmotionBank.get_term_emotions}
6
+
7
+ describe "when EmotionBank module is called" do
8
+ it 'returns a hash' do
9
+ expect(output.class).to eql(Hash)
10
+ end
11
+
12
+ it "is non-empty" do
13
+ expect(output).to_not be_empty
14
+ end
15
+ end
16
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
1
  require 'sad_panda/version'
2
2
  require 'sad_panda/status_message'
3
- require 'lingua/stemmer'
3
+ require 'lingua/stemmer'
4
+ require './lib/sad_panda/emotions/emotion_bank'
5
+ require './lib/sad_panda/emotions/term_polarities'
6
+ require './lib/sad_panda/emotions/stopwords'
@@ -4,8 +4,8 @@ module SadPanda
4
4
  describe StatusMessage do
5
5
 
6
6
  let(:status_message) {SadPanda::StatusMessage.new "a message"}
7
- let(:emotions) {status_message.get_term_emotions}
8
- let(:polarities) {status_message.get_term_polarities}
7
+ let(:emotions) {EmotionBank.get_term_emotions}
8
+ let(:polarities) {TermPolarities.get_term_polarities}
9
9
  let(:term_frequencies) {status_message.build_term_frequencies}
10
10
 
11
11
  describe "when initialized" do
@@ -38,30 +38,6 @@ module SadPanda
38
38
  end
39
39
  end
40
40
 
41
- describe "when 'get_term_emotions method' is called" do
42
- it 'returns a hash' do
43
- output = status_message.get_term_emotions
44
- expect(output.class).to eql(Hash)
45
- end
46
-
47
- it "is non-empty" do
48
- output = status_message.get_term_emotions
49
- expect(output).to_not be_empty
50
- end
51
- end
52
-
53
- describe "when 'get_term_polarities' method is called" do
54
- it "returns a hash" do
55
- output = status_message.get_term_polarities
56
- expect(output.class).to eql(Hash)
57
- end
58
-
59
- it "is non empty" do
60
- output = status_message.get_term_polarities
61
- expect(output).to_not be_empty
62
- end
63
- end
64
-
65
41
  describe "when 'get_emotion_score' method is called" do
66
42
  it 'returns a string' do
67
43
  output = status_message.get_emotion_score emotions,term_frequencies
@@ -126,14 +102,14 @@ module SadPanda
126
102
  end
127
103
 
128
104
  context "when status_message == 'blarg' " do
129
- it "emotion == 'Uncertain' " do
105
+ it "emotion == 'uncertain' " do
130
106
  status_message = SadPanda::StatusMessage.new "blarg"
131
- expect(status_message.emotion).to eql('Uncertain')
107
+ expect(status_message.emotion).to eql('uncertain')
132
108
  end
133
109
  end
134
110
 
135
111
  context "when status_message == ' ' " do
136
- it "emotion is 'Uncertain'" do
112
+ it "emotion is 'uncertain'" do
137
113
  status_message = SadPanda::StatusMessage.new " "
138
114
  end
139
115
  end
@@ -157,49 +133,49 @@ module SadPanda
157
133
  context "when status_message == 'sad' " do
158
134
  it "polarity is less than zero" do
159
135
  status_message = SadPanda::StatusMessage.new "sad"
160
- expect(status_message.polarity).to be < 0
136
+ expect(status_message.polarity).to be < 5
161
137
  end
162
138
  end
163
139
 
164
- context "when status_message == 'angry' " do
165
- it "polarity is less than zero" do
166
- status_message = SadPanda::StatusMessage.new "angry"
167
- expect(status_message.polarity).to be < 0
140
+ context "when status_message == 'anger' " do
141
+ it "polarity is zero" do
142
+ status_message = SadPanda::StatusMessage.new "anger"
143
+ expect(status_message.polarity).to be < 5
168
144
  end
169
145
  end
170
146
 
171
147
  context "when status_message == 'I am terrified' " do
172
- it "polarity is less than zero" do
148
+ it "polarity is zero" do
173
149
  status_message = SadPanda::StatusMessage.new "I am fearful"
174
- expect(status_message.polarity).to be < 0
150
+ expect(status_message.polarity).to be < 5
175
151
  end
176
152
  end
177
153
 
178
154
  context "when status == 'I am disgusted' " do
179
155
  it "has a non-zero polarity value" do
180
156
  status_message = SadPanda::StatusMessage.new "I am disgusted"
181
- expect(status_message.polarity).to be < 0
157
+ expect(status_message.polarity).to be < 5
182
158
  end
183
159
  end
184
160
 
185
161
  context "when status == 'This is surprising'" do
186
- it "has a non-zero polarity value" do
162
+ it "has a neutral polarity value" do
187
163
  status_message = SadPanda::StatusMessage.new "This is surprising"
188
- expect(status_message.polarity).to_not eql(0)
164
+ expect(status_message.polarity).to eql(5)
189
165
  end
190
166
  end
191
167
 
192
168
  context "when status_message == 'blarg' " do
193
169
  it "polarity is zero" do
194
170
  status_message = SadPanda::StatusMessage.new "blarg"
195
- expect(status_message.polarity).to eql(0)
171
+ expect(status_message.polarity).to eql(5)
196
172
  end
197
173
  end
198
174
 
199
175
  context "when status_message == ' ' " do
200
176
  it "polarity is zero" do
201
177
  status_message = SadPanda::StatusMessage.new " "
202
- expect(status_message.polarity).to eql(0)
178
+ expect(status_message.polarity).to eql(5)
203
179
  end
204
180
  end
205
181
 
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe TermPolarities do
4
+ describe "when TermPolarities module is called" do
5
+
6
+ let(:output) {TermPolarities.get_term_polarities}
7
+
8
+ it "returns a hash" do
9
+ expect(output.class).to eql(Hash)
10
+ end
11
+
12
+ it "is non empty" do
13
+ expect(output).to_not be_empty
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sad_panda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-23 00:00:00.000000000 Z
12
+ date: 2013-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -91,14 +91,18 @@ files:
91
91
  - Rakefile
92
92
  - lib/sad_panda.rb
93
93
  - lib/sad_panda/emotions/datalist
94
+ - lib/sad_panda/emotions/emotion_bank.rb
94
95
  - lib/sad_panda/emotions/emotions.csv
96
+ - lib/sad_panda/emotions/stopwords.rb
95
97
  - lib/sad_panda/emotions/subjectivity.csv
98
+ - lib/sad_panda/emotions/term_polarities.rb
96
99
  - lib/sad_panda/status_message.rb
97
100
  - lib/sad_panda/version.rb
98
101
  - sad_panda.gemspec
102
+ - spec/emotion_bank_spec.rb
99
103
  - spec/spec_helper.rb
100
104
  - spec/status_message_spec.rb
101
- - spec/version_spec.rb
105
+ - spec/term_polarities_spec.rb
102
106
  homepage: ''
103
107
  licenses:
104
108
  - MIT
@@ -126,6 +130,7 @@ specification_version: 3
126
130
  summary: ! 'sad_panda is a gem featuring tools for sentiment analysis of natural language:
127
131
  positivity/negativity and emotion classification.'
128
132
  test_files:
133
+ - spec/emotion_bank_spec.rb
129
134
  - spec/spec_helper.rb
130
135
  - spec/status_message_spec.rb
131
- - spec/version_spec.rb
136
+ - spec/term_polarities_spec.rb
data/spec/version_spec.rb DELETED
File without changes