Skip to content

Commit 8bcdc79

Browse files
authored
Merge pull request #109 from watson-developer-cloud/develop
Unity SDK v0.6.0
2 parents 57016a1 + 79eedde commit 8bcdc79

File tree

74 files changed

+21799
-1440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+21799
-1440
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ LICENSE.meta
5050
CHANGELOG.md.meta
5151
README.md.meta
5252
Travis.meta
53+
exclude-filter.txt
54+
exclude-filter.txt.meta
5355
/Travis/UnityTestProject/Assets/StreamingAssets/Config.json
5456
/Travis/UnityTestProject/Assets/StreamingAssets/Config.json.meta
5557
/Travis/UnityTestProject/Assets/StreamingAssets/Config.json.enc.meta
@@ -62,4 +64,4 @@ Travis.meta
6264
/Travis/installUnity.sh.meta
6365
/Travis/README.md.meta
6466
/Travis/runTests.sh.meta
65-
/Travis/TravisBuild.cs.meta
67+
/Travis/TravisBuild.cs.meta

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
Change Log
22
==========
3+
## Version 0.6.0
4+
5+
_2016-07-15_
6+
7+
* New: Added `Document Conversion` abstraction
8+
* New: Added `AlchemyData News` abstraction
9+
* New: Added `Retrieve and Rank` abstraction
10+
* New: Added `Conversation` abstraction
11+
* Fix: Added `LanguageTranslation` and `LanguageTranslator`
12+
313
## Version 0.5.0
414

515
_2016-06-24_

Config.json.enc

1.25 KB
Binary file not shown.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using UnityEngine;
19+
using System.Collections;
20+
using System.Collections.Generic;
21+
using IBM.Watson.DeveloperCloud.Services.AlchemyAPI.v1;
22+
using IBM.Watson.DeveloperCloud.Logging;
23+
using System;
24+
25+
public class ExampleAlchemyDataNews : MonoBehaviour {
26+
private AlchemyAPI m_AlchemyAPI = new AlchemyAPI();
27+
28+
void Start () {
29+
LogSystem.InstallDefaultReactors();
30+
31+
string[] returnFields = {Fields.ENRICHED_URL_ENTITIES, Fields.ENRICHED_URL_KEYWORDS};
32+
Dictionary<string, string> queryFields = new Dictionary<string, string>();
33+
queryFields.Add(Fields.ENRICHED_URL_RELATIONS_RELATION_SUBJECT_TEXT, "Obama");
34+
queryFields.Add(Fields.ENRICHED_URL_CLEANEDTITLE, "Washington");
35+
36+
if (!m_AlchemyAPI.GetNews(OnGetNews, returnFields, queryFields))
37+
Log.Debug("ExampleAlchemyData", "Failed to get news!");
38+
}
39+
40+
private void OnGetNews(NewsResponse newsData, string data)
41+
{
42+
if(newsData != null)
43+
Log.Debug("ExampleAlchemyData", "status: {0}", newsData.status);
44+
}
45+
}

Examples/ServiceExamples/Scripts/ExampleAlchemyDataNews.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/ServiceExamples/Scripts/ExampleAlchemyLanguage.cs

100644100755
Lines changed: 229 additions & 227 deletions
Large diffs are not rendered by default.

Examples/ServiceExamples/Scripts/ExampleConversation.cs

100644100755
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,28 @@
1818
using UnityEngine;
1919
using System.Collections;
2020
using IBM.Watson.DeveloperCloud.Services.Conversation.v1;
21+
using IBM.Watson.DeveloperCloud.Utilities;
22+
using IBM.Watson.DeveloperCloud.Logging;
2123

