stimmung 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +34 -0
- data/lib/emoticons.txt +56 -0
- data/lib/german.txt +31281 -0
- data/lib/stimmung.rb +25 -0
- metadata +49 -0
data/lib/stimmung.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class Stimmung
|
2
|
+
attr_accessor :words
|
3
|
+
|
4
|
+
def initialize(*dicts)
|
5
|
+
@words = Hash.new(0.0)
|
6
|
+
if dicts.empty?
|
7
|
+
load_dictionary(File.join(File.dirname(__FILE__), 'emoticons.txt'), File.join(File.dirname(__FILE__), 'german.txt'))
|
8
|
+
else
|
9
|
+
load_dictionary(dicts)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def score(str)
|
14
|
+
str.to_s.downcase.split(/[\s\!\?\.]+/).reduce(0.0){|s,e| s += @words[e] }
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_dictionary(*files)
|
18
|
+
files.each do |file|
|
19
|
+
File.readlines(file).each do |line|
|
20
|
+
score, text = line.chomp.split(/\s/)
|
21
|
+
@words[text] = score.to_f
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stimmung
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pachacamac
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Sentiment analysis for the German language
|
14
|
+
email: pachacamac@inboxalias.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- README.md
|
20
|
+
- lib/emoticons.txt
|
21
|
+
- lib/german.txt
|
22
|
+
- lib/stimmung.rb
|
23
|
+
homepage: https://github.com/pachacamac/stimmung
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- "."
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.4.5
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Simple German sentiment analysis
|
48
|
+
test_files: []
|
49
|
+
has_rdoc:
|