docomo-nlu 0.1.2 → 0.1.3
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/.reek +97 -0
- data/.rubocop.yml +1 -12
- data/Gemfile +2 -2
- data/Gemfile.lock +26 -2
- data/Rakefile +2 -2
- data/docomo-nlu.gemspec +24 -23
- data/lib/docomo-nlu/config.rb +4 -4
- data/lib/docomo-nlu/management/account.rb +6 -6
- data/lib/docomo-nlu/management/aiml_base.rb +73 -21
- data/lib/docomo-nlu/management/base.rb +6 -6
- data/lib/docomo-nlu/management/bot.rb +1 -1
- data/lib/docomo-nlu/management/config.rb +2 -2
- data/lib/docomo-nlu/management/default_predicate.rb +2 -2
- data/lib/docomo-nlu/management/map.rb +1 -1
- data/lib/docomo-nlu/management/multipart_base.rb +9 -8
- data/lib/docomo-nlu/management/ng_word.rb +1 -1
- data/lib/docomo-nlu/management/ok_word.rb +1 -1
- data/lib/docomo-nlu/management/organization.rb +3 -3
- data/lib/docomo-nlu/management/organization_member.rb +1 -1
- data/lib/docomo-nlu/management/predicate_name.rb +2 -2
- data/lib/docomo-nlu/management/project.rb +1 -1
- data/lib/docomo-nlu/management/project_member.rb +1 -1
- data/lib/docomo-nlu/management/property.rb +1 -1
- data/lib/docomo-nlu/management/provider.rb +1 -1
- data/lib/docomo-nlu/management/scenario.rb +14 -3
- data/lib/docomo-nlu/management/scenario_project.rb +1 -1
- data/lib/docomo-nlu/management/scenario_util.rb +4 -4
- data/lib/docomo-nlu/management/set.rb +1 -1
- data/lib/docomo-nlu/management/task_project.rb +1 -1
- data/lib/docomo-nlu/management.rb +22 -22
- data/lib/docomo-nlu/spontaneous.rb +44 -3
- data/lib/docomo-nlu/version.rb +1 -1
- data/lib/docomo-nlu.rb +6 -6
- data/lib/generators/docomo_nlu/install/install_generator.rb +2 -2
- data/lib/generators/templates/template.rb +3 -3
- metadata +25 -12
- data/lib/docomo-nlu/spontaneous/dialogue.rb +0 -58
- data/lib/docomo-nlu/spontaneous/registration.rb +0 -58
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bfefc9978ca4f4524565449b0b6d0ce2d5b211c5e1ebe480551bd7f529a85d5b
|
|
4
|
+
data.tar.gz: b1c827c8eef22a4d2f7e3e71fa7abc52f9f964b993582b04ec0cd0f8433e0168
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 02b86bf251baacf2408efa3d22841a5e9f0daf79f78972f049360ea9e658cbfb1972181b5621cb360b5222569f2d0f547354461185bc7b9fb550f3c1afcc5066
|
|
7
|
+
data.tar.gz: c6cdfe584432532f26f08cf0f61c4576e2bdd56f7182e620b60128b817023d7f6563e79e2d850716e6850fe867eaf57678d0f1024d7d0eebd282fb0b35fe9cb7
|
data/.reek
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
### enabled rules
|
|
3
|
+
TooManyInstanceVariables:
|
|
4
|
+
enabled: true
|
|
5
|
+
exclude: []
|
|
6
|
+
max_instance_variables: 50
|
|
7
|
+
TooManyMethods:
|
|
8
|
+
enabled: true
|
|
9
|
+
exclude: []
|
|
10
|
+
max_methods: 30
|
|
11
|
+
TooManyStatements:
|
|
12
|
+
enabled: true
|
|
13
|
+
exclude: []
|
|
14
|
+
max_statements: 80
|
|
15
|
+
TooManyConstants:
|
|
16
|
+
enabled: true
|
|
17
|
+
exclude: []
|
|
18
|
+
max_constants: 50
|
|
19
|
+
LongParameterList:
|
|
20
|
+
enabled: true
|
|
21
|
+
exclude: []
|
|
22
|
+
max_params: 8
|
|
23
|
+
LongYieldList:
|
|
24
|
+
enabled: true
|
|
25
|
+
exclude: []
|
|
26
|
+
max_params: 8
|
|
27
|
+
NestedIterators:
|
|
28
|
+
enabled: true
|
|
29
|
+
exclude: []
|
|
30
|
+
max_allowed_nesting: 5
|
|
31
|
+
ignore_iterators:
|
|
32
|
+
- tap
|
|
33
|
+
ModuleInitialize:
|
|
34
|
+
enabled: true
|
|
35
|
+
exclude: []
|
|
36
|
+
SubclassedFromCoreClass:
|
|
37
|
+
enabled: true
|
|
38
|
+
exclude: []
|
|
39
|
+
|
|
40
|
+
### unanabled rules
|
|
41
|
+
Attribute:
|
|
42
|
+
enabled: false
|
|
43
|
+
exclude: []
|
|
44
|
+
BooleanParameter:
|
|
45
|
+
enabled: false
|
|
46
|
+
exclude: []
|
|
47
|
+
ClassVariable:
|
|
48
|
+
enabled: false
|
|
49
|
+
exclude: []
|
|
50
|
+
ControlParameter:
|
|
51
|
+
enabled: false
|
|
52
|
+
exclude: []
|
|
53
|
+
DataClump:
|
|
54
|
+
enabled: false
|
|
55
|
+
exclude: []
|
|
56
|
+
DuplicateMethodCall:
|
|
57
|
+
enabled: false
|
|
58
|
+
exclude: []
|
|
59
|
+
FeatureEnvy:
|
|
60
|
+
enabled: false
|
|
61
|
+
exclude: []
|
|
62
|
+
InstanceVariableAssumption:
|
|
63
|
+
enabled: false
|
|
64
|
+
exclude: []
|
|
65
|
+
IrresponsibleModule:
|
|
66
|
+
enabled: false
|
|
67
|
+
exclude: []
|
|
68
|
+
ManualDispatch:
|
|
69
|
+
enabled: false
|
|
70
|
+
exclude: []
|
|
71
|
+
NilCheck:
|
|
72
|
+
enabled: false
|
|
73
|
+
exclude: []
|
|
74
|
+
PrimaDonnaMethod:
|
|
75
|
+
enabled: false
|
|
76
|
+
exclude: []
|
|
77
|
+
RepeatedConditional:
|
|
78
|
+
enabled: false
|
|
79
|
+
exclude: []
|
|
80
|
+
UncommunicativeMethodName:
|
|
81
|
+
enabled: false
|
|
82
|
+
exclude: []
|
|
83
|
+
UncommunicativeModuleName:
|
|
84
|
+
enabled: false
|
|
85
|
+
exclude: []
|
|
86
|
+
UncommunicativeParameterName:
|
|
87
|
+
enabled: false
|
|
88
|
+
exclude: []
|
|
89
|
+
UncommunicativeVariableName:
|
|
90
|
+
enabled: false
|
|
91
|
+
exclude: []
|
|
92
|
+
UnusedParameters:
|
|
93
|
+
enabled: false
|
|
94
|
+
exclude: []
|
|
95
|
+
UtilityFunction:
|
|
96
|
+
enabled: false
|
|
97
|
+
exclude: []
|
data/.rubocop.yml
CHANGED
|
@@ -8,8 +8,6 @@ AllCops:
|
|
|
8
8
|
TargetRubyVersion: 2.5
|
|
9
9
|
# If you use RuboCop with Ruby on Rails, specify TargetRailsVersion(default: 5.0).
|
|
10
10
|
TargetRailsVersion: 5.1
|
|
11
|
-
Include:
|
|
12
|
-
- rubocop-rspec
|
|
13
11
|
Rails:
|
|
14
12
|
# If you use RuboCop with Ruby on Rails, turn on this option.
|
|
15
13
|
Enabled: true
|
|
@@ -17,16 +15,7 @@ Naming/FileName:
|
|
|
17
15
|
Exclude:
|
|
18
16
|
- "Gemfile"
|
|
19
17
|
- "Rakefile"
|
|
20
|
-
- "Guardfile"
|
|
21
18
|
Rails/HasManyOrHasOneDependent:
|
|
22
19
|
Enabled: false
|
|
23
|
-
Rails/OutputSafety:
|
|
24
|
-
Exclude:
|
|
25
|
-
- "app/views/kaminari/**/*"
|
|
26
|
-
- "app/views/admin/kaminari/**/*"
|
|
27
20
|
Rails/SaveBang:
|
|
28
|
-
Enabled: false
|
|
29
|
-
|
|
30
|
-
Rails/LexicallyScopedActionFilter:
|
|
31
|
-
Exclude:
|
|
32
|
-
- "app/controllers/concerns/main_agent_instance.rb"
|
|
21
|
+
Enabled: false
|
data/Gemfile
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
source
|
|
3
|
+
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
git_source(:github) {
|
|
5
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
6
6
|
|
|
7
7
|
# Specify your gem's dependencies in docomo-nlu.gemspec
|
|
8
8
|
gemspec
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
docomo-nlu (0.1.
|
|
4
|
+
docomo-nlu (0.1.3)
|
|
5
5
|
activeresource (~> 5.0.0)
|
|
6
6
|
bundler
|
|
7
7
|
faraday
|
|
@@ -63,22 +63,35 @@ GEM
|
|
|
63
63
|
public_suffix (>= 2.0.2, < 4.0)
|
|
64
64
|
arel (9.0.0)
|
|
65
65
|
ast (2.4.0)
|
|
66
|
+
axiom-types (0.1.1)
|
|
67
|
+
descendants_tracker (~> 0.0.4)
|
|
68
|
+
ice_nine (~> 0.11.0)
|
|
69
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
|
66
70
|
builder (3.2.3)
|
|
71
|
+
codeclimate-engine-rb (0.4.1)
|
|
72
|
+
virtus (~> 1.0)
|
|
67
73
|
coderay (1.1.2)
|
|
74
|
+
coercible (1.0.0)
|
|
75
|
+
descendants_tracker (~> 0.0.1)
|
|
68
76
|
concurrent-ruby (1.0.5)
|
|
69
77
|
crack (0.4.3)
|
|
70
78
|
safe_yaml (~> 1.0.0)
|
|
71
79
|
crass (1.0.4)
|
|
80
|
+
descendants_tracker (0.0.4)
|
|
81
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
|
72
82
|
diff-lcs (1.3)
|
|
83
|
+
equalizer (0.0.11)
|
|
73
84
|
erubi (1.7.1)
|
|
74
|
-
faraday (0.15.
|
|
85
|
+
faraday (0.15.3)
|
|
75
86
|
multipart-post (>= 1.2, < 3)
|
|
76
87
|
globalid (0.4.1)
|
|
77
88
|
activesupport (>= 4.2.0)
|
|
78
89
|
hashdiff (0.3.7)
|
|
79
90
|
i18n (1.1.0)
|
|
80
91
|
concurrent-ruby (~> 1.0)
|
|
92
|
+
ice_nine (0.11.2)
|
|
81
93
|
jaro_winkler (1.5.1)
|
|
94
|
+
kwalify (0.7.2)
|
|
82
95
|
loofah (2.2.2)
|
|
83
96
|
crass (~> 1.0.2)
|
|
84
97
|
nokogiri (>= 1.5.9)
|
|
@@ -135,6 +148,11 @@ GEM
|
|
|
135
148
|
thor (>= 0.19.0, < 2.0)
|
|
136
149
|
rainbow (3.0.0)
|
|
137
150
|
rake (12.3.1)
|
|
151
|
+
reek (5.0.2)
|
|
152
|
+
codeclimate-engine-rb (~> 0.4.0)
|
|
153
|
+
kwalify (~> 0.7.0)
|
|
154
|
+
parser (>= 2.5.0.0, < 2.6, != 2.5.1.1)
|
|
155
|
+
rainbow (>= 2.0, < 4.0)
|
|
138
156
|
rspec (3.8.0)
|
|
139
157
|
rspec-core (~> 3.8.0)
|
|
140
158
|
rspec-expectations (~> 3.8.0)
|
|
@@ -173,6 +191,11 @@ GEM
|
|
|
173
191
|
thread_safe (~> 0.1)
|
|
174
192
|
unicode-display_width (1.4.0)
|
|
175
193
|
vcr (4.0.0)
|
|
194
|
+
virtus (1.0.5)
|
|
195
|
+
axiom-types (~> 0.1)
|
|
196
|
+
coercible (~> 1.0)
|
|
197
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
|
198
|
+
equalizer (~> 0.0, >= 0.0.9)
|
|
176
199
|
webmock (3.4.2)
|
|
177
200
|
addressable (>= 2.3.6)
|
|
178
201
|
crack (>= 0.3.2)
|
|
@@ -189,6 +212,7 @@ DEPENDENCIES
|
|
|
189
212
|
onkcop
|
|
190
213
|
pry (~> 0.11.3)
|
|
191
214
|
rails
|
|
215
|
+
reek
|
|
192
216
|
rspec
|
|
193
217
|
rubocop (~> 0.58.2)
|
|
194
218
|
vcr (~> 4.0.0)
|
data/Rakefile
CHANGED
data/docomo-nlu.gemspec
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
lib = File.expand_path(
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
-
require
|
|
5
|
+
require "docomo-nlu/version"
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name =
|
|
8
|
+
spec.name = "docomo-nlu"
|
|
9
9
|
spec.version = DocomoNlu::VERSION
|
|
10
|
-
spec.authors = [
|
|
11
|
-
spec.email = [
|
|
10
|
+
spec.authors = ["Koji Yamazaki"]
|
|
11
|
+
spec.email = ["kouji.yamazaki.cv@nttdocomo.com"]
|
|
12
12
|
|
|
13
|
-
spec.summary =
|
|
14
|
-
spec.description =
|
|
15
|
-
spec.homepage =
|
|
13
|
+
spec.summary = "API Client of docomo NLPManagementAPI for ruby."
|
|
14
|
+
spec.description = "API Client of docomo NLPManagementAPI for ruby."
|
|
15
|
+
spec.homepage = "https://github.com/jagrament/docomo-nlu"
|
|
16
16
|
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
|
18
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
19
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
20
|
-
`git ls-files -z`.split("\x0").reject {
|
|
20
|
+
`git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
|
21
21
|
end
|
|
22
|
-
spec.bindir =
|
|
23
|
-
spec.executables = spec.files.grep(%r{^exe/}) {
|
|
24
|
-
spec.require_paths = [
|
|
22
|
+
spec.bindir = "exe"
|
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
|
24
|
+
spec.require_paths = ["lib"]
|
|
25
25
|
|
|
26
|
-
spec.add_dependency
|
|
27
|
-
spec.add_dependency
|
|
28
|
-
spec.add_dependency
|
|
29
|
-
spec.add_dependency
|
|
30
|
-
spec.add_development_dependency
|
|
31
|
-
spec.add_development_dependency
|
|
32
|
-
spec.add_development_dependency
|
|
33
|
-
spec.add_development_dependency
|
|
34
|
-
spec.add_development_dependency
|
|
35
|
-
spec.add_development_dependency
|
|
36
|
-
spec.add_development_dependency
|
|
26
|
+
spec.add_dependency "activeresource", "~> 5.0.0"
|
|
27
|
+
spec.add_dependency "bundler"
|
|
28
|
+
spec.add_dependency "faraday"
|
|
29
|
+
spec.add_dependency "rake"
|
|
30
|
+
spec.add_development_dependency "onkcop"
|
|
31
|
+
spec.add_development_dependency "pry", "~> 0.11.3"
|
|
32
|
+
spec.add_development_dependency "rails"
|
|
33
|
+
spec.add_development_dependency "reek"
|
|
34
|
+
spec.add_development_dependency "rspec"
|
|
35
|
+
spec.add_development_dependency "rubocop", "~> 0.58.2"
|
|
36
|
+
spec.add_development_dependency "vcr", "~> 4.0.0"
|
|
37
|
+
spec.add_development_dependency "webmock", "~> 3.4.2"
|
|
37
38
|
end
|
data/lib/docomo-nlu/config.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "active_support/configurable"
|
|
4
4
|
module DocomoNlu
|
|
5
5
|
def self.configure
|
|
6
6
|
yield @config ||= DocomoNlu::Configuration.new
|
|
@@ -18,8 +18,8 @@ module DocomoNlu
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
configure do |config|
|
|
21
|
-
config.nlu_host =
|
|
22
|
-
config.nlu_version =
|
|
23
|
-
config.admin_access_token =
|
|
21
|
+
config.nlu_host = ""
|
|
22
|
+
config.nlu_version = ""
|
|
23
|
+
config.admin_access_token = ""
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module DocomoNlu
|
|
4
4
|
module Management
|
|
5
5
|
class Account < Base
|
|
6
|
-
self.element_name =
|
|
6
|
+
self.element_name = "accounts"
|
|
7
7
|
self.prefix = "/management/#{DocomoNlu.config.nlu_version}/"
|
|
8
8
|
|
|
9
9
|
# Parameter for create
|
|
@@ -17,14 +17,14 @@ module DocomoNlu
|
|
|
17
17
|
|
|
18
18
|
def self.count
|
|
19
19
|
response_body = JSON.parse(connection.get("#{prefix}#{element_name}/count", headers).body)
|
|
20
|
-
response_body[
|
|
20
|
+
response_body["count"]
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def to_json(options = {})
|
|
24
|
-
attributes.delete(
|
|
25
|
-
attributes.delete(
|
|
26
|
-
attributes.delete(
|
|
27
|
-
attributes.delete(
|
|
24
|
+
attributes.delete("accountId")
|
|
25
|
+
attributes.delete("createDate")
|
|
26
|
+
attributes.delete("loginDate")
|
|
27
|
+
attributes.delete("id")
|
|
28
28
|
super
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -13,17 +13,20 @@
|
|
|
13
13
|
# Not supported
|
|
14
14
|
# GET /{projectId}/bots/{botId}/archive/aiml
|
|
15
15
|
|
|
16
|
-
require
|
|
16
|
+
require "tempfile"
|
|
17
17
|
module DocomoNlu
|
|
18
18
|
module Management
|
|
19
19
|
class AIMLBase < Base
|
|
20
|
-
|
|
20
|
+
## For AIML
|
|
21
|
+
|
|
22
|
+
def download(extra_path = "")
|
|
21
23
|
prefix_options[:bot_id] ||= botId
|
|
22
24
|
@attributes[:file] = self.class.download(prefix_options, extra_path).file
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
def upload(file)
|
|
27
|
+
def upload(file, type = :aiml)
|
|
26
28
|
prefix_options[:bot_id] ||= botId
|
|
29
|
+
prefix_options[:method] ||= type
|
|
27
30
|
self.class.upload(file, prefix_options)
|
|
28
31
|
end
|
|
29
32
|
|
|
@@ -42,57 +45,101 @@ module DocomoNlu
|
|
|
42
45
|
self.class.deploy(prefix_options)
|
|
43
46
|
end
|
|
44
47
|
|
|
48
|
+
## For FAQ
|
|
49
|
+
|
|
50
|
+
def upload_userdic(file)
|
|
51
|
+
prefix_options[:bot_id] ||= botId
|
|
52
|
+
prefix_options[:method] = "userDic"
|
|
53
|
+
self.class.upload(file, prefix_options, FAQModel)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def upload_stopkey(file)
|
|
57
|
+
prefix_options[:bot_id] ||= botId
|
|
58
|
+
prefix_options[:method] = "stopkey"
|
|
59
|
+
self.class.upload(file, prefix_options, FAQModel)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def download_stopkey
|
|
63
|
+
prefix_options[:bot_id] ||= botId
|
|
64
|
+
prefix_options[:method] = "stopkey"
|
|
65
|
+
@attributes[:stopkey] = self.class.download(prefix_options, FAQModel).file
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def upload_truthlist(file)
|
|
69
|
+
prefix_options[:bot_id] ||= botId
|
|
70
|
+
prefix_options[:method] = "truthlist"
|
|
71
|
+
self.class.upload(file, prefix_options, FAQModel)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def download_truthlist
|
|
75
|
+
prefix_options[:bot_id] ||= botId
|
|
76
|
+
prefix_options[:method] = "truthlist"
|
|
77
|
+
@attributes[:truthlist] = self.class.download(prefix_options, FAQModel).file
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def upload_entry(file)
|
|
81
|
+
prefix_options[:bot_id] ||= botId
|
|
82
|
+
prefix_options[:method] = "entry"
|
|
83
|
+
self.class.upload(file, prefix_options, FAQModel)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def check_faq_status(method)
|
|
87
|
+
prefix_options[:bot_id] ||= botId
|
|
88
|
+
prefix_options[:method] = method
|
|
89
|
+
self.class.check_status(:faq, "#{FileModel.collection_path(prefix_options)}/status")
|
|
90
|
+
end
|
|
91
|
+
|
|
45
92
|
class << self
|
|
46
|
-
def download(prefix_options, extra_path =
|
|
93
|
+
def download(prefix_options, extra_path = "", model = FileModel)
|
|
47
94
|
conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
|
|
48
95
|
builder.adapter :net_http
|
|
49
96
|
end
|
|
50
|
-
conn.headers[
|
|
51
|
-
response = conn.get("#{
|
|
97
|
+
conn.headers["Authorization"] = access_token
|
|
98
|
+
response = conn.get("#{model.collection_path(prefix_options)}/#{extra_path}")
|
|
52
99
|
|
|
53
100
|
if check_response(response)
|
|
54
101
|
instantiate_record({}, prefix_options).tap do |record|
|
|
55
|
-
record.file = Tempfile.open([
|
|
56
|
-
f.write response.body
|
|
102
|
+
record.file = Tempfile.open(["docomo-nlu", ".#{prefix_options[:method].to_s.gsub(/archive/, "zip")}"]) do |f|
|
|
103
|
+
f.write response.body.force_encoding("UTF-8")
|
|
57
104
|
f
|
|
58
105
|
end
|
|
59
106
|
end
|
|
60
107
|
end
|
|
61
108
|
end
|
|
62
109
|
|
|
63
|
-
def upload(file, prefix_options)
|
|
110
|
+
def upload(file, prefix_options, model = FileModel)
|
|
64
111
|
conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
|
|
65
112
|
builder.request :multipart # マルチパートでデータを送信
|
|
66
113
|
builder.request :url_encoded
|
|
67
114
|
builder.adapter :net_http
|
|
68
115
|
end
|
|
69
|
-
conn.headers[
|
|
116
|
+
conn.headers["Authorization"] = access_token
|
|
70
117
|
params = {
|
|
71
|
-
uploadFile: Faraday::UploadIO.new(file.path,
|
|
118
|
+
uploadFile: Faraday::UploadIO.new(file.path, "text/plain"),
|
|
72
119
|
}
|
|
73
|
-
response = conn.put
|
|
120
|
+
response = conn.put model.collection_path(prefix_options), params
|
|
74
121
|
check_response(response)
|
|
75
122
|
end
|
|
76
123
|
|
|
77
124
|
def compile(prefix_options)
|
|
78
|
-
return if deploy_request(:compile, prefix_options) !=
|
|
125
|
+
return if deploy_request(:compile, prefix_options) != ""
|
|
79
126
|
end
|
|
80
127
|
|
|
81
128
|
def transfer(prefix_options)
|
|
82
|
-
return if deploy_request(:transfer, prefix_options) !=
|
|
129
|
+
return if deploy_request(:transfer, prefix_options) != ""
|
|
83
130
|
end
|
|
84
131
|
|
|
85
132
|
def deploy_request(method, prefix_options)
|
|
86
|
-
response_body = JSON.parse(connection.post(Scenario.element_path(method, prefix_options),
|
|
133
|
+
response_body = JSON.parse(connection.post(Scenario.element_path(method, prefix_options), "", headers).body)
|
|
87
134
|
# Sometimes, API returns wrong url, replace correct path.
|
|
88
|
-
URI.parse(response_body[
|
|
135
|
+
URI.parse(response_body["statusUri"]).path.gsub!(/NLPManagementAPI/, "management/#{DocomoNlu.config.nlu_version}")
|
|
89
136
|
end
|
|
90
137
|
|
|
91
138
|
def deploy(prefix_options)
|
|
92
139
|
# compile and status check
|
|
93
140
|
compile_status = false
|
|
94
141
|
check_path = deploy_request(:compile, prefix_options)
|
|
95
|
-
while check_path && compile_status !=
|
|
142
|
+
while check_path && compile_status != "Completed"
|
|
96
143
|
sleep(0.2)
|
|
97
144
|
compile_status = check_status(:compile, check_path)
|
|
98
145
|
raise ActiveResource::ServerError if %w[ErrorFinish NotCompiled].include?(compile_status)
|
|
@@ -101,7 +148,7 @@ module DocomoNlu
|
|
|
101
148
|
# transfer and status check
|
|
102
149
|
transfer_status = false
|
|
103
150
|
check_path = deploy_request(:transfer, prefix_options)
|
|
104
|
-
while check_path && transfer_status !=
|
|
151
|
+
while check_path && transfer_status != "Completed"
|
|
105
152
|
sleep(0.2)
|
|
106
153
|
transfer_status = check_status(:transfer, check_path)
|
|
107
154
|
raise ActiveResource::ServerError if %w[ErrorFinish NotTransfered].include?(transfer_status)
|
|
@@ -111,16 +158,21 @@ module DocomoNlu
|
|
|
111
158
|
|
|
112
159
|
def check_status(method, path)
|
|
113
160
|
case method
|
|
114
|
-
when :compile
|
|
115
|
-
when :transfer
|
|
161
|
+
when :compile, :faq then JSON.parse(connection.get(path, headers).body)["status"]
|
|
162
|
+
when :transfer then JSON.parse(connection.get(path, headers).body)["transferStatusResponses"][0]["status"]
|
|
116
163
|
end
|
|
117
164
|
end
|
|
118
165
|
end
|
|
119
166
|
|
|
120
167
|
class FileModel < Base
|
|
121
|
-
self.element_name =
|
|
168
|
+
self.element_name = ""
|
|
122
169
|
self.prefix = "/management/#{DocomoNlu.config.nlu_version}/projects/:project_id/bots/:bot_id/:method"
|
|
123
170
|
end
|
|
171
|
+
|
|
172
|
+
class FAQModel < Base
|
|
173
|
+
self.element_name = ""
|
|
174
|
+
self.prefix = "/faqmanagement/#{DocomoNlu.config.nlu_version}/projects/:project_id/bots/:bot_id/:method"
|
|
175
|
+
end
|
|
124
176
|
end
|
|
125
177
|
end
|
|
126
178
|
end
|
|
@@ -26,13 +26,13 @@ module DocomoNlu
|
|
|
26
26
|
def login(accountName, password)
|
|
27
27
|
request_body = { accountName: accountName, password: password }.to_json
|
|
28
28
|
response_body = JSON.parse(connection.post("/management/#{DocomoNlu.config.nlu_version}/login", request_body, self.class.headers).body)
|
|
29
|
-
self.access_token = response_body[
|
|
29
|
+
self.access_token = response_body["accessToken"]
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
## Delete NLPManagement's AccessToken.
|
|
33
33
|
def logout
|
|
34
34
|
res = connection.get("/management/#{DocomoNlu.config.nlu_version}/logout", self.class.headers) if access_token.present?
|
|
35
|
-
raise ActiveResource::BadRequest,
|
|
35
|
+
raise ActiveResource::BadRequest, "Invalid access token" unless res
|
|
36
36
|
|
|
37
37
|
self.access_token = nil
|
|
38
38
|
true
|
|
@@ -40,7 +40,7 @@ module DocomoNlu
|
|
|
40
40
|
|
|
41
41
|
## Override. Insert generated id to parameter 'id' after save or create
|
|
42
42
|
def id_from_response(response)
|
|
43
|
-
ActiveSupport::JSON.decode(response.body)["#{self.class.to_s.split(
|
|
43
|
+
ActiveSupport::JSON.decode(response.body)["#{self.class.to_s.split("::").last.downcase!}Id"] if response.body.present?
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
class << self
|
|
@@ -59,14 +59,14 @@ module DocomoNlu
|
|
|
59
59
|
|
|
60
60
|
def instantiate_record(record, prefix_options = {})
|
|
61
61
|
record = record[0] if record.is_a?(Array)
|
|
62
|
-
resource_id = record["#{to_s.split(
|
|
63
|
-
record[
|
|
62
|
+
resource_id = record["#{to_s.split("::").last.downcase!}Id"]
|
|
63
|
+
record["id"] = resource_id if resource_id
|
|
64
64
|
super
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def headers
|
|
68
68
|
new_headers = static_headers.clone
|
|
69
|
-
new_headers[
|
|
69
|
+
new_headers["Authorization"] = access_token
|
|
70
70
|
new_headers
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module DocomoNlu
|
|
4
4
|
module Management
|
|
5
5
|
class Config < Base
|
|
6
|
-
self.element_name =
|
|
6
|
+
self.element_name = "configs"
|
|
7
7
|
self.prefix = "/management/#{DocomoNlu.config.nlu_version}/projects/:project_id/bots/:bot_id/"
|
|
8
8
|
|
|
9
9
|
# {
|
|
@@ -17,7 +17,7 @@ module DocomoNlu
|
|
|
17
17
|
# }
|
|
18
18
|
|
|
19
19
|
def destroy(keys)
|
|
20
|
-
self.id = keys.join(
|
|
20
|
+
self.id = keys.join(",")
|
|
21
21
|
super()
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
module DocomoNlu
|
|
4
4
|
module Management
|
|
5
5
|
class DefaultPredicate < Base
|
|
6
|
-
self.element_name =
|
|
6
|
+
self.element_name = "defaultPredicates"
|
|
7
7
|
self.prefix = "/management/#{DocomoNlu.config.nlu_version}/projects/:project_id/bots/:bot_id/"
|
|
8
8
|
|
|
9
9
|
def destroy(keys)
|
|
10
|
-
self.id = keys.join(
|
|
10
|
+
self.id = keys.join(",")
|
|
11
11
|
super()
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "tempfile"
|
|
4
4
|
module DocomoNlu
|
|
5
5
|
module Management
|
|
6
6
|
class MultipartBase < Base
|
|
@@ -16,7 +16,7 @@ module DocomoNlu
|
|
|
16
16
|
class << self
|
|
17
17
|
def create(file, prefix_options)
|
|
18
18
|
check_prefix_options(prefix_options)
|
|
19
|
-
raise ActiveResource::BadRequest,
|
|
19
|
+
raise ActiveResource::BadRequest, "" unless file.instance_of?(File)
|
|
20
20
|
|
|
21
21
|
upload(file, prefix_options)
|
|
22
22
|
end
|
|
@@ -36,6 +36,7 @@ module DocomoNlu
|
|
|
36
36
|
|
|
37
37
|
def where(clauses = {})
|
|
38
38
|
raise ArgumentError, "expected a clauses Hash, got #{clauses.inspect}" unless clauses.is_a? Hash
|
|
39
|
+
|
|
39
40
|
category = clauses[:category]
|
|
40
41
|
find(category, params: clauses)
|
|
41
42
|
end
|
|
@@ -43,19 +44,19 @@ module DocomoNlu
|
|
|
43
44
|
private
|
|
44
45
|
|
|
45
46
|
def download(category = nil, prefix_options)
|
|
46
|
-
extention = category.blank? ?
|
|
47
|
+
extention = category.blank? ? ".zip" : ".map"
|
|
47
48
|
|
|
48
49
|
conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
|
|
49
50
|
builder.adapter :net_http
|
|
50
51
|
end
|
|
51
|
-
conn.headers[
|
|
52
|
+
conn.headers["Authorization"] = access_token
|
|
52
53
|
|
|
53
54
|
response = conn.get(element_path(category, prefix_options))
|
|
54
55
|
|
|
55
56
|
if check_response(response)
|
|
56
57
|
instantiate_record({}, prefix_options).tap do |record|
|
|
57
|
-
record.file = Tempfile.open([
|
|
58
|
-
f.write response.body
|
|
58
|
+
record.file = Tempfile.open(["docomo-nlu", extention]) do |f|
|
|
59
|
+
f.write response.body.force_encoding("UTF-8")
|
|
59
60
|
f
|
|
60
61
|
end
|
|
61
62
|
record.category = category
|
|
@@ -69,9 +70,9 @@ module DocomoNlu
|
|
|
69
70
|
builder.request :url_encoded
|
|
70
71
|
builder.adapter :net_http
|
|
71
72
|
end
|
|
72
|
-
conn.headers[
|
|
73
|
+
conn.headers["Authorization"] = access_token
|
|
73
74
|
params = {
|
|
74
|
-
uploadFile: Faraday::UploadIO.new(file.path,
|
|
75
|
+
uploadFile: Faraday::UploadIO.new(file.path, "text/plain"),
|
|
75
76
|
}
|
|
76
77
|
response = conn.put collection_path(prefix_options), params
|
|
77
78
|
check_response(response)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module DocomoNlu
|
|
4
4
|
module Management
|
|
5
5
|
class Organization < Base
|
|
6
|
-
self.element_name =
|
|
6
|
+
self.element_name = "organizations"
|
|
7
7
|
self.prefix = "/management/#{DocomoNlu.config.nlu_version}/"
|
|
8
8
|
|
|
9
9
|
# Parameter create
|
|
@@ -14,8 +14,8 @@ module DocomoNlu
|
|
|
14
14
|
# }
|
|
15
15
|
|
|
16
16
|
def to_json(options = {})
|
|
17
|
-
attributes.delete(
|
|
18
|
-
attributes.delete(
|
|
17
|
+
attributes.delete("organizationId")
|
|
18
|
+
attributes.delete("id")
|
|
19
19
|
super
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
module DocomoNlu
|
|
4
4
|
module Management
|
|
5
5
|
class PredicateName < Base
|
|
6
|
-
self.element_name =
|
|
6
|
+
self.element_name = "predicateNames"
|
|
7
7
|
self.prefix = "/management/#{DocomoNlu.config.nlu_version}/projects/:project_id/bots/:bot_id/"
|
|
8
8
|
|
|
9
9
|
def destroy(keys)
|
|
10
|
-
self.id = keys.join(
|
|
10
|
+
self.id = keys.join(",")
|
|
11
11
|
super()
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -3,14 +3,25 @@
|
|
|
3
3
|
module DocomoNlu
|
|
4
4
|
module Management
|
|
5
5
|
class Scenario < AIMLBase
|
|
6
|
-
self.element_name =
|
|
6
|
+
self.element_name = "scenarios"
|
|
7
7
|
self.prefix = "/management/#{DocomoNlu.config.nlu_version}/projects/:project_id/bots/:bot_id/"
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
@permitted_root_param = [:userScenarios,:templateScenarios]
|
|
10
|
+
@permitted_userScenarios_param = [:scenarioId, :description, :compileFlag]
|
|
11
|
+
|
|
12
|
+
def save
|
|
13
|
+
@attributes.select!{|a| a =~ /(userScenarios|templateScenarios)/}
|
|
14
|
+
userScenarios.each do |us|
|
|
15
|
+
us.attributes.select!{|a| a =~ /(scenarioId|description|compileFlag)/}
|
|
16
|
+
end
|
|
11
17
|
super
|
|
12
18
|
end
|
|
13
19
|
|
|
20
|
+
def destroy(scenario_id)
|
|
21
|
+
self.id = scenario_id
|
|
22
|
+
super()
|
|
23
|
+
end
|
|
24
|
+
|
|
14
25
|
class UserScenarios < Base; end
|
|
15
26
|
class TemplateScenarios < Base; end
|
|
16
27
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module DocomoNlu
|
|
4
4
|
module Management
|
|
5
5
|
class ScenarioUtil < Base
|
|
6
|
-
self.element_name =
|
|
6
|
+
self.element_name = "scenarioUtils"
|
|
7
7
|
self.prefix = "/management/#{DocomoNlu.config.nlu_version}/"
|
|
8
8
|
|
|
9
9
|
def normalize
|
|
@@ -15,15 +15,15 @@ module DocomoNlu
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def save
|
|
18
|
-
print
|
|
18
|
+
print "Method not used"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def destroy
|
|
22
|
-
print
|
|
22
|
+
print "Method not used"
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def delete
|
|
26
|
-
print
|
|
26
|
+
print "Method not used"
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
module DocomoNlu
|
|
4
4
|
module Management
|
|
5
|
-
autoload :Account,
|
|
6
|
-
autoload :AIMLBase,
|
|
7
|
-
autoload :Base,
|
|
8
|
-
autoload :Bot,
|
|
9
|
-
autoload :Config,
|
|
10
|
-
autoload :DefaultPredicate,
|
|
11
|
-
autoload :MultipartBase,
|
|
12
|
-
autoload :Map,
|
|
13
|
-
autoload :NGWord,
|
|
14
|
-
autoload :OKWord,
|
|
15
|
-
autoload :OrganizationMember,
|
|
16
|
-
autoload :Organization,
|
|
17
|
-
autoload :PredicateName,
|
|
18
|
-
autoload :ProjectMember,
|
|
19
|
-
autoload :Project,
|
|
20
|
-
autoload :Property,
|
|
21
|
-
autoload :Provider,
|
|
22
|
-
autoload :ScenarioProject,
|
|
23
|
-
autoload :ScenarioUtil,
|
|
24
|
-
autoload :Scenario,
|
|
25
|
-
autoload :Set,
|
|
26
|
-
autoload :TaskProject,
|
|
5
|
+
autoload :Account, "docomo-nlu/management/account"
|
|
6
|
+
autoload :AIMLBase, "docomo-nlu/management/aiml_base"
|
|
7
|
+
autoload :Base, "docomo-nlu/management/base"
|
|
8
|
+
autoload :Bot, "docomo-nlu/management/bot"
|
|
9
|
+
autoload :Config, "docomo-nlu/management/config"
|
|
10
|
+
autoload :DefaultPredicate, "docomo-nlu/management/default_predicate"
|
|
11
|
+
autoload :MultipartBase, "docomo-nlu/management/multipart_base"
|
|
12
|
+
autoload :Map, "docomo-nlu/management/map"
|
|
13
|
+
autoload :NGWord, "docomo-nlu/management/ng_word"
|
|
14
|
+
autoload :OKWord, "docomo-nlu/management/ok_word"
|
|
15
|
+
autoload :OrganizationMember, "docomo-nlu/management/organization_member"
|
|
16
|
+
autoload :Organization, "docomo-nlu/management/organization"
|
|
17
|
+
autoload :PredicateName, "docomo-nlu/management/predicate_name"
|
|
18
|
+
autoload :ProjectMember, "docomo-nlu/management/project_member"
|
|
19
|
+
autoload :Project, "docomo-nlu/management/project"
|
|
20
|
+
autoload :Property, "docomo-nlu/management/property"
|
|
21
|
+
autoload :Provider, "docomo-nlu/management/provider"
|
|
22
|
+
autoload :ScenarioProject, "docomo-nlu/management/scenario_project"
|
|
23
|
+
autoload :ScenarioUtil, "docomo-nlu/management/scenario_util"
|
|
24
|
+
autoload :Scenario, "docomo-nlu/management/scenario"
|
|
25
|
+
autoload :Set, "docomo-nlu/management/set"
|
|
26
|
+
autoload :TaskProject, "docomo-nlu/management/task_project"
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -1,8 +1,49 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module DocomoNlu
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
class Spontaneous < ActiveResource::Base
|
|
5
|
+
attr_reader :result
|
|
6
|
+
attr_reader :error
|
|
7
|
+
self.site = DocomoNlu.config.nlu_host
|
|
8
|
+
|
|
9
|
+
## Remove format in path (remove .json)
|
|
10
|
+
self.include_format_in_path = false
|
|
11
|
+
|
|
12
|
+
## Setting Format
|
|
13
|
+
self.format = :json
|
|
14
|
+
|
|
15
|
+
def initialize
|
|
16
|
+
super
|
|
17
|
+
{
|
|
18
|
+
clientVer: "1.0.4",
|
|
19
|
+
language: "ja-JP",
|
|
20
|
+
location: { lat: "0", lon: "0" },
|
|
21
|
+
appRecvTime: DateTime.now.strftime("%Y-%m-%d %H:%M:%S"),
|
|
22
|
+
appSendTime: DateTime.now.strftime("%Y-%m-%d %H:%M:%S"),
|
|
23
|
+
}.each do |k, v|
|
|
24
|
+
@attributes.store(k, v)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def registration(app_kind = "docomo-nlu", app_id = "", registration_id = "", notification = false)
|
|
29
|
+
body = {
|
|
30
|
+
bot_id: @attributes[:botId],
|
|
31
|
+
app_id: app_id,
|
|
32
|
+
registration_id: registration_id,
|
|
33
|
+
app_kind: app_kind,
|
|
34
|
+
notification: notification,
|
|
35
|
+
}
|
|
36
|
+
res = connection.post("/UserRegistrationServer/users/applications", body.to_json, self.class.headers)
|
|
37
|
+
@attributes.store(:appId, JSON.parse(res.body)["app_id"])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def dialogue(voiceText, **params)
|
|
41
|
+
@attributes[:voiceText] = voiceText
|
|
42
|
+
params.each do |k, v|
|
|
43
|
+
@attributes[k] ||= v
|
|
44
|
+
end
|
|
45
|
+
res = connection.post("/SpontaneousDialogueServer/dialogue", @attributes.to_json, self.class.headers)
|
|
46
|
+
@result = JSON.parse(res.body)
|
|
47
|
+
end
|
|
7
48
|
end
|
|
8
49
|
end
|
data/lib/docomo-nlu/version.rb
CHANGED
data/lib/docomo-nlu.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
3
|
+
require "docomo-nlu/version"
|
|
4
|
+
require "docomo-nlu/config"
|
|
5
|
+
require "activeresource"
|
|
6
|
+
require "faraday"
|
|
7
7
|
|
|
8
8
|
module DocomoNlu
|
|
9
|
-
autoload :Spontaneous,
|
|
10
|
-
autoload :Management,
|
|
9
|
+
autoload :Spontaneous, "docomo-nlu/spontaneous"
|
|
10
|
+
autoload :Management, "docomo-nlu/management"
|
|
11
11
|
end
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module DocomoNlu
|
|
4
4
|
class InstallGenerator < ::Rails::Generators::Base
|
|
5
|
-
source_root File.expand_path(
|
|
5
|
+
source_root File.expand_path("../../templates", __dir__)
|
|
6
6
|
|
|
7
7
|
def copy_initializer
|
|
8
|
-
copy_file
|
|
8
|
+
copy_file "template.rb", "config/initializers/docomo_nlu.rb"
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
DocomoNlu.configure do |config|
|
|
4
|
-
config.nlu_host =
|
|
5
|
-
config.nlu_version =
|
|
6
|
-
config.admin_access_token =
|
|
4
|
+
config.nlu_host = "Set your host"
|
|
5
|
+
config.nlu_version = "Set version"
|
|
6
|
+
config.admin_access_token = "Set token that able to create account"
|
|
7
7
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: docomo-nlu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Koji Yamazaki
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activeresource
|
|
@@ -67,7 +67,7 @@ dependencies:
|
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
70
|
+
name: onkcop
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - ">="
|
|
@@ -81,7 +81,21 @@ dependencies:
|
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
84
|
+
name: pry
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 0.11.3
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 0.11.3
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rails
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
86
100
|
requirements:
|
|
87
101
|
- - ">="
|
|
@@ -95,7 +109,7 @@ dependencies:
|
|
|
95
109
|
- !ruby/object:Gem::Version
|
|
96
110
|
version: '0'
|
|
97
111
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
112
|
+
name: reek
|
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
|
100
114
|
requirements:
|
|
101
115
|
- - ">="
|
|
@@ -109,19 +123,19 @@ dependencies:
|
|
|
109
123
|
- !ruby/object:Gem::Version
|
|
110
124
|
version: '0'
|
|
111
125
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
126
|
+
name: rspec
|
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
|
114
128
|
requirements:
|
|
115
|
-
- - "
|
|
129
|
+
- - ">="
|
|
116
130
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: 0
|
|
131
|
+
version: '0'
|
|
118
132
|
type: :development
|
|
119
133
|
prerelease: false
|
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
135
|
requirements:
|
|
122
|
-
- - "
|
|
136
|
+
- - ">="
|
|
123
137
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: 0
|
|
138
|
+
version: '0'
|
|
125
139
|
- !ruby/object:Gem::Dependency
|
|
126
140
|
name: rubocop
|
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -172,6 +186,7 @@ extensions: []
|
|
|
172
186
|
extra_rdoc_files: []
|
|
173
187
|
files:
|
|
174
188
|
- ".gitignore"
|
|
189
|
+
- ".reek"
|
|
175
190
|
- ".rspec"
|
|
176
191
|
- ".rubocop.yml"
|
|
177
192
|
- ".ruby-version"
|
|
@@ -210,8 +225,6 @@ files:
|
|
|
210
225
|
- lib/docomo-nlu/management/set.rb
|
|
211
226
|
- lib/docomo-nlu/management/task_project.rb
|
|
212
227
|
- lib/docomo-nlu/spontaneous.rb
|
|
213
|
-
- lib/docomo-nlu/spontaneous/dialogue.rb
|
|
214
|
-
- lib/docomo-nlu/spontaneous/registration.rb
|
|
215
228
|
- lib/docomo-nlu/version.rb
|
|
216
229
|
- lib/generators/docomo_nlu/install/install_generator.rb
|
|
217
230
|
- lib/generators/templates/template.rb
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'securerandom'
|
|
4
|
-
module DocomoNlu
|
|
5
|
-
module Spontaneous
|
|
6
|
-
class Dialogue < ActiveResource::Base
|
|
7
|
-
attr_accessor :result
|
|
8
|
-
self.site = "http://#{DocomoNlu.config.nlu_host}/"
|
|
9
|
-
|
|
10
|
-
## Remove format in path (remove .json)
|
|
11
|
-
self.include_format_in_path = false
|
|
12
|
-
|
|
13
|
-
## Setting Format
|
|
14
|
-
self.format = :json
|
|
15
|
-
|
|
16
|
-
# 対話サーバからのapp_Id払い出し処理
|
|
17
|
-
# Parameter
|
|
18
|
-
# {
|
|
19
|
-
# "app_id" : "sebastien-marketplace",
|
|
20
|
-
# "bot_id" : "botId",
|
|
21
|
-
# "registration_id" : "null",
|
|
22
|
-
# "app_kind" : "sebastien-marketplace",
|
|
23
|
-
# "notification" : false
|
|
24
|
-
# }
|
|
25
|
-
def registration(app_id, bot_id, app_kind = 'developer_dashboard')
|
|
26
|
-
request_body =
|
|
27
|
-
{ 'app_id' => app_id, 'bot_id' => bot_id, 'registration_id' => nil, 'app_kind' => app_kind, 'notification' => false }.to_json
|
|
28
|
-
res = connection.post('/UserRegistrationServer/users/applications', request_body, self.class.headers)
|
|
29
|
-
if res.code == '200'
|
|
30
|
-
attributes.store('appId', app_id)
|
|
31
|
-
else
|
|
32
|
-
attributes.store('errors', res.body)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def execute(voiceText, initTopicId = nil)
|
|
37
|
-
self.voiceText = voiceText
|
|
38
|
-
self.initTopicId = initTopicId unless initTopicId.nil?
|
|
39
|
-
res = connection.post('/SpontaneousDialogueServer/dialogue', attributes.to_json, self.class.headers)
|
|
40
|
-
@result = res
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
class << self
|
|
44
|
-
def collection_path(prefix_options = {}, query_options = nil)
|
|
45
|
-
check_prefix_options(prefix_options)
|
|
46
|
-
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
|
47
|
-
"#{prefix(prefix_options)}#{collection_name}#{format_extension}#{query_string(query_options)}"
|
|
48
|
-
end
|
|
49
|
-
# Override. Native code is here
|
|
50
|
-
# @collection_name ||= ActiveSupport::Inflector.pluralize(element_name)
|
|
51
|
-
|
|
52
|
-
def collection_name
|
|
53
|
-
@collection_name ||= element_name
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'securerandom'
|
|
4
|
-
module DocomoNlu
|
|
5
|
-
module Spontaneous
|
|
6
|
-
class Registration < ActiveResource::Base
|
|
7
|
-
attr_accessor :result
|
|
8
|
-
self.site = "http://#{DocomoNlu.config.nlu_host}/"
|
|
9
|
-
|
|
10
|
-
## Remove format in path (remove .json)
|
|
11
|
-
self.include_format_in_path = false
|
|
12
|
-
|
|
13
|
-
## Setting Format
|
|
14
|
-
self.format = :json
|
|
15
|
-
|
|
16
|
-
# 対話サーバからのapp_Id払い出し処理
|
|
17
|
-
# Parameter
|
|
18
|
-
# {
|
|
19
|
-
# "app_id" : "sebastien-marketplace",
|
|
20
|
-
# "bot_id" : "botId",
|
|
21
|
-
# "registration_id" : "null",
|
|
22
|
-
# "app_kind" : "sebastien-marketplace",
|
|
23
|
-
# "notification" : false
|
|
24
|
-
# }
|
|
25
|
-
def registration(app_id, bot_id, app_kind = 'developer_dashboard')
|
|
26
|
-
request_body =
|
|
27
|
-
{ 'app_id' => app_id, 'bot_id' => bot_id, 'registration_id' => nil, 'app_kind' => app_kind, 'notification' => false }.to_json
|
|
28
|
-
res = connection.post('/UserRegistrationServer/users/applications', request_body, self.class.headers)
|
|
29
|
-
if res.code == '200'
|
|
30
|
-
attributes.store('appId', app_id)
|
|
31
|
-
else
|
|
32
|
-
attributes.store('errors', res.body)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def execute(voice_text, _init_topic_d = nil)
|
|
37
|
-
self.voiceText = voice_text
|
|
38
|
-
self.initTopicId = init_topic_id unless init_topic_id.nil?
|
|
39
|
-
res = connection.post('/SpontaneousDialogueServer/dialogue', attributes.to_json, self.class.headers)
|
|
40
|
-
@result = res
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
class << self
|
|
44
|
-
def collection_path(prefix_options = {}, query_options = nil)
|
|
45
|
-
check_prefix_options(prefix_options)
|
|
46
|
-
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
|
|
47
|
-
"#{prefix(prefix_options)}#{collection_name}#{format_extension}#{query_string(query_options)}"
|
|
48
|
-
end
|
|
49
|
-
# Override. Native code is here
|
|
50
|
-
# @collection_name ||= ActiveSupport::Inflector.pluralize(element_name)
|
|
51
|
-
|
|
52
|
-
def collection_name
|
|
53
|
-
@collection_name ||= element_name
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|