artemo 3.1.2 → 3.1.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/.DS_Store +0 -0
- data/CHANGELOG +4 -1
- data/README.md +4 -0
- data/lib/artemo/.DS_Store +0 -0
- data/lib/artemo/basic_emotions.rb +13 -3
- data/lib/artemo/common.rb +4 -1
- data/lib/artemo/complex_emotions.rb +7 -0
- data/lib/artemo/keywords.rb +4 -1
- data/lib/artemo/loader.rb +4 -0
- data/lib/artemo/result.rb +9 -2
- data/lib/artemo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf26e4f0d7cb45edef5b71c09ce29ebac9714ea3
|
4
|
+
data.tar.gz: bfd683dc37102896cb1638a3f8a3110f2e40c226
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b40379ec380e9717ddc9493a113ed61f1e18161b7a108a3e6c841d9ba9bfa25089b74a836c4ad915ce25a3e3525a540e86ea3b3d9a730f5947017e48c8d4bfd
|
7
|
+
data.tar.gz: 34eb3c2c2fb6af3b8c6c81ab06a0079dd377de99a38923706cdcbd12a34cae8c3c2f0d928984d12431c009fea8cb7949cb89f04257233f5f95c4ea8ab6e0c5a4
|
data/.DS_Store
CHANGED
Binary file
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
data/lib/artemo/.DS_Store
CHANGED
Binary file
|
@@ -4,6 +4,8 @@ class BasicEmotions < Common
|
|
4
4
|
attr_reader :keywords
|
5
5
|
attr_reader :text
|
6
6
|
|
7
|
+
# @note This method initializes class
|
8
|
+
|
7
9
|
def self.call(keywords, text)
|
8
10
|
@keywords = keywords
|
9
11
|
@text = text
|
@@ -14,18 +16,21 @@ class BasicEmotions < Common
|
|
14
16
|
expand(scaled_array)
|
15
17
|
end
|
16
18
|
|
19
|
+
# @note This method compare two words, if word is in array text then add one.
|
20
|
+
|
17
21
|
def self.compare
|
18
22
|
sum_array = Array.new(8).fill(0)
|
19
23
|
@keywords.each.with_index do |line, index|
|
20
24
|
line.each do |keyword|
|
21
|
-
@text.
|
22
|
-
sum_array[index] += 1 if keyword == word
|
23
|
-
end
|
25
|
+
sum_array[index] += 1 if @text.include?(keyword)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
sum_array
|
27
29
|
end
|
28
30
|
|
31
|
+
# @note This method is after inherited method comparing values in gradient,
|
32
|
+
# and it's checking which value is greater, if it's greater then it is true.
|
33
|
+
|
29
34
|
def self.check(array_one)
|
30
35
|
values_array = Array.new(8).fill(0)
|
31
36
|
array_one.each_index do |index|
|
@@ -42,6 +47,9 @@ class BasicEmotions < Common
|
|
42
47
|
values_array
|
43
48
|
end
|
44
49
|
|
50
|
+
# @note This method check which value is true and if it's true add two,
|
51
|
+
# else add one.
|
52
|
+
|
45
53
|
def self.weigh(array_one, array_two)
|
46
54
|
weighed_array = Array.new(8).fill(0)
|
47
55
|
array_one.each.with_index do |item, index|
|
@@ -56,6 +64,8 @@ class BasicEmotions < Common
|
|
56
64
|
weighed_array
|
57
65
|
end
|
58
66
|
|
67
|
+
# @note This method is expanding 8 element array to 24 element array in ranges.
|
68
|
+
|
59
69
|
def self.expand(array_one)
|
60
70
|
expanded_array = Array.new(24).fill(0)
|
61
71
|
array_one.each.with_index do |item, index|
|
data/lib/artemo/common.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# @note This class have all common classes for all program
|
2
|
-
# @return [Array] of scaled emotions in range 0
|
2
|
+
# @return [Array] of scaled emotions in range 0..100
|
3
3
|
class Common
|
4
|
+
|
5
|
+
# @note This method is scaling values in range 1..100
|
6
|
+
|
4
7
|
def self.scale(array_one)
|
5
8
|
min, max = array_one.minmax
|
6
9
|
array_one.each.with_index do |item, index|
|
@@ -1,12 +1,17 @@
|
|
1
1
|
# @note This class analyze complex emotions
|
2
2
|
# @return [Array] of sum of sorted complex emotions
|
3
3
|
class ComplexEmotions < Common
|
4
|
+
|
5
|
+
# @note This method initializes class
|
6
|
+
|
4
7
|
def self.call(array_one)
|
5
8
|
scaled_array = scale(array_one)
|
6
9
|
sorted_array = sort(scaled_array)
|
7
10
|
sum(sorted_array)
|
8
11
|
end
|
9
12
|
|
13
|
+
# @note This method is sorting values by pattern x+0, x+8, x+16 then (x*3), (x*3)+1, (x*3)+2.
|
14
|
+
|
10
15
|
def self.sort(array_one)
|
11
16
|
sorted_array = Array.new(24)
|
12
17
|
tmp_array = Array.new(3)
|
@@ -22,6 +27,8 @@ class ComplexEmotions < Common
|
|
22
27
|
sorted_array
|
23
28
|
end
|
24
29
|
|
30
|
+
# @note This method is summing values if they are greater than 25.
|
31
|
+
|
25
32
|
def self.sum(array_one)
|
26
33
|
sum_array = Array.new(24).fill(0)
|
27
34
|
index = 0
|
data/lib/artemo/keywords.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# @note This class create database of keywords
|
2
2
|
# @return [Array] of keywords
|
3
3
|
class Keywords
|
4
|
-
|
4
|
+
|
5
|
+
# @note This method is loading database of emotions (source: http://saifmohammad.com)
|
6
|
+
# in binary format.
|
7
|
+
|
5
8
|
def self.call
|
6
9
|
include = File.expand_path('../../../include/database.db', __FILE__)
|
7
10
|
f = File.open(include, "rb")
|
data/lib/artemo/loader.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# @note This class loads file with text to analyze
|
2
2
|
# @return [Array] of whole text
|
3
3
|
class Loader
|
4
|
+
|
5
|
+
# @note This method is loading text, next is removing special characters,
|
6
|
+
# next is splitting it to Array.
|
7
|
+
|
4
8
|
def self.call(path)
|
5
9
|
begin
|
6
10
|
File.read(File.expand_path(path)).gsub!(/[^a-zA-Z ]/, '').downcase!.split(' ')
|
data/lib/artemo/result.rb
CHANGED
@@ -1,18 +1,25 @@
|
|
1
|
-
# @note This class show
|
1
|
+
# @note This class show results
|
2
2
|
# @return [Hash] of sorted complex emotions
|
3
3
|
class Result
|
4
|
+
|
5
|
+
# @note This method initializes all class
|
6
|
+
|
4
7
|
def self.call(array_one)
|
5
8
|
show(array_one)
|
6
9
|
end
|
7
10
|
|
11
|
+
# @note This method is showing results.
|
12
|
+
|
8
13
|
def self.show(array_one)
|
9
14
|
results = {}
|
10
15
|
array_one.each_index do |index|
|
11
16
|
results[titles[index]] = array_one[index]
|
12
17
|
end
|
13
|
-
results
|
18
|
+
results.sort_by { |_k, v| v }.to_h
|
14
19
|
end
|
15
20
|
|
21
|
+
# @note This method is storing titles of emotions in Array.
|
22
|
+
|
16
23
|
def self.titles
|
17
24
|
['love', 'guilt', 'delight', 'submission', 'curiosity', 'sentimentality', 'awe', 'despair', 'shame', 'disappointment', 'revulsion', 'outrage', 'remorse', 'envy', 'pessimism', 'contempt', 'cynicism', 'morbidness', 'aggressiveness', 'pride', 'dominance', 'optimism', 'fatalism', 'anxiety']
|
18
25
|
end
|
data/lib/artemo/version.rb
CHANGED