textmood 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -4
- data/lib/textmood.rb +6 -2
- metadata +1 -1
data/README.md
CHANGED
@@ -51,7 +51,7 @@ You can use it in a Ruby program like this:
|
|
51
51
|
```ruby
|
52
52
|
require "textmood"
|
53
53
|
|
54
|
-
# The :
|
54
|
+
# The :language parameter makes TextMood use one of the bundled language sentiment files
|
55
55
|
tm = TextMood.new(language: "en")
|
56
56
|
score = tm.analyze("some text")
|
57
57
|
#=> '1.121'
|
@@ -133,10 +133,10 @@ output from `textmood -h`:
|
|
133
133
|
```
|
134
134
|
Usage: textmood [options] "<text>"
|
135
135
|
OR
|
136
|
-
echo "<text>" | textmood [options]
|
136
|
+
echo "<text>" | textmood [options]"
|
137
137
|
|
138
|
-
Returns a
|
139
|
-
|
138
|
+
Returns a sentiment score of the provided text. Above 0 is usually
|
139
|
+
considered positive, below is considered negative.
|
140
140
|
|
141
141
|
MANDATORY options:
|
142
142
|
-l, --language LANGUAGE The IETF language tag for the provided text.
|
@@ -181,6 +181,10 @@ OPTIONAL options:
|
|
181
181
|
-k, --skip-symbols Do not include symbols file (emoticons etc.). Only applies
|
182
182
|
when using -l/--language.
|
183
183
|
|
184
|
+
-c, --config PATH TO FILE Use the specified config file. If not specified, textmood will look
|
185
|
+
for /etc/textmood.cfg and ~/.textmood. Settings in the user config
|
186
|
+
will override settings from the global file.
|
187
|
+
|
184
188
|
-d, --debug Prints out the score for each token in the provided text
|
185
189
|
or 'nil' if the token was not found in the sentiment file
|
186
190
|
|
data/lib/textmood.rb
CHANGED
@@ -138,8 +138,12 @@ class TextMood
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def normalize_score(score, count)
|
141
|
-
|
142
|
-
|
141
|
+
if score != 0
|
142
|
+
factor = NORMALIZE_TO.to_f / count.to_f
|
143
|
+
(score * factor).round
|
144
|
+
else
|
145
|
+
score
|
146
|
+
end
|
143
147
|
end
|
144
148
|
|
145
149
|
end
|