luis 0.1.0.pre.alpha → 0.1.0.pre.alpha1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b83040709168c1c1a7f61d9758f8e5780b14811d
4
- data.tar.gz: cae2c8190be6adaac97213c66c02fb0d9a83ee0f
3
+ metadata.gz: 20b89c0201f2815959c4bc71542c32504ff338fe
4
+ data.tar.gz: 8e32841762775a9c9f282524a36e301e9efa4da8
5
5
  SHA512:
6
- metadata.gz: 5662ad732127ed62bb2ca116a75603434bdb81d68c7f9e27809ad8891b39958789872de4846373a1bf3e931652fa06c74b59b177237c43464f5d6bf7a369c1fd
7
- data.tar.gz: 15430726c7f93eaa65a990bbf8663fe61675ab971eefb1b3eb01832ca05e1203b07d0ffacc45cbe34b3474456ea7281a38243a9f45cebc5ea89654e4d4699e74
6
+ metadata.gz: 31332d6ef01a60e03a9d84b87e211266723d58379bf700dddd3a509e3c43a307506ca4243704976eb56554c8f884ec09f3a519ad1fd7efc0bf1e77d11f91ed51
7
+ data.tar.gz: ed93283d7e347d373881e1f493b126b73875300a9e70d3cd7bfe970463b5a23c031fbe068846d68998cfc972ca1cfb7188feefc0d2585de519f6078e6d7232c3
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Luis
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/luis`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Microsoft Language Understanding Intelligent Service (LUIS) Ruby client
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,8 +20,16 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ```ruby
24
+ Luis.configure do |config|
25
+ config.id = "<id>"
26
+ config.subscription_key ="<key>"
27
+ end
28
+ ```
26
29
 
30
+ ```ruby
31
+ Luis.query("Book flight to Banagalore")
32
+ ```
27
33
  ## Development
28
34
 
29
35
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -32,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
38
 
33
39
  ## Contributing
34
40
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/luis. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tachyons/luis. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
42
 
37
43
 
38
44
  ## License
data/lib/luis/action.rb CHANGED
@@ -0,0 +1,9 @@
1
+ module Luis
2
+ class Action < Base
3
+ attr_accessor :triggered, :name, :parameters
4
+
5
+ def parameters
6
+ @parameters.map { |parameter| Parameter.new parameter }
7
+ end
8
+ end
9
+ end
@@ -1,14 +1,9 @@
1
1
  module Luis
2
- class Response
3
- attr_accessor :query, :intents, :entities, :dialog
2
+ class Base
4
3
  def initialize(options = {})
5
4
  options.each do |key, value|
6
5
  instance_variable_set("@#{key}", value)
7
6
  end
8
7
  end
9
-
10
- def intent
11
- intents.first
12
- end
13
8
  end
14
9
  end
data/lib/luis/dialog.rb CHANGED
@@ -0,0 +1,13 @@
1
+ module Luis
2
+ class Dialog < Base
3
+ attr_accessor :prompt, :parameterName, :parameterType, :contentId, :status
4
+
5
+ def finished?
6
+ status == 'Finished'
7
+ end
8
+
9
+ def question?
10
+ status == 'Question'
11
+ end
12
+ end
13
+ end
data/lib/luis/entity.rb CHANGED
@@ -0,0 +1,5 @@
1
+ module Luis
2
+ class Entity < Base
3
+ attr_accessor :entity, :type, :startIndex, :endIndex, :score
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ module Luis
2
+ class Intent < Base
3
+ attr_accessor :intent, :score, :actions
4
+
5
+ def actions
6
+ @actions.map { |action| Action.new action }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Luis
2
+ class Parameter < Base
3
+ attr_accessor :name, :required, :value
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ module Luis
2
+ class Result < Base
3
+ attr_accessor :query, :intents, :entities, :dialog, :top_scoring_indent
4
+
5
+ def top_scoring_intent
6
+ @topScoringIndent ||= @intents.first
7
+ end
8
+
9
+ def intents
10
+ (@intents ||= [@topScoringIntent]).map do |intent|
11
+ Intent.new intent
12
+ end
13
+ end
14
+
15
+ def dialog
16
+ Dialog.new @dialog
17
+ end
18
+
19
+ def entities
20
+ @entities.map { |entity| Entity.new entity }
21
+ end
22
+
23
+ def awaiting_dialog_response?
24
+ dialog && (dialog['status'] == 'Question')
25
+ end
26
+ end
27
+ end
data/lib/luis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Luis
2
- VERSION = '0.1.0-alpha'.freeze
2
+ VERSION = '0.1.0-alpha1'.freeze
3
3
  end
data/lib/luis.rb CHANGED
@@ -1,19 +1,26 @@
1
1
  require 'luis/version'
2
- require 'luis/response'
3
2
  require 'httparty'
4
3
  module Luis
4
+ autoload :Base, 'luis/base'
5
+ autoload :Result, 'luis/result'
6
+ autoload :Intent, 'luis/intent'
7
+ autoload :Action, 'luis/action'
8
+ autoload :Parameter, 'luis/parameter'
9
+ autoload :Dialog, 'luis/dialog'
10
+ autoload :Entity, 'luis/entity'
11
+
5
12
  include HTTParty
6
13
  class << self
7
14
  attr_accessor :id, :subscription_key
8
15
  end
9
- API_URL = 'https://api.projectoxford.ai/luis/v1/application'.freeze
16
+ API_URL = 'https://api.projectoxford.ai/luis/v1/application/preview'.freeze
10
17
 
11
18
  def self.query(query)
12
19
  response = get(API_URL, query: { 'id' => id, 'subscription-key' => subscription_key, 'q' => query })
13
- Response.new JSON.parse(response.body)
20
+ Result.new JSON.parse(response.body)
14
21
  end
15
22
 
16
- def self.configure(*_args)
23
+ def self.configure(options = {})
17
24
  options.each do |key, value|
18
25
  instance_variable_set("@#{key}", value)
19
26
  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.0.pre.alpha
4
+ version: 0.1.0.pre.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aboobacker MK
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-25 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,12 +85,14 @@ files:
85
85
  - bin/setup
86
86
  - lib/luis.rb
87
87
  - lib/luis/action.rb
88
- - lib/luis/action_parameter.rb
88
+ - lib/luis/base.rb
89
89
  - lib/luis/combosite_entity_child.rb
90
90
  - lib/luis/composite_entity.rb
91
91
  - lib/luis/dialog.rb
92
92
  - lib/luis/entity.rb
93
- - lib/luis/response.rb
93
+ - lib/luis/intent.rb
94
+ - lib/luis/parameter.rb
95
+ - lib/luis/result.rb
94
96
  - lib/luis/version.rb
95
97
  - luis.gemspec
96
98
  homepage: http://github.com/tachyons/luis
File without changes