Skip to content

Commit 4ee04f3

Browse files
committed
feat(examples): Update examples with new packages
1 parent 28c9f2d commit 4ee04f3

11 files changed

Lines changed: 93 additions & 96 deletions

examples/assistant_v1.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
from ibm_watson import AssistantV1
44

55
# If service instance provides API key authentication
6-
# assistant = AssistantV1(
7-
# version='2018-07-10',
8-
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
9-
# url='https://gateway.watsonplatform.net/assistant/api',
10-
# iam_apikey='iam_apikey')
11-
126
assistant = AssistantV1(
13-
username='YOUR SERVICE USERNAME',
14-
password='YOUR SERVICE PASSWORD',
7+
version='2018-07-10',
158
## url is optional, and defaults to the URL below. Use the correct URL for your region.
16-
# url='https://gateway.watsonplatform.net/assistant/api',
17-
version='2018-07-10')
9+
url='https://gateway.watsonplatform.net/assistant/api',
10+
iam_apikey='YOUR APIKEY')
11+
12+
# assistant = AssistantV1(
13+
# username='YOUR SERVICE USERNAME',
14+
# password='YOUR SERVICE PASSWORD',
15+
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
16+
# # url='https://gateway.watsonplatform.net/assistant/api',
17+
# version='2018-07-10')
1818

1919
#########################
2020
# Workspaces

examples/assistant_v2.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
from ibm_watson import AssistantV2
44

55
# If service instance provides API key authentication
6-
# assistant = AssistantV2(
7-
# version='2018-09-20',
8-
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
9-
# url='https://gateway.watsonplatform.net/assistant/api',
10-
# iam_apikey='iam_apikey')
11-
126
assistant = AssistantV2(
13-
username='YOUR SERVICE USERNAME',
14-
password='YOUR SERVICE PASSWORD',
7+
version='2018-09-20',
158
## url is optional, and defaults to the URL below. Use the correct URL for your region.
169
url='https://gateway.watsonplatform.net/assistant/api',
17-
version='2018-09-20')
10+
iam_apikey='YOUR APIKEY')
11+
12+
# assistant = AssistantV2(
13+
# username='YOUR SERVICE USERNAME',
14+
# password='YOUR SERVICE PASSWORD',
15+
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
16+
# url='https://gateway.watsonplatform.net/assistant/api',
17+
# version='2018-09-20')
1818

1919
#########################
2020
# Sessions

examples/discovery_v1.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
from ibm_watson import DiscoveryV1
55

66
# If service instance provides API key authentication
7-
# discovery = DiscoveryV1(
8-
# version='2018-08-01',
9-
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
10-
# url='https://gateway.watsonplatform.net/discovery/api',
11-
# iam_apikey='iam_apikey')
12-
137
discovery = DiscoveryV1(
148
version='2018-08-01',
159
## url is optional, and defaults to the URL below. Use the correct URL for your region.
16-
# url='https://gateway.watsonplatform.net/discovery/api',
17-
username='YOUR SERVICE USERNAME',
18-
password='YOUR SERVICE PASSWORD')
10+
url='https://gateway.watsonplatform.net/discovery/api',
11+
iam_apikey='YOUR APIKEY')
12+
13+
# discovery = DiscoveryV1(
14+
# version='2018-08-01',
15+
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
16+
# # url='https://gateway.watsonplatform.net/discovery/api',
17+
# username='YOUR SERVICE USERNAME',
18+
# password='YOUR SERVICE PASSWORD')
1919

2020
environments = discovery.list_environments().get_result()
2121
print(json.dumps(environments, indent=2))
@@ -60,9 +60,6 @@
6060
# collections = discovery.list_collections(environment_id=writable_environment_id).get_result()
6161
# print(collections)
6262

63-
# # with open(os.path.join(os.getcwd(),'..', 'resources','simple.html')) as fileinfo:
64-
# # print(discovery.test_document(environment_id=writable_environment_id, fileinfo=fileinfo).get_result())
65-
6663
# with open(os.path.join(os.getcwd(), '..','resources', 'simple.html')) as fileinfo:
6764
# res = discovery.add_document(environment_id=writable_environment_id,
6865
# collection_id=collections['collections'][0]['collection_id'],

examples/language_translator_v3.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
import json
44
from ibm_watson import LanguageTranslatorV3
55

