1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pythonでwatson discoveryのプロジェクトを作成

Posted at
# %%
from ibm_watson import DiscoveryV2
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
import json

# %%
apikey='APIKEY'
version='VERSION'
authenticator = IAMAuthenticator(apikey=apikey)
discovery = DiscoveryV2(version=version, authenticator=authenticator)

# %%
service_url='SERVICE_URL'
discovery.set_service_url(service_url=service_url)

# %%
response = discovery.list_projects().get_result()
print(response)

# %%
projects = response['projects']
for project in projects:
    print(project)

# %%
name = 'PROJECT_NAME'
projects = [project for project in projects if project['name'] == name]
for project in projects:
    print(project)

# %%
if len(projects) == 0:
    response = discovery.create_project(name=name, type='content_mining').get_result()
    print(response)

# %%
print(json.dumps(response, indent=4, ensure_ascii=False))
# %%
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?