Skip to content

5904 regenerate sdk 01 #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Assistant.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assistant/v2.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Core.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Core/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Core/Editor/Help.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Core/Editor/Help/Working.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 92 additions & 0 deletions Examples/ServiceExamples/Scripts/ExampleDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using Environment = IBM.Watson.DeveloperCloud.Services.Discovery.v1.Environment;

Expand Down Expand Up @@ -92,11 +93,23 @@ public class ExampleDiscovery : MonoBehaviour
private bool _getMetricsQueryTokenEventTested = false;
private bool _queryLogTested = false;

private string _stopwordsFilepath;
private bool _createStopwordListTested = false;
private bool _deleteStopwordListTested = false;

private bool _listGatewaysTested = false;
private bool _createGatewayTested = false;
private bool _getGatewayTested = false;
private bool _deleteGatewayTested = false;
private string _createdGatewayId;

private void Start()
{
LogSystem.InstallDefaultReactors();
_filePathToIngest = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
_documentFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
_stopwordsFilepath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/Discovery/stopwords.txt";

Runnable.Run(CreateService());
}

Expand Down Expand Up @@ -333,6 +346,46 @@ private IEnumerator Examples()
while (!_isEnvironmentReady)
yield return null;

// Create stopword list
using (FileStream fs = File.OpenRead(_stopwordsFilepath))
{

Log.Debug("ExampleDiscovery.RunTest()", "Attempting to create stopword list {0}", _createdCollectionId);
_service.CreateStopwordList(OnCreateStopwordList, OnFail, _environmentId, _createdCollectionId, fs);
while (!_createStopwordListTested)
yield return null;
}

// Delete stopword list
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete stopword list {0}", _createdCollectionId);
_service.DeleteStopwordList(OnDeleteStopwordList, OnFail, _environmentId, _createdCollectionId);
while (!_deleteStopwordListTested)
yield return null;

// List Gateways
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to list gateways.");
_service.ListGateways(OnListGateways, OnFail, _environmentId);
while (!_listGatewaysTested)
yield return null;

// Create Gateway
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to create gateway.");
_service.CreateGateway(OnCreateGateway, OnFail, _environmentId);
while (!_createGatewayTested)
yield return null;

// Get Gateway
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to get gateway.");
_service.GetGateway(OnGetGateway, OnFail, _environmentId, _createdGatewayId);
while (!_getGatewayTested)
yield return null;

// Delete Gateway
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete gateway.");
_service.GetGateway(OnDelteGateway, OnFail, _environmentId, _createdGatewayId);
while (!_deleteGatewayTested)
yield return null;

// Delete Collection
Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete collection {0}", _createdCollectionId);
if (!_service.DeleteCollection(OnDeleteCollection, OnFail, _environmentId, _createdCollectionId))
Expand Down Expand Up @@ -579,6 +632,45 @@ private void OnQueryLog(LogQueryResponse response, Dictionary<string, object> cu
_queryLogTested = true;
}

private void OnCreateStopwordList(TokenDictStatusResponse response, Dictionary<string, object> customData)
{
Log.Debug("ExampleDiscovery.OnCreateStopwordList()", "Response: {0}", customData["json"].ToString());
_createStopwordListTested = true;
}

private void OnDeleteStopwordList(object response, Dictionary<string, object> customData)
{
Log.Debug("ExampleDiscovery.OnDeleteStopwordList()", "Success!");
_deleteStopwordListTested = true;
}


private void OnListGateways(GatewayList response, Dictionary<string, object> customData)
{
Log.Debug("ExampleDiscovery.OnListGateways()", "Response: {0}", customData["json"].ToString());
_listGatewaysTested = true;
}

private void OnCreateGateway(Gateway response, Dictionary<string, object> customData)
{
Log.Debug("ExampleDiscovery.OnCreateGateway()", "Response: {0}", customData["json"].ToString());
_createdGatewayId = response.GatewayId;
_createGatewayTested = true;
}

private void OnGetGateway(Gateway response, Dictionary<string, object> customData)
{
Log.Debug("ExampleDiscovery.OnGetGateway()", "Response: {0}", customData["json"].ToString());
_getGatewayTested = true;
}

private void OnDelteGateway(Gateway response, Dictionary<string, object> customData)
{
Log.Debug("ExampleDiscovery.OnDelteGateway()", "Response: {0}", customData["json"].ToString());
_createdGatewayId = null;
_deleteGatewayTested = true;
}

