Skip to content

Commit ff69ebf

Browse files
committed
Merge branch 'develop' into feature-vrTrainingMimeType
2 parents cbcbf0e + 20c54de commit ff69ebf

28 files changed

+5327
-834
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
Change Log
22
==========
3+
## Version 0.11.0
4+
_2016_10_27_
5+
* New: Abstracted `Speech to Text` customization methods.
6+
7+
## Version 0.10.0
8+
_2016_09_23_
9+
10+
* New: Added `similarity search` to the `Visual Recognition` service.
11+
* Fix: `Touch Widget` improvmements.
12+
* Fix: Disabled 3rd Party plugin warnings.
13+
* Fix: Removed `Conversation` Message overload method that takes only input and conversationID.
14+
* Fix: Rewrote `Conversation` example script to show how to create MessageRequest object.
15+
316
## Version 0.9.0
417
_2016-08-26_
518

Examples/ServiceExamples/Scripts/ExampleConversation.cs

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,66 @@
1616
*/
1717

1818
using UnityEngine;
19-
using System.Collections;
2019
using IBM.Watson.DeveloperCloud.Services.Conversation.v1;
2120
using IBM.Watson.DeveloperCloud.Utilities;
2221
using IBM.Watson.DeveloperCloud.Logging;
22+
using System;
2323

2424
public class ExampleConversation : MonoBehaviour
2525
{
2626
private Conversation m_Conversation = new Conversation();
2727
private string m_WorkspaceID;
28-
private string m_Input = "Can you unlock the door?";
28+
private bool m_UseAlternateIntents = true;
29+
private string[] questionArray = { "can you turn up the AC", "can you turn on the wipers", "can you turn off the wipers", "can you turn down the ac", "can you unlock the door"};
2930

3031
void Start () {
3132
LogSystem.InstallDefaultReactors();
3233
m_WorkspaceID = Config.Instance.GetVariableValue("ConversationV1_ID");
33-
Debug.Log("User: " + m_Input);
3434

35-
// Message with input only
36-
//m_Conversation.Message(OnMessage, m_WorkspaceID, m_Input);
35+
Debug.Log("**********User: Hello!");
36+
MessageWithOnlyInput("Hello!");
37+
}
3738

38-
// Message by creating message request
39-
//MessageRequest messageRequest = new MessageRequest();
40-
//messageRequest.inputText = m_Input;
41-
//m_Conversation.Message(OnMessage, m_WorkspaceID, messageRequest);
39+
private void MessageWithOnlyInput(string input)
40+
{
41+
if (string.IsNullOrEmpty(input))
42+
throw new ArgumentNullException("input");
43+
44+
m_Conversation.Message(OnMessageWithOnlyInput, m_WorkspaceID, input);
45+
}
46+
47+
48+
private void OnMessageWithOnlyInput(MessageResponse resp, string customData)
49+
{
50+
if (resp != null)
51+
{
52+
foreach (Intent mi in resp.intents)
53+
Debug.Log("intent: " + mi.intent + ", confidence: " + mi.confidence);
54+
55+
if (resp.output != null && resp.output.text.Length > 0)
56+
foreach (string txt in resp.output.text)
57+
Debug.Log("output: " + txt);
58+
59+
string questionStr = questionArray[UnityEngine.Random.Range(0, questionArray.Length - 1)];
60+
Debug.Log(string.Format("**********User: {0}", questionStr));
61+
62+
MessageRequest messageRequest = new MessageRequest();
63+
messageRequest.InputText = questionStr;
64+
messageRequest.alternate_intents = m_UseAlternateIntents;
65+
messageRequest.ContextData = resp.context;
4266

43-
// Message by passing input, alternate intents and conversationID
44-
m_Conversation.Message(OnMessage, m_WorkspaceID, m_Input, false, null);
67+
MessageWithFullMessageRequest(messageRequest);
68+
}
69+
else
70+
{
71+
Debug.Log("Failed to invoke Message();");
72+
}
4573
}
4674

47-
void OnMessage (MessageResponse resp, string customData)
75+
private void MessageWithFullMessageRequest(MessageRequest messageRequest)
4876
{
49-
if(resp != null)
50-
{
51-
foreach(Intent mi in resp.intents)
52-
Debug.Log("intent: " + mi.intent + ", confidence: " + mi.confidence);
53-
54-
if(resp.output != null && resp.output.text.Length > 0)
55-
foreach(string txt in resp.output.text)
56-
Debug.Log("output: " + txt);
57-
}
58-
else
59-
{
60-
Debug.Log("Failed to invoke Message();");
61-
}
77+
if (messageRequest == null)
78+
throw new ArgumentNullException("messageRequest");
79+
m_Conversation.Message(OnMessageWithOnlyInput, m_WorkspaceID, messageRequest);
6280
}
6381
}

0 commit comments

Comments
 (0)