Sha256: 399b3cae4cfd902816695f4ee575c13c68555dc3668543381ba08234063bcaa3
Contents?: true
Size: 913 Bytes
Versions: 2
Compression:
Stored size: 913 Bytes
Contents
require 'crack' require 'addressable/uri' require 'open-uri' class TermExtraction class Yahoo < TermExtraction def terms begin Crack::XML.parse(remote_xml)['ResultSet']['Result'] rescue [] end end def uri api_uri = Addressable::URI.parse(gateway) api_uri.query_values = { 'appid' => @api_key, 'output' => 'xml', 'context' => @context } api_uri end class << self def canonical_name 'yahoo' end end private def ns {'s' => 'urn:yahoo:cate'} end def gateway 'http://search.yahooapis.com/ContentAnalysisService/V1/termExtraction' end def remote_xml begin open(uri).read rescue => e $stderr.puts "Couldn't fetch from API: #{e.message}" if $VERBOSE nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
term_extraction-0.1.6 | lib/term_extraction/yahoo.rb |
term_extraction-0.1.5 | lib/term_extraction/yahoo.rb |