Sha256: 75fe9a0c11e1b062d050580562606757c468339490aae9d0fa0c4765cd79788d
Contents?: true
Size: 829 Bytes
Versions: 1
Compression:
Stored size: 829 Bytes
Contents
require 'net/http' require 'nokogiri' class TermExtraction class Zemanta < TermExtraction def terms terms = [] data = Nokogiri::XML.parse(remote_xml) data.search('//name').each do |n| terms << n.text end terms end class << self def canonical_name 'zemanta' end end private def gateway 'http://api.zemanta.com/services/rest/0.0/' end def url URI.parse(gateway) end def post_params { 'method' =>'zemanta.suggest', 'api_key' => @api_key, 'return_images' => 0, 'text' => @context, 'format' => 'xml' } end def remote_xml Net::HTTP.post_form(url, post_params).body end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alexrabarts-term_extraction-0.1.2 | lib/term_extraction/zemanta.rb |