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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b14cd389857ce36b0935981f62c4a19f4a80c1b7
4
- data.tar.gz: 24418d8508b9a790d0ec148a62d21c3ea1d15a17
3
+ metadata.gz: bf26e4f0d7cb45edef5b71c09ce29ebac9714ea3
4
+ data.tar.gz: bfd683dc37102896cb1638a3f8a3110f2e40c226
5
5
  SHA512:
6
- metadata.gz: '0149c68d210643046ea48edfdeedec0b82c49ea4bf14129e4abf3d7b562443bc34e92a3e0ab74fe30a4f0274a850f953a728cd2062bb75e49f4417795cdfd24a'
7
- data.tar.gz: 662fc2decc820ed164a674460c7853c04cda8c363b9f8de75671d0229c29bcf8cbc3c539a1cb64597909cff1170ec3e59cb98f4b03ed1f2a62a7925089360c9c
6
+ metadata.gz: 0b40379ec380e9717ddc9493a113ed61f1e18161b7a108a3e6c841d9ba9bfa25089b74a836c4ad915ce25a3e3525a540e86ea3b3d9a730f5947017e48c8d4bfd
7
+ data.tar.gz: 34eb3c2c2fb6af3b8c6c81ab06a0079dd377de99a38923706cdcbd12a34cae8c3c2f0d928984d12431c009fea8cb7949cb89f04257233f5f95c4ea8ab6e0c5a4
data/.DS_Store CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -41,4 +41,7 @@ Version 3.1.1
41
41
  Last small fixes.
42
42
 
43
43
  Version 3.1.2
44
- Marshal binary database for faster work.
44
+ Marshal binary database for faster work.
45
+
46
+ Version 3.1.3
47
+ Full documentation is added. Faster comparing word with keyword.
data/README.md CHANGED
@@ -64,6 +64,10 @@ Version 3.1.2
64
64
 
65
65
  * Marshal binary database for faster work.
66
66
 
67
+ Version 3.1.3
68
+
69
+ * Full documentation is added. Faster comparing word with keyword.
70
+
67
71
  ## Examples:
68
72
 
69
73
  ### Adam Mickiewicz - Świtezianka
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.each do |word|
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-100
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
@@ -1,7 +1,10 @@
1
1
  # @note This class create database of keywords
2
2
  # @return [Array] of keywords
3
3
  class Keywords
4
- # Databases of emotions (source: http://saifmohammad.com/WebPages/NRC-Emotion-Lexicon.htm)
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 result
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 = results.sort_by { |_k, v| v }.to_h
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
@@ -1,4 +1,4 @@
1
1
  # @note This module returns version
2
2
  module ArtEmo
3
- VERSION = "3.1.2"
3
+ VERSION = "3.1.3"
4
4
  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.2
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Łukasz Fuszara