Method: Runestone::Settings#corpus

Defined in:
lib/runestone/settings.rb

#corpus(data) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/runestone/settings.rb', line 76

def corpus(data)
  words = []
  
  @indexes.each do |weight, paths|
    paths.each do |path|
      dig(data, path.to_s.split('.')).each do |value|
        next if !value
        value.to_s.split(/\s+/).each do |word|
          words << word.downcase.gsub(/\A\W/, '').gsub(/\W\Z/, '')
        end
      end
    end
  end
  
  words
end