Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/summa.rb,
lib/SummaUtils.rb

Instance Method Summary collapse

Instance Method Details

#frequentObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/SummaUtils.rb', line 7

def frequent
  @freqCount = {}
  @stopwords = SummaData.stopwords
  @mean = 0
  @keywords = [];

  self.each(' ') { |word|
    if word != nil
      word.removePunctuation!
      word.delete!(' ')
      if !@stopwords.include?(word.downcase)
        #stemmed = word.stem
        if @freqCount.has_key?(word)
          @freqCount[word] = @freqCount[word] + 1
        else
          @freqCount[word] = 1
        end
      end
    end
  }

  sum = 0
  count = 0
  keys = @freqCount.keys
  for i in 0..keys.length
    if keys[i] != nil
      sum = sum + @freqCount[keys[i]]
      count = count + 1
    end
  end

  @mean = sum/count

  keys = @freqCount.keys
#    p keys
  for i in 0..keys.length
    if keys[i] != nil
      value = @freqCount[keys[i]]
      if value > 2 * @mean && keys[i] != ""
        @keywords << keys[i]
#           p @keywords
      end
    end
  end
  @keywords
end

#removePunctuation!Object



3
4
5
# File 'lib/SummaUtils.rb', line 3

def removePunctuation!
  self.delete!(".,-:;()?!\"\'*_")
end

#summaryObject



12
13
14
# File 'lib/summa.rb', line 12

def summary
puts "11..." 
end