@@ -37,15 +37,15 @@ import RecastAI
37
37
38
38
class ViewController : UIViewController , HandlerRecastRequestProtocol
39
39
{
40
- var app : RecastAPI?
40
+ var bot : RecastAPI?
41
41
42
42
override func viewDidLoad ()
43
43
{
44
44
super .viewDidLoad ()
45
45
// Do any additional setup after loading the view, typically from a nib.
46
46
47
- // Initialise app with token & handlerRecastProtocol
48
- self .app = RecastAPI (token : " YOUR_APP_TOKEN " , handlerRecastRequestProtocol : self )
47
+ // Initialise bot with token & handlerRecastProtocol
48
+ self .bot = RecastAPI (token : " YOUR_BOT_TOKEN " , handlerRecastRequestProtocol : self )
49
49
}
50
50
}
51
51
```
@@ -60,7 +60,7 @@ Make text request to Recast.AI API
60
60
@IBAction func makeRequest ()
61
61
{
62
62
// Call makeRequest with string parameter to make a text request
63
- self .app ? .makeRequest (< #T ##request : String ##String #> )
63
+ self .bot ? .makeRequest (< #T ##request : String ##String #> )
64
64
}
65
65
```
66
66
@@ -81,13 +81,13 @@ Make Voice request to Recast.AI API
81
81
{
82
82
self .recording = ! self .recording
83
83
// Call startVoiceRequest to start recording your voice
84
- self .app ! .startVoiceRequest ()
84
+ self .bot ! .startVoiceRequest ()
85
85
}
86
86
else
87
87
{
88
88
self .recording = ! self .recording
89
89
// Call stopVoiceRequest to stop recording your voice and launch the request to the Recast.AI API
90
- self .app ! .stopVoiceRequest ()
90
+ self .bot ! .stopVoiceRequest ()
91
91
}
92
92
}
93
93
```
@@ -146,7 +146,7 @@ We will return an error (400: bad_request) if any of these cases is met:
146
146
147
147
We will return an error (401: unauthorized) if the following case is met:
148
148
149
- - The token provided in your request is not linked to any of your apps .
149
+ - The token provided in your request is not linked to any of your bots .
150
150
151
151
### Response
152
152
@@ -173,7 +173,7 @@ public class Sentence
173
173
public var type : String ?
174
174
public var polarity : String ?
175
175
public var action : String ?
176
- public var agent : String ?
176
+ public var agent : String ?
177
177
public var entities : Entities?
178
178
}
179
179
```
@@ -216,19 +216,37 @@ public class Entities
216
216
}
217
217
```
218
218
219
- ### Accessing Custom Entities
219
+ You can print a description of the entity using the description attribute :
220
+ ``` swift
221
+ public var description: String
222
+ {
223
+ return " Custom(value : \( value ) , raw : \( raw ) )"
224
+ }
225
+ ```
220
226
221
- If you want to get the custom entities you can do it this way :
227
+ ### Accessing Entities
222
228
223
- print(response.sentences![ 0] .entities?.custom)
229
+ You can access entities from the first sentence this way :
230
+ ``` swift
231
+ response.sentences ! [0 ].entities ? .age .raw
232
+ ```
224
233
234
+ ### Accessing Custom Entities
235
+
236
+ If you want to get custom entities you can do it this way :
237
+ ``` swift
238
+ print (response.sentences ! [0 ].entities ? .custom )
239
+ ```
240
+ Output :
225
241
``` swift
226
242
Optional ([" movie" : [Custom (value : star wars 8 , raw : Star Wars 8 )]])
227
243
```
228
- If you want to access the array of a specific custom entity :
229
244
245
+ If you want to access the array of a specific custom entity you can do it with its key:
246
+ ``` swift
230
247
print (response.sentences ! [0 ].entities ? .custom ! [" movie" ]
231
-
248
+ ```
249
+ Output :
232
250
```swift
233
251
Optional ([Custom (value : star wars 8 , raw : Star Wars 8 )])
234
252
```
0 commit comments