Class: TermExtraction::Zemanta

Inherits:
TermExtraction show all
Defined in:
lib/term_extraction/zemanta.rb

Instance Attribute Summary

Attributes inherited from TermExtraction

#api_key, #context

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TermExtraction

#canonical_name, #initialize

Constructor Details

This class inherits a constructor from TermExtraction

Class Method Details

.canonical_nameObject



30
31
32
# File 'lib/term_extraction/zemanta.rb', line 30

def canonical_name
  'zemanta'
end

Instance Method Details

#post_paramsObject



19
20
21
22
23
24
25
26
27
# File 'lib/term_extraction/zemanta.rb', line 19

def post_params
  {
    'method'        =>'zemanta.suggest',
    'api_key'       => @api_key,
    'return_images' => 0,
    'text'          => @context,
    'format'        => 'xml'
  }
end

#termsObject



7
8
9
10
11
12
13
# File 'lib/term_extraction/zemanta.rb', line 7

def terms
  begin
    Crack::XML.parse(remote_xml)['rsp']['keywords']['keyword'].map { |h| h['name'] }
  rescue
    []
  end
end

#uriObject



15
16
17
# File 'lib/term_extraction/zemanta.rb', line 15

def uri
  URI.parse(gateway)
end