luis 0.1.1beta → 0.1.1
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/README.md +1 -1
- data/bin/console +4 -4
- data/lib/luis/base.rb +10 -1
- data/lib/luis/composite_entity.rb +1 -1
- data/lib/luis/dialog.rb +2 -2
- data/lib/luis/entity.rb +1 -1
- data/lib/luis/result.rb +8 -2
- data/lib/luis/version.rb +1 -1
- data/lib/luis.rb +3 -3
- data/luis.gemspec +4 -0
- metadata +47 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 644f4ea3032205c0ebac56d6f8a33dbf84dbb7c8
|
4
|
+
data.tar.gz: 4e6970743efa0415f129869f3d8e7d774fd68de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 968280a0b58392f9a2306e2e52d766134b1fd8f0a81742f2b35ab819962fef31e7c728c7b3358de7479dcc65a564ec4ff4ce0e1bdeffbdd0eecaf9c38cb75be6
|
7
|
+
data.tar.gz: 6179aad7009b9593b95e806337bae4a1c7883e07cd3b91b2da292cee0d652285cf67cbbeb1aef59358ef9b9830e2ddd92722aa208c76a10e383bb19c62329a6f
|
data/README.md
CHANGED
data/bin/console
CHANGED
@@ -7,8 +7,8 @@ require 'luis'
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
|
11
|
-
|
10
|
+
require 'pry'
|
11
|
+
Pry.start
|
12
12
|
|
13
|
-
require 'irb'
|
14
|
-
IRB.start
|
13
|
+
# require 'irb'
|
14
|
+
# IRB.start
|
data/lib/luis/base.rb
CHANGED
@@ -6,8 +6,17 @@ module Luis
|
|
6
6
|
# @param [Hash] options hash
|
7
7
|
def initialize(options = {})
|
8
8
|
options.each do |key, value|
|
9
|
-
instance_variable_set("@#{key}", value)
|
9
|
+
instance_variable_set("@#{snake_case(key)}", value)
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def snake_case(string)
|
16
|
+
return string.downcase if string =~ /\A[A-Z]+\z/
|
17
|
+
string.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
18
|
+
.gsub(/([a-z])([A-Z])/, '\1_\2')
|
19
|
+
.downcase
|
20
|
+
end
|
12
21
|
end
|
13
22
|
end
|
data/lib/luis/dialog.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Luis
|
2
2
|
# Luis dialog class
|
3
3
|
class Dialog < Base
|
4
|
-
attr_accessor :prompt, :
|
4
|
+
attr_accessor :prompt, :parameter_name, :parameter_type, :context_id, :status
|
5
5
|
|
6
6
|
# @return whether the dialog is finished
|
7
7
|
def finished?
|
@@ -16,7 +16,7 @@ module Luis
|
|
16
16
|
# Reply to dialog
|
17
17
|
# @param reply message
|
18
18
|
def reply(query)
|
19
|
-
Luis.query(query,
|
19
|
+
Luis.query(query, context_id)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/luis/entity.rb
CHANGED
data/lib/luis/result.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Luis
|
2
2
|
# Luis result class
|
3
3
|
class Result < Base
|
4
|
-
attr_accessor :query, :intents, :entities, :dialog, :
|
4
|
+
attr_accessor :query, :intents, :entities, :dialog, :top_scoring_intent
|
5
5
|
|
6
6
|
# Intent with maximum score
|
7
7
|
# @return intent with maximum score
|
8
8
|
def top_scoring_intent
|
9
|
-
@
|
9
|
+
Intent.new(@top_scoring_intent) || @intents.first
|
10
10
|
end
|
11
11
|
|
12
12
|
# List of intents
|
@@ -18,6 +18,7 @@ module Luis
|
|
18
18
|
|
19
19
|
# Dialog object
|
20
20
|
def dialog
|
21
|
+
return false unless @dialog
|
21
22
|
Dialog.new @dialog
|
22
23
|
end
|
23
24
|
|
@@ -26,6 +27,11 @@ module Luis
|
|
26
27
|
@entities.map { |entity| Entity.new entity }
|
27
28
|
end
|
28
29
|
|
30
|
+
# Entitities with specific type
|
31
|
+
def entities_of_type(type)
|
32
|
+
@entities.select { |entity| entity['type'] == type }.map { |entity| Entity.new entity }
|
33
|
+
end
|
34
|
+
|
29
35
|
# Weather dialog is waiting for a response
|
30
36
|
def awaiting_dialog_response?
|
31
37
|
dialog && dialog.question?
|
data/lib/luis/version.rb
CHANGED
data/lib/luis.rb
CHANGED
@@ -14,10 +14,10 @@ module Luis
|
|
14
14
|
class << self
|
15
15
|
attr_accessor :id, :subscription_key, :is_preview_mod, :is_verbose
|
16
16
|
end
|
17
|
-
API_BASE_URI = 'https://api.
|
17
|
+
API_BASE_URI = 'https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/%{id}'.freeze
|
18
18
|
|
19
19
|
def self.api_uri
|
20
|
-
uri = API_BASE_URI
|
20
|
+
uri = format(API_BASE_URI, id: id)
|
21
21
|
uri += '/preview' if is_preview_mod
|
22
22
|
uri
|
23
23
|
end
|
@@ -45,7 +45,7 @@ module Luis
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.default_options
|
48
|
-
options = { '
|
48
|
+
options = { 'subscription-key' => subscription_key }
|
49
49
|
options['verbose'] = true if is_verbose
|
50
50
|
options
|
51
51
|
end
|
data/luis.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'luis/version'
|
@@ -22,6 +23,9 @@ Gem::Specification.new do |spec|
|
|
22
23
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
23
24
|
spec.add_development_dependency 'rake', '~> 10.0'
|
24
25
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
spec.add_development_dependency 'vcr'
|
27
|
+
spec.add_development_dependency 'webmock'
|
28
|
+
spec.add_development_dependency 'pry'
|
25
29
|
|
26
30
|
spec.add_dependency 'httparty'
|
27
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aboobacker MK
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,48 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: httparty
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,12 +152,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
152
|
version: '0'
|
111
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
154
|
requirements:
|
113
|
-
- - "
|
155
|
+
- - ">="
|
114
156
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
157
|
+
version: '0'
|
116
158
|
requirements: []
|
117
159
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.6.
|
160
|
+
rubygems_version: 2.6.11
|
119
161
|
signing_key:
|
120
162
|
specification_version: 4
|
121
163
|
summary: Luis
|