All pastes #824331 Raw Edit

Stuff

public text v1 · immutable
·published 2007-12-19 22:15 UTC
rendered paste body
class SearchEngine
  def self.query(query)

    #Execute the command
    command_output = `java Search index/wikidb_quality '#{query}'`
    
    #Iterate through the results adding them to the results array
    results = []
    i = 1
    command_output.split("\n").each do |f|
      result = ResultItem.new
      result.id = i
      #delimit is manual for now, set in Search.java, note index
      result.title = f.split('----')
      result.link = "http://en.wikipedia.org/wiki/#{result.title[0]}"
      results << result
      i += 1
      #number of results to return
      break if i>10
    end
    
    return results
  end
end