artemo 3.1.3 → 3.1.4

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: bf26e4f0d7cb45edef5b71c09ce29ebac9714ea3
4
- data.tar.gz: bfd683dc37102896cb1638a3f8a3110f2e40c226
3
+ metadata.gz: 2e5d7350349eadce2c67667225cc6f4e63665c31
4
+ data.tar.gz: 5b149744bea4ba98acf4ec63a960140e40075f5c
5
5
  SHA512:
6
- metadata.gz: 0b40379ec380e9717ddc9493a113ed61f1e18161b7a108a3e6c841d9ba9bfa25089b74a836c4ad915ce25a3e3525a540e86ea3b3d9a730f5947017e48c8d4bfd
7
- data.tar.gz: 34eb3c2c2fb6af3b8c6c81ab06a0079dd377de99a38923706cdcbd12a34cae8c3c2f0d928984d12431c009fea8cb7949cb89f04257233f5f95c4ea8ab6e0c5a4
6
+ metadata.gz: 75d6302af2ddd330c94474d0c60e42829a84c0fde081f2d54a3a58cd78d5934a83a9ddc5775b9c6e2e1b20e827047a1116d50b2b7af4f071a020444503e9534e
7
+ data.tar.gz: 68f9f9a043db2e5a84c9054ad8536598daa71cab829fd1123ac1a60d6e23882d8436b4c99cc7dc8c52d5ee3bd3b16704d12bec0569468a9a73b29ac59562d6d2
data/CHANGELOG CHANGED
@@ -44,4 +44,7 @@ Version 3.1.2
44
44
  Marshal binary database for faster work.
45
45
 
46
46
  Version 3.1.3
47
- Full documentation is added. Faster comparing word with keyword.
47
+ Full documentation is added. Faster comparing word with keyword.
48
+
49
+ Version 3.1.4
50
+ Add plotting library.
data/Gemfile.lock CHANGED
@@ -1,12 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artemo (3.1.2)
4
+ artemo (3.1.4)
5
+ squid (~> 1.3)
5
6
 
6
7
  GEM
7
8
  remote: http://rubygems.org/
8
9
  specs:
