RecastAI 1.0.0
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 +7 -0
- data/.gitignore +26 -0
- data/.rspec +2 -0
- data/.rubocop.yml +12 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +64 -0
- data/LICENSE +21 -0
- data/README.md +190 -0
- data/bin/file +11 -0
- data/bin/text +11 -0
- data/lib/recastai.rb +14 -0
- data/lib/recastai/client.rb +55 -0
- data/lib/recastai/entity.rb +14 -0
- data/lib/recastai/errors.rb +11 -0
- data/lib/recastai/response.rb +81 -0
- data/lib/recastai/sentence.rb +19 -0
- data/lib/recastai/utils.rb +13 -0
- data/misc/.gitkeep +0 -0
- data/recastai.gemspec +30 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0ae37ffab60dbf742c6a06a8c2411032b3e4ff4d
|
4
|
+
data.tar.gz: e92fa41890dee300927a64adeb8dab2119a31f78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ca79e4a0900c717570bf9e72c9db3d5da210246d9b5eb1d8e09d37002ff39aeefb602d7a20af1ac4b7eeff9459981e1c1cfd595ac1ef8108b5f2c8ff9a10881
|
7
|
+
data.tar.gz: 7341f41cecdfc328311f3bf27e78304b20dfa7241e1287406c603cd57f75799580a794b0a31f6a500c6d29412a355017b03cea6e4b488088e8d4ef9bd57cd998
|
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Default
|
2
|
+
cache
|
3
|
+
log/*.log
|
4
|
+
VM/*.log
|
5
|
+
tmp/**/*
|
6
|
+
public/system/**
|
7
|
+
public/uploads/
|
8
|
+
db/schema.rb
|
9
|
+
dump.rdb
|
10
|
+
coverage/
|
11
|
+
|
12
|
+
# Configuration
|
13
|
+
config/application.yml
|
14
|
+
config/database.yml
|
15
|
+
config/secrets.yml
|
16
|
+
|
17
|
+
# OS-Generated
|
18
|
+
.DS_Store
|
19
|
+
|
20
|
+
# IDE-Generated
|
21
|
+
.idea/
|
22
|
+
.bashrc
|
23
|
+
|
24
|
+
# Misc
|
25
|
+
*~
|
26
|
+
.ruby-version
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
RecastAI (1.0.0)
|
5
|
+
httmultiparty (~> 0.3)
|
6
|
+
httparty (~> 0.13)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.4.0)
|
12
|
+
awesome_print (1.6.1)
|
13
|
+
crack (0.4.3)
|
14
|
+
safe_yaml (~> 1.0.0)
|
15
|
+
diff-lcs (1.2.5)
|
16
|
+
docile (1.1.5)
|
17
|
+
hashdiff (0.3.0)
|
18
|
+
httmultiparty (0.3.16)
|
19
|
+
httparty (>= 0.7.3)
|
20
|
+
mimemagic
|
21
|
+
multipart-post
|
22
|
+
httparty (0.13.7)
|
23
|
+
json (~> 1.8)
|
24
|
+
multi_xml (>= 0.5.2)
|
25
|
+
json (1.8.3)
|
26
|
+
mimemagic (0.3.1)
|
27
|
+
multi_xml (0.5.5)
|
28
|
+
multipart-post (2.0.0)
|
29
|
+
rspec (3.4.0)
|
30
|
+
rspec-core (~> 3.4.0)
|
31
|
+
rspec-expectations (~> 3.4.0)
|
32
|
+
rspec-mocks (~> 3.4.0)
|
33
|
+
rspec-core (3.4.4)
|
34
|
+
rspec-support (~> 3.4.0)
|
35
|
+
rspec-expectations (3.4.0)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.4.0)
|
38
|
+
rspec-mocks (3.4.1)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.4.0)
|
41
|
+
rspec-support (3.4.1)
|
42
|
+
safe_yaml (1.0.4)
|
43
|
+
simplecov (0.11.2)
|
44
|
+
docile (~> 1.1.0)
|
45
|
+
json (~> 1.8)
|
46
|
+
simplecov-html (~> 0.10.0)
|
47
|
+
simplecov-html (0.10.0)
|
48
|
+
webmock (1.24.2)
|
49
|
+
addressable (>= 2.3.6)
|
50
|
+
crack (>= 0.3.2)
|
51
|
+
hashdiff
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
RecastAI!
|
58
|
+
awesome_print (~> 1.6)
|
59
|
+
rspec (~> 3.4)
|
60
|
+
simplecov
|
61
|
+
webmock (~> 1.24)
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.11.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 RecastAI
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
# SDK-ruby
|
2
|
+
|
3
|
+
Recast.AI official SDK in Ruby.
|
4
|
+
|
5
|
+
|
6
|
+
## Synospis
|
7
|
+
|
8
|
+
This gem is a pure Ruby interface to the [Recast.AI](https://recast.ai) API. It allows you to make requests to your bots.
|
9
|
+
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
### Via Gemfile
|
14
|
+
|
15
|
+
From [rubygems.org](https://rubygems.org/):
|
16
|
+
|
17
|
+
```bash
|
18
|
+
gem 'RecastAI'
|
19
|
+
```
|
20
|
+
|
21
|
+
From [github.com](https://github.com/):
|
22
|
+
|
23
|
+
```bash
|
24
|
+
gem 'RecastAI', github: 'RecastAI/SDK-ruby'
|
25
|
+
```
|
26
|
+
|
27
|
+
### Via Terminal
|
28
|
+
|
29
|
+
From [rubygems.org](https://rubygems.org/):
|
30
|
+
|
31
|
+
```bash
|
32
|
+
gem install 'RecastAI'
|
33
|
+
```
|
34
|
+
|
35
|
+
From [github.com](https://github.com/):
|
36
|
+
|
37
|
+
```bash
|
38
|
+
git clone https://github.com/RecastAI/SDK-ruby
|
39
|
+
gem build recastai.gemspec
|
40
|
+
gem install RecastAI-*.gem
|
41
|
+
```
|
42
|
+
|
43
|
+
|
44
|
+
## Usage
|
45
|
+
|
46
|
+
### Gem
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
require 'RecastAI'
|
50
|
+
|
51
|
+
client = RecastAI::Client.new(YOUR_TOKEN)
|
52
|
+
response = client.text_request(YOUR_TEXT)
|
53
|
+
|
54
|
+
if response.intent == YOUR_EXPECTED_INTENT
|
55
|
+
# Do your code...
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
require 'RecastAI'
|
61
|
+
|
62
|
+
client = RecastAI::Client.new(YOUR_TOKEN)
|
63
|
+
response = client.file_request(File.new(File.join(File.dirname(__FILE__), YOUR_FILE)))
|
64
|
+
|
65
|
+
if response.intent == YOUR_EXPECTED_INTENT
|
66
|
+
# Do your code...
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
You can find more examples in the `misc/` folder.
|
71
|
+
|
72
|
+
### CLI
|
73
|
+
|
74
|
+
```bash
|
75
|
+
./bin/text YOUR_TOKEN YOUR_TEXT
|
76
|
+
# => Recast.AI's response
|
77
|
+
```
|
78
|
+
|
79
|
+
```bash
|
80
|
+
./bin/file YOUR_TOKEN YOUR_VOICE_FILE
|
81
|
+
# => Recast.AI's response
|
82
|
+
```
|
83
|
+
|
84
|
+
## Specs
|
85
|
+
|
86
|
+
### Classes
|
87
|
+
|
88
|
+
This gem contains 5 main classes, as follows:
|
89
|
+
|
90
|
+
* RecastAI::Client is the client allowing you to make requests.
|
91
|
+
* RecastAI::Response contains the response from [Recast.AI](https://recast.ai).
|
92
|
+
* RecastAI::Sentence represents a sentence of the response.
|
93
|
+
* RecastAI::Entity represents an entity found by Recast.AI in your user's input.
|
94
|
+
* RecastAI::RecastError is the error thrown by the gem.
|
95
|
+
|
96
|
+
Don't hesitate to dive into the code, it's commented ;)
|
97
|
+
|
98
|
+
### RecastAI::Client
|
99
|
+
|
100
|
+
The Recast.AI Client can be instanciated with a token and provides the two following methods:
|
101
|
+
|
102
|
+
* text_request(text, options = {}) *Performs a text request*
|
103
|
+
* file_request(file, options = {}) *Performs a voice file request*
|
104
|
+
|
105
|
+
*Accepted options are :token, to override the default token provided at initialization*
|
106
|
+
|
107
|
+
### RecastAI::Response
|
108
|
+
|
109
|
+
The Recast.AI Response is generated after a call with the two previous methods and contains the following methods:
|
110
|
+
|
111
|
+
* raw(\*) *Returns the raw unparsed response*
|
112
|
+
* source(\*) *Returns the source sentence Recast.AI processed*
|
113
|
+
* intents(\*) *Returns all the matched intents*
|
114
|
+
* intent(\*) *Returns the first matched intent*
|
115
|
+
* sentences(\*) *Returns all the detected sentences*
|
116
|
+
* sentence(\*) *Returns the first detected sentence*
|
117
|
+
* get(name) *Returns the first entity matching -name-*
|
118
|
+
* all(name) *Returns all the entities matching -name-*
|
119
|
+
* version(\*) *Returns the version of the JSON*
|
120
|
+
* timestamp(\*) *Returns the timestamp at the end of the processing*
|
121
|
+
* status(\*) *Returns the status of the response*
|
122
|
+
|
123
|
+
### RecastAI::Sentence
|
124
|
+
|
125
|
+
The Recast.AI Sentence is generated by the Recast.AI Response initializer and provides the following methods:
|
126
|
+
|
127
|
+
* source(\*) *Returns the source of the sentence*
|
128
|
+
* type(\*) *Returns the type of the sentence*
|
129
|
+
* action(\*) *Returns the action of the sentence*
|
130
|
+
* agent(\*) *Returns the agent of the sentence*
|
131
|
+
* polarity(\*) *Returns the polarity (negation or not) of the sentence*
|
132
|
+
* entities(\*) *Returns all the entities detected in the sentence*
|
133
|
+
|
134
|
+
### RecastAI::Entity
|
135
|
+
|
136
|
+
The Recast.AI Entity is generated by the Recast.AI Sentence initializer and provides the following method:
|
137
|
+
|
138
|
+
* name(\*) *Returns the name of the entity*
|
139
|
+
* raw(\*) *Returns the raw text on which the entity was detected*
|
140
|
+
|
141
|
+
In addition to this method, more attributes are generated depending of the nature of the entity, which can be one of the following:
|
142
|
+
|
143
|
+
* hex(\*)
|
144
|
+
* value(\*)
|
145
|
+
* deg(\*)
|
146
|
+
* formated(\*)
|
147
|
+
* lng(\*)
|
148
|
+
* lat(\*)
|
149
|
+
* unit(\*)
|
150
|
+
* code(\*)
|
151
|
+
* person(\*)
|
152
|
+
* number(\*)
|
153
|
+
* gender(\*)
|
154
|
+
* next(\*)
|
155
|
+
* grain(\*)
|
156
|
+
* order(\*)
|
157
|
+
|
158
|
+
### RecastAI::RecastError
|
159
|
+
|
160
|
+
The Recast.AI Error is thrown when receiving an non-200 response from Recast.AI, it implements the following methods:
|
161
|
+
|
162
|
+
* message(\*) *Returns the message of the error*
|
163
|
+
* code(\*) *Returns the error code*
|
164
|
+
|
165
|
+
## More
|
166
|
+
|
167
|
+
You can view the whole API reference at [man.recast.ai](https://man.recast.ai).
|
168
|
+
|
169
|
+
|
170
|
+
## License
|
171
|
+
|
172
|
+
Copyright (c) [2016] [Recast.AI](https://recast.ai)
|
173
|
+
|
174
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
175
|
+
of this software and associated documentation files (the "Software"), to deal
|
176
|
+
in the Software without restriction, including without limitation the rights
|
177
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
178
|
+
copies of the Software, and to permit persons to whom the Software is
|
179
|
+
furnished to do so, subject to the following conditions:
|
180
|
+
|
181
|
+
The above copyright notice and this permission notice shall be included in all
|
182
|
+
copies or substantial portions of the Software.
|
183
|
+
|
184
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
185
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
186
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
187
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
188
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
189
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
190
|
+
SOFTWARE.
|
data/bin/file
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/recastai'
|
4
|
+
|
5
|
+
raise 'You must provide a token for your sentence to be processed' unless ARGV.any? && !ARGV[0].nil?
|
6
|
+
raise 'You must provide a voice file to be processed' unless ARGV.any? && !ARGV[1].nil?
|
7
|
+
|
8
|
+
client = RecastAI::Client.new(ARGV[0])
|
9
|
+
response = client.file_request(ARGV[1])
|
10
|
+
|
11
|
+
ap JSON.parse(response.raw)
|
data/bin/text
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/recastai'
|
4
|
+
|
5
|
+
raise 'You must provide a token for your sentence to be processed' unless ARGV.any? && !ARGV[0].nil?
|
6
|
+
raise 'You must provide a sentence to be processed' unless ARGV.any? && !ARGV[1].nil?
|
7
|
+
|
8
|
+
client = RecastAI::Client.new(ARGV[0])
|
9
|
+
response = client.text_request(ARGV[1])
|
10
|
+
|
11
|
+
ap JSON.parse(response.raw)
|
data/lib/recastai.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'httparty'
|
4
|
+
require 'httmultiparty'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
require 'recastai/utils'
|
8
|
+
require 'recastai/errors'
|
9
|
+
require 'recastai/client'
|
10
|
+
require 'recastai/response'
|
11
|
+
require 'recastai/sentence'
|
12
|
+
require 'recastai/entity'
|
13
|
+
|
14
|
+
require 'awesome_print'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module RecastAI
|
2
|
+
class Client
|
3
|
+
attr_accessor :token
|
4
|
+
|
5
|
+
def initialize(token = nil)
|
6
|
+
@token = token
|
7
|
+
end
|
8
|
+
|
9
|
+
##
|
10
|
+
# Perform a text request to Recast.AI
|
11
|
+
#
|
12
|
+
# * *Args* :
|
13
|
+
# - +text+ - String, the text to process
|
14
|
+
# - +options+ - Hash, request's options
|
15
|
+
# * *Returns* :
|
16
|
+
# - An instance of Response
|
17
|
+
# * *Throws* :
|
18
|
+
# - RecastError
|
19
|
+
def text_request(text, options = {})
|
20
|
+
token = options[:token] || @token
|
21
|
+
raise(RecastError.new('Token is missing', 400)) if token.nil?
|
22
|
+
|
23
|
+
response = HTTParty.post(Utils::API_ENDPOINT,
|
24
|
+
body: { 'text' => text },
|
25
|
+
headers: { 'Authorization' => "Token #{token}" }
|
26
|
+
)
|
27
|
+
raise(RecastError.new(response.message, response.code)) if response.code != 200
|
28
|
+
|
29
|
+
Response.new(response.body)
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Perform a voice file request to Recast.AI
|
34
|
+
#
|
35
|
+
# * *Args* :
|
36
|
+
# - +file+ - String or File, the voice file to process
|
37
|
+
# - +options+ - Hash, request's options
|
38
|
+
# * *Returns* :
|
39
|
+
# - An instance of Response
|
40
|
+
# * *Throws* :
|
41
|
+
# - RecastError
|
42
|
+
def file_request(file, options = {})
|
43
|
+
token = options[:token] || @token
|
44
|
+
raise(RecastError.new('Token is missing', 400)) if token.nil?
|
45
|
+
|
46
|
+
response = HTTMultiParty.post(Utils::API_ENDPOINT,
|
47
|
+
body: { 'voice' => File.new(file) },
|
48
|
+
headers: { 'Authorization' => "Token #{token}" }
|
49
|
+
)
|
50
|
+
raise(RecastError.new(response.message, response.code)) if response.code != 200
|
51
|
+
|
52
|
+
Response.new(response.body)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module RecastAI
|
2
|
+
class Response
|
3
|
+
attr_reader :raw
|
4
|
+
attr_reader :source
|
5
|
+
attr_reader :intents
|
6
|
+
attr_reader :sentences
|
7
|
+
attr_reader :version
|
8
|
+
attr_reader :timestamp
|
9
|
+
attr_reader :status
|
10
|
+
|
11
|
+
def initialize(response)
|
12
|
+
@raw = response
|
13
|
+
|
14
|
+
response = JSON.parse(response)
|
15
|
+
response = response['results']
|
16
|
+
|
17
|
+
@source = response['source']
|
18
|
+
@intents = response['intents']
|
19
|
+
@sentences = response['sentences'].map{ |s| Sentence.new(s) }
|
20
|
+
@version = response['version']
|
21
|
+
@timestamp = response['timestamp']
|
22
|
+
@status = response['status']
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Returns the first intent provided there is one
|
27
|
+
#
|
28
|
+
# * *Args* :
|
29
|
+
# * *Returns* :
|
30
|
+
# - A String or nil
|
31
|
+
def intent
|
32
|
+
@intents.any? ? @intents.first : nil
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Returns the first sentence provided there is one
|
37
|
+
#
|
38
|
+
# * *Args* :
|
39
|
+
# * *Returns* :
|
40
|
+
# - A Sentence or nil
|
41
|
+
def sentence
|
42
|
+
@sentences.any? ? @sentences.first : nil
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Returns the first entity whose name matches the parameter
|
47
|
+
#
|
48
|
+
# * *Args* :
|
49
|
+
# - +name+ - String, the entity's name
|
50
|
+
# * *Returns* :
|
51
|
+
# - An instance of Entity or nil
|
52
|
+
def get(name)
|
53
|
+
@sentences.each do |sentence|
|
54
|
+
sentence.entities.each do |entity|
|
55
|
+
return entity if entity.name.downcase == name.to_s.downcase
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Returns all entities whose names matches the parameter
|
64
|
+
#
|
65
|
+
# * *Args* :
|
66
|
+
# - +name+ - String, the entities' names
|
67
|
+
# * *Returns* :
|
68
|
+
# - An array of instances of Entity or an empty array
|
69
|
+
def all(name = nil)
|
70
|
+
entities = []
|
71
|
+
|
72
|
+
@sentences.each do |sentence|
|
73
|
+
sentence.entities.each do |entity|
|
74
|
+
entities << entity if entity.name.downcase == name.to_s.downcase
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
entities
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module RecastAI
|
2
|
+
class Sentence
|
3
|
+
attr_reader :source
|
4
|
+
attr_reader :type
|
5
|
+
attr_reader :action
|
6
|
+
attr_reader :agent
|
7
|
+
attr_reader :polarity
|
8
|
+
attr_reader :entities
|
9
|
+
|
10
|
+
def initialize(sentence)
|
11
|
+
@source = sentence['source']
|
12
|
+
@type = sentence['type']
|
13
|
+
@action = sentence['action']
|
14
|
+
@agent = sentence['agent']
|
15
|
+
@polarity = sentence['polarity']
|
16
|
+
@entities = sentence['entities'].flat_map{ |n, e| e.map{ |ee| Entity.new(n, ee) } }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RecastAI
|
2
|
+
class Utils
|
3
|
+
# Versioning
|
4
|
+
MAJOR = '1'.freeze
|
5
|
+
MINOR = '0'.freeze
|
6
|
+
MICRO = '0'.freeze
|
7
|
+
VERSION = "#{MAJOR}.#{MINOR}.#{MICRO}".freeze
|
8
|
+
|
9
|
+
# Endpoints
|
10
|
+
API_ENDPOINT = 'https://api.recast.ai/v1/request'.freeze
|
11
|
+
WS_ENDPOINT = 'wss://api.recast.ai/v1/request'.freeze
|
12
|
+
end
|
13
|
+
end
|
data/misc/.gitkeep
ADDED
File without changes
|
data/recastai.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
dir = File.dirname(__FILE__)
|
4
|
+
$LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
require 'lib/recastai/utils'
|
8
|
+
|
9
|
+
Gem::Specification.new do |spec|
|
10
|
+
spec.name = 'RecastAI'
|
11
|
+
spec.version = RecastAI::Utils::VERSION
|
12
|
+
spec.date = Date.today
|
13
|
+
spec.summary = %q(Recast.AI official SDK in Ruby)
|
14
|
+
spec.description = %q(Recast.AI official SDK in Ruby. Allows you to make requests to your bots.)
|
15
|
+
spec.homepage = 'https://github.com/RecastAI/SDK-ruby'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
spec.authors = ['Paul Renvoisé']
|
18
|
+
spec.email = 'paul.renvoise@recast.ai'
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject{ |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.executables = ['text', 'file']
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency 'httparty', '~> 0.13'
|
24
|
+
spec.add_dependency 'httmultiparty', '~> 0.3'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
27
|
+
spec.add_development_dependency 'webmock', '~> 1.24'
|
28
|
+
spec.add_development_dependency 'awesome_print', '~> 1.6'
|
29
|
+
spec.add_development_dependency 'simplecov', '~> 0.11'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: RecastAI
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Renvoisé
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httmultiparty
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.24'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.24'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: awesome_print
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.6'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.11'
|
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'
|
97
|
+
description: Recast.AI official SDK in Ruby. Allows you to make requests to your bots.
|
98
|
+
email: paul.renvoise@recast.ai
|
99
|
+
executables:
|
100
|
+
- text
|
101
|
+
- file
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- LICENSE
|
111
|
+
- README.md
|
112
|
+
- bin/file
|
113
|
+
- bin/text
|
114
|
+
- lib/recastai.rb
|
115
|
+
- lib/recastai/client.rb
|
116
|
+
- lib/recastai/entity.rb
|
117
|
+
- lib/recastai/errors.rb
|
118
|
+
- lib/recastai/response.rb
|
119
|
+
- lib/recastai/sentence.rb
|
120
|
+
- lib/recastai/utils.rb
|
121
|
+
- misc/.gitkeep
|
122
|
+
- recastai.gemspec
|
123
|
+
homepage: https://github.com/RecastAI/SDK-ruby
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.5.1
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: Recast.AI official SDK in Ruby
|
147
|
+
test_files: []
|