Skip to content

Commit b80a72d

Browse files
authored
Merge pull request #154 from watson-developer-cloud/develop
Unity Watson SDK 0.10.0
2 parents cfefb7e + 54b3496 commit b80a72d

35 files changed

+2659
-588
lines changed

CHANGELOG.md

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

Config.json.enc

64 Bytes
Binary file not shown.

Examples/ServiceExamples/Scripts/ExampleAlchemyLanguage.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
using IBM.Watson.DeveloperCloud.Services.AlchemyAPI.v1;
2121
using IBM.Watson.DeveloperCloud.Logging;
2222

23+
#pragma warning disable 0219
24+
#pragma warning disable 0414
2325
public class ExampleAlchemyLanguage : MonoBehaviour
2426
{
2527
private AlchemyAPI m_AlchemyAPI = new AlchemyAPI();
@@ -52,7 +54,7 @@ void Start()
5254
// Log.Debug("ExampleAlchemyLanguage", "Failed to get concepts HTML POST!");
5355

5456
////Get Concepts URL POST
55-
//if (!m_AlchemyAPI.GetRankedConcepts(OnGetConcepts, m_ExampleURL_watsonJeopardy))
57+
//if (!m_AlchemyAPI.GetRankedConcepts(OnGetCzoncepts, m_ExampleURL_watsonJeopardy))
5658
// Log.Debug("ExampleAlchemyLanguage", "Failed to get concepts HTML POST!");
5759

5860
////Get Date URL POST

Examples/ServiceExamples/Scripts/ExampleConversation.cs

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,69 @@
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 string m_ConversationID;
29+
private bool m_UseAlternateIntents = true;
30+
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"};
2931

3032
void Start () {
3133
LogSystem.InstallDefaultReactors();
3234
m_WorkspaceID = Config.Instance.GetVariableValue("ConversationV1_ID");
33-
Debug.Log("User: " + m_Input);
3435

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

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

43-
// Message by passing input, alternate intents and conversationID
44-
m_Conversation.Message(OnMessage, m_WorkspaceID, m_Input, false, null);
70+
MessageWithFullMessageRequest(messageRequest);
71+
}
72+
else
73+
{
74+
Debug.Log("Failed to invoke Message();");
75+
}
4576
}
4677

47-
void OnMessage (MessageResponse resp, string customData)
78+
private void MessageWithFullMessageRequest(MessageRequest messageRequest)
4879
{
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-
}
80+
if (messageRequest == null)
81+
throw new ArgumentNullException("messageRequest");
82+
m_Conversation.Message(OnMessageWithOnlyInput, m_WorkspaceID, messageRequest);
6283
}
6384
}

Examples/ServiceExamples/Scripts/ExampleRetrieveAndRank.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using UnityEditor;
2626
#endif
2727