6-
# language_translator = LanguageTranslatorV3(
7-
# version='2018-05-01.',
8-
# ### url is optional, and defaults to the URL below. Use the correct URL for your region.
9-
# # url='https://gateway.watsonplatform.net/language-translator/api',
10-
# iam_apikey='your_apikey')
6+
language_translator = LanguageTranslatorV3(
7+
version='2018-05-01.',
8+
### url is optional, and defaults to the URL below. Use the correct URL for your region.
9+
# url='https://gateway.watsonplatform.net/language-translator/api',
10+
iam_apikey='YOUR APIKEY')
1111

1212
# Authenticate with username/password if your service instance doesn't provide an API key
13-
language_translator = LanguageTranslatorV3(
14-
version='2018-05-01',
15-
username='YOUR SERVICE USERNAME',
16-
password='YOUR SERVICE PASSWORD')
13+
# language_translator = LanguageTranslatorV3(
14+
# version='2018-05-01',
15+
# username='YOUR SERVICE USERNAME',
16+
# password='YOUR SERVICE PASSWORD')
1717

1818
## Translate
1919
translation = language_translator.translate(

examples/natural_language_classifier_v1.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
# from os.path import join, dirname
66
from ibm_watson import NaturalLanguageClassifierV1
77

8-
# # If service instance provides API key authentication
9-
# service = NaturalLanguageClassifierV1(
10-
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
11-
# url='https://gateway.watsonplatform.net/natural-language-classifier/api',
12-
# iam_apikey='your_apikey')
13-
8+
# If service instance provides API key authentication
149
service = NaturalLanguageClassifierV1(
1510
## url is optional, and defaults to the URL below. Use the correct URL for your region.
16-
# url='https://gateway.watsonplatform.net/natural-language-classifier/api',
17-
username='YOUR SERVICE USERNAME',
18-
password='YOUR SERVICE PASSWORD')
11+
url='https://gateway.watsonplatform.net/natural-language-classifier/api',
12+
iam_apikey='YOUR APIKEY')
13+
14+
# service = NaturalLanguageClassifierV1(
15+
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
16+
# # url='https://gateway.watsonplatform.net/natural-language-classifier/api',
17+
# username='YOUR SERVICE USERNAME',
18+
# password='YOUR SERVICE PASSWORD')
1919

2020
classifiers = service.list_classifiers().get_result()
2121
print(json.dumps(classifiers, indent=2))

examples/natural_language_understanding_v1.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
from ibm_watson.natural_language_understanding_v1 import Features, EntitiesOptions, KeywordsOptions
55

66
# If service instance provides API key authentication
7-
# service = NaturalLanguageUnderstandingV1(
8-
# version='2018-03-16',
9-
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
10-
# url='https://gateway.watsonplatform.net/natural-language-understanding/api',
11-
# iam_apikey='your_apikey')
12-
137
service = NaturalLanguageUnderstandingV1(
148
version='2018-03-16',
159
## url is optional, and defaults to the URL below. Use the correct URL for your region.
16-
# url='https://gateway.watsonplatform.net/natural-language-understanding/api',
17-
username='YOUR SERVICE USERNAME',
18-
password='YOUR SERVICE PASSWORD')
10+
url='https://gateway.watsonplatform.net/natural-language-understanding/api',
11+
iam_apikey='YOUR APIKEY')
12+
13+
# service = NaturalLanguageUnderstandingV1(
14+
# version='2018-03-16',
15+
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
16+
# # url='https://gateway.watsonplatform.net/natural-language-understanding/api',
17+
# username='YOUR SERVICE USERNAME',
18+
# password='YOUR SERVICE PASSWORD')
1919

