RecastAI 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e0d9d38204152540d567fca3d5d666bc1074bff
4
- data.tar.gz: 6c75863441add341d3832dc812ed281088d68da7
3
+ metadata.gz: 815462dab5fa1be22867b8da2f81cbc2e5273edd
4
+ data.tar.gz: 990e593aa2e0ea07362f2af79b8453f7a3cd9641
5
5
  SHA512:
6
- metadata.gz: fd45c6c44cfd34dd279b9a45399284c6085a61404b98e08b308b24220085510f5d60be5d5bf9de0969e3318c10719e29dd3876af0f9d73535c5ed8feab34ff83
7
- data.tar.gz: 4c8f99a187d5db0885f10b1166602ce0e52a7d1142c00eb3c3fc8697e4b885d931fa5d171e2a5e6dc560aba8c3543b78eb07cfa5b5cd9917bec1fb0ea10b1c1f
6
+ metadata.gz: b74a8724a020b0477349acbae7e283f7c30408bd4b4594fd2b35ecbffc23e90cd8ea3a0cfc858f74b602bac1433fd18a2749719b387d45011e2bc9d0c86f66bc
7
+ data.tar.gz: e5c2cfef93104bfff29eec219ce03e334a1c992251299885ba1a96569754332230a8acb86ab928afc660e75d4d6746a2fbf1b7a563d73e67023d87e350ac7a2a
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
- # Recast.AI - SDK Ruby
2
1
 
3
- [logo]: https://github.com/RecastAI/SDK-Ruby/blob/master/misc/logo-inline.png "Recast.AI"
2
+
3
+ [logo]: https://cdn.recast.ai/brand/recast-ai-logo-inline.png "Recast.AI"
4
4
 
5
5
  ![alt text][logo]
6
6
 
7
+ # Recast.AI - SDK Ruby
8
+
7
9
  Recast.AI official SDK in Ruby
8
10
 
9
11
  ## Synospis
@@ -27,7 +29,10 @@ Using the entire SDK:
27
29
  ```ruby
28
30
  require 'recastai'
29
31
 
30
- client = RecastAI.new('YOUR_TOKEN')
32
+ client = RecastAI::Client.new('YOUR_TOKEN')
33
+
34
+ client.request.analyse_text('Hi')
35
+ client.connect.broadcast_message('Hello')
31
36
  ```
32
37
 
33
38
  Extracting one single API:
@@ -35,7 +40,10 @@ Extracting one single API:
35
40
  require 'recastai'
36
41
 
37
42
  request = RecastAI::Request.new('YOUR_TOKEN')
43
+ request.analyse_text('Hi')
44
+
38
45
  connect = RecastAI::Connect.new('YOUR_TOKEN')
46
+ connect.broadcast_message('Hi')
39
47
  ```
40
48
 
41
49
  ## More
@@ -3,11 +3,12 @@
3
3
  require_relative 'action'
4
4
  require_relative 'entity'
5
5
  require_relative 'intent'
6
+ require_relative '../utils'
6
7
 
7
8
  module RecastAI
8
9
  class Conversation
9
- attr_reader :raw, :uuid, :source, :replies, :action, :next_actions, :memory, :entities, :intents,
10
- :conversation_token, :language, :version, :timestamp, :status
10
+ attr_reader :raw, :uuid, :source, :replies, :action, :next_actions, :memory, :entities, :sentiment, :intents,
11
+ :conversation_token, :language, :processing_language, :version, :timestamp, :status
11
12
 
12
13
  def initialize(response, token)
13
14
  @token = token
@@ -17,19 +18,21 @@ module RecastAI
17
18
  response = JSON.parse(response)
18
19
  response = response['results']
19
20
 
20
- @uuid = response['uuid']
21
- @source = response['source']
22
- @replies = response['replies']
23
- @action = response['action'] ? Action.new(response['action']) : nil
24
- @next_actions = response['next_actions'].map{ |i| Action.new(i) }
25
- @memory = response['memory'].reject { |_, e| e.nil? }.map{ |n, e| Entity.new(n, e) }
26
- @entities = response['entities'].flat_map{ |_, e| e.map{ |ee| Entity.new(n, ee) } }
27
- @intents = response['intents'].map{ |i| Intent.new(i) }
28
- @conversation_token = response['conversation_token']
29
- @language = response['language']
30
- @version = response['version']
31
- @timestamp = response['timestamp']
32
- @status = response['status']
21
+ @uuid = response['uuid']
22
+ @source = response['source']
23
+ @replies = response['replies']
24
+ @action = response['action'] ? Action.new(response['action']) : nil
25
+ @next_actions = response['next_actions'].map{ |i| Action.new(i) }
26
+ @sentiment = response['sentiment']
27
+ @memory = response['memory'].reject { |_, e| e.nil? }.map{ |n, e| Entity.new(n, e) }
28
+ @entities = response['entities'].flat_map{ |_, e| e.map{ |ee| Entity.new(n, ee) } }
29
+ @intents = response['intents'].map{ |i| Intent.new(i) }
30
+ @conversation_token = response['conversation_token']
31
+ @language = response['language']
32
+ @processing_language = response['processing_language']
33
+ @version = response['version']
34
+ @timestamp = response['timestamp']
35
+ @status = response['status']
33
36
  end
34
37
 
35
38
  def reply
@@ -58,6 +61,26 @@ module RecastAI
58
61
  @intents.any? ? @intents.first : nil
59
62
  end
60
63
 
64
+ def vpositive?
65
+ @sentiment == Utils::SENTIMENT_VPOSITIVE
66
+ end
67
+
68
+ def positive?
69
+ @sentiment == Utils::SENTIMENT_POSITIVE
70
+ end
71
+
72
+ def neutral?
73
+ @sentiment == Utils::SENTIMENT_NEUTRAL
74
+ end
75
+
76
+ def negative?
77
+ @sentiment == Utils::SENTIMENT_NEGATIVE
78
+ end
79
+
80
+ def vnegative?
81
+ @sentiment == Utils::SENTIMENT_VNEGATIVE
82
+ end
83
+
61
84
  def set_memory(memory)
62
85
  body = { conversation_token: @conversation_token, memory: memory }
63
86
  response = HTTParty.put(
@@ -15,6 +15,7 @@ module RecastAI
15
15
  attr_reader :sentiment
16
16
  attr_reader :entities
17
17
  attr_reader :language
18
+ attr_reader :processing_language
18
19
  attr_reader :version
19
20
  attr_reader :timestamp
20
21
  attr_reader :status
@@ -25,17 +26,18 @@ module RecastAI
25
26
  response = JSON.parse(response)
26
27
  response = response['results']
27
28
 
28
- @uuid = response['uuid']
29
- @source = response['source']
30
- @intents = response['intents'].map{ |i| Intent.new(i) }
31
- @act = response['act']
32
- @type = response['type']
33
- @sentiment = response['sentiment']
34
- @entities = response['entities'].flat_map{ |n, e| e.map{ |ee| Entity.new(n, ee) } }
35
- @language = response['language']
36
- @version = response['version']
37
- @timestamp = response['timestamp']
38
- @status = response['status']
29
+ @uuid = response['uuid']
30
+ @source = response['source']
31
+ @intents = response['intents'].map{ |i| Intent.new(i) }
32
+ @act = response['act']
33
+ @type = response['type']
34
+ @sentiment = response['sentiment']
35
+ @entities = response['entities'].flat_map{ |n, e| e.map{ |ee| Entity.new(n, ee) } }
36
+ @language = response['language']
37
+ @processing_language = response['processing_language']
38
+ @version = response['version']
39
+ @timestamp = response['timestamp']
40
+ @status = response['status']
39
41
  end
40
42
 
41
43
  def intent
@@ -4,7 +4,7 @@ module RecastAI
4
4
  class Utils
5
5
  # Versioning
6
6
  MAJOR = '3'.freeze
7
- MINOR = '0'.freeze
7
+ MINOR = '1'.freeze
8
8
  MICRO = '0'.freeze
9
9
  VERSION = "#{MAJOR}.#{MINOR}.#{MICRO}".freeze
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RecastAI
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Renvoisé
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-30 00:00:00.000000000 Z
11
+ date: 2017-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty