ibm_watson 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ibm_watson/assistant_v1.rb +791 -736
  3. data/lib/ibm_watson/assistant_v2.rb +12 -8
  4. data/lib/ibm_watson/common.rb +2 -1
  5. data/lib/ibm_watson/compare_comply_v1.rb +171 -169
  6. data/lib/ibm_watson/discovery_v1.rb +778 -689
  7. data/lib/ibm_watson/language_translator_v3.rb +65 -63
  8. data/lib/ibm_watson/natural_language_classifier_v1.rb +36 -35
  9. data/lib/ibm_watson/natural_language_understanding_v1.rb +28 -25
  10. data/lib/ibm_watson/personality_insights_v3.rb +10 -10
  11. data/lib/ibm_watson/speech_to_text_v1.rb +764 -702
  12. data/lib/ibm_watson/text_to_speech_v1.rb +215 -200
  13. data/lib/ibm_watson/tone_analyzer_v3.rb +10 -9
  14. data/lib/ibm_watson/version.rb +1 -1
  15. data/lib/ibm_watson/visual_recognition_v3.rb +94 -95
  16. data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +1 -1
  17. data/test/integration/test_assistant_v1.rb +18 -289
  18. data/test/integration/test_assistant_v2.rb +21 -31
  19. data/test/integration/test_discovery_v1.rb +21 -18
  20. data/test/integration/test_language_translator_v3.rb +3 -3
  21. data/test/integration/test_natural_language_classifier_v1.rb +3 -3
  22. data/test/integration/test_natural_language_understanding_v1.rb +16 -20
  23. data/test/integration/test_personality_insights_v3.rb +12 -40
  24. data/test/integration/test_speech_to_text_v1.rb +3 -3
  25. data/test/integration/test_text_to_speech_v1.rb +3 -3
  26. data/test/integration/test_tone_analyzer_v3.rb +14 -31
  27. data/test/integration/test_visual_recognition_v3.rb +3 -3
  28. data/test/unit/test_compare_comply_v1.rb +3 -7
  29. data/test/unit/test_discovery_v1.rb +21 -7
  30. data/test/unit/test_language_translator_v3.rb +1 -3
  31. data/test/unit/test_natural_language_classifier_v1.rb +1 -3
  32. data/test/unit/test_speech_to_text_v1.rb +25 -7
  33. data/test/unit/test_text_to_speech_v1.rb +0 -4
  34. data/test/unit/test_visual_recognition_v3.rb +2 -6
  35. metadata +2 -2
@@ -4,15 +4,15 @@ require("json")
4
4
  require_relative("./../test_helper.rb")
5
5
  require("minitest/hooks/test")
6
6
 
7
- if !ENV["NATURAL_LANGUAGE_CLASSIFIER_USERNAME"].nil? && !ENV["NATURAL_LANGUAGE_CLASSIFIER_PASSWORD"].nil?
7
+ if !ENV["NATURAL_LANGUAGE_CLASSIFIER_APIKEY"].nil? && !ENV["NATURAL_LANGUAGE_CLASSIFIER_URL"].nil?
8
8
  # Integration tests for the Natural Language Classifier V1 Service
9
9
  class NaturalLanguageClassifierV1Test < Minitest::Test
10
10
  include Minitest::Hooks
11
11
  attr_accessor :service
12
12
  def before_all
13
13
  @service = IBMWatson::NaturalLanguageClassifierV1.new(
14
- username: ENV["NATURAL_LANGUAGE_CLASSIFIER_USERNAME"],
15
- password: ENV["NATURAL_LANGUAGE_CLASSIFIER_PASSWORD"]
14
+ iam_apikey: ENV["NATURAL_LANGUAGE_CLASSIFIER_APIKEY"],
15
+ url: ENV["NATURAL_LANGUAGE_CLASSIFIER_URL"]
16
16
  )
17
17
  @service.add_default_headers(
18
18
  headers: {
@@ -3,15 +3,26 @@
3
3
  require("json")
4
4
  require_relative("./../test_helper.rb")
5
5
 
6
- if !ENV["NATURAL_LANGUAGE_UNDERSTANDING_USERNAME"].nil? && !ENV["NATURAL_LANGUAGE_UNDERSTANDING_PASSWORD"].nil?
6
+ if !ENV["NATURAL_LANGUAGE_UNDERSTANDING_APIKEY"].nil? && !ENV["NATURAL_LANGUAGE_UNDERSTANDING_URL"].nil?
7
7
  # Integration tests for the Natural Language Understanding V1 Service
8
8
  class NaturalLanguageUnderstandingV1Test < Minitest::Test
9
- def test_text_analyze
10
- service = IBMWatson::NaturalLanguageUnderstandingV1.new(
9
+ include Minitest::Hooks
10
+ attr_accessor :service
11
+ def before_all
12
+ @service = IBMWatson::NaturalLanguageUnderstandingV1.new(
11
13
  version: "2018-03-16",
12
- username: ENV["NATURAL_LANGUAGE_UNDERSTANDING_USERNAME"],
13
- password: ENV["NATURAL_LANGUAGE_UNDERSTANDING_PASSWORD"]
14
+ iam_apikey: ENV["NATURAL_LANGUAGE_UNDERSTANDING_APIKEY"],
15
+ url: ENV["NATURAL_LANGUAGE_UNDERSTANDING_URL"]
16
+ )
17
+ @service.add_default_headers(
18
+ headers: {
19
+ "X-Watson-Learning-Opt-Out" => "1",
20
+ "X-Watson-Test" => "1"
21
+ }
14
22
  )
23
+ end
24
+
25
+ def test_text_analyze
15
26
  service.add_default_headers(
16
27
  headers: {
17
28
  "X-Watson-Learning-Opt-Out" => "1",
@@ -40,11 +51,6 @@ if !ENV["NATURAL_LANGUAGE_UNDERSTANDING_USERNAME"].nil? && !ENV["NATURAL_LANGUAG
40
51
  end
41
52
 
42
53
  def test_html_analyze
43
- service = IBMWatson::NaturalLanguageUnderstandingV1.new(
44
- version: "2018-03-16",
45
- username: ENV["NATURAL_LANGUAGE_UNDERSTANDING_USERNAME"],
46
- password: ENV["NATURAL_LANGUAGE_UNDERSTANDING_PASSWORD"]
47
- )
48
54
  service.add_default_headers(
49
55
  headers: {
50
56
  "X-Watson-Learning-Opt-Out" => "1",
@@ -61,11 +67,6 @@ if !ENV["NATURAL_LANGUAGE_UNDERSTANDING_USERNAME"].nil? && !ENV["NATURAL_LANGUAG
61
67
  end
62
68
 
63
69
  def test_url_analyze
64
- service = IBMWatson::NaturalLanguageUnderstandingV1.new(
65
- version: "2018-03-16",
66
- username: ENV["NATURAL_LANGUAGE_UNDERSTANDING_USERNAME"],
67
- password: ENV["NATURAL_LANGUAGE_UNDERSTANDING_PASSWORD"]
68
- )
69
70
  service.add_default_headers(
70
71
  headers: {
71
72
  "X-Watson-Learning-Opt-Out" => "1",
@@ -83,11 +84,6 @@ if !ENV["NATURAL_LANGUAGE_UNDERSTANDING_USERNAME"].nil? && !ENV["NATURAL_LANGUAG
83
84
 
84
85
  def test_list_models
85
86
  skip
86
- service = IBMWatson::NaturalLanguageUnderstandingV1.new(
87
- version: "2018-03-16",
88
- username: ENV["NATURAL_LANGUAGE_UNDERSTANDING_USERNAME"],
89
- password: ENV["NATURAL_LANGUAGE_UNDERSTANDING_PASSWORD"]
90
- )
91
87
  service.add_default_headers(
92
88
  headers: {
93
89
  "X-Watson-Learning-Opt-Out" => "1",
@@ -3,22 +3,27 @@
3
3
  require("json")
4
4
  require_relative("./../test_helper.rb")
5
5
 
6
- if !ENV["PERSONALITY_INSIGHTS_USERNAME"].nil? && !ENV["PERSONALITY_INSIGHTS_PASSWORD"].nil?
6
+ if !ENV["PERSONALITY_INSIGHTS_APIKEY"].nil? && !ENV["PERSONALITY_INSIGHTS_URL"].nil?
7
7
  # Integration tests for the Personality Insights V3 Service
8
8
  class PersonalityInsightsV3Test < Minitest::Test
9
- def test_plain_to_json
10
- personality_text = File.read(Dir.getwd + "/resources/personality-v3.txt")
11
- service = IBMWatson::PersonalityInsightsV3.new(
9
+ include Minitest::Hooks
10
+ attr_accessor :service
11
+ def before_all
12
+ @service = IBMWatson::PersonalityInsightsV3.new(
12
13
  version: "2017-10-13",
13
- username: ENV["PERSONALITY_INSIGHTS_USERNAME"],
14
- password: ENV["PERSONALITY_INSIGHTS_PASSWORD"]
14
+ iam_apikey: ENV["PERSONALITY_INSIGHTS_APIKEY"],
15
+ url: ENV["PERSONALITY_INSIGHTS_URL"]
15
16
  )
16
- service.add_default_headers(
17
+ @service.add_default_headers(
17
18
  headers: {
18
19
  "X-Watson-Learning-Opt-Out" => "1",
19
20
  "X-Watson-Test" => "1"
20
21
  }
21
22
  )
23
+ end
24
+
25
+ def test_plain_to_json
26
+ personality_text = File.read(Dir.getwd + "/resources/personality-v3.txt")
22
27
  service_response = service.profile(
23
28
  accept: "application/json",
24
29
  content: personality_text,
@@ -29,17 +34,6 @@ if !ENV["PERSONALITY_INSIGHTS_USERNAME"].nil? && !ENV["PERSONALITY_INSIGHTS_PASS
29
34
 
30
35
  def test_json_to_json
31
36
  personality_text = File.read(Dir.getwd + "/resources/personality-v3.json")
32
- service = IBMWatson::PersonalityInsightsV3.new(
33
- version: "2017-10-13",
34
- username: ENV["PERSONALITY_INSIGHTS_USERNAME"],
35
- password: ENV["PERSONALITY_INSIGHTS_PASSWORD"]
36
- )
37
- service.add_default_headers(
38
- headers: {
39
- "X-Watson-Learning-Opt-Out" => "1",
40
- "X-Watson-Test" => "1"
41
- }
42
- )
43
37
  service_response = service.profile(
44
38
  accept: "application/json",
45
39
  content: personality_text,
@@ -52,17 +46,6 @@ if !ENV["PERSONALITY_INSIGHTS_USERNAME"].nil? && !ENV["PERSONALITY_INSIGHTS_PASS
52
46
 
53
47
  def test_json_to_csv
54
48
  personality_text = File.read(Dir.getwd + "/resources/personality-v3.json")
55
- service = IBMWatson::PersonalityInsightsV3.new(
56
- version: "2017-10-13",
57
- username: ENV["PERSONALITY_INSIGHTS_USERNAME"],
58
- password: ENV["PERSONALITY_INSIGHTS_PASSWORD"]
59
- )
60
- service.add_default_headers(
61
- headers: {
62
- "X-Watson-Learning-Opt-Out" => "1",
63
- "X-Watson-Test" => "1"
64
- }
65
- )
66
49
  service_response = service.profile(
67
50
  content: personality_text,
68
51
  content_type: "application/json",
@@ -76,17 +59,6 @@ if !ENV["PERSONALITY_INSIGHTS_USERNAME"].nil? && !ENV["PERSONALITY_INSIGHTS_PASS
76
59
 
77
60
  def test_plain_to_json_es
78
61
  personality_text = File.read(Dir.getwd + "/resources/personality-v3-es.txt")
79
- service = IBMWatson::PersonalityInsightsV3.new(
80
- version: "2017-10-13",
81
- username: ENV["PERSONALITY_INSIGHTS_USERNAME"],
82
- password: ENV["PERSONALITY_INSIGHTS_PASSWORD"]
83
- )
84
- service.add_default_headers(
85
- headers: {
86
- "X-Watson-Learning-Opt-Out" => "1",
87
- "X-Watson-Test" => "1"
88
- }
89
- )
90
62
  service_response = service.profile(
91
63
  accept: "application/json",
92
64
  content: personality_text,
@@ -22,15 +22,15 @@ class MyRecognizeCallback < IBMWatson::RecognizeCallback
22
22
  end
23
23
  end
24
24
 
25
- if !ENV["SPEECH_TO_TEXT_USERNAME"].nil? && !ENV["SPEECH_TO_TEXT_PASSWORD"].nil?
25
+ if !ENV["SPEECH_TO_TEXT_APIKEY"].nil? && !ENV["SPEECH_TO_TEXT_URL"].nil?
26
26
  # Integration tests for the Speech to Text V1 Service
27
27
  class SpeechToTextV1Test < Minitest::Test
28
28
  include Minitest::Hooks
29
29
  attr_accessor :service
30
30
  def before_all
31
31
  @service = IBMWatson::SpeechToTextV1.new(
32
- username: ENV["SPEECH_TO_TEXT_USERNAME"],
33
- password: ENV["SPEECH_TO_TEXT_PASSWORD"]
32
+ iam_apikey: ENV["SPEECH_TO_TEXT_APIKEY"],
33
+ url: ENV["SPEECH_TO_TEXT_URL"]
34
34
  )
35
35
  @service.add_default_headers(
36
36
  headers: {
@@ -3,15 +3,15 @@
3
3
  require_relative("./../test_helper.rb")
4
4
  require("minitest/hooks/test")
5
5
 
6
- if !ENV["TEXT_TO_SPEECH_USERNAME"].nil? && !ENV["TEXT_TO_SPEECH_PASSWORD"].nil?
6
+ if !ENV["TEXT_TO_SPEECH_APIKEY"].nil? && !ENV["TEXT_TO_SPEECH_URL"].nil?
7
7
  # Integration tests for the Text to Speech V1 Service
8
8
  class TextToSpeechV1Test < Minitest::Test
9
9
  include Minitest::Hooks
10
10
  attr_accessor :service
11
11
  def before_all
12
12
  @service = IBMWatson::TextToSpeechV1.new(
13
- username: ENV["TEXT_TO_SPEECH_USERNAME"],
14
- password: ENV["TEXT_TO_SPEECH_PASSWORD"]
13
+ iam_apikey: ENV["TEXT_TO_SPEECH_APIKEY"],
14
+ url: ENV["TEXT_TO_SPEECH_URL"]
15
15
  )
16
16
  @service.add_default_headers(
17
17
  headers: {
@@ -3,22 +3,27 @@
3
3
  require("json")
4
4
  require_relative("./../test_helper.rb")
5
5
 
6
- if !ENV["TONE_ANALYZER_USERNAME"].nil? && !ENV["TONE_ANALYZER_PASSWORD"].nil?
6
+ if !ENV["TONE_ANALYZER_APIKEY"].nil? && !ENV["TONE_ANALYZER_URL"].nil?
7
7
  # Integration tests for the Tone Analyzer V3 Service
8
8
  class ToneAnalyzerV3Test < Minitest::Test
9
- def test_tone
10
- tone_text = File.read(Dir.getwd + "/resources/personality.txt")
11
- service = IBMWatson::ToneAnalyzerV3.new(
12
- version: "2017-09-21",
13
- username: ENV["TONE_ANALYZER_USERNAME"],
14
- password: ENV["TONE_ANALYZER_PASSWORD"]
15
- )
16
- service.add_default_headers(
9
+ include Minitest::Hooks
10
+ attr_accessor :service
11
+ def before_all
12
+ @service = IBMWatson::ToneAnalyzerV3.new(
13
+ iam_apikey: ENV["TONE_ANALYZER_APIKEY"],
14
+ url: ENV["TONE_ANALYZER_URL"],
15
+ version: "2017-09-21"
16
+ )
17
+ @service.add_default_headers(
17
18
  headers: {
18
19
  "X-Watson-Learning-Opt-Out" => "1",
19
20
  "X-Watson-Test" => "1"
20
21
  }
21
22
  )
23
+ end
24
+
25
+ def test_tone
26
+ tone_text = File.read(Dir.getwd + "/resources/personality.txt")
22
27
  service_response = service.tone(
23
28
  tone_input: tone_text,
24
29
  content_type: "text/plain"
@@ -28,17 +33,6 @@ if !ENV["TONE_ANALYZER_USERNAME"].nil? && !ENV["TONE_ANALYZER_PASSWORD"].nil?
28
33
 
29
34
  def test_tone_with_args
30
35
  tone_text = File.read(Dir.getwd + "/resources/personality.txt")
31
- service = IBMWatson::ToneAnalyzerV3.new(
32
- version: "2017-09-21",
33
- username: ENV["TONE_ANALYZER_USERNAME"],
34
- password: ENV["TONE_ANALYZER_PASSWORD"]
35
- )
36
- service.add_default_headers(
37
- headers: {
38
- "X-Watson-Learning-Opt-Out" => "1",
39
- "X-Watson-Test" => "1"
40
- }
41
- )
42
36
  service_response = service.tone(
43
37
  tone_input: tone_text,
44
38
  content_type: "text/plain",
@@ -48,17 +42,6 @@ if !ENV["TONE_ANALYZER_USERNAME"].nil? && !ENV["TONE_ANALYZER_PASSWORD"].nil?
48
42
  end
49
43
 
50
44
  def test_tone_chat
51
- service = IBMWatson::ToneAnalyzerV3.new(
52
- version: "2017-09-21",
53
- username: ENV["TONE_ANALYZER_USERNAME"],
54
- password: ENV["TONE_ANALYZER_PASSWORD"]
55
- )
56
- service.add_default_headers(
57
- headers: {
58
- "X-Watson-Learning-Opt-Out" => "1",
59
- "X-Watson-Test" => "1"
60
- }
61
- )
62
45
  utterances = [
63
46
  {
64
47
  "text" => "I am very happy",
@@ -4,16 +4,16 @@ require("json")
4
4
  require_relative("./../test_helper.rb")
5
5
  require("minitest/hooks/test")
6
6
 
7
- if !ENV["VISUAL_RECOGNITION_IAM_APIKEY"].nil? && !ENV["VISUAL_RECOGNITION_IAM_URL"].nil?
7
+ if !ENV["VISUAL_RECOGNITION_APIKEY"].nil? && !ENV["VISUAL_RECOGNITION_URL"].nil?
8
8
  # Integration tests for the Visual Recognition V3 Service
9
9
  class VisualRecognitionV3Test < Minitest::Test
10
10
  include Minitest::Hooks
11
11
  attr_accessor :service, :classifier_id
12
12
  def before_all
13
13
  @service = IBMWatson::VisualRecognitionV3.new(
14
- iam_apikey: ENV["VISUAL_RECOGNITION_IAM_APIKEY"],
14
+ iam_apikey: ENV["VISUAL_RECOGNITION_APIKEY"],
15
15
  version: "2018-03-19",
16
- url: ENV["VISUAL_RECOGNITION_IAM_URL"]
16
+ url: ENV["VISUAL_RECOGNITION_URL"]
17
17
  )
18
18
  @classifier_id = "doxnotxdeletexsdksxintegration_718351350"
19
19
  @service.add_default_headers(
@@ -46,8 +46,7 @@ class CompareComplyV1 < Minitest::Test
46
46
  file: file
47
47
  )
48
48
  service.classify_elements(
49
- file: "dummy",
50
- filename: "file"
49
+ file: "dummy"
51
50
  )
52
51
  end
53
52
 
@@ -67,8 +66,7 @@ class CompareComplyV1 < Minitest::Test
67
66
  file: file
68
67
  )
69
68
  service.extract_tables(
70
- file: "dummy",
71
- filename: "file"
69
+ file: "dummy"
72
70
  )
73
71
  end
74
72
 
@@ -90,9 +88,7 @@ class CompareComplyV1 < Minitest::Test
90
88
  )
91
89
  service.compare_documents(
92
90
  file_1: "dummy data",
93
- file_1_filename: "file1",
94
- file_2: "dummy data",
95
- file_2_filename: "file1"
91
+ file_2: "dummy data"
96
92
  )
97
93
  end
98
94
 
@@ -571,7 +571,6 @@ class DiscoveryV1Test < Minitest::Test
571
571
  stub_request(:delete, "https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/collid/training_data?version=2018-03-05")
572
572
  .with(
573
573
  headers: {
574
- "Accept" => "application/json",
575
574
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
576
575
  "Host" => "gateway.watsonplatform.net"
577
576
  }
@@ -682,7 +681,6 @@ class DiscoveryV1Test < Minitest::Test
682
681
  stub_request(:delete, "https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/collid/training_data/queryid?version=2018-03-05")
683
682
  .with(
684
683
  headers: {
685
- "Accept" => "application/json",
686
684
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
687
685
  "Host" => "gateway.watsonplatform.net"
688
686
  }
@@ -773,7 +771,6 @@ class DiscoveryV1Test < Minitest::Test
773
771
  stub_request(:delete, "https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/collid/training_data/queryid/examples/exampleid?version=2018-03-05")
774
772
  .with(
775
773
  headers: {
776
- "Accept" => "application/json",
777
774
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
778
775
  "Host" => "gateway.watsonplatform.net"
779
776
  }
@@ -894,7 +891,6 @@ class DiscoveryV1Test < Minitest::Test
894
891
  stub_request(:delete, "https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/collid/expansions?version=2018-03-05")
895
892
  .with(
896
893
  headers: {
897
- "Accept" => "application/json",
898
894
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
899
895
  "Host" => "gateway.watsonplatform.net"
900
896
  }
@@ -951,7 +947,6 @@ class DiscoveryV1Test < Minitest::Test
951
947
  stub_request(:delete, "https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/collid/word_lists/tokenization_dictionary?version=2018-03-05")
952
948
  .with(
953
949
  headers: {
954
- "Accept" => "application/json",
955
950
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
956
951
  "Host" => "gateway.watsonplatform.net"
957
952
  }
@@ -972,7 +967,6 @@ class DiscoveryV1Test < Minitest::Test
972
967
  stub_request(:delete, "https://gateway.watsonplatform.net/discovery/api/v1/user_data?customer_id=id&version=2018-03-05")
973
968
  .with(
974
969
  headers: {
975
- "Accept" => "application/json",
976
970
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
977
971
  "Host" => "gateway.watsonplatform.net"
978
972
  }
@@ -1390,6 +1384,27 @@ class DiscoveryV1Test < Minitest::Test
1390
1384
  assert_equal({ "received" => "true" }, service_response.result)
1391
1385
  end
1392
1386
 
1387
+ def test_list_fields
1388
+ service = IBMWatson::DiscoveryV1.new(
1389
+ username: "username",
1390
+ password: "password",
1391
+ version: "2018-03-05"
1392
+ )
1393
+ stub_request(:get, "https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/fields?collection_ids=collid&version=2018-03-05")
1394
+ .with(
1395
+ headers: {
1396
+ "Accept" => "application/json",
1397
+ "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1398
+ "Host" => "gateway.watsonplatform.net"
1399
+ }
1400
+ ).to_return(status: 200, body: { "received" => "true" }.to_json, headers: { "Content-Type" => "application/json" })
1401
+ service_response = service.list_fields(
1402
+ environment_id: "envid",
1403
+ collection_ids: ["collid"]
1404
+ )
1405
+ assert_equal({ "received" => "true" }, service_response.result)
1406
+ end
1407
+
1393
1408
  def test_create_stopword_list
1394
1409
  service = IBMWatson::DiscoveryV1.new(
1395
1410
  username: "username",
@@ -1418,7 +1433,6 @@ class DiscoveryV1Test < Minitest::Test
1418
1433
  stub_request(:delete, "https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/colid/word_lists/stopwords?version=2018-03-05")
1419
1434
  .with(
1420
1435
  headers: {
1421
- "Accept" => "application/json",
1422
1436
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1423
1437
  "Host" => "gateway.watsonplatform.net"
1424
1438
  }
@@ -286,8 +286,7 @@ class LanguageTranslatorV3Test < Minitest::Test
286
286
  base_model_id: "en-fr",
287
287
  name: "test_glossary",
288
288
  forced_glossary: custom_model.read,
289
- parallel_corpus: "parallel corpus",
290
- parallel_corpus_filename: "parallel_corpus_filename"
289
+ parallel_corpus: "parallel corpus"
291
290
  )
292
291
  assert_equal(expected, service_response.result)
293
292
 
@@ -295,7 +294,6 @@ class LanguageTranslatorV3Test < Minitest::Test
295
294
  base_model_id: "en-fr",
296
295
  name: "test_glossary",
297
296
  forced_glossary: custom_model,
298
- forced_glossary_filename: "language_translator_model.tmx",
299
297
  parallel_corpus: "parallel corpus"
300
298
  )
301
299
  assert_equal(expected, service_response.result)
@@ -101,9 +101,7 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
101
101
  training_data = File.open(Dir.getwd + "/resources/weather_data_train.csv")
102
102
  service_response = service.create_classifier(
103
103
  training_data: training_data,
104
- training_data_filename: "weather_data_train.csv",
105
- metadata: { "language" => "en" },
106
- metadata_filename: "metadata"
104
+ metadata: { "language" => "en" }
107
105
  )
108
106
  assert_equal(create_response, service_response.result)
109
107
 
@@ -3,9 +3,25 @@
3
3
  require("json")
4
4
  require_relative("./../test_helper.rb")
5
5
  require("webmock/minitest")
6
+ require_relative("./../../lib/ibm_watson/websocket/recognize_callback.rb")
6
7
 
7
8
  WebMock.disable_net_connect!(allow_localhost: true)
8
9
 
10
+ class MyRecognizeCallback < IBMWatson::RecognizeCallback
11
+ def initialize(atomic_boolean: nil)
12
+ super
13
+ @atomic_boolean = atomic_boolean
14
+ end
15
+
16
+ def on_error(*)
17
+ @atomic_boolean.make_true
18
+ end
19
+
20
+ def on_inactivity_timeout(*)
21
+ @atomic_boolean.make_true
22
+ end
23
+ end
24
+
9
25
  # Unit tests for the Speech to Text V1 Service
10
26
  class SpeechToTextV1Test < Minitest::Test
11
27
  def test_success
@@ -63,6 +79,14 @@ class SpeechToTextV1Test < Minitest::Test
63
79
  content_type: "audio/l16; rate=44100"
64
80
  )
65
81
  assert_equal(recognize_response, service_response.result)
82
+
83
+ mycallback = MyRecognizeCallback.new
84
+ service_response = service.recognize_using_websocket(
85
+ audio: audio_file,
86
+ recognize_callback: mycallback,
87
+ content_type: "audio/l16; rate=44100"
88
+ )
89
+ refute_nil(service_response)
66
90
  end
67
91
 
68
92
  def test_get_model
@@ -142,7 +166,6 @@ class SpeechToTextV1Test < Minitest::Test
142
166
  stub_request(:delete, "https://stream.watsonplatform.net/speech-to-text/api/v1/recognitions/jobid")
143
167
  .with(
144
168
  headers: {
145
- "Accept" => "application/json",
146
169
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
147
170
  "Host" => "stream.watsonplatform.net"
148
171
  }
@@ -161,7 +184,6 @@ class SpeechToTextV1Test < Minitest::Test
161
184
  stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/register_callback?callback_url=monitorcalls.com")
162
185
  .with(
163
186
  headers: {
164
- "Accept" => "application/json",
165
187
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
166
188
  "Host" => "stream.watsonplatform.net"
167
189
  }
@@ -174,7 +196,6 @@ class SpeechToTextV1Test < Minitest::Test
174
196
  stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/unregister_callback?callback_url=monitorcalls.com")
175
197
  .with(
176
198
  headers: {
177
- "Accept" => "application/json",
178
199
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
179
200
  "Host" => "stream.watsonplatform.net"
180
201
  }
@@ -351,7 +372,6 @@ class SpeechToTextV1Test < Minitest::Test
351
372
  stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/customid/corpora/corpus")
352
373
  .with(
353
374
  headers: {
354
- "Accept" => "application/json",
355
375
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
356
376
  "Host" => "stream.watsonplatform.net"
357
377
  }
@@ -360,8 +380,7 @@ class SpeechToTextV1Test < Minitest::Test
360
380
  service_response = service.add_corpus(
361
381
  customization_id: "customid",
362
382
  corpus_name: "corpus",
363
- corpus_file: corpus_file,
364
- corpus_filename: "corpus-short-1.txt"
383
+ corpus_file: corpus_file
365
384
  )
366
385
  assert_nil(service_response)
367
386
 
@@ -699,7 +718,6 @@ class SpeechToTextV1Test < Minitest::Test
699
718
  stub_request(:delete, "https://stream.watsonplatform.net/speech-to-text/api/v1/user_data?customer_id=id")
700
719
  .with(
701
720
  headers: {
702
- "Accept" => "application/json",
703
721
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
704
722
  "Host" => "stream.watsonplatform.net"
705
723
  }
@@ -220,7 +220,6 @@ class TextToSpeechV1Test < Minitest::Test
220
220
  stub_request(:delete, "https://stream.watsonplatform.net/text-to-speech/api/v1/customizations/custid")
221
221
  .with(
222
222
  headers: {
223
- "Accept" => "application/json",
224
223
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
225
224
  "Host" => "stream.watsonplatform.net"
226
225
  }
@@ -287,7 +286,6 @@ class TextToSpeechV1Test < Minitest::Test
287
286
  .with(
288
287
  body: "{\"translation\":\"I'm translated\"}",
289
288
  headers: {
290
- "Accept" => "application/json",
291
289
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
292
290
  "Content-Type" => "application/json",
293
291
  "Host" => "stream.watsonplatform.net"
@@ -303,7 +301,6 @@ class TextToSpeechV1Test < Minitest::Test
303
301
  stub_request(:delete, "https://stream.watsonplatform.net/text-to-speech/api/v1/customizations/custid/words/word")
304
302
  .with(
305
303
  headers: {
306
- "Accept" => "application/json",
307
304
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
308
305
  "Host" => "stream.watsonplatform.net"
309
306
  }
@@ -323,7 +320,6 @@ class TextToSpeechV1Test < Minitest::Test
323
320
  stub_request(:delete, "https://stream.watsonplatform.net/text-to-speech/api/v1/user_data?customer_id=id")
324
321
  .with(
325
322
  headers: {
326
- "Accept" => "application/json",
327
323
  "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
328
324
  "Host" => "stream.watsonplatform.net"
329
325
  }
@@ -124,9 +124,7 @@ class VisualRecognitionV3Test < Minitest::Test
124
124
  service_response = service.create_classifier(
125
125
  name: "Cars vs Trucks",
126
126
  positive_examples: { cars: "cars" },
127
- positive_examples_filename: { cars: "cars" },
128
- negative_examples: "trucks",
129
- negative_examples_filename: "trucks"
127
+ negative_examples: "trucks"
130
128
  )
131
129
  assert_equal(response, service_response.result)
132
130
  end
@@ -166,9 +164,7 @@ class VisualRecognitionV3Test < Minitest::Test
166
164
  service_response = service.update_classifier(
167
165
  classifier_id: "bogusid",
168
166
  positive_examples: { example: "positive examples classname" },
169
- positive_examples_filename: { example: "positive_filename" },
170
- negative_examples: "negative examples",
171
- negative_examples_filename: "negative_filename"
167
+ negative_examples: "negative examples"
172
168
  )
173
169
  assert_equal(response, service_response.result)
174
170
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm_watson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Nussbaum
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-28 00:00:00.000000000 Z
11
+ date: 2019-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby