Last active
December 25, 2015 10:29
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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