artemo 3.1.4 → 3.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e5d7350349eadce2c67667225cc6f4e63665c31
4
- data.tar.gz: 5b149744bea4ba98acf4ec63a960140e40075f5c
3
+ metadata.gz: 23724fad07817c5010b8bbcceebeaf53821c9576
4
+ data.tar.gz: 86b1473a7688193b0702dbc85cc80e026bd9a904
5
5
  SHA512:
6
- metadata.gz: 75d6302af2ddd330c94474d0c60e42829a84c0fde081f2d54a3a58cd78d5934a83a9ddc5775b9c6e2e1b20e827047a1116d50b2b7af4f071a020444503e9534e
7
- data.tar.gz: 68f9f9a043db2e5a84c9054ad8536598daa71cab829fd1123ac1a60d6e23882d8436b4c99cc7dc8c52d5ee3bd3b16704d12bec0569468a9a73b29ac59562d6d2
6
+ metadata.gz: c4ccff9b0ef6501516c7e38815b075a6c2e61efe513bc3af1baf283076fb38039da8a133635b1061a61da141749b7a5d0e0afde34a88c97671efb80095b509c1
7
+ data.tar.gz: 2a2a13cbd11a294f6901d659ca2c1966fbc1b84d3ca66bafa6ce4422db779685ecfd706f524ea89226d126170ddd32c6b731515315ae7d605483d2a13517c8ce
data/.DS_Store CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -48,3 +48,6 @@ Full documentation is added. Faster comparing word with keyword.
48
48
 
49
49
  Version 3.1.4
50
50
  Add plotting library.
51
+
52
+ Version 3.1.5
53
+ Better scaling mathod.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artemo (3.1.4)
4
+ artemo (3.1.5)
5
5
  squid (~> 1.3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -72,6 +72,10 @@ Version 3.1.4
72
72
 
73
73
  * Add plotting library.
74
74
 
75
+ Version 3.1.5
76
+
77
+ * Better scaling mathod.
78
+
75
79
  ## Examples:
76
80
 
77
81
  ### Adam Mickiewicz - Świtezianka
data/lib/.DS_Store CHANGED
Binary file
@@ -18,6 +18,7 @@ class BasicEmotions < Common
18
18
 
19
19
  # @note This method compare two words, if word is in array text then add one.
20
20
 
21
+ private
21
22
  def self.compare
22
23
  sum_array = Array.new(8).fill(0)
23
24
  @keywords.each.with_index do |line, index|
@@ -31,6 +32,7 @@ class BasicEmotions < Common
31
32
  # @note This method is after inherited method comparing values in gradient,
32
33
  # and it's checking which value is greater, if it's greater then it is true.
33
34
 
35
+ private
34
36
  def self.check(array_one)
35
37
  values_array = Array.new(8).fill(0)
36
38
  array_one.each_index do |index|
@@ -50,6 +52,7 @@ class BasicEmotions < Common
50
52
  # @note This method check which value is true and if it's true add two,
51
53
  # else add one.
52
54
 
55
+ private
53
56
  def self.weigh(array_one, array_two)
54
57
  weighed_array = Array.new(8).fill(0)
55
58
  array_one.each.with_index do |item, index|
@@ -66,6 +69,7 @@ class BasicEmotions < Common
66
69
 
67
70
  # @note This method is expanding 8 element array to 24 element array in ranges.
68
71
 
72
+ private
69
73
  def self.expand(array_one)
70
74
  expanded_array = Array.new(24).fill(0)
71
75
  array_one.each.with_index do |item, index|
data/lib/artemo/common.rb CHANGED
@@ -7,7 +7,7 @@ class Common
7
7
  def self.scale(array_one)
8
8
  min, max = array_one.minmax
9
9
  array_one.each.with_index do |item, index|
10
- array_one[index] = (((100.0 - 0.0) / (max - min)) * (item - max) + 100.0).floor
10
+ array_one[index] = (((100.0 - 1.0) / (max - min)) * (item - max) + 100.0).floor
11
11
  end
12
12
  array_one
13
13
  end
@@ -12,6 +12,7 @@ class ComplexEmotions < Common
12
12
 
13
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
14
 
15
+ private
15
16
  def self.sort(array_one)
16
17
  sorted_array = Array.new(24)
17
18
  tmp_array = Array.new(3)
@@ -29,6 +30,7 @@ class ComplexEmotions < Common
29
30
 
30
31
  # @note This method is summing values if they are greater than 25.
31
32
 
33
+ private
32
34
  def self.sum(array_one)
33
35
  sum_array = Array.new(24).fill(0)
34
36
  index = 0
data/lib/artemo/plot.rb CHANGED
@@ -5,7 +5,6 @@ class Plot
5
5
  # @note This method is plotting data to pdf.
6
6
 
7
7
  def self.call(hash)
8
- hash.delete_if{|_,v| v == 0}
9
8
  Prawn::Document.generate 'emotions.pdf' do
10
9
  data = {views: hash}
11
10
  chart data, legend: false, label: true, format: :percentage
data/lib/artemo/result.rb CHANGED
@@ -1,26 +1,29 @@
1
1
  # @note This class show results
2
2
  # @return [Hash] of sorted complex emotions
3
- class Result
3
+ class Result < Common
4
4
 
5
5
  # @note This method initializes all class
6
6
 
7
7
  def self.call(array_one)
8
- show(array_one)
8
+ scaled = scale(array_one)
9
+ finish(scaled)
9
10
  end
10
11
 
11
12
  # @note This method is showing results.
12
-
13
- def self.show(array_one)
13
+
14
+ private
15
+ def self.finish(array_one)
14
16
  results = {}
15
- _min, max = array_one.minmax
16
17
  array_one.each_index do |index|
17
- results[titles[index]] = ((array_one[index].to_f / max.to_f) * 100.0).round(2)
18
+ results[titles[index]] = array_one[index]
18
19
  end
20
+ results.delete_if{|_k, v| v == 1 || v == 2}
19
21
  results.sort_by { |_k, v| v }.to_h
20
22
  end
21
23
 
22
24
  # @note This method is storing titles of emotions in Array.
23
25
 
26
+ private
24
27
  def self.titles
25
28
  ['love', 'guilt', 'delight', 'submission', 'curiosity', 'sentimentality', 'awe', 'despair', 'shame', 'disappointment', 'revulsion', 'outrage', 'remorse', 'envy', 'pessimism', 'contempt', 'cynicism', 'morbidness', 'aggressiveness', 'pride', 'dominance', 'optimism', 'fatalism', 'anxiety']
26
29
  end
@@ -1,4 +1,4 @@
1
1
  # @note This module returns version
2
2
  module ArtEmo
3
- VERSION = "3.1.4"
3
+ VERSION = "3.1.5"
4
4
  end
@@ -4,32 +4,7 @@ describe BasicEmotions do
4
4
  context 'Basic emotions: ' do
5
5
  it 'call to first method' do
6
6
  be = BasicEmotions.call [['test'], ['test'], ['test'], ['test'], ['test'], ['test'], ['test'], ['test']], ['test']
7
- expect(be).to eq [33, 0, 33, 0, 33, 0, 33, 0, 34, 0, 34, 0, 34, 0, 34, 0, 33, 0, 33, 0, 33, 0, 33, 0]
8
- end
9
-
10
- it 'check method' do
11
- be = BasicEmotions.check([50, 0, 25, 0, 0, 50, 0, 75])
12
- expect(be).to eq [true, false, true, false, false, true, false, true]
13
- end
14
-
15
- it 'weigh method' do
16
- be = BasicEmotions.weigh([50, 25, 25, 12, 25, 50, 35, 75], [true, false, true, false, false, true, false, true])
17
- expect(be).to eq [100, 25, 50, 12, 25, 100, 35, 150]
18
- end
19
-
20
- it 'scale method' do
21
- be = BasicEmotions.scale([100, 25, 50, 12, 25, 100, 35, 150])
22
- expect(be).to eq [63, 9, 27, 0, 9, 63, 16, 100]
23
- end
24
-
25
- it 'expand method #1' do
26
- be = BasicEmotions.expand([63, 9, 27, 0, 9, 63, 16, 100])
27
- expect(be).to eq [0, 0, 0, 0, 0, 0, 0, 33, 30, 0, 0, 0, 0, 30, 0, 34, 33, 9, 27, 0, 9, 33, 16, 33]
28
- end
29
-
30
- it 'expand method #2' do
31
- be = BasicEmotions.expand([100, 100, 0, 0, 0, 0, 0, 0])
32
- expect(be).to eq [33, 33, 0, 0, 0, 0, 0, 0, 34, 34, 0, 0, 0, 0, 0, 0, 33, 33, 0, 0, 0, 0, 0, 0]
7
+ expect(be).to eq [33, 0, 33, 0, 33, 0, 33, 0, 34, 0, 34, 0, 34, 0, 34, 0, 33, 1, 33, 1, 33, 1, 33, 1]
33
8
  end
34
9
  end
35
10
  end
@@ -4,7 +4,7 @@ describe Common do
4
4
  context 'Common method ' do
5
5
  it 'scale' do
6
6
  s = Common.scale([500, 250, 100, 50, 25, 0, -75])
7
- expect(s).to eq [100, 56, 30, 21, 17, 13, 0]
7
+ expect(s).to eq [100, 56, 31, 22, 18, 13, 1]
8
8
  end
9
9
  end
10
10
  end
@@ -6,20 +6,5 @@ describe ComplexEmotions do
6
6
  ce = ComplexEmotions.call [33, 33, 0, 0, 0, 0, 0, 0, 34, 34, 0, 0, 0, 0, 0, 0, 33, 33, 0, 0, 0, 0, 0, 0]
7
7
  expect(ce).to eq [97, 97, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
8
8
  end
9
-
10
- it 'sort method' do
11
- ce = ComplexEmotions.sort [97, 97, 0, 0, 0, 0, 0, 0, 100, 100, 0, 0, 0, 0, 0, 0, 97, 97, 0, 0, 0, 0, 0, 0]
12
- expect(ce).to eq [97, 100, 97, 97, 100, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
13
- end
14
-
15
- it 'sum method #1' do
16
- ce = ComplexEmotions.sum [97, 97, 0, 0, 0, 0, 0, 0, 100, 100, 0, 0, 0, 0, 0, 0, 97, 97, 0, 0, 0, 0, 0, 0]
17
- expect(ce).to eq [97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
18
- end
19
-
20
- it 'sum method #2' do
21
- ce = ComplexEmotions.sum [100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0]
22
- expect(ce).to eq [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 200, 0, 0]
23
- end
24
9
  end
25
10
  end
@@ -3,21 +3,21 @@ require 'artemo'
3
3
  describe Result do
4
4
  context 'Results ' do
5
5
  it 'show love' do
6
- s = Result.show([100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
6
+ s = Result.call([100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
7
7
  sh = s.keys.last
8
8
  expect(sh).to eq "love"
9
9
  end
10
10
 
11
11
  it 'show despair' do
12
- s = Result.show([0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
12
+ s = Result.call([0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
13
13
  sh = s.keys.last
14
14
  expect(sh).to eq "despair"
15
15
  end
16
16
 
17
17
  it 'min, max' do
18
- s = Result.show([100, 30, 30, 30, 30, 30, 30, 5, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 700, 30])
18
+ s = Result.call([100, 30, 30, 30, 30, 30, 30, 5, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 700, 30])
19
19
  min, max = s.values.minmax
20
- expect(min).to eq 0.71
20
+ expect(min).to eq 4.0
21
21
  expect(max).to eq 100.0
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artemo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Łukasz Fuszara