2020
response = service.analyze(
2121
text='Bruce Banner is the Hulk and Bruce Wayne is BATMAN! '

examples/personality_insights_v3.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
from ibm_watson import PersonalityInsightsV3
99
import csv
1010

11-
# # If service instance provides API key authentication
12-
# service = PersonalityInsightsV3(
13-
# version='2017-10-13',
14-
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
15-
# url='https://gateway.watsonplatform.net/personality-insights/api',
16-
# iam_apikey='your_apikey')
17-
11+
# If service instance provides API key authentication
1812
service = PersonalityInsightsV3(
1913
version='2017-10-13',
2014
## url is optional, and defaults to the URL below. Use the correct URL for your region.
21-
# url='https://gateway.watsonplatform.net/personality-insights/api',
22-
username='YOUR SERVICE USERNAME',
23-
password='YOUR SERVICE PASSWORD')
15+
url='https://gateway.watsonplatform.net/personality-insights/api',
16+
iam_apikey='YOUR APIKEY')
17+
18+
# service = PersonalityInsightsV3(
19+
# version='2017-10-13',
20+
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
21+
# # url='https://gateway.watsonplatform.net/personality-insights/api',
22+
# username='YOUR SERVICE USERNAME',
23+
# password='YOUR SERVICE PASSWORD')
2424

2525
############################
2626
# Profile with JSON output #

examples/speech_to_text_v1.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
import threading
77

88
# If service instance provides API key authentication
9-
# service = SpeechToTextV1(
10-
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
11-
# url='https://stream.watsonplatform.net/speech-to-text/api',
12-
# iam_apikey='your_apikey')
13-
149
service = SpeechToTextV1(
15-
username='YOUR SERVICE USERNAME',
16-
password='YOUR SERVICE PASSWORD',
17-
url='https://stream.watsonplatform.net/speech-to-text/api')
10+
## url is optional, and defaults to the URL below. Use the correct URL for your region.
11+
url='https://stream.watsonplatform.net/speech-to-text/api',
12+
iam_apikey='YOUR APIKEY')
13+
14+
# service = SpeechToTextV1(
15+
# username='YOUR SERVICE USERNAME',
16+
# password='YOUR SERVICE PASSWORD',
17+
# url='https://stream.watsonplatform.net/speech-to-text/api')
1818

1919
models = service.list_models().get_result()
2020
print(json.dumps(models, indent=2))

examples/text_to_speech_v1.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
from ibm_watson.websocket import SynthesizeCallback
77

88
# If service instance provides API key authentication
9-
# service = TextToSpeechV1(
10-
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
11-
# url='https://stream.watsonplatform.net/text-to-speech/api',
12-
# iam_apikey='your_apikey')
13-
149
service = TextToSpeechV1(
1510
## url is optional, and defaults to the URL below. Use the correct URL for your region.
16-
# url='https://stream.watsonplatform.net/text-to-speech/api,
17-
username='YOUR SERVICE USERNAME',
18-
password='YOUR SERVICE PASSWORD')
11+
url='https://stream.watsonplatform.net/text-to-speech/api',
12+
iam_apikey='YOUR APIKEY')
13+
14+
# service = TextToSpeechV1(
15+
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
16+
# # url='https://stream.watsonplatform.net/text-to-speech/api,
17+
# username='YOUR SERVICE USERNAME',
18+
# password='YOUR SERVICE PASSWORD')
1919

2020
voices = service.list_voices().get_result()
2121
print(json.dumps(voices, indent=2))

examples/tone_analyzer_v3.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
from ibm_watson.tone_analyzer_v3 import ToneInput
66

77
# If service instance provides API key authentication
8-
# service = ToneAnalyzerV3(
9-
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
10-
# url='https://gateway.watsonplatform.net/tone-analyzer/api',
11-
# version='2017-09-21',
12-
# iam_apikey='your_apikey')
13-
148
service = ToneAnalyzerV3(
159
## url is optional, and defaults to the URL below. Use the correct URL for your region.
16-
# url='https://gateway.watsonplatform.net/tone-analyzer/api',
17-
username='YOUR SERVICE USERNAME',
18-
password='YOUR SERVICE PASSWORD',
19-
version='2017-09-21')
10+
url='https://gateway.watsonplatform.net/tone-analyzer/api',
11+
version='2017-09-21',
12+
iam_apikey='YOU APIKEY')
13+
14+
# service = ToneAnalyzerV3(
15+
# ## url is optional, and defaults to the URL below. Use the correct URL for your region.
16+
# # url='https://gateway.watsonplatform.net/tone-analyzer/api',
17+
# username='YOUR SERVICE USERNAME',
18+
# password='YOUR SERVICE PASSWORD',
19+
# version='2017-09-21')
2020

2121
print("\ntone_chat() example 1:\n")
2222
utterances = [{

0 commit comments

Comments
 (0)