stealth-luis 1.0.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +39 -46
- data/README.md +5 -0
- data/lib/stealth/nlp/luis/client.rb +11 -6
- data/lib/stealth/nlp/luis/result.rb +19 -2
- data/stealth-luis.gemspec +8 -3
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26190207d9a05e1834bdc87a01e776086a2ebe42185721318da7dad8bb99d571
|
4
|
+
data.tar.gz: bf40713a23368020624fe4ece78672c5036cb6f024d97060c2c39a8e3b0af697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23605e8ac81023589db30ca9598d39086d2373b76785a97769a368aaf00cdca105706935e1001caf6705c2db792780ed4819bd70d99fbab93a87f0015f7f03c2
|
7
|
+
data.tar.gz: 82a1e7268c759dc2817b7d603f3de4dface711de5b37c41927f4a08c318f3381b739ea7429e80d5fb14f55909ddc857b9e7b6751e0603c41f443a60334955090
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# Changelog 1.2.1
|
2
|
+
|
3
|
+
## Features
|
4
|
+
|
5
|
+
* Updated gems
|
6
|
+
|
7
|
+
# Changelog 1.2.0
|
8
|
+
|
9
|
+
## Bugfixes
|
10
|
+
|
11
|
+
* `datetimeReference` is not respected by LUIS when specified as a `GET`. Switched to `POST`
|
12
|
+
* Renamed `tz_offset` option to `datetime_reference` to more closely match the LUIS API
|
13
|
+
|
14
|
+
# Changelog 1.1.0
|
15
|
+
|
16
|
+
## Features
|
17
|
+
|
18
|
+
* Added intent threshold option; intents with lower scores than the threshold are not matched.
|
19
|
+
|
1
20
|
# Changelog 1.0.0
|
2
21
|
|
3
22
|
## Bugfixes
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,44 +1,31 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/hellostealth/stealth
|
3
|
-
revision: d6d3c626d2faa951203da652f733c4a18162e1f5
|
4
|
-
branch: master
|
5
|
-
specs:
|
6
|
-
stealth (2.0.0)
|
7
|
-
activesupport (~> 6.0)
|
8
|
-
multi_json (~> 1.12)
|
9
|
-
puma (>= 4.2, < 5.0)
|
10
|
-
sidekiq (~> 6.0)
|
11
|
-
sinatra (~> 2.0)
|
12
|
-
thor (~> 1.0)
|
13
|
-
|
14
1
|
PATH
|
15
2
|
remote: .
|
16
3
|
specs:
|
17
|
-
stealth-luis (
|
4
|
+
stealth-luis (1.2.1)
|
18
5
|
http (~> 4)
|
19
|
-
stealth (
|
6
|
+
stealth (>= 2.0.0.beta)
|
20
7
|
|
21
8
|
GEM
|
22
9
|
remote: https://rubygems.org/
|
23
10
|
specs:
|
24
|
-
activesupport (6.0.
|
11
|
+
activesupport (6.0.3.3)
|
25
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
13
|
i18n (>= 0.7, < 2)
|
27
14
|
minitest (~> 5.1)
|
28
15
|
tzinfo (~> 1.1)
|
29
|
-
zeitwerk (~> 2.2)
|
16
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
30
17
|
addressable (2.7.0)
|
31
18
|
public_suffix (>= 2.0.2, < 5.0)
|
32
|
-
concurrent-ruby (1.1.
|
33
|
-
connection_pool (2.2.
|
34
|
-
diff-lcs (1.
|
19
|
+
concurrent-ruby (1.1.7)
|
20
|
+
connection_pool (2.2.3)
|
21
|
+
diff-lcs (1.4.4)
|
35
22
|
domain_name (0.5.20190701)
|
36
23
|
unf (>= 0.0.5, < 1.0.0)
|
37
|
-
ffi (1.
|
24
|
+
ffi (1.13.1)
|
38
25
|
ffi-compiler (1.0.1)
|
39
26
|
ffi (>= 1.0.0)
|
40
27
|
rake
|
41
|
-
http (4.
|
28
|
+
http (4.4.1)
|
42
29
|
addressable (~> 2.3)
|
43
30
|
http-cookie (~> 1.0)
|
44
31
|
http-form_data (~> 2.2)
|
@@ -48,62 +35,68 @@ GEM
|
|
48
35
|
http-form_data (2.3.0)
|
49
36
|
http-parser (1.2.1)
|
50
37
|
ffi-compiler (>= 1.0, < 2.0)
|
51
|
-
i18n (1.8.
|
38
|
+
i18n (1.8.5)
|
52
39
|
concurrent-ruby (~> 1.0)
|
53
|
-
minitest (5.14.
|
54
|
-
multi_json (1.
|
40
|
+
minitest (5.14.2)
|
41
|
+
multi_json (1.15.0)
|
55
42
|
mustermann (1.1.1)
|
56
43
|
ruby2_keywords (~> 0.0.1)
|
57
|
-
nio4r (2.5.
|
58
|
-
public_suffix (4.0.
|
59
|
-
puma (4.3.
|
44
|
+
nio4r (2.5.4)
|
45
|
+
public_suffix (4.0.6)
|
46
|
+
puma (4.3.6)
|
60
47
|
nio4r (~> 2.0)
|
61
|
-
rack (2.2.
|
62
|
-
rack-protection (2.0
|
48
|
+
rack (2.2.3)
|
49
|
+
rack-protection (2.1.0)
|
63
50
|
rack
|
64
51
|
rake (13.0.1)
|
65
|
-
redis (4.
|
52
|
+
redis (4.2.2)
|
66
53
|
rspec (3.9.0)
|
67
54
|
rspec-core (~> 3.9.0)
|
68
55
|
rspec-expectations (~> 3.9.0)
|
69
56
|
rspec-mocks (~> 3.9.0)
|
70
|
-
rspec-core (3.9.
|
71
|
-
rspec-support (~> 3.9.
|
72
|
-
rspec-expectations (3.9.
|
57
|
+
rspec-core (3.9.2)
|
58
|
+
rspec-support (~> 3.9.3)
|
59
|
+
rspec-expectations (3.9.2)
|
73
60
|
diff-lcs (>= 1.2.0, < 2.0)
|
74
61
|
rspec-support (~> 3.9.0)
|
75
62
|
rspec-mocks (3.9.1)
|
76
63
|
diff-lcs (>= 1.2.0, < 2.0)
|
77
64
|
rspec-support (~> 3.9.0)
|
78
|
-
rspec-support (3.9.
|
65
|
+
rspec-support (3.9.3)
|
79
66
|
ruby2_keywords (0.0.2)
|
80
|
-
sidekiq (6.
|
67
|
+
sidekiq (6.1.2)
|
81
68
|
connection_pool (>= 2.2.2)
|
82
69
|
rack (~> 2.0)
|
83
|
-
|
84
|
-
|
85
|
-
sinatra (2.0.8.1)
|
70
|
+
redis (>= 4.2.0)
|
71
|
+
sinatra (2.1.0)
|
86
72
|
mustermann (~> 1.0)
|
87
|
-
rack (~> 2.
|
88
|
-
rack-protection (= 2.0
|
73
|
+
rack (~> 2.2)
|
74
|
+
rack-protection (= 2.1.0)
|
89
75
|
tilt (~> 2.0)
|
76
|
+
stealth (2.0.0.beta1)
|
77
|
+
activesupport (~> 6.0)
|
78
|
+
multi_json (~> 1.12)
|
79
|
+
puma (>= 4.2, < 5.0)
|
80
|
+
sidekiq (~> 6.0)
|
81
|
+
sinatra (~> 2.0)
|
82
|
+
thor (~> 1.0)
|
90
83
|
thor (1.0.1)
|
91
84
|
thread_safe (0.3.6)
|
92
85
|
tilt (2.0.10)
|
93
|
-
tzinfo (1.2.
|
86
|
+
tzinfo (1.2.7)
|
94
87
|
thread_safe (~> 0.1)
|
95
88
|
unf (0.1.4)
|
96
89
|
unf_ext
|
97
|
-
unf_ext (0.0.7.
|
98
|
-
zeitwerk (2.
|
90
|
+
unf_ext (0.0.7.7)
|
91
|
+
zeitwerk (2.4.0)
|
99
92
|
|
100
93
|
PLATFORMS
|
101
94
|
ruby
|
102
95
|
|
103
96
|
DEPENDENCIES
|
104
97
|
rspec (= 3.9.0)
|
105
|
-
stealth
|
98
|
+
stealth (>= 2.0.0.beta)
|
106
99
|
stealth-luis!
|
107
100
|
|
108
101
|
BUNDLED WITH
|
109
|
-
2.1.
|
102
|
+
2.1.4
|
data/README.md
CHANGED
@@ -16,6 +16,7 @@ default: &default
|
|
16
16
|
app_id: 9434fbd8-420b-6d75-8a6f-b6c9a0ac5ec0
|
17
17
|
subscription_key: 1b69a4b9db669805b4fcba5f1f2f87bb
|
18
18
|
tz_offset: 0
|
19
|
+
intent_threshold: 0.2
|
19
20
|
|
20
21
|
production:
|
21
22
|
<<: *default
|
@@ -49,6 +50,10 @@ Otherwise, the intent named `yes` and the intent named `no` will attempt to be m
|
|
49
50
|
|
50
51
|
For more info about how intents are matched, please see the [Stealth NLP documentation](https://github.com/hellostealth/stealth/wiki/NLP).
|
51
52
|
|
53
|
+
### intent_threshold
|
54
|
+
|
55
|
+
This is the real number that respresents the minimum threshold required for an intent to match. So if for example your `intent_threshold` is set to `0.2`, if the top intent scores `0.09`, it will not be returned as a match.
|
56
|
+
|
52
57
|
## Entities
|
53
58
|
|
54
59
|
The entity types listed below are named using their corresponding Stealth type. The equivalent type used by Microsoft LUIS is also listed. For each code sample, the sample query is first provided followed by the array of entities extracted from the queries (for the given type).
|
@@ -5,12 +5,12 @@ module Stealth
|
|
5
5
|
module Luis
|
6
6
|
class Client < Stealth::Nlp::Client
|
7
7
|
|
8
|
-
def initialize(subscription_key: nil, app_id: nil, endpoint: nil,
|
8
|
+
def initialize(subscription_key: nil, app_id: nil, endpoint: nil, datetime_ref: nil)
|
9
9
|
begin
|
10
10
|
@subscription_key = subscription_key || Stealth.config.luis.subscription_key
|
11
11
|
@app_id = app_id || Stealth.config.luis.app_id
|
12
12
|
@endpoint = endpoint || Stealth.config.luis.endpoint
|
13
|
-
@
|
13
|
+
@datetime_ref = datetime_ref || Stealth.config.luis.datetime_reference
|
14
14
|
@slot = Stealth.env.development? ? 'staging' : 'production'
|
15
15
|
rescue NoMethodError
|
16
16
|
raise(
|
@@ -35,16 +35,21 @@ module Stealth
|
|
35
35
|
|
36
36
|
def understand(query:)
|
37
37
|
params = {
|
38
|
-
'
|
39
|
-
'subscription-key' => @subscription_key,
|
40
|
-
'query' => query
|
38
|
+
'subscription-key' => @subscription_key
|
41
39
|
}
|
42
40
|
|
41
|
+
body = MultiJson.dump({
|
42
|
+
'query' => query,
|
43
|
+
'options' => {
|
44
|
+
'datetimeReference' => @datetime_ref,
|
45
|
+
}
|
46
|
+
})
|
47
|
+
|
43
48
|
Stealth::Logger.l(
|
44
49
|
topic: :nlp,
|
45
50
|
message: 'Performing NLP lookup via Microsoft LUIS'
|
46
51
|
)
|
47
|
-
result = client.
|
52
|
+
result = client.post(endpoint, params: params, body: body)
|
48
53
|
Result.new(result: result)
|
49
54
|
end
|
50
55
|
|
@@ -71,7 +71,7 @@ module Stealth
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def intent_score
|
74
|
-
parsed_result&.dig('prediction', 'intents', top_intent)
|
74
|
+
parsed_result&.dig('prediction', 'intents', top_intent, 'score')
|
75
75
|
end
|
76
76
|
|
77
77
|
def raw_entities
|
@@ -105,7 +105,24 @@ module Stealth
|
|
105
105
|
private
|
106
106
|
|
107
107
|
def top_intent
|
108
|
-
|
108
|
+
@top_intent ||= begin
|
109
|
+
matched_intent = parsed_result&.dig('prediction', 'topIntent')
|
110
|
+
_intent_score = parsed_result&.dig('prediction', 'intents', matched_intent, 'score')
|
111
|
+
|
112
|
+
if Stealth.config.luis.intent_threshold.is_a?(Numeric)
|
113
|
+
if _intent_score > Stealth.config.luis.intent_threshold
|
114
|
+
matched_intent
|
115
|
+
else
|
116
|
+
Stealth::Logger.l(
|
117
|
+
topic: :nlp,
|
118
|
+
message: "Ignoring intent match. Does not meet threshold (#{Stealth.config.luis.intent_threshold})"
|
119
|
+
)
|
120
|
+
'None' # can't be nil or this doesn't get memoized
|
121
|
+
end
|
122
|
+
else
|
123
|
+
matched_intent
|
124
|
+
end
|
125
|
+
end
|
109
126
|
end
|
110
127
|
|
111
128
|
end
|
data/stealth-luis.gemspec
CHANGED
@@ -1,17 +1,22 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = 'stealth-luis'
|
3
|
-
s.version = '1.
|
5
|
+
s.version = '1.2.1'
|
4
6
|
s.summary = "Stealth LUIS"
|
5
7
|
s.description = "Built-in NLP for Stealth bots via Microsoft's Language Understanding (LUIS)."
|
6
8
|
s.authors = ["Mauricio Gomes"]
|
7
9
|
s.email = 'mauricio@edge14.com'
|
8
|
-
s.files = `git ls-files`.split("\n")
|
9
10
|
s.homepage = 'http://github.com/hellostealth/stealth-luis'
|
10
11
|
s.license = 'MIT'
|
11
12
|
|
12
|
-
s.add_dependency 'stealth', '
|
13
|
+
s.add_dependency 'stealth', '>= 2.0.0.beta'
|
13
14
|
s.add_dependency 'http', '~> 4'
|
14
15
|
|
15
16
|
s.add_development_dependency "rspec", "= 3.9.0"
|
16
17
|
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
|
+
s.require_paths = ['lib']
|
17
22
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stealth-luis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mauricio Gomes
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stealth
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.0.beta
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.0.beta
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: http
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,7 +75,7 @@ homepage: http://github.com/hellostealth/stealth-luis
|
|
75
75
|
licenses:
|
76
76
|
- MIT
|
77
77
|
metadata: {}
|
78
|
-
post_install_message:
|
78
|
+
post_install_message:
|
79
79
|
rdoc_options: []
|
80
80
|
require_paths:
|
81
81
|
- lib
|
@@ -91,7 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
93
|
rubygems_version: 3.1.2
|
94
|
-
signing_key:
|
94
|
+
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Stealth LUIS
|
97
|
-
test_files:
|
97
|
+
test_files:
|
98
|
+
- spec/spec_helper.rb
|