Skip to content

Instantly share code, notes, and snippets.

@RedFred7
Last active December 25, 2015 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedFred7/6961853 to your computer and use it in GitHub Desktop.
Save RedFred7/6961853 to your computer and use it in GitHub Desktop.
Use DoverToCalais to find all Persons or Organizations with a relevance score greater than 0.1, if the data source contains an environmental event.
require 'dover_to_calais'
EM.run do
# use Control + C to stop the EM
Signal.trap('INT') { EventMachine.stop }
Signal.trap('TERM') { EventMachine.stop }
DoverToCalais::API_KEY = 'my_opencalais_key'
source = 'http://www.eurocities.eu/eurocities/news/World-Mayors-Summit-on-Climate-Change-2013-WSPO-9BXLMT'
dover = DoverToCalais::Dover.new(source)
dover.to_calais do |response|
if response.error
puts response.error
else
organisations = response.filter({:entity => 'Organization', :given => {:entity => 'Event', :value => 'Environment'}})
persons = response.filter({:entity => 'Person', :given => {:entity => 'Event', :value => 'Environment'}})
results = organisations | persons
results.each do |item|
puts item.value if item.relevance > 0.1
end
end #if
end #block
dover.analyse_this
end #EM run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment