Sha256: d7b3da9d97b9eb462b5829c42bdb82b694a0a7a28fb3bcf8f631146f751d5178
Contents?: true
Size: 614 Bytes
Versions: 1
Compression:
Stored size: 614 Bytes
Contents
module Wc class Reader HIDE_LIST = ['or', 'the', 'of', 'a', 'if', 'to', 'and', 'in', 'is', 'are'] def self.read(filename, hide_list=nil) occurrences = Hash.new { |h, k| h[k] = 0 } File.open(filename, "r") { |f| f.each_line { |line| Wc::Reader.consume(line) } } occurrences end def self.consume(a_text) occurrences = Hash.new { |h, k| h[k] = 0 } words = a_text.split words.each { |w| if ! HIDE_LIST.include?(w.downcase) occurrences[w.downcase] += 1 end } occurrences end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wc-0.99.0 | lib/wc/reader.rb |