无法找到 Python 的 IBM NLU 最新语法

Not able to find out the IBM NLU latest syntax for Python

我正在尝试使用 python 连接 IBM Watson NLU,但下面的代码已过时,因为今天我为 IBM NLU 创建了新的资源组,然后我试图找出凭据,但我没有获取用户名和密码。

有新的东西。 请检查下图。

    natural_language_understanding = NaturalLanguageUnderstandingV1(
        url=<URL>,
        version='2018-03-16',
        username=<UserName>,
        password=<Password>)

    natural_language_understanding.disable_SSL_verification()
    try:
        response = natural_language_understanding.analyze(
            text=str(user_answer_sent),
            features=Features(
                semantic_roles=SemanticRolesOptions(),
                sentiment=SentimentOptions()
            ), language='en'
        ).get_result()

我无法找到 IBM Watson NLU 的最新语法。有的话请告诉我,我试试看

请检查是否使用了 Python SDK for the IBM Watson services. It includes sample code for IBM Watson NLU which shows how the new Authenticator model。它是这样的:

import json
from ibm_watson import NaturalLanguageUnderstandingV1
from ibm_watson.natural_language_understanding_v1 import Features, EntitiesOptions, KeywordsOptions
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

# Authentication via IAM
authenticator = IAMAuthenticator('your_api_key')
 service = NaturalLanguageUnderstandingV1(
     version='2018-03-16',
     authenticator=authenticator)
 service.set_service_url('https://gateway.watsonplatform.net/natural-language-understanding/api')

API reference 中有更多示例和更多信息。