private void OnFail(RESTConnector.Error error, Dictionary<string, object> customData)
{
Log.Error("ExampleDiscovery.OnFail()", "Error received: {0}", error.ToString());
Expand Down
75 changes: 67 additions & 8 deletions Examples/ServiceExamples/Scripts/ExampleSpeechToText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ExampleSpeechToText : MonoBehaviour
private byte[] _oggResourceData;
private string _oggResourceMimeType;
private bool _isOggLoaded = false;
private string _grammarFilePath;

private bool _recognizeTested = false;
private bool _recognizeOggTested = false;
Expand Down Expand Up @@ -94,11 +95,20 @@ public class ExampleSpeechToText : MonoBehaviour
private bool _readyToContinue = false;
private float _delayTimeInSeconds = 10f;

private bool _listGrammarsTested = false;
private bool _addGrammarTested = false;
private bool _getGrammarTested = false;
private bool _deleteGrammarTested = false;
private string _createdGrammarId;
private string _grammarFileContentType = "application/srgs";
private string _grammarName = "unity-integration-test-grammar";

void Start()
{
LogSystem.InstallDefaultReactors();
_customCorpusFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/theJabberwocky-utf8.txt";
_customWordsFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/test-stt-words.json";
_customCorpusFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/speech-to-text/theJabberwocky-utf8.txt";
_customWordsFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/speech-to-text/test-stt-words.json";
_grammarFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/speech-to-text/confirm.abnf";
_acousticResourceMimeType = Utility.GetMimeType(Path.GetExtension(_acousticResourceUrl));
_oggResourceMimeType = Utility.GetMimeType(Path.GetExtension(_oggResourceUrl));
Runnable.Run(CreateService());
Expand Down Expand Up @@ -285,12 +295,6 @@ private IEnumerator Examples()
while (!_isCustomizationReady)
yield return null;

// Upgrade customization - not currently implemented in service
//Log.Debug("ExampleSpeechToText.Examples()", "Attempting to upgrade customization {0}", _createdCustomizationID);
//_speechToText.UpgradeCustomization(HandleUpgradeCustomization, _createdCustomizationID);
//while (!_upgradeCustomizationTested)
// yield return null;

// Delete custom word
Log.Debug("ExampleSpeechToText.Examples()", "Attempting to delete custom word {1} in customization {0}", _createdCustomizationID, words.words[2].word);
_service.DeleteCustomWord(HandleDeleteCustomWord, OnFail, _createdCustomizationID, words.words[2].word);
Expand Down Expand Up @@ -329,6 +333,37 @@ private IEnumerator Examples()
while (!_readyToContinue)
yield return null;

// List Grammars
Log.Debug("TestSpeechToText.Examples()", "Attempting to list grammars {0}", _createdCustomizationID);
_service.ListGrammars(OnListGrammars, OnFail, _createdCustomizationID);
while (!_listGrammarsTested)
yield return null;

// Add Grammar
Log.Debug("TestSpeechToText.Examples()", "Attempting to add grammar {0}", _createdCustomizationID);
string grammarFile = File.ReadAllText(_grammarFilePath);
_service.AddGrammar(OnAddGrammar, OnFail, _createdCustomizationID, _grammarName, grammarFile, _grammarFileContentType);
while (!_addGrammarTested)
yield return null;

// Get Grammar
Log.Debug("TestSpeechToText.Examples()", "Attempting to get grammar {0}", _createdCustomizationID);
_service.GetGrammar(OnGetGrammar, OnFail, _createdCustomizationID, _grammarName);
while (!_getGrammarTested)
yield return null;

// Wait for customization
_isCustomizationReady = false;
Runnable.Run(CheckCustomizationStatus(_createdCustomizationID));
while (!_isCustomizationReady)
yield return null;

// Delete Grammar
Log.Debug("TestSpeechToText.Examples()", "Attempting to delete grammar {0}", _createdCustomizationID);
_service.DeleteGrammar(OnDeleteGrammar, OnFail, _createdCustomizationID, _grammarName);
while (!_deleteGrammarTested)
yield return null;

_readyToContinue = false;
// Delete customization
Log.Debug("ExampleSpeechToText.Examples()", "Attempting to delete customization {0}", _createdCustomizationID);
Expand Down Expand Up @@ -639,6 +674,30 @@ private void HandleDeleteAcousticCustomization(bool success, Dictionary<string,
DeleteAcousticCustomization();
}

private void OnListGrammars(Grammars response, Dictionary<string, object> customData)
{
Log.Debug("ExampleSpeechToText.OnListGrammars()", "{0}", customData["json"].ToString());
_listGrammarsTested = true;
}

private void OnAddGrammar(object response, Dictionary<string, object> customData)
{
Log.Debug("ExampleSpeechToText.OnAddGrammar()", "Success!");
_addGrammarTested = true;
}

private void OnGetGrammar(Grammar response, Dictionary<string, object> customData)
{
Log.Debug("ExampleSpeechToText.OnGetGrammar()", "{0}", customData["json"].ToString());
_getGrammarTested = true;
}

private void OnDeleteGrammar(object response, Dictionary<string, object> customData)
{
Log.Debug("ExampleSpeechToText.OnDeleteGrammar()", "Success!");
_deleteGrammarTested = true;
}

private IEnumerator CheckCustomizationStatus(string customizationID, float delay = 0.1f)
{
Log.Debug("ExampleSpeechToText.CheckCustomizationStatus()", "Checking customization status in {0} seconds...", delay.ToString());
Expand Down
4 changes: 2 additions & 2 deletions Examples/ServiceExamples/Scripts/ExampleVisualRecognition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private IEnumerator Examples()

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

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

while (!_detectFacesPostTested)
Expand Down
35 changes: 35 additions & 0 deletions Examples/ServiceExamples/TestData/Discovery/stopwords.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
| US English default stopword list

a
an
and
are
as
at
be
but
by
for
if
in
into
is
it
no
not
of
on
or
such
that
the
their
then
there
these
they
this
to
was
will
with
8 changes: 8 additions & 0 deletions Examples/ServiceExamples/TestData/speech-to-text.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Examples/ServiceExamples/TestData/speech-to-text/confirm.abnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ABNF 1.0 ISO-8859-1;
language en-US;
mode voice;
root $yesno;

$yesno = affirmative | nah | no | nope | yeah | yep | yes | yup | fine
| negative | OK | sure ;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Loading