Skip to content

Instantly share code, notes, and snippets.

@aktowns
Created May 10, 2012 14:37
Show Gist options
  • Save aktowns/2653459 to your computer and use it in GitHub Desktop.
Save aktowns/2653459 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: utf-8
require 'iconv'
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
questions = []
print "Starting.."
Dir['*.txt'].each do |file|
print "."
questions << ic.iconv(File.open(file).read).downcase.split("\n")
end
questions.flatten!
puts "\n#{questions.length} loaded"
print "> "
while true
str = gets.strip.downcase
a = questions.select{|x|x.include?(str)}
puts "#{a.length} responses for #{str}"
puts a
print "> "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment