lib/jkl/calais_client.rb in jakal-0.0.8 vs lib/jkl/calais_client.rb in jakal-0.0.9
- old
+ new
@@ -27,13 +27,14 @@
end
cleaned_result
end
- def self.get_calais_metadata(response)
- #ce = CalaisExtractor.new( response )
- #ce.prettify
- #TODO work out how to implement this
+ def self.get_calais_metadata(key, text)
+ name_value_pairs = Jkl::tags(key, text).entities.map{|e| {e.type => [e.attributes["name"]]}}
+ nested_list = {}
+ name_value_pairs.each { |a| nested_list = nested_list.merge!(a){ |key,v1,v2| v1+v2 }}
+ nested_list
end
#jkl doesn't work with these aspects of the calais response, also removing blanks
def self.clean_unwanted_items_from_hash h
h.delete_if {|k, v| k == "relevance" }