summa 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +0 -1
- data/lib/FrequencyAnalyzer.rb +20 -2
- data/lib/summa.rb +22 -2
- metadata +1 -2
- data/lib/helloworld.rb +0 -5
data/Manifest.txt
CHANGED
data/lib/FrequencyAnalyzer.rb
CHANGED
@@ -6,7 +6,7 @@ class FrequencyAnalyzer
|
|
6
6
|
@mean = 0
|
7
7
|
@keywords = [];
|
8
8
|
|
9
|
-
doctext.each { |word|
|
9
|
+
doctext.each(' ') { |word|
|
10
10
|
if word != nil
|
11
11
|
word.removePunctuation!
|
12
12
|
if !@stopwords.include?(word.downcase)
|
@@ -19,7 +19,7 @@ class FrequencyAnalyzer
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
}
|
22
|
-
|
22
|
+
#@freqCount.each {|key, value| puts "#{key} has #{value}" }
|
23
23
|
|
24
24
|
sum = 0
|
25
25
|
count = 0
|
@@ -33,5 +33,23 @@ class FrequencyAnalyzer
|
|
33
33
|
|
34
34
|
@mean = sum/count
|
35
35
|
end
|
36
|
+
|
37
|
+
|
38
|
+
def analyze(k=3)
|
39
|
+
@keywords = [];
|
40
|
+
|
41
|
+
keys = @freqCount.keys
|
42
|
+
for i in 0..keys.length
|
43
|
+
if keys[i] != nil
|
44
|
+
value = @freqCount[keys[i]]
|
45
|
+
if value > k * @mean && keys[i] != ""
|
46
|
+
@keywords << keys[i]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
@keywords
|
51
|
+
end
|
52
|
+
|
53
|
+
attr_accessor :freqCount, :keywords
|
36
54
|
end
|
37
55
|
|
data/lib/summa.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
|
+
|
5
|
+
require 'FrequencyAnalyzer'
|
6
|
+
|
4
7
|
module Summa
|
5
|
-
VERSION = '0.0.
|
8
|
+
VERSION = '0.0.6'
|
6
9
|
end
|
7
10
|
|
8
11
|
class String
|
9
12
|
def summarize
|
10
|
-
puts "
|
13
|
+
puts "Yet even more testing!... of Summa #{VERSION}"
|
11
14
|
end
|
12
15
|
|
13
16
|
def removePunctuation!
|
@@ -28,6 +31,23 @@ class PheremoneAnalysis
|
|
28
31
|
@threshold = SummaData.threshold
|
29
32
|
@output = ""
|
30
33
|
end
|
34
|
+
|
35
|
+
def initialize(text)
|
36
|
+
@document = document
|
37
|
+
@fa = FrequencyAnalysis.new(text)
|
38
|
+
@keywords = fa.analyze()
|
39
|
+
@sigma = SummaData.sigma
|
40
|
+
@sigma_sq = @sigma * @sigma
|
41
|
+
@threshold = SummaData.threshold
|
42
|
+
@output = ""
|
43
|
+
words_in_text = Array.new
|
44
|
+
text.each(' ') { |w| words_in_text.insert(at_end=-1,w) }
|
45
|
+
@pheremones = Array.new(words_in_text.length())
|
46
|
+
for i in 0...words_in_text.length
|
47
|
+
@pheremones[i] = 0
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
31
51
|
|
32
52
|
def analyze()
|
33
53
|
front = 1/(@sigma * Math.sqrt(2 * Math::PI))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: summa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HyLiter.org
|
@@ -42,7 +42,6 @@ files:
|
|
42
42
|
- README.rdoc
|
43
43
|
- Rakefile
|
44
44
|
- lib/summa.rb
|
45
|
-
- lib/helloworld.rb
|
46
45
|
- lib/FrequencyAnalyzer.rb
|
47
46
|
- script/console
|
48
47
|
- script/destroy
|