lib/jkl/calais_client.rb in sshingler-jkl-0.0.5 vs lib/jkl/calais_client.rb in sshingler-jkl-0.0.6

- old
+ new

@@ -1,7 +1,8 @@ require 'json' -require 'lib/jkl/rest_client' +require 'rest_client' +require 'calais-utils' module Jkl LICENSE_ID = YAML::load_file('config/keys.yml')['calais'] C_URI = URI.parse('http://api.opencalais.com/enlighten/rest/') @@ -19,20 +20,28 @@ result.each do |key,tag| tag = clean_unwanted_items_from_hash tag cleaned_result << tag yield tag if block_given? end + cleaned_result end + def get_calais_metadata(response) + ce = CalaisExtractor.new( response ) + ce.prettify + end + + #jkl doesn't work with these aspects of the calais response, also removing blanks def clean_unwanted_items_from_hash h h.delete_if {|k, v| k == "relevance" } h.delete_if {|k, v| k == "instances" } - h.delete_if {|k,v| v == "N/A"} - h.delete_if {|k,v| v == []} - h.delete_if {|k,v| v == ""} + h.delete_if {|k, v| v == "N/A"} + h.delete_if {|k, v| v == []} + h.delete_if {|k, v| v == ""} + h.delete_if {|k, v| k == "_typeGroup"} h end private @@ -47,6 +56,6 @@ <c:userDirectives /> <c:externalMetadata /> </c:params> paramsXML end -end \ No newline at end of file +end