28+
#pragma warning disable 219
2829
public class ExampleRetrieveAndRank : MonoBehaviour
2930
{
3031
private RetrieveAndRank m_RetrieveAndRank = new RetrieveAndRank();

Examples/ServiceExamples/Scripts/ExampleTextToSpeech.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using UnityEngine;
1919
using IBM.Watson.DeveloperCloud.Services.TextToSpeech.v1;
2020
using IBM.Watson.DeveloperCloud.Logging;
21+
#pragma warning disable 0414
2122

2223
public class ExampleTextToSpeech : MonoBehaviour
2324
{

Examples/ServiceExamples/Scripts/ExampleVisualRecognition.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222
using IBM.Watson.DeveloperCloud.Logging;
2323
using IBM.Watson.DeveloperCloud.Utilities;
2424

25+
#pragma warning disable 0414
26+
2527
public class ExampleVisualRecognition : MonoBehaviour
2628
{
2729
private VisualRecognition m_VisualRecognition = new VisualRecognition();
28-
private string m_classifierName = "Apples_OptionalParams";
29-
private string m_classifierID = "ApplesClassifierNameWithSpaces_73100404";
30-
private string m_classifierToDelete = "unitytestclassifier2b_37849361";
30+
private string m_classifierName = "unity-test-classifier-example";
31+
private string m_classifierID = "unitytestclassifierexample_487365485";
32+
private string m_classifierToDelete = "unitytestclassifierexample_263072401";
3133
private string m_imageURL = "https://upload.wikimedia.org/wikipedia/commons/e/e9/Official_portrait_of_Barack_Obama.jpg";
3234
private string m_imageTextURL = "http://i.stack.imgur.com/ZS6nH.png";
3335

@@ -65,37 +67,37 @@ void Start()
6567

6668
//// Classify get
6769
//Log.Debug("ExampleVisualRecognition", "Attempting to get classify via URL");
68-
//if (!m_VisualRecognition.Classify(m_imageURL, OnClassify))
70+
//if (!m_VisualRecognition.Classify(OnClassify, m_imageURL))
6971
// Log.Debug("ExampleVisualRecognition", "Classify image failed!");
7072

7173
//// Classify post image
72-
//Log.Debug("ExampleVisualRecognition", "Attempting to classify via image on file system");
73-
//string imagesPath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/visual-recognition-classifiers/obama.jpg";
74-
//string[] owners = { "IBM", "me" };
75-
//string[] classifierIDs = { "default" };
76-
//if (!m_VisualRecognition.Classify(OnClassify, imagesPath, owners, classifierIDs, 0.5f))
77-
// Log.Debug("ExampleVisualRecognition", "Classify image failed!");
74+
Log.Debug("ExampleVisualRecognition", "Attempting to classify via image on file system");
75+
string imagesPath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/visual-recognition-classifiers/giraffe_to_classify.jpg";
76+
string[] owners = { "IBM", "me" };
77+
string[] classifierIDs = { "default", m_classifierID };
78+
if (!m_VisualRecognition.Classify(imagesPath, OnClassify, owners, classifierIDs, 0.5f))
79+
Log.Debug("ExampleVisualRecognition", "Classify image failed!");
7880

7981
//// Detect faces get
8082
//Log.Debug("ExampleVisualRecognition", "Attempting to detect faces via URL");
81-
//if (!m_VisualRecognition.DetectFaces(m_imageURL, OnDetectFaces))
83+
//if (!m_VisualRecognition.DetectFaces(OnDetectFaces, m_imageURL))
8284
// Log.Debug("ExampleVisualRecogntiion", "Detect faces failed!");
8385

8486
//// Detect faces post image
8587
//Log.Debug("ExampleVisualRecognition", "Attempting to detect faces via image");
8688
//string faceExamplePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/visual-recognition-classifiers/obama.jpg";
87-
//if (!m_VisualRecognition.DetectFaces(OnDetectFaces, faceExamplePath))
89+
//if (!m_VisualRecognition.DetectFaces(faceExamplePath, OnDetectFaces))
8890
// Log.Debug("ExampleVisualRecognition", "Detect faces failed!");
8991

9092
//// Recognize text get
9193
//Log.Debug("ExampleVisualRecognition", "Attempting to recognizeText via URL");
92-
//if (!m_VisualRecognition.RecognizeText(m_imageTextURL, OnRecognizeText))
94+
//if (!m_VisualRecognition.RecognizeText(OnRecognizeText, m_imageTextURL))
9395
// Log.Debug("ExampleVisualRecognition", "Recognize text failed!");
9496

9597
//// Recognize text post image
9698
//Log.Debug("ExampleVisualRecognition", "Attempting to recognizeText via image");
9799
//string textExamplePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/visual-recognition-classifiers/from_platos_apology.png";
98-
//if (!m_VisualRecognition.RecognizeText(OnRecognizeText, textExamplePath))
100+
//if (!m_VisualRecognition.RecognizeText(textExamplePath, OnRecognizeText))
99101
// Log.Debug("ExampleVisualRecognition", "Recognize text failed!");
100102
}
101103

@@ -170,11 +172,14 @@ private void OnClassify(ClassifyTopLevelMultiple classify, string data)
170172
foreach (ClassifyTopLevelSingle image in classify.images)
171173
{
172174
Log.Debug("ExampleVisualRecognition", "\tsource_url: " + image.source_url + ", resolved_url: " + image.resolved_url);
173-
foreach (ClassifyPerClassifier classifier in image.classifiers)
175+
if (image.classifiers != null && image.classifiers.Length > 0)
174176
{
175-
Log.Debug("ExampleVisualRecognition", "\t\tclassifier_id: " + classifier.classifier_id + ", name: " + classifier.name);
176-
foreach (ClassResult classResult in classifier.classes)
177-
Log.Debug("ExampleVisualRecognition", "\t\t\tclass: " + classResult.m_class + ", score: " + classResult.score + ", type_hierarchy: " + classResult.type_hierarchy);
177+
foreach (ClassifyPerClassifier classifier in image.classifiers)
178+
{
179+
Log.Debug("ExampleVisualRecognition", "\t\tclassifier_id: " + classifier.classifier_id + ", name: " + classifier.name);
180+
foreach (ClassResult classResult in classifier.classes)
181+
Log.Debug("ExampleVisualRecognition", "\t\t\tclass: " + classResult.m_class + ", score: " + classResult.score + ", type_hierarchy: " + classResult.type_hierarchy);
182+
}
178183
}
179184
}
180185
}

Examples/ServiceExamples/ServiceExamples.unity

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ RenderSettings:
3737
m_ReflectionIntensity: 1
3838
m_CustomReflection: {fileID: 0}
3939
m_Sun: {fileID: 0}
40-
m_IndirectSpecularColor: {r: 0.3735644, g: 0.38112032, b: 0.35887682, a: 1}
40+
m_IndirectSpecularColor: {r: 0.3735645, g: 0.38112062, b: 0.35887584, a: 1}
4141
--- !u!157 &3
4242
LightmapSettings:
4343
m_ObjectHideFlags: 0
@@ -352,7 +352,7 @@ GameObject:
352352
m_Icon: {fileID: 0}
353353
m_NavMeshLayer: 0
354354
m_StaticEditorFlags: 0
355-
m_IsActive: 0
355+
m_IsActive: 1
356356
--- !u!114 &859102723
357357
MonoBehaviour:
358358
m_ObjectHideFlags: 0
@@ -633,7 +633,7 @@ GameObject:
633633
m_Icon: {fileID: 0}
634634
m_NavMeshLayer: 0
635635
m_StaticEditorFlags: 0
636-
m_IsActive: 1
636+
m_IsActive: 0
637637
--- !u!114 &1740459832
638638
MonoBehaviour:
639639
m_ObjectHideFlags: 0
@@ -658,47 +658,6 @@ Transform:
658658
m_Children: []
659659
m_Father: {fileID: 0}
660660
m_RootOrder: 1
661-
--- !u!1 &1979050314
662-
GameObject:
663-
m_ObjectHideFlags: 0
664-
m_PrefabParentObject: {fileID: 0}
665-
m_PrefabInternal: {fileID: 0}
666-
serializedVersion: 4
667-
m_Component:
668-
- 4: {fileID: 1979050316}
669-
- 114: {fileID: 1979050315}
670-
m_Layer: 0
671-
m_Name: ExampleDialog
672-
m_TagString: Untagged
673-
m_Icon: {fileID: 0}
674-
m_NavMeshLayer: 0
675-
m_StaticEditorFlags: 0
676-
m_IsActive: 0
677-
--- !u!114 &1979050315
678-
MonoBehaviour:
679-
m_ObjectHideFlags: 0
680-
m_PrefabParentObject: {fileID: 0}
681-
m_PrefabInternal: {fileID: 0}
682-
m_GameObject: {fileID: 1979050314}
683-
m_Enabled: 1
684-
m_EditorHideFlags: 0
685-
m_Script: {fileID: 11500000, guid: e8b52562568714a48a89536c62fb978e, type: 3}
686-
m_Name:
687-
m_EditorClassIdentifier:
688-
m_DialogID: 61343031353936302d333963322d346436622d393537312d333863373461656366666664
689-
--- !u!4 &1979050316
690-
Transform:
691-
m_ObjectHideFlags: 0
692-
m_PrefabParentObject: {fileID: 0}
693-
m_PrefabInternal: {fileID: 0}
694-
m_GameObject: {fileID: 1979050314}
695-
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
696-
m_LocalPosition: {x: 0, y: 1, z: -10}
697-
m_LocalScale: {x: 1, y: 1, z: 1}
698-
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
699-
m_Children: []
700-
m_Father: {fileID: 0}
701-
m_RootOrder: 2
702661
--- !u!1 &2004886371
703662
GameObject:
704663
m_ObjectHideFlags: 0

0 commit comments

Comments
 (0)