Skip to content

Instantly share code, notes, and snippets.

Last active Dec 25, 2015
What would you like to do?
Using DoverToCalais to semantically tag all files in a directory
require 'dover_to_calais' do
# use Control + C to stop the EM
Signal.trap('INT') { EventMachine.stop }
Signal.trap('TERM') { EventMachine.stop }
DoverToCalais::API_KEY = 'my_opencalais_key'
directory = '/home/fred/Documents/'
#create a list of all our documents as Dover objects
dovers = []
Dir.foreach(directory) do |filename|
next if filename == '.' or filename == '..'
dovers << + '/' + filename)
#set callbacks for each dover
dovers.each do |dover|
dover.to_calais do |response|
puts "----------------------------------------"
if response.error
puts "Data source #{dover.data_src} -error: #{response.error}"
puts "Data source #{dover.data_src}: #{response}"
end #if
end #block
end #each
#analyse our dovers
dovers.each do |dover|
end #EM run
Copy link

RedFred7 commented Feb 11, 2014

updated gist for dover_ro_calais-0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment