Class: Wit::Importer

Inherits:
Object
  • Object
show all
Defined in:
lib/wit/importer.rb,
lib/wit/importer/version.rb

Constant Summary collapse

API_VERSION =
'20170307'
API_URL =
'https://api.wit.ai/'
VERSION =
"0.1.0"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, path) ⇒ Importer

Returns a new instance of Importer.



18
19
20
21
22
23
# File 'lib/wit/importer.rb', line 18

def initialize(key, path)
  @key = key
  @path = Pathname.new(path)
  @entities = {}
  @expressions = []
end

Class Method Details

.import(key, path) ⇒ Object



14
15
16
# File 'lib/wit/importer.rb', line 14

def self.import(key, path)
  self.new(key, path).perform!
end

Instance Method Details

#perform!Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/wit/importer.rb', line 25

def perform!
  puts "Loading entities\n"
  load_entities(@path.join('entities'))
  puts "Uploading entities\n"
  submit_entities

  puts "Loading expressions\n"
  load_expressions(@path)
  puts "Uploading expressions\n"
  submit_expressions
  puts "Done"
end