zipfy 1.0.1 → 1.0.2
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/Gemfile +2 -0
- data/lib/zipfy/version.rb +1 -1
- data/lib/zipfy.rb +5 -2
- 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: 17e618c03b645632d79392e3c654de7fc20411cf
|
4
|
+
data.tar.gz: aa0d47c69385a7ff49024985c064786d2a06ea26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2485f416b1cde499f19deeb05c99b2293655759229b046b8aa0b7bf9f73c11643dae3af35d5880a387249e8b0e0e5c2e05b1d3a545909da06d17a89683181c5
|
7
|
+
data.tar.gz: af86ef5e591acc56b4a429645e059dc449d6c8da7cc5744bfea5a58f96b0860535e41701ce6e339677cef8447199864a4ff82b430ae59b53109cff89248bc988
|
data/Gemfile
CHANGED
data/lib/zipfy/version.rb
CHANGED
data/lib/zipfy.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
begin #dev optional gems
|
2
2
|
require 'pry'
|
3
3
|
rescue LoadError
|
4
|
+
STDERR.puts "some dev deps not installed .. ignoring"
|
4
5
|
#probably a travis or non-dev build
|
5
6
|
end
|
6
7
|
|
@@ -47,6 +48,7 @@ module Zipfy
|
|
47
48
|
temp_hash.keys.each do |k|
|
48
49
|
@distribution << WordData.new(k, temp_hash[k])
|
49
50
|
end
|
51
|
+
sort_distribution
|
50
52
|
end
|
51
53
|
|
52
54
|
def sort_distribution
|
@@ -97,12 +99,13 @@ module Zipfy
|
|
97
99
|
|
98
100
|
#must calculate zipfness first
|
99
101
|
def calculate_std_dev_from_reg
|
100
|
-
#
|
102
|
+
#binding.pry
|
103
|
+
#the zipfness should be equal to 1/rank. lets see the average deviation from that number
|
101
104
|
length = @distribution.length
|
102
105
|
deviations = []
|
103
106
|
|
104
107
|
@distribution.each_with_index do |wd,i|
|
105
|
-
theoretical = 1/(length - i).to_f
|
108
|
+
theoretical = 1.0/(length - i).to_f
|
106
109
|
actual = wd.zip_number
|
107
110
|
deviation = (theoretical - actual).abs
|
108
111
|
deviations << deviation
|