|
23 | 23 | using System;
|
24 | 24 | using System.Collections;
|
25 | 25 | using System.Collections.Generic;
|
| 26 | +using System.IO; |
26 | 27 | using UnityEngine;
|
27 | 28 | using Environment = IBM.Watson.DeveloperCloud.Services.Discovery.v1.Environment;
|
28 | 29 |
|
@@ -92,11 +93,17 @@ public class ExampleDiscovery : MonoBehaviour
|
92 | 93 | private bool _getMetricsQueryTokenEventTested = false;
|
93 | 94 | private bool _queryLogTested = false;
|
94 | 95 |
|
| 96 | + private string _stopwordsFilepath; |
| 97 | + private bool _createStopwordListTested = false; |
| 98 | + private bool _deleteStopwordListTested = false; |
| 99 | + |
95 | 100 | private void Start()
|
96 | 101 | {
|
97 | 102 | LogSystem.InstallDefaultReactors();
|
98 | 103 | _filePathToIngest = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
|
99 | 104 | _documentFilePath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/watson_beats_jeopardy.html";
|
| 105 | + _stopwordsFilepath = Application.dataPath + "/Watson/Examples/ServiceExamples/TestData/Discovery/stopwords.txt"; |
| 106 | + |
100 | 107 | Runnable.Run(CreateService());
|
101 | 108 | }
|
102 | 109 |
|
@@ -333,6 +340,22 @@ private IEnumerator Examples()
|
333 | 340 | while (!_isEnvironmentReady)
|
334 | 341 | yield return null;
|
335 | 342 |
|
| 343 | + // Create stopword list |
| 344 | + using (FileStream fs = File.OpenRead(_stopwordsFilepath)) |
| 345 | + { |
| 346 | + |
| 347 | + Log.Debug("TestDiscovery.RunTest()", "Attempting to create stopword list {0}", _createdCollectionId); |
| 348 | + _service.CreateStopwordList(OnCreateStopwordList, OnFail, _environmentId, _createdCollectionId, fs); |
| 349 | + while (!_createStopwordListTested) |
| 350 | + yield return null; |
| 351 | + } |
| 352 | + |
| 353 | + // Delete stopword list |
| 354 | + Log.Debug("TestDiscovery.RunTest()", "Attempting to delete stopword list {0}", _createdCollectionId); |
| 355 | + _service.DeleteStopwordList(OnDeleteStopwordList, OnFail, _environmentId, _createdCollectionId); |
| 356 | + while (!_deleteStopwordListTested) |
| 357 | + yield return null; |
| 358 | + |
336 | 359 | // Delete Collection
|
337 | 360 | Log.Debug("ExampleDiscovery.RunTest()", "Attempting to delete collection {0}", _createdCollectionId);
|
338 | 361 | if (!_service.DeleteCollection(OnDeleteCollection, OnFail, _environmentId, _createdCollectionId))
|
@@ -579,6 +602,18 @@ private void OnQueryLog(LogQueryResponse response, Dictionary<string, object> cu
|
579 | 602 | _queryLogTested = true;
|
580 | 603 | }
|
581 | 604 |
|
| 605 | + private void OnCreateStopwordList(TokenDictStatusResponse response, Dictionary<string, object> customData) |
| 606 | + { |
| 607 | + Log.Debug("ExampleDiscovery.OnCreateStopwordList()", "Response: {0}", customData["json"].ToString()); |
| 608 | + _createStopwordListTested = true; |
| 609 | + } |
| 610 | + |
| 611 | + private void OnDeleteStopwordList(object response, Dictionary<string, object> customData) |
| 612 | + { |
| 613 | + Log.Debug("ExampleDiscovery.OnDeleteStopwordList()", "Success!"); |
| 614 | + _deleteStopwordListTested = true; |
| 615 | + } |
| 616 | + |
582 | 617 | private void OnFail(RESTConnector.Error error, Dictionary<string, object> customData)
|
583 | 618 | {
|
584 | 619 | Log.Error("ExampleDiscovery.OnFail()", "Error received: {0}", error.ToString());
|
|
0 commit comments