10
+ activesupport (5.0.0.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (~> 0.7)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ concurrent-ruby (1.0.2)
9
16
  diff-lcs (1.2.5)
17
+ i18n (0.7.0)
18
+ minitest (5.9.1)
19
+ pdf-core (0.6.1)
20
+ prawn (2.1.0)
21
+ pdf-core (~> 0.6.1)
22
+ ttfunk (~> 1.4.0)
10
23
  rake (11.3.0)
11
24
  rspec (3.5.0)
12
25
  rspec-core (~> 3.5.0)
@@ -21,6 +34,13 @@ GEM
21
34
  diff-lcs (>= 1.2.0, < 2.0)
22
35
  rspec-support (~> 3.5.0)
23
36
  rspec-support (3.5.0)
37
+ squid (1.3.0)
38
+ activesupport (>= 4.0)
39
+ prawn (~> 2.0)
40
+ thread_safe (0.3.5)
41
+ ttfunk (1.4.0)
42
+ tzinfo (1.2.2)
43
+ thread_safe (~> 0.1)
24
44
  yard (0.9.5)
25
45
 
26
46
  PLATFORMS
data/README.md CHANGED
@@ -68,6 +68,10 @@ Version 3.1.3
68
68
 
69
69
  * Full documentation is added. Faster comparing word with keyword.
70
70
 
71
+ Version 3.1.4
72
+
73
+ * Add plotting library.
74
+
71
75
  ## Examples:
72
76
 
73
77
  ### Adam Mickiewicz - Świtezianka
data/artemo.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.summary = "Analyze emotions in texts"
8
8
  s.description = <<-DESCRIPTION
9
9
  Simple program to analyze emotions in texts by keywords database.
10
- Use by: artemo [your file]
10
+ Use by: artemo [your text file], to plot data to pdf use artemo --plot [your text file]
11
11
  DESCRIPTION
12
12
  s.author = ["Łukasz Fuszara"]
13
13
  s.email = 'opalizoid@gmail.com'
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
20
20
  s.executable = 'artemo'
21
21
  s.require_path = ['lib']
22
22
 
23
+ s.add_runtime_dependency 'squid', '~> 1.3'
24
+
23
25
  s.add_development_dependency 'rake', '~> 11.3'
24
26
  s.add_development_dependency 'rspec', '~> 3.5'
25
27
  s.add_development_dependency 'yard', '~> 0.9.5'
data/lib/artemo.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'squid'
2
+
1
3
  require 'artemo/keywords'
2
4
  require 'artemo/loader'
3
5
 
@@ -5,7 +7,9 @@ require 'artemo/common'
5
7
 
6
8
  require 'artemo/basic_emotions'
7
9
  require 'artemo/complex_emotions'
10
+
8
11
  require 'artemo/result'
12
+ require 'artemo/plot'
9
13
 
10
14
  # @note This class starts all program
11
15
  # @return [Hash] of complex emotions
@@ -25,8 +29,11 @@ class ArtEmo
25
29
  end
26
30
  end
27
31
 
28
- if ARGV.first.nil?
29
- puts "artemo [your text file]"
32
+ if ARGV.empty?
33
+ puts "artemo [your text file], to plot data to pdf use artemo --plot [your text file]"
34
+ elsif ARGV.first != '--plot'
35
+ puts ArtEmo.call(ARGV.last)
30
36
  else
31
- puts ArtEmo.call(ARGV.first)
37
+ to_plot = ArtEmo.call(ARGV.last)
38
+ Plot.call(to_plot)
32
39
  end
data/lib/artemo/loader.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # @note This class loads file with text to analyze
2
- # @return [Array] of whole text
2
+ # @return [Hash] of all text
3
3
  class Loader
4
4
 
5
- # @note This method is loading text, next is removing special characters,
6
- # next is splitting it to Array.
5
+ # @note This method is loading text, next is removing special characters,
6
+ # next is splitting it to Array.
7
7
 
8
8
  def self.call(path)
9
9
  begin
@@ -0,0 +1,15 @@
1
+ # @note This class plots file to pdf
2
+
3
+ class Plot
4
+
5
+ # @note This method is plotting data to pdf.
6
+
7
+ def self.call(hash)
8
+ hash.delete_if{|_,v| v == 0}
9
+ Prawn::Document.generate 'emotions.pdf' do
10
+ data = {views: hash}
11
+ chart data, legend: false, label: true, format: :percentage
12
+ end
13
+ end
14
+ end
15
+
data/lib/artemo/result.rb CHANGED
@@ -12,8 +12,9 @@ class Result
12
12
 
13
13
  def self.show(array_one)
14
14
  results = {}
15
+ _min, max = array_one.minmax
15
16
  array_one.each_index do |index|
16
- results[titles[index]] = array_one[index]
17
+ results[titles[index]] = ((array_one[index].to_f / max.to_f) * 100.0).round(2)
17
18
  end
18
19
  results.sort_by { |_k, v| v }.to_h
19
20
  end
@@ -1,4 +1,4 @@
1
1
  # @note This module returns version
2
2
  module ArtEmo
3
- VERSION = "3.1.3"
3
+ VERSION = "3.1.4"
4
4
  end
@@ -17,8 +17,8 @@ describe Result do
17
17
  it 'min, max' do
18
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])
19
19
  min, max = s.values.minmax
20
- expect(min).to eq 5
21
- expect(max).to eq 700
20
+ expect(min).to eq 0.71
21
+ expect(max).to eq 100.0
22
22
  end
23
23
  end
24
24
  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.3
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Łukasz Fuszara
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: squid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +81,8 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '1.13'
69
83
  description: " Simple program to analyze emotions in texts by keywords database.
70
- \n Use by: artemo [your file]\n"
84
+ \n Use by: artemo [your text file], to plot data to pdf use artemo --plot [your
85
+ text file]\n"
71
86
  email: opalizoid@gmail.com
72
87
  executables:
73
88
  - artemo
@@ -97,6 +112,7 @@ files:
97
112
  - lib/artemo/complex_emotions.rb
98
113
  - lib/artemo/keywords.rb
99
114
  - lib/artemo/loader.rb
115
+ - lib/artemo/plot.rb
100
116
  - lib/artemo/result.rb
101
117
  - lib/artemo/version.rb
102
118
  - spec/.DS_Store