Skip to content

Commit cf3f332

Browse files
Merge branch 'master' into patch-1
2 parents 6e8e100 + f09b1ea commit cf3f332

30 files changed

+8734
-840
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.0.4
2+
current_version = 4.1.0
33
commit = True
44

55
[bumpversion:file:ibm_watson/version.py]

.github/CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ehdsouza27@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

.github/issue_template.md

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

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# [4.1.0](https://github.com/watson-developer-cloud/python-sdk/compare/v4.0.4...v4.1.0) (2019-11-27)
2+
3+
4+
### Features
5+
6+
* **assistantv1:** New param `new_disambiguation_opt_out ` in `create_dialog_node` ([5a5b840](https://github.com/watson-developer-cloud/python-sdk/commit/5a5b84076ff4b0d87355ed71cf7a2cbb9612c866))
7+
* **assistantv1:** New param `new_disambiguation_opt_out ` in `update_dialog_node() ` ([6e52e07](https://github.com/watson-developer-cloud/python-sdk/commit/6e52e07b3e3ab0a9bc2687406b8a98c5e5826e33))
8+
* **assistantv1:** New param `webhooks` in `create_workspace()` and `update_workspace()` ([0134b69](https://github.com/watson-developer-cloud/python-sdk/commit/0134b6981c09fc7132297aeb161eb75029bbd54d))
9+
* **assistantv1:** New properties `randomize` and `max_ssuggestions` in `WorkspaceSystemSettingsDisambiguation` ([27a8cd7](https://github.com/watson-developer-cloud/python-sdk/commit/27a8cd7173a48fb6aaf909598fc3eb34e1320fe4))
10+
* **assistantv1:** New property `off_topic` in `WorkspaceSystemSettings` ([5f93c55](https://github.com/watson-developer-cloud/python-sdk/commit/5f93c552828b539b846c9a44df4f69ed888d27b4))
11+
* **discoveryv1:** `title` property not part of `QueryNoticesResult` and `QueryResult` ([2ce0ad3](https://github.com/watson-developer-cloud/python-sdk/commit/2ce0ad33c91714eb6d9b2adb7ac44ff70ad378e9))
12+
* **discoveryv2:** Add examples for discoveryv2 ([2b54527](https://github.com/watson-developer-cloud/python-sdk/commit/2b54527725438d229e4acd80dc31d0869bdaa464))
13+
* **discoveryv2:** New discovery v2 available on CP4D ([73df7e4](https://github.com/watson-developer-cloud/python-sdk/commit/73df7e4a53ef83ad1271b71215ab357f7a538177))
14+
* **VisualRecognitionv4:** New method `get_training_usage` ([a5bec46](https://github.com/watson-developer-cloud/python-sdk/commit/a5bec467005db9340f6983654c293c94587258d9))
15+
116
## [4.0.4](https://github.com/watson-developer-cloud/python-sdk/compare/v4.0.3...v4.0.4) (2019-11-22)
217

318

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Python client library to quickly get started with the various [Watson APIs][wdc]
1313
* [Before you begin](#before-you-begin)
1414
* [Installation](#installation)
1515
* [Examples](#examples)
16+
* [Discovery v2 only on CP4D](#discovery-v2-only-on-cp4d)
1617
* [Running in IBM Cloud](#running-in-ibm-cloud)
1718
* [Authentication](#authentication)
1819
* [Getting credentials](#getting-credentials)
@@ -83,6 +84,9 @@ For more details see [#405](https://github.com/watson-developer-cloud/python-sdk
8384

8485
The [examples][examples] folder has basic and advanced examples. The examples within each service assume that you already have [service credentials](#getting-credentials).
8586

87+
## Discovery v2 only on CP4D
88+
Discovery v2 is only available on Cloud Pak for Data.
89+
8690
## Running in IBM Cloud
8791

8892
If you run your app in IBM Cloud, the SDK gets credentials from the [`VCAP_SERVICES`][vcap_services] environment variable.

examples/discovery_v2.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import json
2+
import os
3+
from ibm_watson import DiscoveryV2
4+
from ibm_watson.discovery_v2 import TrainingExample
5+
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator, BearerTokenAuthenticator
6+
7+
## Important: Discovery v2 is only available on Cloud Pak for Data. ##
8+
9+
## Authentication ##
10+
## Option 1: username/password
11+
authenticator = CloudPakForDataAuthenticator('<your username>',
12+
'<your password>',
13+
'<url for authentication>',
14+
disable_ssl_verification=True)
15+
16+
## Option 2: bearer token
17+
authenticator = BearerTokenAuthenticator('your bearer token')
18+
19+
## Initialize discovery instance ##
20+
discovery = DiscoveryV2(version='2019-11-22', authenticator=authenticator)
21+
discovery.set_service_url(
22+
'<service url>'
23+
)
24+
discovery.set_disable_ssl_verification(True)
25+
26+
PROJECT_ID = 'your project id'
27+
## List Collections ##
28+
collections = discovery.list_collections(project_id=PROJECT_ID).get_result()
29+
print(json.dumps(collections, indent=2))
30+
31+
## Component settings ##
32+
settings_result = discovery.get_component_settings(
33+
project_id=PROJECT_ID).get_result()
34+
print(json.dumps(settings_result, indent=2))
35+
36+
## Add Document ##
37+
COLLECTION_ID = 'your collection id'
38+
with open(os.path.join(os.getcwd(), '..', 'resources',
39+
'simple.html')) as fileinfo:
40+
add_document_result = discovery.add_document(project_id=PROJECT_ID,
41+
collection_id=COLLECTION_ID,
42+
file=fileinfo).get_result()
43+
print(json.dumps(add_document_result, indent=2))
44+
document_id = add_document_result.get('document_id')
45+
46+
## Create Training Data ##
47+
training_example = TrainingExample(document_id=document_id,
48+
collection_id=COLLECTION_ID,
49+
relevance=1)
50+
create_query = discovery.create_training_query(
51+
project_id=PROJECT_ID,
52+
natural_language_query='How is the weather today?',
53+
examples=[training_example]).get_result()
54+
print(json.dumps(create_query, indent=2))
55+
56+
training_queries = discovery.list_training_queries(
57+
project_id=PROJECT_ID).get_result()
58+
print(json.dumps(training_queries, indent=2))
59+
60+
## Queries ##
61+
query_result = discovery.query(
62+
project_id=PROJECT_ID,
63+
collection_ids=[COLLECTION_ID],
64+
natural_language_query='How is the weather today?').get_result()
65+
print(json.dumps(query_result, indent=2))
66+
67+
autocomplete_result = discovery.get_autocompletion(
68+
project_id=PROJECT_ID, prefix="The content").get_result()
69+
print(json.dumps(autocomplete_result, indent=2))
70+
71+
query_notices_result = discovery.query_notices(
72+
project_id=PROJECT_ID, natural_language_query='warning').get_result()
73+
print(json.dumps(query_notices_result, indent=2))
74+
75+
list_fields = discovery.list_fields(project_id=PROJECT_ID).get_result()
76+
print(json.dumps(list_fields, indent=2))
77+
78+
## Cleanup ##
79+
discovery.delete_training_queries(project_id=PROJECT_ID).get_result()
80+
81+
delete_document_result = discovery.delete_document(
82+
project_id=PROJECT_ID, collection_id=COLLECTION_ID,
83+
document_id=document_id).get_result()
84+
print(json.dumps(delete_document_result, indent=2))

examples/visual_recognition_v4.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,15 @@
3535
TrainingDataObject(object='giraffe training data',
3636
location=Location(64, 270, 755, 784))
3737
]).get_result()
38+
print(json.dumps(training_data, indent=2))
3839

3940
# train collection
4041
train_result = service.train(collection_id).get_result()
42+
print(json.dumps(train_result, indent=2))
43+
44+
# training usage
45+
training_usage = service.get_training_usage()
46+
print(json.dumps(training_usage, indent=2))
4147

4248
# analyze
4349
dog_path = os.path.join(os.path.dirname(__file__), '../resources/dog.jpg')
@@ -51,7 +57,7 @@
5157
FileWithMetadata(giraffe_files)
5258
],
5359
image_url=['https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/American_Eskimo_Dog.jpg/1280px-American_Eskimo_Dog.jpg']).get_result()
54-
assert analyze_images is not None
60+
print(json.dumps(analyze_images, indent=2))
5561

5662
# delete collection
5763
service.delete_collection(collection_id)

ibm_watson/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from .text_to_speech_v1 import TextToSpeechV1
2525
from .tone_analyzer_v3 import ToneAnalyzerV3
2626
from .discovery_v1 import DiscoveryV1
27+
from .discovery_v2 import DiscoveryV2
2728
from .compare_comply_v1 import CompareComplyV1
2829
from .visual_recognition_v3 import VisualRecognitionV3
2930
from .version import __version__

0 commit comments

Comments
 (0)