Skip to content

Commit 0618de5

Browse files
authored
Merge pull request #500 from watson-developer-cloud/5904-regenerate-sdk-01
5904 regenerate sdk 01
2 parents f8d2228 + 3cc4302 commit 0618de5

File tree

71 files changed

+3084
-297
lines changed

Some content is hidden

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

71 files changed

+3084
-297
lines changed

Assistant.meta

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

Assistant/v2.meta

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

Core.meta

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

Core/Editor.meta

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

Core/Editor/Help.meta

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

Core/Editor/Help/Working.meta

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

Examples/ServiceExamples/Scripts/ExampleDiscovery.cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System;
2424
using System.Collections;
2525
using System.Collections.Generic;
26+
using System.IO;
2627
using UnityEngine;
2728
using Environment = IBM.Watson.DeveloperCloud.Services.Discovery.v1.Environment;
2829

@@ -92,11 +93,23 @@ public class ExampleDiscovery : MonoBehaviour
9293
private bool _getMetricsQueryTokenEventTested = false;
9394
private bool _queryLogTested = false;
9495

96+
private string _stopwordsFilepath;
97+
private bool _createStopwordListTested = false;
98+
private bool _deleteStopwordListTested = false;
99+
100+
private bool _listGatewaysTested = false;
101+
private bool _createGatewayTested = false;
102+
private bool _getGatewayTested = false;
103+
private bool _deleteGatewayTested = false;
104+
private string _createdGatewayId;
105+
95106
private void Start()
96107
{
97108
LogSystem.InstallDefaultReactors();
98109
_filePathToIngest = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
99110
_documentFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
111+
_stopwordsFilepath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/Discovery/stopwords.txt";
112+
100113
Runnable.Run(CreateService());
101114
}
102115

@@ -333,6 +346,46 @@ private IEnumerator Examples()
333346
while (!_isEnvironmentReady)
334347
yield return null;
335348

349+
// Create stopword list
350+
using (FileStream fs = File.OpenRead(_stopwordsFilepath))
351+
{
352+
353+
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to create stopword list {0}", _createdCollectionId);
354+
_service.CreateStopwordList(OnCreateStopwordList, OnFail, _environmentId, _createdCollectionId, fs);
355+
while (!_createStopwordListTested)
356+
yield return null;
357+
}
358+
359+
// Delete stopword list
360+
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete stopword list {0}", _createdCollectionId);
361+
_service.DeleteStopwordList(OnDeleteStopwordList, OnFail, _environmentId, _createdCollectionId);
362+
while (!_deleteStopwordListTested)
363+
yield return null;
364+
365+
// List Gateways
366+
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to list gateways.");
367+
_service.ListGateways(OnListGateways, OnFail, _environmentId);
368+
while (!_listGatewaysTested)
369+
yield return null;
370+
371+
// Create Gateway
372+
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to create gateway.");
373+
_service.CreateGateway(OnCreateGateway, OnFail, _environmentId);
374+
while (!_createGatewayTested)
375+
yield return null;
376+
377+
// Get Gateway
378+
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get gateway.");
379+
_service.GetGateway(OnGetGateway, OnFail, _environmentId, _createdGatewayId);
380+
while (!_getGatewayTested)
381+
yield return null;
382+
383+
// Delete Gateway
384+
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete gateway.");
385+
_service.GetGateway(OnDelteGateway, OnFail, _environmentId, _createdGatewayId);
386+
while (!_deleteGatewayTested)
387+
yield return null;
388+
336389
// Delete Collection
337390
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete collection {0}", _createdCollectionId);
338391
if (!_service.DeleteCollection(OnDeleteCollection, OnFail, _environmentId, _createdCollectionId))
@@ -579,6 +632,45 @@ private void OnQueryLog(LogQueryResponse response, Dictionary<string, object> cu
579632
_queryLogTested = true;
580633
}
581634

