Module: SemanticHacker::Setup

Includes:
HTTParty
Defined in:
lib/semantic_hacker/setup.rb

Class Method Summary collapse

Class Method Details

.categories ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/semantic_hacker/setup.rb', line 20

def self.categories
  if File.exist?(file = File.join(SemanticHacker.data_path, "categories.yaml"))
    categories = YAML.load(File.read(file))
  else        
    raw = get('http://textwise.com/api_docs/labels/odp_2009_l1_1.6k_categories.txt')
    File.open(file, "w") do |f|
      f.puts YAML.dump(categories = @convert.call(raw))
    end
  end
  return categories
end

.labels ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/semantic_hacker/setup.rb', line 8

def self.labels
  if File.exist?(file = File.join(SemanticHacker.data_path, "labels.yaml"))
    labels = YAML.load(File.read(file))
  else        
    raw = get('http://textwise.com/api_docs/labels/odp_2009_l1_1.6k.txt')
    File.open(file, "w") do |f| 
      f.puts YAML.dump(labels = @convert.call(raw))
    end
  end
  return labels
end