Skip to content

Commit 1da8659

Browse files
Merge pull request #167 from watson-developer-cloud/feature-codeFormatting
Feature code formatting
2 parents 230d15e + f4a59d9 commit 1da8659

File tree

120 files changed

+34565
-34511
lines changed

Some content is hidden

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

120 files changed

+34565
-34511
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; Top-most EditorConfig file
2+
root = true
3+
4+
; Unix-style newlines
5+
[*]
6+
end_of_line = LF
7+
8+
; 2-column space indentation
9+
[*.cs]
10+
indent_style = space
11+
indent_size = 2

Examples/ServiceExamples/Scripts/ExampleAlchemyDataNews.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,31 @@
1616
*/
1717

1818
using UnityEngine;
19-
using System.Collections;
2019
using System.Collections.Generic;
2120
using IBM.Watson.DeveloperCloud.Services.AlchemyAPI.v1;
2221
using IBM.Watson.DeveloperCloud.Logging;
2322
using System;
2423

25-
public class ExampleAlchemyDataNews : MonoBehaviour {
26-
private AlchemyAPI m_AlchemyAPI = new AlchemyAPI();
27-
28-
void Start () {
29-
LogSystem.InstallDefaultReactors();
24+
public class ExampleAlchemyDataNews : MonoBehaviour
25+
{
26+
private AlchemyAPI m_AlchemyAPI = new AlchemyAPI();
3027

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");
28+
void Start()
29+
{
30+
LogSystem.InstallDefaultReactors();
3531

36-
if (!m_AlchemyAPI.GetNews(OnGetNews, returnFields, queryFields))
37-
Log.Debug("ExampleAlchemyData", "Failed to get news!");
38-
}
32+
string[] returnFields = { Fields.ENRICHED_URL_ENTITIES, Fields.ENRICHED_URL_KEYWORDS };
33+
Dictionary<string, string> queryFields = new Dictionary<string, string>();
34+
queryFields.Add(Fields.ENRICHED_URL_RELATIONS_RELATION_SUBJECT_TEXT, "Obama");
35+
queryFields.Add(Fields.ENRICHED_URL_CLEANEDTITLE, "Washington");
3936

40-
private void OnGetNews(NewsResponse newsData, string data)
41-
{
42-
if(newsData != null)
43-
Log.Debug("ExampleAlchemyData", "status: {0}", newsData.status);
44-
}
37+
if (!m_AlchemyAPI.GetNews(OnGetNews, returnFields, queryFields))
38+
Log.Debug("ExampleAlchemyData", "Failed to get news!");
39+
}
40+
41+
private void OnGetNews(NewsResponse newsData, string data)
42+
{
43+
if (newsData != null)
44+
Log.Debug("ExampleAlchemyData", "status: {0}", newsData.status);
45+
}
4546
}

Examples/ServiceExamples/Scripts/ExampleAlchemyLanguage.cs

Lines changed: 569 additions & 570 deletions
Large diffs are not rendered by default.

Examples/ServiceExamples/Scripts/ExampleConversation.cs

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -23,59 +23,60 @@
2323

2424
public class ExampleConversation : MonoBehaviour
2525
{
26-
private Conversation m_Conversation = new Conversation();
27-
private string m_WorkspaceID;
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"};
26+
private Conversation m_Conversation = new Conversation();
27+
private string m_WorkspaceID;
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" };
3030

31-
void Start () {
32-
LogSystem.InstallDefaultReactors();
33-
m_WorkspaceID = Config.Instance.GetVariableValue("ConversationV1_ID");
31+
void Start()
32+
{
33+
LogSystem.InstallDefaultReactors();
34+
m_WorkspaceID = Config.Instance.GetVariableValue("ConversationV1_ID");
3435

35-
Debug.Log("**********User: Hello!");
36-
MessageWithOnlyInput("Hello!");
37-
}
36+
Debug.Log("**********User: Hello!");
37+
MessageWithOnlyInput("Hello!");
38+
}
39+
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+
}
3847

39-
private void MessageWithOnlyInput(string input)
40-
{
41-
if (string.IsNullOrEmpty(input))
42-
throw new ArgumentNullException("input");
4348

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);
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);
5455

55-
if (resp.output != null && resp.output.text.Length > 0)
56-
foreach (string txt in resp.output.text)
57-
Debug.Log("output: " + txt);
56+
if (resp.output != null && resp.output.text.Length > 0)
57+
foreach (string txt in resp.output.text)
58+
Debug.Log("output: " + txt);
5859

59-
string questionStr = questionArray[UnityEngine.Random.Range(0, questionArray.Length - 1)];
60-
Debug.Log(string.Format("**********User: {0}", questionStr));
60+
string questionStr = questionArray[UnityEngine.Random.Range(0, questionArray.Length - 1)];
61+
Debug.Log(string.Format("**********User: {0}", questionStr));
6162

62-
MessageRequest messageRequest = new MessageRequest();
63-
messageRequest.InputText = questionStr;
64-
messageRequest.alternate_intents = m_UseAlternateIntents;
65-
messageRequest.ContextData = resp.context;
63+
MessageRequest messageRequest = new MessageRequest();
64+
messageRequest.InputText = questionStr;
65+
messageRequest.alternate_intents = m_UseAlternateIntents;
66+
messageRequest.ContextData = resp.context;
6667

67-
MessageWithFullMessageRequest(messageRequest);
68-
}
69-
else
70-
{
71-
Debug.Log("Failed to invoke Message();");
72-
}
73-
}
68+
MessageWithFullMessageRequest(messageRequest);
69+
}
70+
else
71+
{
72+
Debug.Log("Failed to invoke Message();");
73+
}
74+
}
7475

