Class: WhoNeedsWP::YahooTermExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/who-needs-wp/keywords.rb

Constant Summary collapse

@@API_URI =
URI.parse('http://api.search.yahoo.com/ContentAnalysisService/V1/termExtraction')

Class Method Summary collapse

Class Method Details

.generate_keywords(text) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/who-needs-wp/keywords.rb', line 6

def self.generate_keywords(text)
  return [] if text.empty? 
  keywords = []
  i = Net::HTTP.post_form(@@API_URI, { 'appid' => 'who-needs-wp', 'context' => text  } )
  i = REXML::Document.new i.body
  i.each_element("//Result") do |result| 
    keywords << result.text
  end
  return keywords
end