Sha256: f99724abd5e6fd5e7a383fd21f5b516bb2b70149faba6dac306c1e643eb8c3fd
Contents?: true
Size: 912 Bytes
Versions: 2
Compression:
Stored size: 912 Bytes
Contents
require 'nokogiri' class TermExtraction class Yahoo < TermExtraction def terms terms = [] unless data.nil? data.search('//s:Result', ns).each do |n| terms << n.text end end terms 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 url uri = Addressable::URI.parse(gateway) uri.query_values = { # TODO: Change appid to the BMP one 'appid' => @api_key, 'output' => 'xml', 'context' => @context } uri end def remote_xml open(url).read end def data @data ||= Nokogiri::XML.parse(remote_xml) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alexrabarts-term_extraction-0.1.0 | lib/term_extraction/yahoo.rb |
alexrabarts-term_extraction-0.1.1 | lib/term_extraction/yahoo.rb |