docomo-nlu 0.3.2 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +73 -61
- data/docomo-nlu.gemspec +1 -1
- data/lib/docomo_nlu/management.rb +1 -0
- data/lib/docomo_nlu/management/ng_word.rb +2 -1
- data/lib/docomo_nlu/management/ok_ng_base.rb +76 -0
- data/lib/docomo_nlu/management/ok_word.rb +2 -1
- data/lib/docomo_nlu/spontaneous.rb +3 -3
- data/lib/docomo_nlu/version.rb +1 -1
- data/vcr/vcr_cassettes/management/ng_word/create.yml +46 -0
- data/vcr/vcr_cassettes/management/ng_word/create_400.yml +50 -0
- data/vcr/vcr_cassettes/management/ng_word/create_409.yml +48 -0
- data/vcr/vcr_cassettes/management/ng_word/delete.yml +38 -0
- data/vcr/vcr_cassettes/management/ng_word/download.yml +44 -0
- data/vcr/vcr_cassettes/management/ng_word/index_all.yml +44 -0
- data/vcr/vcr_cassettes/management/ng_word/index_find.yml +44 -0
- data/vcr/vcr_cassettes/management/ng_word/index_where.yml +44 -0
- data/vcr/vcr_cassettes/management/ng_word/save.yml +46 -0
- data/vcr/vcr_cassettes/management/ng_word/save_400.yml +50 -0
- data/vcr/vcr_cassettes/management/ng_word/save_409.yml +48 -0
- data/vcr/vcr_cassettes/management/ng_word/show_find.yml +44 -0
- data/vcr/vcr_cassettes/management/ok_word/create.yml +46 -0
- data/vcr/vcr_cassettes/management/ok_word/create_400.yml +50 -0
- data/vcr/vcr_cassettes/management/ok_word/create_409.yml +48 -0
- data/vcr/vcr_cassettes/management/ok_word/delete.yml +38 -0
- data/vcr/vcr_cassettes/management/ok_word/download.yml +44 -0
- data/vcr/vcr_cassettes/management/ok_word/index_all.yml +44 -0
- data/vcr/vcr_cassettes/management/ok_word/index_find.yml +44 -0
- data/vcr/vcr_cassettes/management/ok_word/index_where.yml +44 -0
- data/vcr/vcr_cassettes/management/ok_word/save.yml +46 -0
- data/vcr/vcr_cassettes/management/ok_word/save_400.yml +50 -0
- data/vcr/vcr_cassettes/management/ok_word/save_409.yml +48 -0
- data/vcr/vcr_cassettes/management/ok_word/show_find.yml +44 -0
- metadata +31 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d47523db1c4072b7ae33456b4a9c6dfb42794cad3f5cce027628ebbc677ed3e8
|
4
|
+
data.tar.gz: 882644849015a6f177bca7d8da3540f06dcd94b74bb59058c7f90f02a6cad7a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33953e22ea5dc056262b65d99a49bfc3677f1d7cea1f985645ada6c8fa0eed46b62794ec12d3c64c48950aa1518e0ae8c529d74017649e8fba67c70b3d0d905f
|
7
|
+
data.tar.gz: a1af58b992bf5fb24c1339fd9c975e743c10e536befbb1f97ba059510b0d664c649e4624aa6f8977acaa80cda86175e3129d8fa6ce73a963ffcdc6665a0bc055
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
docomo-nlu (0.3.
|
4
|
+
docomo-nlu (0.3.8)
|
5
5
|
activeresource (>= 5.0, < 5.2)
|
6
6
|
bundler
|
7
7
|
faraday
|
@@ -11,51 +11,51 @@ PATH
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
actioncable (5.2.
|
15
|
-
actionpack (= 5.2.
|
14
|
+
actioncable (5.2.6)
|
15
|
+
actionpack (= 5.2.6)
|
16
16
|
nio4r (~> 2.0)
|
17
17
|
websocket-driver (>= 0.6.1)
|
18
|
-
actionmailer (5.2.
|
19
|
-
actionpack (= 5.2.
|
20
|
-
actionview (= 5.2.
|
21
|
-
activejob (= 5.2.
|
18
|
+
actionmailer (5.2.6)
|
19
|
+
actionpack (= 5.2.6)
|
20
|
+
actionview (= 5.2.6)
|
21
|
+
activejob (= 5.2.6)
|
22
22
|
mail (~> 2.5, >= 2.5.4)
|
23
23
|
rails-dom-testing (~> 2.0)
|
24
|
-
actionpack (5.2.
|
25
|
-
actionview (= 5.2.
|
26
|
-
activesupport (= 5.2.
|
24
|
+
actionpack (5.2.6)
|
25
|
+
actionview (= 5.2.6)
|
26
|
+
activesupport (= 5.2.6)
|
27
27
|
rack (~> 2.0, >= 2.0.8)
|
28
28
|
rack-test (>= 0.6.3)
|
29
29
|
rails-dom-testing (~> 2.0)
|
30
30
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
31
|
-
actionview (5.2.
|
32
|
-
activesupport (= 5.2.
|
31
|
+
actionview (5.2.6)
|
32
|
+
activesupport (= 5.2.6)
|
33
33
|
builder (~> 3.1)
|
34
34
|
erubi (~> 1.4)
|
35
35
|
rails-dom-testing (~> 2.0)
|
36
36
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
37
|
-
activejob (5.2.
|
38
|
-
activesupport (= 5.2.
|
37
|
+
activejob (5.2.6)
|
38
|
+
activesupport (= 5.2.6)
|
39
39
|
globalid (>= 0.3.6)
|
40
|
-
activemodel (5.2.
|
41
|
-
activesupport (= 5.2.
|
40
|
+
activemodel (5.2.6)
|
41
|
+
activesupport (= 5.2.6)
|
42
42
|
activemodel-serializers-xml (1.0.2)
|
43
43
|
activemodel (> 5.x)
|
44
44
|
activesupport (> 5.x)
|
45
45
|
builder (~> 3.1)
|
46
|
-
activerecord (5.2.
|
47
|
-
activemodel (= 5.2.
|
48
|
-
activesupport (= 5.2.
|
46
|
+
activerecord (5.2.6)
|
47
|
+
activemodel (= 5.2.6)
|
48
|
+
activesupport (= 5.2.6)
|
49
49
|
arel (>= 9.0)
|
50
50
|
activeresource (5.1.1)
|
51
51
|
activemodel (>= 5.0, < 7)
|
52
52
|
activemodel-serializers-xml (~> 1.0)
|
53
53
|
activesupport (>= 5.0, < 7)
|
54
|
-
activestorage (5.2.
|
55
|
-
actionpack (= 5.2.
|
56
|
-
activerecord (= 5.2.
|
57
|
-
marcel (~> 0.
|
58
|
-
activesupport (5.2.
|
54
|
+
activestorage (5.2.6)
|
55
|
+
actionpack (= 5.2.6)
|
56
|
+
activerecord (= 5.2.6)
|
57
|
+
marcel (~> 1.0.0)
|
58
|
+
activesupport (5.2.6)
|
59
59
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
60
60
|
i18n (>= 0.7, < 2)
|
61
61
|
minitest (~> 5.1)
|
@@ -66,36 +66,46 @@ GEM
|
|
66
66
|
ast (2.4.0)
|
67
67
|
builder (3.2.4)
|
68
68
|
coderay (1.1.2)
|
69
|
-
concurrent-ruby (1.1.
|
69
|
+
concurrent-ruby (1.1.8)
|
70
70
|
crack (0.4.3)
|
71
71
|
safe_yaml (~> 1.0.0)
|
72
72
|
crass (1.0.6)
|
73
73
|
diff-lcs (1.3)
|
74
|
-
erubi (1.
|
75
|
-
faraday (1.
|
74
|
+
erubi (1.10.0)
|
75
|
+
faraday (1.4.2)
|
76
|
+
faraday-em_http (~> 1.0)
|
77
|
+
faraday-em_synchrony (~> 1.0)
|
78
|
+
faraday-excon (~> 1.1)
|
79
|
+
faraday-net_http (~> 1.0)
|
80
|
+
faraday-net_http_persistent (~> 1.1)
|
76
81
|
multipart-post (>= 1.2, < 3)
|
82
|
+
ruby2_keywords (>= 0.0.4)
|
83
|
+
faraday-em_http (1.0.0)
|
84
|
+
faraday-em_synchrony (1.0.0)
|
85
|
+
faraday-excon (1.1.0)
|
86
|
+
faraday-net_http (1.0.1)
|
87
|
+
faraday-net_http_persistent (1.1.0)
|
77
88
|
globalid (0.4.2)
|
78
89
|
activesupport (>= 4.2.0)
|
79
90
|
hashdiff (1.0.1)
|
80
|
-
i18n (1.8.
|
91
|
+
i18n (1.8.10)
|
81
92
|
concurrent-ruby (~> 1.0)
|
82
93
|
kwalify (0.7.2)
|
83
|
-
loofah (2.
|
94
|
+
loofah (2.9.1)
|
84
95
|
crass (~> 1.0.2)
|
85
96
|
nokogiri (>= 1.5.9)
|
86
97
|
mail (2.7.1)
|
87
98
|
mini_mime (>= 0.1.1)
|
88
|
-
marcel (0.
|
89
|
-
mimemagic (~> 0.3.2)
|
99
|
+
marcel (1.0.1)
|
90
100
|
method_source (0.9.2)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
minitest (5.14.1)
|
101
|
+
mini_mime (1.1.0)
|
102
|
+
mini_portile2 (2.5.1)
|
103
|
+
minitest (5.14.4)
|
95
104
|
multipart-post (2.1.1)
|
96
|
-
nio4r (2.5.
|
97
|
-
nokogiri (1.
|
98
|
-
mini_portile2 (~> 2.
|
105
|
+
nio4r (2.5.7)
|
106
|
+
nokogiri (1.11.4)
|
107
|
+
mini_portile2 (~> 2.5.0)
|
108
|
+
racc (~> 1.4)
|
99
109
|
parallel (1.19.1)
|
100
110
|
parser (2.7.1.2)
|
101
111
|
ast (~> 2.4.0)
|
@@ -104,41 +114,42 @@ GEM
|
|
104
114
|
method_source (~> 0.9.0)
|
105
115
|
psych (3.1.0)
|
106
116
|
public_suffix (4.0.5)
|
107
|
-
|
117
|
+
racc (1.5.2)
|
118
|
+
rack (2.2.3)
|
108
119
|
rack-test (1.1.0)
|
109
120
|
rack (>= 1.0, < 3)
|
110
|
-
rails (5.2.
|
111
|
-
actioncable (= 5.2.
|
112
|
-
actionmailer (= 5.2.
|
113
|
-
actionpack (= 5.2.
|
114
|
-
actionview (= 5.2.
|
115
|
-
activejob (= 5.2.
|
116
|
-
activemodel (= 5.2.
|
117
|
-
activerecord (= 5.2.
|
118
|
-
activestorage (= 5.2.
|
119
|
-
activesupport (= 5.2.
|
121
|
+
rails (5.2.6)
|
122
|
+
actioncable (= 5.2.6)
|
123
|
+
actionmailer (= 5.2.6)
|
124
|
+
actionpack (= 5.2.6)
|
125
|
+
actionview (= 5.2.6)
|
126
|
+
activejob (= 5.2.6)
|
127
|
+
activemodel (= 5.2.6)
|
128
|
+
activerecord (= 5.2.6)
|
129
|
+
activestorage (= 5.2.6)
|
130
|
+
activesupport (= 5.2.6)
|
120
131
|
bundler (>= 1.3.0)
|
121
|
-
railties (= 5.2.
|
132
|
+
railties (= 5.2.6)
|
122
133
|
sprockets-rails (>= 2.0.0)
|
123
134
|
rails-dom-testing (2.0.3)
|
124
135
|
activesupport (>= 4.2.0)
|
125
136
|
nokogiri (>= 1.6)
|
126
137
|
rails-html-sanitizer (1.3.0)
|
127
138
|
loofah (~> 2.3)
|
128
|
-
railties (5.2.
|
129
|
-
actionpack (= 5.2.
|
130
|
-
activesupport (= 5.2.
|
139
|
+
railties (5.2.6)
|
140
|
+
actionpack (= 5.2.6)
|
141
|
+
activesupport (= 5.2.6)
|
131
142
|
method_source
|
132
143
|
rake (>= 0.8.7)
|
133
144
|
thor (>= 0.19.0, < 2.0)
|
134
145
|
rainbow (3.0.0)
|
135
|
-
rake (13.0.
|
146
|
+
rake (13.0.3)
|
136
147
|
reek (6.0.0)
|
137
148
|
kwalify (~> 0.7.0)
|
138
149
|
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
139
150
|
psych (~> 3.1.0)
|
140
151
|
rainbow (>= 2.0, < 4.0)
|
141
|
-
rexml (3.2.
|
152
|
+
rexml (3.2.5)
|
142
153
|
rspec (3.9.0)
|
143
154
|
rspec-core (~> 3.9.0)
|
144
155
|
rspec-expectations (~> 3.9.0)
|
@@ -166,18 +177,19 @@ GEM
|
|
166
177
|
rubocop-rspec (1.35.0)
|
167
178
|
rubocop (>= 0.60.0)
|
168
179
|
ruby-progressbar (1.10.1)
|
180
|
+
ruby2_keywords (0.0.4)
|
169
181
|
rubyzip (2.3.0)
|
170
182
|
safe_yaml (1.0.5)
|
171
|
-
sprockets (4.0.
|
183
|
+
sprockets (4.0.2)
|
172
184
|
concurrent-ruby (~> 1.0)
|
173
185
|
rack (> 1, < 3)
|
174
|
-
sprockets-rails (3.2.
|
186
|
+
sprockets-rails (3.2.2)
|
175
187
|
actionpack (>= 4.0)
|
176
188
|
activesupport (>= 4.0)
|
177
189
|
sprockets (>= 3.0.0)
|
178
|
-
thor (1.0
|
190
|
+
thor (1.1.0)
|
179
191
|
thread_safe (0.3.6)
|
180
|
-
tzinfo (1.2.
|
192
|
+
tzinfo (1.2.9)
|
181
193
|
thread_safe (~> 0.1)
|
182
194
|
unicode-display_width (1.7.0)
|
183
195
|
vcr (5.1.0)
|
@@ -185,7 +197,7 @@ GEM
|
|
185
197
|
addressable (>= 2.3.6)
|
186
198
|
crack (>= 0.3.2)
|
187
199
|
hashdiff
|
188
|
-
websocket-driver (0.7.
|
200
|
+
websocket-driver (0.7.3)
|
189
201
|
websocket-extensions (>= 0.1.0)
|
190
202
|
websocket-extensions (0.1.5)
|
191
203
|
|
@@ -195,7 +207,7 @@ PLATFORMS
|
|
195
207
|
DEPENDENCIES
|
196
208
|
docomo-nlu!
|
197
209
|
pry (~> 0.11.3)
|
198
|
-
rails
|
210
|
+
rails (~> 5.2.5)
|
199
211
|
reek
|
200
212
|
rspec
|
201
213
|
rspec_junit_formatter
|
data/docomo-nlu.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_dependency "rake"
|
30
30
|
spec.add_dependency "rubyzip"
|
31
31
|
spec.add_development_dependency "pry", "~> 0.11.3"
|
32
|
-
spec.add_development_dependency "rails"
|
32
|
+
spec.add_development_dependency "rails", "~> 5.2.5"
|
33
33
|
spec.add_development_dependency "reek"
|
34
34
|
spec.add_development_dependency "rspec"
|
35
35
|
spec.add_development_dependency "rspec_junit_formatter"
|
@@ -15,6 +15,7 @@ module DocomoNlu
|
|
15
15
|
autoload :Map, "docomo_nlu/management/map"
|
16
16
|
autoload :NGWord, "docomo_nlu/management/ng_word"
|
17
17
|
autoload :OKWord, "docomo_nlu/management/ok_word"
|
18
|
+
autoload :OKNGBase, "docomo_nlu/management/ok_ng_base"
|
18
19
|
autoload :OrganizationMember, "docomo_nlu/management/organization_member"
|
19
20
|
autoload :Organization, "docomo_nlu/management/organization"
|
20
21
|
autoload :PredicateName, "docomo_nlu/management/predicate_name"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tempfile"
|
4
|
+
module DocomoNlu
|
5
|
+
module Management
|
6
|
+
class OKNGBase < Base
|
7
|
+
class_attribute :extention
|
8
|
+
|
9
|
+
def save
|
10
|
+
self.class.create(attributes[:file], prefix_options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def destroy
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def download
|
18
|
+
self.file = self.class.download(prefix_options).file
|
19
|
+
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def create(file, prefix_options)
|
23
|
+
check_prefix_options(prefix_options)
|
24
|
+
upload(file, prefix_options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def all(options = {})
|
28
|
+
find(options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def find(options)
|
32
|
+
prefix_options, = split_options(options[:params])
|
33
|
+
check_prefix_options(prefix_options)
|
34
|
+
download(prefix_options)
|
35
|
+
end
|
36
|
+
|
37
|
+
def where(clauses = {})
|
38
|
+
find(params: clauses)
|
39
|
+
end
|
40
|
+
|
41
|
+
def download(prefix_options = {})
|
42
|
+
conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
|
43
|
+
builder.adapter :net_http
|
44
|
+
end
|
45
|
+
conn.headers["Authorization"] = access_token
|
46
|
+
|
47
|
+
response = conn.get(element_path(nil, prefix_options))
|
48
|
+
|
49
|
+
if check_response(response)
|
50
|
+
return instantiate_record({}, prefix_options).tap do |record|
|
51
|
+
record.file = Tempfile.open(["docomo-nlu", extention]) do |f|
|
52
|
+
f.write response.body.force_encoding("UTF-8")
|
53
|
+
f
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def upload(file, prefix_options)
|
61
|
+
conn = Faraday.new(url: site.to_s, ssl: { verify: false }) do |builder|
|
62
|
+
builder.request :multipart
|
63
|
+
builder.request :url_encoded
|
64
|
+
builder.adapter :net_http
|
65
|
+
end
|
66
|
+
conn.headers["Authorization"] = access_token
|
67
|
+
params = {
|
68
|
+
uploadFile: Faraday::UploadIO.new(file.path, "text/plain"),
|
69
|
+
}
|
70
|
+
response = conn.put collection_path(prefix_options), params
|
71
|
+
check_response(response)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -19,8 +19,8 @@ module DocomoNlu
|
|
19
19
|
clientVer: "1.0.4",
|
20
20
|
language: "ja-JP",
|
21
21
|
location: { lat: "0", lon: "0" },
|
22
|
-
appRecvTime: Time.
|
23
|
-
appSendTime: Time.
|
22
|
+
appRecvTime: Time.now.strftime("%Y-%m-%d %H:%M:%S"),
|
23
|
+
appSendTime: Time.now.strftime("%Y-%m-%d %H:%M:%S"),
|
24
24
|
}.each do |k, v|
|
25
25
|
@attributes.store(k, v)
|
26
26
|
end
|
@@ -38,7 +38,7 @@ module DocomoNlu
|
|
38
38
|
@attributes.store(:appId, JSON.parse(res.body)["app_id"])
|
39
39
|
end
|
40
40
|
|
41
|
-
def dialogue(voice_text,
|
41
|
+
def dialogue(voice_text, params = {})
|
42
42
|
@attributes[:voiceText] = voice_text
|
43
43
|
params.each do |k, v|
|
44
44
|
@attributes[k] ||= v
|
data/lib/docomo_nlu/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: "<Host>/management/<Version>/projects/48/bots/test_bot/ngWords"
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "-------------RubyMultipartPost-dca8336190defd6700cdd232ce51c186\r\nContent-Disposition:
|
9
|
+
form-data; name=\"uploadFile\"; filename=\"test.ng\"\r\nContent-Length: 6\r\nContent-Type:
|
10
|
+
text/plain\r\nContent-Transfer-Encoding: binary\r\n\r\nNG OK\r\n-------------RubyMultipartPost-dca8336190defd6700cdd232ce51c186--\r\n"
|
11
|
+
headers:
|
12
|
+
User-Agent:
|
13
|
+
- Faraday v1.0.1
|
14
|
+
Authorization:
|
15
|
+
- "<AdminAccessToken>"
|
16
|
+
Content-Type:
|
17
|
+
- multipart/form-data; boundary=-----------RubyMultipartPost-dca8336190defd6700cdd232ce51c186
|
18
|
+
Content-Length:
|
19
|
+
- '293'
|
20
|
+
Accept-Encoding:
|
21
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
22
|
+
Accept:
|
23
|
+
- "*/*"
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 201
|
27
|
+
message: '201'
|
28
|
+
headers:
|
29
|
+
Date:
|
30
|
+
- Sun, 25 Oct 2020 14:04:22 GMT
|
31
|
+
Content-Length:
|
32
|
+
- '0'
|
33
|
+
Connection:
|
34
|
+
- keep-alive
|
35
|
+
Server:
|
36
|
+
- Apache
|
37
|
+
X-Content-Type-Options:
|
38
|
+
- nosniff
|
39
|
+
X-Frame-Options:
|
40
|
+
- SAMEORIGIN
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: ''
|
44
|
+
http_version: null
|
45
|
+
recorded_at: Sun, 25 Oct 2020 14:04:22 GMT
|
46
|
+
recorded_with: VCR 5.1.0
|