class PolyrexSearch
Public Class Methods
new(index_file=nil)
click to toggle source
# File lib/polyrex-search.rb, line 9 def initialize(index_file=nil) if index_file then @polyrex = Polyrex.new(index_file) else @polyrex = Polyrex.new('words/key[word]/location[url]') end end
Public Instance Methods
search(keywords)
click to toggle source
# File lib/polyrex-search.rb, line 18 def search(keywords) a = keywords.split.map {|x| @polyrex.find_by_key_word(x).records.map(&:url) }.flatten freq = a.inject(Hash.new(0)) { |h,v| h[v] += 1; h } freq.sort_by(&:last).reverse end