2224
public class ExampleConversation : MonoBehaviour
2325
{
2426
private Conversation m_Conversation = new Conversation();
25-
private string m_WorkspaceID = "25dfa8a0-0263-471b-8980-317e68c30488";
27+
private string m_WorkspaceID;
2628
private string m_Input = "Can you unlock the door?";
2729

2830
void Start () {
29-
Debug.Log("User: " + m_Input);
30-
m_Conversation.Message(m_WorkspaceID, m_Input, OnMessage);
31+
LogSystem.InstallDefaultReactors();
32+
m_WorkspaceID = Config.Instance.GetVariableValue("ConversationV1_WorkspaceID");
33+
Debug.Log("User: " + m_Input);
34+
35+
m_Conversation.Message(m_WorkspaceID, m_Input, OnMessage);
3136
}
3237

33-
void OnMessage (DataModels.MessageResponse resp)
38+
void OnMessage (MessageResponse resp)
3439
{
3540
if(resp != null)
3641
{
37-
foreach(DataModels.MessageIntent mi in resp.intents)
42+
foreach(MessageIntent mi in resp.intents)
3843
Debug.Log("intent: " + mi.intent + ", confidence: " + mi.confidence);
3944

4045
if(resp.output != null && !string.IsNullOrEmpty(resp.output.text))
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using UnityEngine;
19+
using System.Collections;
20+
using IBM.Watson.DeveloperCloud.Services.ConversationExperimental.v1;
21+
using IBM.Watson.DeveloperCloud.Logging;
22+
using IBM.Watson.DeveloperCloud.Utilities;
23+
24+
public class ExampleConversationExperimental : MonoBehaviour
25+
{
26+
private ConversationExperimental m_Conversation = new ConversationExperimental();
27+
private string m_WorkspaceID;
28+
private string m_Input = "Can you unlock the door?";
29+
30+
void Start () {
31+
LogSystem.InstallDefaultReactors();
32+
m_WorkspaceID = Config.Instance.GetVariableValue("ConversationExperimentalV1_ID");
33+
Debug.Log("User: " + m_Input);
34+
35+
m_Conversation.Message(m_WorkspaceID, m_Input, OnMessage);
36+
}
37+
38+
void OnMessage (MessageResponse resp)
39+
{
40+
if(resp != null)
41+
{
42+
foreach(MessageIntent mi in resp.intents)
43+
Debug.Log("intent: " + mi.intent + ", confidence: " + mi.confidence);
44+
45+
if(resp.output != null && !string.IsNullOrEmpty(resp.output.text))
46+
Debug.Log("response: " + resp.output.text);
47+
}
48+
else
49+
{
50+
Debug.Log("Failed to invoke Message();");
51+
}
52+
}
53+
}

Examples/ServiceExamples/Scripts/ExampleConversationExperimental.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/ServiceExamples/Scripts/ExampleDIalog.cs

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
using UnityEngine;
1919
using IBM.Watson.DeveloperCloud.Services.Dialog.v1;
2020

21-
public class ExampleDIalog : MonoBehaviour
21+
public class ExampleDialog : MonoBehaviour
2222
{
2323
private Dialog m_Dialog = new Dialog();
2424
private string m_DialogID = "a4015960-39c2-4d6b-9571-38c74aecfffd";
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using UnityEngine;
19+
using IBM.Watson.DeveloperCloud.Services.DocumentConversion.v1;
20+
using System.Collections;
21+
using IBM.Watson.DeveloperCloud.Logging;
22+
23+
public class ExampleDocumentConversion : MonoBehaviour
24+
{
25+
private DocumentConversion m_DocumentConversion = new DocumentConversion();
26+
27+
void Start ()
28+
{
29+
LogSystem.InstallDefaultReactors(); LogSystem.InstallDefaultReactors();
30+
string examplePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
31+
32+
if (!m_DocumentConversion.ConvertDocument(OnConvertDocument, examplePath, ConversionTarget.NORMALIZED_TEXT))
33+
Log.Debug("ExampleDocumentConversion", "Document conversion failed!");
34+
}
35+
36+
private void OnConvertDocument(ConvertedDocument documentConversionResponse, string data)
37+
{
38+
if (documentConversionResponse != null)
39+
{
40+
if(!string.IsNullOrEmpty(documentConversionResponse.media_type_detected))
41+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.media_type_detected);
42+
if (!string.IsNullOrEmpty(documentConversionResponse.source_document_id))
43+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.source_document_id);
44+
if(!string.IsNullOrEmpty(documentConversionResponse.timestamp))
45+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.timestamp);
46+
if (documentConversionResponse.metadata != null && documentConversionResponse.metadata.Length > 0)
47+
{
48+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.metadata.Length);
49+
foreach (Metadata metadata in documentConversionResponse.metadata)
50+
Log.Debug("ExampleDocumentConversion", "metadata | name: {0}, content: {1}", metadata.name, metadata.content);
51+
}
52+
if (documentConversionResponse.answer_units != null && documentConversionResponse.answer_units.Length > 0)
53+
{
54+
Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.answer_units.Length);
55+
foreach (AnswerUnit answerUnit in documentConversionResponse.answer_units)
56+
{
57+
Log.Debug("ExampleDocumentConversion", "answerUnit | type: {0}, title: {1}, parent_id: {2}, id: {3}, direction: {4}", answerUnit.type, answerUnit.title, answerUnit.parent_id, answerUnit.id, answerUnit.direction);
58+
if (answerUnit.content != null && answerUnit.content.Length > 0)
59+
foreach (Content content in answerUnit.content)
60+
Log.Debug("ExampleDocumentConversion", "content | mediaType: {0}, text: {1}", content.media_type, content.text);
61+
}
62+
}
63+
64+
if (!string.IsNullOrEmpty(documentConversionResponse.htmlContent))
65+
Log.Debug("ExampleDocumentConversion", "HTMLContent: {0}", documentConversionResponse.htmlContent);
66+
if (!string.IsNullOrEmpty(documentConversionResponse.textContent))
67+
Log.Debug("ExampleDocumentConversion", "TextContent: {0}", documentConversionResponse.textContent);
68+
}
69+
}
70+
}

Examples/ServiceExamples/Scripts/ExampleDocumentConversion.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using UnityEngine;
19+
using IBM.Watson.DeveloperCloud.Services.LanguageTranslation.v1;
20+
21+
public class ExampleLanguageTranslation : MonoBehaviour {
22+
private LanguageTranslation m_Translate = new LanguageTranslation();
23+
private string m_PharseToTranslate = "How do I get to the disco?";
24+
25+
void Start ()
26+
{
27+
Debug.Log("English Phrase to translate: " + m_PharseToTranslate);
28+
m_Translate.GetTranslation(m_PharseToTranslate, "en", "es", OnGetTranslation);
29+
}
30+
31+
private void OnGetTranslation(Translations translation)
32+
{
33+
if (translation != null && translation.translations.Length > 0)
34+
Debug.Log("Spanish Translation: " + translation.translations[0].translation);
35+
}
36+
}

Examples/ServiceExamples/Scripts/ExampleLanguageTranslation.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)