stimmung 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/emoticons.txt +0 -1
- data/lib/stimmung.rb +10 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f9169fc6c1557a510676990396f70de9a8b4cf6
|
4
|
+
data.tar.gz: 07d8be74953098bdd5a104475e03518df04baf15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 497d9424d744ab4b54775857f12b1dfb0293fe289d3f3acb5887bda1ae01e70c84bedcbdefd2b8f22e47900020038c0e284fdb6f75041106e28d2deba9d384cc
|
7
|
+
data.tar.gz: c46e355f12a984014826a005a18e979c3022f9a8d7c27c30a874b928aacc95ad01690d7e99297dfce19ee963698b6cec96c1d137f362427cf4879403304fbd62
|
data/lib/emoticons.txt
CHANGED
data/lib/stimmung.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
+
#<Encoding:UTF-8>
|
2
|
+
|
1
3
|
class Stimmung
|
2
4
|
attr_accessor :words
|
3
5
|
|
4
6
|
def initialize(*dicts)
|
5
7
|
@words = Hash.new(0.0)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
load_dictionary(*dicts)
|
10
|
-
end
|
8
|
+
directory = File.dirname(__FILE__)
|
9
|
+
dicts = %w(emoticons.txt german.txt).map! {|file| File.join(directory, file)} if dicts.empty?
|
10
|
+
load_dictionary(*dicts)
|
11
11
|
end
|
12
12
|
|
13
13
|
def score(str)
|
14
|
-
str.
|
14
|
+
str.downcase.gsub(/(\w{3,})(\W)(?=\s|$)/, '\1').split(/\s|\b(?=\W)/).reduce(0.0) {|s,e| s += @words[e]}
|
15
15
|
end
|
16
16
|
|
17
17
|
def load_dictionary(*files)
|
18
18
|
files.each do |file|
|
19
|
-
File.
|
20
|
-
score, text = line.chomp
|
21
|
-
@words[text] = score.to_f
|
19
|
+
File.foreach(file, :encoding => 'UTF-8') do |line|
|
20
|
+
score, text = line.chomp!.split
|
21
|
+
@words[text.downcase.freeze] = score.to_f
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimmung
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pachacamac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Sentiment analysis for the German language
|
14
14
|
email: pachacamac@inboxalias.com
|