docomo-nlu 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -1
- data/docomo-nlu.gemspec +1 -0
- data/lib/docomo-nlu/management/{account.rb → V23/account.rb} +4 -6
- data/lib/docomo-nlu/management/{aiml_base.rb → V23/aiml_base.rb} +31 -5
- data/lib/docomo-nlu/management/{base.rb → V23/base.rb} +5 -4
- data/lib/docomo-nlu/management/{bot.rb → V23/bot.rb} +2 -2
- data/lib/docomo-nlu/management/{config.rb → V23/config.rb} +2 -2
- data/lib/docomo-nlu/management/{default_predicate.rb → V23/default_predicate.rb} +2 -2
- data/lib/docomo-nlu/management/{map.rb → V23/map.rb} +2 -2
- data/lib/docomo-nlu/management/{multipart_base.rb → V23/multipart_base.rb} +1 -1
- data/lib/docomo-nlu/management/{ng_word.rb → V23/ng_word.rb} +2 -2
- data/lib/docomo-nlu/management/{ok_word.rb → V23/ok_word.rb} +2 -2
- data/lib/docomo-nlu/management/{organization.rb → V23/organization.rb} +2 -2
- data/lib/docomo-nlu/management/{organization_member.rb → V23/organization_member.rb} +2 -2
- data/lib/docomo-nlu/management/{predicate_name.rb → V23/predicate_name.rb} +2 -2
- data/lib/docomo-nlu/management/{project.rb → V23/project.rb} +2 -2
- data/lib/docomo-nlu/management/{project_member.rb → V23/project_member.rb} +2 -2
- data/lib/docomo-nlu/management/{property.rb → V23/property.rb} +2 -2
- data/lib/docomo-nlu/management/{provider.rb → V23/provider.rb} +2 -2
- data/lib/docomo-nlu/management/{scenario.rb → V23/scenario.rb} +5 -5
- data/lib/docomo-nlu/management/{scenario_project.rb → V23/scenario_project.rb} +2 -2
- data/lib/docomo-nlu/management/{scenario_util.rb → V23/scenario_util.rb} +2 -2
- data/lib/docomo-nlu/management/{set.rb → V23/set.rb} +2 -2
- data/lib/docomo-nlu/management/{task_project.rb → V23/task_project.rb} +2 -2
- data/lib/docomo-nlu/management/V26/account.rb +31 -0
- data/lib/docomo-nlu/management/V26/aiml_base.rb +199 -0
- data/lib/docomo-nlu/management/V26/base.rb +88 -0
- data/lib/docomo-nlu/management/V26/bot.rb +18 -0
- data/lib/docomo-nlu/management/V26/config.rb +25 -0
- data/lib/docomo-nlu/management/V26/default_predicate.rb +15 -0
- data/lib/docomo-nlu/management/V26/map.rb +10 -0
- data/lib/docomo-nlu/management/V26/multipart_base.rb +83 -0
- data/lib/docomo-nlu/management/V26/ng_word.rb +10 -0
- data/lib/docomo-nlu/management/V26/ok_word.rb +10 -0
- data/lib/docomo-nlu/management/V26/organization.rb +23 -0
- data/lib/docomo-nlu/management/V26/organization_member.rb +15 -0
- data/lib/docomo-nlu/management/V26/predicate_name.rb +15 -0
- data/lib/docomo-nlu/management/V26/project.rb +16 -0
- data/lib/docomo-nlu/management/V26/project_member.rb +15 -0
- data/lib/docomo-nlu/management/V26/property.rb +10 -0
- data/lib/docomo-nlu/management/V26/provider.rb +17 -0
- data/lib/docomo-nlu/management/V26/scenario.rb +29 -0
- data/lib/docomo-nlu/management/V26/scenario_project.rb +10 -0
- data/lib/docomo-nlu/management/V26/scenario_util.rb +30 -0
- data/lib/docomo-nlu/management/V26/set.rb +10 -0
- data/lib/docomo-nlu/management/V26/task_project.rb +20 -0
- data/lib/docomo-nlu/management.rb +48 -22
- data/lib/docomo-nlu/version.rb +1 -1
- metadata +59 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d5ed12b21cda6ecf562f293c3ca33ec2053200d910d4a26bf77f0ff29467fae
|
4
|
+
data.tar.gz: c81c539dbe8cf4e1ba20ddce48eb8ae80ac6006fb36be1e4edd05407ee334920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da8d0a357eede445f3b172bf36ba69bddc5f98fafd138f027af20d12158994b3197f556262a2266ebb7415b365a881fbb8ddb8e845babdee91ff48c421482cd0
|
7
|
+
data.tar.gz: 8d85d2ae501e73379baf89cd783b7407f5063abfd016ee8766d09f343d4e20f48be045b788d4bf75570380a98d7411cb7752abedae19caabdb7d3982722beff9
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
docomo-nlu (0.
|
4
|
+
docomo-nlu (0.2.0)
|
5
5
|
activeresource (~> 5.0.0)
|
6
6
|
bundler
|
7
7
|
faraday
|
@@ -215,6 +215,7 @@ DEPENDENCIES
|
|
215
215
|
reek
|
216
216
|
rspec
|
217
217
|
rubocop (~> 0.58.2)
|
218
|
+
rubocop-rspec
|
218
219
|
vcr (~> 4.0.0)
|
219
220
|
webmock (~> 3.4.2)
|
220
221
|
|
data/docomo-nlu.gemspec
CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "reek"
|
34
34
|
spec.add_development_dependency "rspec"
|
35
35
|
spec.add_development_dependency "rubocop", "~> 0.58.2"
|
36
|
+
spec.add_development_dependency "rubocop-rspec"
|
36
37
|
spec.add_development_dependency "vcr", "~> 4.0.0"
|
37
38
|
spec.add_development_dependency "webmock", "~> 3.4.2"
|
38
39
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Account < Base
|
6
6
|
self.element_name = "accounts"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/"
|
8
8
|
|
9
9
|
# Parameter for create
|
10
10
|
# {
|
@@ -21,10 +21,8 @@ module DocomoNlu
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_json(options = {})
|
24
|
-
|
25
|
-
attributes.
|
26
|
-
attributes.delete("loginDate")
|
27
|
-
attributes.delete("id")
|
24
|
+
enable_params = ["accountName", "password", "description", "authorization", "enable"]
|
25
|
+
attributes.select! {|a| enable_params.include?(a) }
|
28
26
|
super
|
29
27
|
end
|
30
28
|
end
|
@@ -13,9 +13,11 @@
|
|
13
13
|
# Not supported
|
14
14
|
# GET /{projectId}/bots/{botId}/archive/aiml
|
15
15
|
|
16
|
+
# require 'rubyzip'
|
17
|
+
|
16
18
|
require "tempfile"
|
17
19
|
module DocomoNlu
|
18
|
-
module Management
|
20
|
+
module Management::V23
|
19
21
|
class AIMLBase < Base
|
20
22
|
## For AIML
|
21
23
|
|
@@ -99,7 +101,7 @@ module DocomoNlu
|
|
99
101
|
|
100
102
|
if check_response(response)
|
101
103
|
instantiate_record({}, prefix_options).tap do |record|
|
102
|
-
record.file = Tempfile.open(["docomo-nlu", ".#{prefix_options[:method]
|
104
|
+
record.file = Tempfile.open(["docomo-nlu", ".#{prefix_options[:method]}"]) do |f|
|
103
105
|
f.write response.body.force_encoding("UTF-8")
|
104
106
|
f
|
105
107
|
end
|
@@ -132,7 +134,7 @@ module DocomoNlu
|
|
132
134
|
def deploy_request(method, prefix_options)
|
133
135
|
response_body = JSON.parse(connection.post(Scenario.element_path(method, prefix_options), "", headers).body)
|
134
136
|
# Sometimes, API returns wrong url, replace correct path.
|
135
|
-
URI.parse(response_body["statusUri"]).path.gsub!(/NLPManagementAPI/, "management
|
137
|
+
URI.parse(response_body["statusUri"]).path.gsub!(/NLPManagementAPI/, "management/v2.2")
|
136
138
|
end
|
137
139
|
|
138
140
|
def deploy(prefix_options)
|
@@ -162,16 +164,40 @@ module DocomoNlu
|
|
162
164
|
when :transfer then JSON.parse(connection.get(path, headers).body)["transferStatusResponses"][0]["status"]
|
163
165
|
end
|
164
166
|
end
|
167
|
+
|
168
|
+
# def generate_file(response, method)
|
169
|
+
# case method
|
170
|
+
# when :aiml, :dat then
|
171
|
+
# Tempfile.open(["docomo-nlu", ".#{prefix_options[:method].to_s}"]) do |f|
|
172
|
+
# f.write response.body.force_encoding("UTF-8")
|
173
|
+
# f
|
174
|
+
# end
|
175
|
+
# when :zip then
|
176
|
+
# zip_file = Tempfile.new(["docomo-nlu", ".#{prefix_options[:method].to_s.gsub(/archive/, "zip")}"])
|
177
|
+
# Zip::OutputStream.open(zip_file.path) do |zip|
|
178
|
+
# @targets.each do |target|
|
179
|
+
# zip.put_next_entry("#{target.filename}.pdf")
|
180
|
+
# zip.print Net::HTTP.get URI.parse(target.url)
|
181
|
+
# end
|
182
|
+
# end
|
183
|
+
# Zip::File.open_buffer(file.read) do |zf|
|
184
|
+
# zf.each do |entry|
|
185
|
+
# p entry.name # ファイル名
|
186
|
+
# p entry.get_input_stream.read # ファイルの中身
|
187
|
+
# end
|
188
|
+
# end
|
189
|
+
# end
|
190
|
+
# end
|
165
191
|
end
|
166
192
|
|
167
193
|
class FileModel < Base
|
168
194
|
self.element_name = ""
|
169
|
-
self.prefix = "/management
|
195
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/:method"
|
170
196
|
end
|
171
197
|
|
172
198
|
class FAQModel < Base
|
173
199
|
self.element_name = ""
|
174
|
-
self.prefix = "/faqmanagement
|
200
|
+
self.prefix = "/faqmanagement/v2.2/projects/:project_id/bots/:bot_id/:method"
|
175
201
|
end
|
176
202
|
end
|
177
203
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "net/http"
|
4
|
+
|
3
5
|
module DocomoNlu
|
4
|
-
module Management
|
6
|
+
module Management::V23
|
5
7
|
class Base < ActiveResource::Base
|
6
8
|
## For Dynamically generated headers via http://rmosolgo.github.io/blog/2014/02/05/dynamically-generated-headers-for-activeresource-requests/
|
7
9
|
cattr_accessor :static_headers
|
@@ -19,19 +21,18 @@ module DocomoNlu
|
|
19
21
|
## Remove format in path (remove .json)
|
20
22
|
self.include_format_in_path = false
|
21
23
|
|
22
|
-
## Setting Format
|
23
24
|
self.format = :json
|
24
25
|
|
25
26
|
## Get NLPManagement's AccessToken.
|
26
27
|
def login(accountName, password)
|
27
28
|
request_body = { accountName: accountName, password: password }.to_json
|
28
|
-
response_body = JSON.parse(connection.post("/management
|
29
|
+
response_body = JSON.parse(connection.post("/management/v2.2/login", request_body, self.class.headers).body)
|
29
30
|
self.access_token = response_body["accessToken"]
|
30
31
|
end
|
31
32
|
|
32
33
|
## Delete NLPManagement's AccessToken.
|
33
34
|
def logout
|
34
|
-
res = connection.get("/management
|
35
|
+
res = connection.get("/management/v2.2/logout", self.class.headers) if access_token.present?
|
35
36
|
raise ActiveResource::BadRequest, "Invalid access token" unless res
|
36
37
|
|
37
38
|
self.access_token = nil
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Bot < AIMLBase
|
6
6
|
self.element_name = "bots"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/"
|
8
8
|
|
9
9
|
# Parameter for create
|
10
10
|
# {
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Config < Base
|
6
6
|
self.element_name = "configs"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
|
8
8
|
|
9
9
|
# {
|
10
10
|
# "dialogTimeout": 300,
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class DefaultPredicate < Base
|
6
6
|
self.element_name = "defaultPredicates"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
|
8
8
|
|
9
9
|
def destroy(keys)
|
10
10
|
self.id = keys.join(",")
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Map < MultipartBase
|
6
6
|
self.element_name = "maps"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class NGWord < Base
|
6
6
|
self.element_name = "ngWords"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class OKWord < Base
|
6
6
|
self.element_name = "okWords"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Organization < Base
|
6
6
|
self.element_name = "organizations"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/"
|
8
8
|
|
9
9
|
# Parameter create
|
10
10
|
# {
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class OrganizationMember < Base
|
6
6
|
self.element_name = "members"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/organizations/:organization_id/"
|
8
8
|
|
9
9
|
def destroy
|
10
10
|
self.id = accountId
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class PredicateName < Base
|
6
6
|
self.element_name = "predicateNames"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
|
8
8
|
|
9
9
|
def destroy(keys)
|
10
10
|
self.id = keys.join(",")
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Project < Base
|
6
6
|
self.element_name = "projects"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/"
|
8
8
|
|
9
9
|
# Parameter for create
|
10
10
|
# {
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class ProjectMember < Base
|
6
6
|
self.element_name = "members"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/"
|
8
8
|
|
9
9
|
def destroy
|
10
10
|
self.id = accountId
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Property < Base
|
6
6
|
self.element_name = "properties"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Provider < Base
|
6
6
|
self.element_name = "providers"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/"
|
8
8
|
|
9
9
|
# Parameter for create
|
10
10
|
# {
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Scenario < AIMLBase
|
6
6
|
self.element_name = "scenarios"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
|
8
8
|
|
9
|
-
@permitted_root_param = [:userScenarios
|
9
|
+
@permitted_root_param = [:userScenarios, :templateScenarios]
|
10
10
|
@permitted_userScenarios_param = [:scenarioId, :description, :compileFlag]
|
11
11
|
|
12
12
|
def save
|
13
|
-
@attributes.select!{|a| a =~ /(userScenarios|templateScenarios)/}
|
13
|
+
@attributes.select! {|a| a =~ /(userScenarios|templateScenarios)/ }
|
14
14
|
userScenarios.each do |us|
|
15
|
-
us.attributes.select!{|a| a =~ /(scenarioId|description|compileFlag)/}
|
15
|
+
us.attributes.select! {|a| a =~ /(scenarioId|description|compileFlag)/ }
|
16
16
|
end
|
17
17
|
super
|
18
18
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class ScenarioProject < Base
|
6
6
|
self.element_name = "scenarioProjects"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class ScenarioUtil < Base
|
6
6
|
self.element_name = "scenarioUtils"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/"
|
8
8
|
|
9
9
|
def normalize
|
10
10
|
# TODO
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class Set < MultipartBase
|
6
6
|
self.element_name = "sets"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/projects/:project_id/bots/:bot_id/"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DocomoNlu
|
4
|
-
module Management
|
4
|
+
module Management::V23
|
5
5
|
class TaskProject < Base
|
6
6
|
self.element_name = "taskProjects"
|
7
|
-
self.prefix = "/management
|
7
|
+
self.prefix = "/management/v2.2/"
|
8
8
|
|
9
9
|
# Parameter for create
|
10
10
|
# {
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DocomoNlu
|
4
|
+
module Management::V26
|
5
|
+
class Account < Base
|
6
|
+
self.element_name = "accounts"
|
7
|
+
self.prefix = "/management/v2.6/"
|
8
|
+
|
9
|
+
# Parameter for create
|
10
|
+
# {
|
11
|
+
# "accountName": "your account name",
|
12
|
+
# "password": "your account password",
|
13
|
+
# "description": "account description",
|
14
|
+
# "authorization": 2,
|
15
|
+
# "enable": true
|
16
|
+
# "eternity": true
|
17
|
+
# }
|
18
|
+
|
19
|
+
def self.count
|
20
|
+
response_body = JSON.parse(connection.get("#{prefix}#{element_name}/count", headers).body)
|
21
|
+
response_body["count"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_json(options = {})
|
25
|
+
enable_params = ["accountName", "password", "description", "authorization", "enable", "eternity"]
|
26
|
+
attributes.select! {|a| enable_params.include?(a) }
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|