Method: Runestone::Settings#corpus

Defined in:
lib/runestone/settings.rb

#corpus(data) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/runestone/settings.rb', line 59

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