Class: SemExtractor::Zemanta
- Inherits:
-
SemExtractor
- Object
- SemExtractor
- SemExtractor::Zemanta
- Defined in:
- lib/apis/zemanta.rb
Instance Attribute Summary
Attributes inherited from SemExtractor
#api_key, #categories, #context, #geos, #terms
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Zemanta
constructor
A new instance of Zemanta.
- #post_params ⇒ Object
- #uri ⇒ Object
Methods inherited from SemExtractor
Constructor Details
#initialize(options = {}) ⇒ Zemanta
Returns a new instance of Zemanta.
4 5 6 7 8 9 |
# File 'lib/apis/zemanta.rb', line 4 def initialize(={}) self.set() xml = remote_xml @categories = Nokogiri::XML(xml).css('category').map { |h| {"score" => h.at_css('confidence').content, "name" => h.at_css('name').content} } @terms = Nokogiri::XML(xml).css('keyword').map { |h| {"score" => h.at_css('confidence').content, "name" => h.at_css('name').content} } end |
Instance Method Details
#post_params ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/apis/zemanta.rb', line 15 def post_params { 'method' =>'zemanta.suggest', 'api_key' => @api_key, 'return_images' => 0, 'text' => @context, 'format' => 'xml', 'articles_limit' => 1, 'return_categories' => 'dmoz' } end |
#uri ⇒ Object
11 12 13 |
# File 'lib/apis/zemanta.rb', line 11 def uri URI.parse(gateway) end |