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



33
34
35
# File 'lib/term_extraction/zemanta.rb', line 33

def canonical_name
  'zemanta'
end

Instance Method Details

#post_paramsObject



22
23
24
25
26
27
28
29
30
# File 'lib/term_extraction/zemanta.rb', line 22

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
14
15
16
# File 'lib/term_extraction/zemanta.rb', line 7

def terms
  terms = []
  data  = Nokogiri::XML.parse(remote_xml)

  data.search('//name').each do |n|
    terms << n.text
  end

  terms
end

#uriObject



18
19
20
# File 'lib/term_extraction/zemanta.rb', line 18

def uri
  URI.parse gateway
end