635+
private void OnCreateStopwordList(TokenDictStatusResponse response, Dictionary<string, object> customData)
636+
{
637+
Log.Debug("ExampleDiscovery.OnCreateStopwordList()", "Response: {0}", customData["json"].ToString());
638+
_createStopwordListTested = true;
639+
}
640+
641+
private void OnDeleteStopwordList(object response, Dictionary<string, object> customData)
642+
{
643+
Log.Debug("ExampleDiscovery.OnDeleteStopwordList()", "Success!");
644+
_deleteStopwordListTested = true;
645+
}
646+
647+
648+
private void OnListGateways(GatewayList response, Dictionary<string, object> customData)
649+
{
650+
Log.Debug("ExampleDiscovery.OnListGateways()", "Response: {0}", customData["json"].ToString());
651+
_listGatewaysTested = true;
652+
}
653+
654+
private void OnCreateGateway(Gateway response, Dictionary<string, object> customData)
655+
{
656+
Log.Debug("ExampleDiscovery.OnCreateGateway()", "Response: {0}", customData["json"].ToString());
657+
_createdGatewayId = response.GatewayId;
658+
_createGatewayTested = true;
659+
}
660+
661+
private void OnGetGateway(Gateway response, Dictionary<string, object> customData)
662+
{
663+
Log.Debug("ExampleDiscovery.OnGetGateway()", "Response: {0}", customData["json"].ToString());
664+
_getGatewayTested = true;
665+
}
666+
667+
private void OnDelteGateway(Gateway response, Dictionary<string, object> customData)
668+
{
669+
Log.Debug("ExampleDiscovery.OnDelteGateway()", "Response: {0}", customData["json"].ToString());
670+
_createdGatewayId = null;
671+
_deleteGatewayTested = true;
672+
}
673+
582674
private void OnFail(RESTConnector.Error error, Dictionary<string, object> customData)
583675
{
584676
Log.Error("ExampleDiscovery.OnFail()", "Error received: {0}", error.ToString());

Examples/ServiceExamples/Scripts/ExampleSpeechToText.cs

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class ExampleSpeechToText : MonoBehaviour
5858
private byte[] _oggResourceData;
5959
private string _oggResourceMimeType;
6060
private bool _isOggLoaded = false;
61+
private string _grammarFilePath;
6162

6263
private bool _recognizeTested = false;
6364
private bool _recognizeOggTested = false;
@@ -94,11 +95,20 @@ public class ExampleSpeechToText : MonoBehaviour
9495
private bool _readyToContinue = false;
9596
private float _delayTimeInSeconds = 10f;
9697

98+
private bool _listGrammarsTested = false;
99+
private bool _addGrammarTested = false;
100+
private bool _getGrammarTested = false;
101+
private bool _deleteGrammarTested = false;
102+
private string _createdGrammarId;
103+
private string _grammarFileContentType = "application/srgs";
104+
private string _grammarName = "unity-integration-test-grammar";
105+
97106
void Start()
98107
{
99108
LogSystem.InstallDefaultReactors();
100-
_customCorpusFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/theJabberwocky-utf8.txt";
101-
_customWordsFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/test-stt-words.json";
109+
_customCorpusFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/speech-to-text/theJabberwocky-utf8.txt";
110+
_customWordsFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/speech-to-text/test-stt-words.json";
111+
_grammarFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/speech-to-text/confirm.abnf";
102112
_acousticResourceMimeType = Utility.GetMimeType(Path.GetExtension(_acousticResourceUrl));
103113
_oggResourceMimeType = Utility.GetMimeType(Path.GetExtension(_oggResourceUrl));
104114
Runnable.Run(CreateService());
@@ -285,12 +295,6 @@ private IEnumerator Examples()
285295
while (!_isCustomizationReady)
286296
yield return null;
287297

288-
// Upgrade customization - not currently implemented in service
289-
//Log.Debug("ExampleSpeechToText.Examples()", "Attempting to upgrade customization {0}", _createdCustomizationID);
290-
//_speechToText.UpgradeCustomization(HandleUpgradeCustomization, _createdCustomizationID);
291-
//while (!_upgradeCustomizationTested)
292-
// yield return null;
293-
294298
// Delete custom word
295299
Log.Debug("ExampleSpeechToText.Examples()", "Attempting to delete custom word {1} in customization {0}", _createdCustomizationID, words.words[2].word);
296300
_service.DeleteCustomWord(HandleDeleteCustomWord, OnFail, _createdCustomizationID, words.words[2].word);
@@ -329,6 +333,37 @@ private IEnumerator Examples()
329333
while (!_readyToContinue)
330334
yield return null;
331335

336+
// List Grammars
337+
Log.Debug("TestSpeechToText.Examples()", "Attempting to list grammars {0}", _createdCustomizationID);
338+
_service.ListGrammars(OnListGrammars, OnFail, _createdCustomizationID);
339+
while (!_listGrammarsTested)
340+
yield return null;
341+
342+
// Add Grammar
343+
Log.Debug("TestSpeechToText.Examples()", "Attempting to add grammar {0}", _createdCustomizationID);
344+
string grammarFile = File.ReadAllText(_grammarFilePath);
345+
_service.AddGrammar(OnAddGrammar, OnFail, _createdCustomizationID, _grammarName, grammarFile, _grammarFileContentType);
346+
while (!_addGrammarTested)
347+
yield return null;
348+
349+
// Get Grammar
350+
Log.Debug("TestSpeechToText.Examples()", "Attempting to get grammar {0}", _createdCustomizationID);
351+
_service.GetGrammar(OnGetGrammar, OnFail, _createdCustomizationID, _grammarName);
352+
while (!_getGrammarTested)
353+
yield return null;
354+
355+
// Wait for customization
356+
_isCustomizationReady = false;
357+
Runnable.Run(CheckCustomizationStatus(_createdCustomizationID));
358+
while (!_isCustomizationReady)
359+
yield return null;
360+
361+
// Delete Grammar
362+
Log.Debug("TestSpeechToText.Examples()", "Attempting to delete grammar {0}", _createdCustomizationID);
363+
_service.DeleteGrammar(OnDeleteGrammar, OnFail, _createdCustomizationID, _grammarName);
364+
while (!_deleteGrammarTested)
365+
yield return null;
366+
332367
_readyToContinue = false;
333368
// Delete customization
334369
Log.Debug("ExampleSpeechToText.Examples()", "Attempting to delete customization {0}", _createdCustomizationID);
@@ -639,6 +674,30 @@ private void HandleDeleteAcousticCustomization(bool success, Dictionary<string,
639674
DeleteAcousticCustomization();
640675
}
641676

677+
private void OnListGrammars(Grammars response, Dictionary<string, object> customData)
678+
{
679+
Log.Debug("ExampleSpeechToText.OnListGrammars()", "{0}", customData["json"].ToString());
680+
_listGrammarsTested = true;
681+
}
682+
683+
private void OnAddGrammar(object response, Dictionary<string, object> customData)
684+
{
685+
Log.Debug("ExampleSpeechToText.OnAddGrammar()", "Success!");
686+
_addGrammarTested = true;
687+
}
688+
689+
private void OnGetGrammar(Grammar response, Dictionary<string, object> customData)
690+
{
691+
Log.Debug("ExampleSpeechToText.OnGetGrammar()", "{0}", customData["json"].ToString());
692+
_getGrammarTested = true;
693+
}
694+
695+
private void OnDeleteGrammar(object response, Dictionary<string, object> customData)
696+
{
697+
Log.Debug("ExampleSpeechToText.OnDeleteGrammar()", "Success!");
698+
_deleteGrammarTested = true;
699+
}
700+
642701
private IEnumerator CheckCustomizationStatus(string customizationID, float delay = 0.1f)
643702
{
644703
Log.Debug("ExampleSpeechToText.CheckCustomizationStatus()", "Checking customization status in {0} seconds...", delay.ToString());

Examples/ServiceExamples/Scripts/ExampleVisualRecognition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private IEnumerator Examples()
161161

162162
// Detect faces get
163163
Log.Debug("ExampleVisualRecognition.Examples()", "Attempting to detect faces via URL");
164-
if (!_visualRecognition.DetectFaces(_imageURL, OnDetectFacesGet, OnFail))
164+
if (!_visualRecognition.DetectFaces(_imageURL, OnDetectFacesGet, OnFail, "es"))
165165
Log.Debug("ExampleVisualRecognition.DetectFaces()", "Detect faces failed!");
166166

167167
while (!_detectFacesGetTested)
@@ -170,7 +170,7 @@ private IEnumerator Examples()
170170
// Detect faces post image
171171
Log.Debug("ExampleVisualRecognition.Examples()", "Attempting to detect faces via image");
172172
string faceExamplePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/visual-recognition-classifiers/obama.jpg";
173-
if (!_visualRecognition.DetectFaces(OnDetectFacesPost, OnFail, faceExamplePath))
173+
if (!_visualRecognition.DetectFaces(OnDetectFacesPost, OnFail, faceExamplePath, "es"))
174174
Log.Debug("ExampleVisualRecognition.DetectFaces()", "Detect faces failed!");
175175

176176
while (!_detectFacesPostTested)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
| US English default stopword list
2+
3+
a
4+
an
5+
and
6+
are
7+
as
8+
at
9+
be
10+
but
11+
by
12+
for
13+
if
14+
in
15+
into
16+
is
17+
it
18+
no
19+
not
20+
of
21+
on
22+
or
23+
such
24+
that
25+
the
26+
their
27+
then
28+
there
29+
these
30+
they
31+
this
32+
to
33+
was
34+
will
35+
with

Examples/ServiceExamples/TestData/speech-to-text.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ABNF 1.0 ISO-8859-1;
2+
language en-US;
3+
mode voice;
4+
root $yesno;
5+
6+
$yesno = affirmative | nah | no | nope | yeah | yep | yes | yup | fine
7+
| negative | OK | sure ;

Examples/ServiceExamples/TestData/speech-to-text/confirm.abnf.meta

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

Examples/ServiceExamples/TestData/test-stt-words.json.meta renamed to Examples/ServiceExamples/TestData/speech-to-text/test-stt-words.json.meta

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

Examples/ServiceExamples/TestData/theJabberwocky-utf8.txt.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)