75-
private void MessageWithFullMessageRequest(MessageRequest messageRequest)
76-
{
77-
if (messageRequest == null)
78-
throw new ArgumentNullException("messageRequest");
79-
m_Conversation.Message(OnMessageWithOnlyInput, m_WorkspaceID, messageRequest);
80-
}
76+
private void MessageWithFullMessageRequest(MessageRequest messageRequest)
77+
{
78+
if (messageRequest == null)
79+
throw new ArgumentNullException("messageRequest");
80+
m_Conversation.Message(OnMessageWithOnlyInput, m_WorkspaceID, messageRequest);
81+
}
8182
}

Examples/ServiceExamples/Scripts/ExampleConversationExperimental.cs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,32 @@
2323

2424
public class ExampleConversationExperimental : MonoBehaviour
2525
{
26-
private ConversationExperimental m_Conversation = new ConversationExperimental();
27-
private string m_WorkspaceID;
28-
private string m_Input = "Can you unlock the door?";
26+
private ConversationExperimental m_Conversation = new ConversationExperimental();
27+
private string m_WorkspaceID;
28+
private string m_Input = "Can you unlock the door?";
2929

30-
void Start () {
31-
LogSystem.InstallDefaultReactors();
32-
m_WorkspaceID = Config.Instance.GetVariableValue("ConversationExperimentalV1_ID");
33-
Debug.Log("User: " + m_Input);
30+
void Start()
31+
{
32+
LogSystem.InstallDefaultReactors();
33+
m_WorkspaceID = Config.Instance.GetVariableValue("ConversationExperimentalV1_ID");
34+
Debug.Log("User: " + m_Input);
3435

35-
m_Conversation.Message(m_WorkspaceID, m_Input, OnMessage);
36-
}
36+
m_Conversation.Message(m_WorkspaceID, m_Input, OnMessage);
37+
}
3738

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-
}
39+
void OnMessage(MessageResponse resp)
40+
{
41+
if (resp != null)
42+
{
43+
foreach (MessageIntent mi in resp.intents)
44+
Debug.Log("intent: " + mi.intent + ", confidence: " + mi.confidence);
45+
46+
if (resp.output != null && !string.IsNullOrEmpty(resp.output.text))
47+
Debug.Log("response: " + resp.output.text);
48+
}
49+
else
50+
{
51+
Debug.Log("Failed to invoke Message();");
52+
}
53+
}
5354
}

Examples/ServiceExamples/Scripts/ExampleDocumentConversion.cs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,49 @@
2222

2323
public class ExampleDocumentConversion : MonoBehaviour
2424
{
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";
25+
private DocumentConversion m_DocumentConversion = new DocumentConversion();
3126

32-
if (!m_DocumentConversion.ConvertDocument(OnConvertDocument, examplePath, ConversionTarget.NORMALIZED_TEXT))
33-
Log.Debug("ExampleDocumentConversion", "Document conversion failed!");
34-
}
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+
}
3535

36-
private void OnConvertDocument(ConvertedDocument documentConversionResponse, string data)
36+
private void OnConvertDocument(ConvertedDocument documentConversionResponse, string data)
37+
{
38+
if (documentConversionResponse != null)
3739
{
38-
if (documentConversionResponse != null)
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)
3956
{
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);
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);
6861
}
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);
6968
}
69+
}
7070
}

Examples/ServiceExamples/Scripts/ExampleLanguageTranslation.cs

100644100755
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
1818
using UnityEngine;
1919
using IBM.Watson.DeveloperCloud.Services.LanguageTranslation.v1;
2020

21-
public class ExampleLanguageTranslation : MonoBehaviour {
22-
private LanguageTranslation m_Translate = new LanguageTranslation();
23-
private string m_PharseToTranslate = "How do I get to the disco?";
21+
public class ExampleLanguageTranslation : MonoBehaviour
22+
{
23+
private LanguageTranslation m_Translate = new LanguageTranslation();
24+
private string m_PharseToTranslate = "How do I get to the disco?";
2425

25-
void Start ()
26-
{
27-
Debug.Log("English Phrase to translate: " + m_PharseToTranslate);
28-
m_Translate.GetTranslation(m_PharseToTranslate, "en", "es", OnGetTranslation);
29-
}
26+
void Start()
27+
{
28+
Debug.Log("English Phrase to translate: " + m_PharseToTranslate);
29+
m_Translate.GetTranslation(m_PharseToTranslate, "en", "es", OnGetTranslation);
30+
}
3031

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-
}
32+
private void OnGetTranslation(Translations translation)
33+
{
34+
if (translation != null && translation.translations.Length > 0)
35+
Debug.Log("Spanish Translation: " + translation.translations[0].translation);
36+
}
3637
}

Examples/ServiceExamples/Scripts/ExampleLanguageTranslator.cs

100644100755
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@
1818
using UnityEngine;
1919
using IBM.Watson.DeveloperCloud.Services.LanguageTranslator.v1;
2020

21-
public class ExampleLanguageTranslator : MonoBehaviour {
22-
private LanguageTranslator m_Translate = new LanguageTranslator();
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-
}
21+
public class ExampleLanguageTranslator : MonoBehaviour
22+
{
23+
private LanguageTranslator m_Translate = new LanguageTranslator();
24+
private string m_PharseToTranslate = "How do I get to the disco?";
3025

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-
}
26+
void Start()
27+
{
28+
Debug.Log("English Phrase to translate: " + m_PharseToTranslate);
29+
m_Translate.GetTranslation(m_PharseToTranslate, "en", "es", OnGetTranslation);
30+
}
31+
32+
private void OnGetTranslation(Translations translation)
33+
{
34+
if (translation != null && translation.translations.Length > 0)
35+
Debug.Log("Spanish Translation: " + translation.translations[0].translation);
36+
}
3637
}

0 commit comments

Comments
 (0)