0

私は Watson NLU に取り組んでおり、アンケート データの分析を実行する必要があります。別々の人から約300の回答。「...」形式のテキストで実行できますが、1 回の実行で 300 個すべてを実行する方法について助けてもらいたいです。私の現在の入力は、ID 列を含む Excel です。ご検討いただきありがとうございます。

nlu_api_key = "MY API KEY"
nlu_url = "https://api.eu-gb.natural-language-understanding.watson.cloud.ibm.com/instances/MY INSTANCE"


import json
from ibm_watson import NaturalLanguageUnderstandingV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_watson.natural_language_understanding_v1 import Features, EntitiesOptions, KeywordsOptions, CategoriesOptions,SentimentOptions
import pandas as pd


gtm_Q6 = pd.read_excel(r'C:\Users\...\INPUT FILE.xlsx', sheet_name='OUPUT1')
print(gtm_Q6)


authenticator = IAMAuthenticator(nlu_api_key)
natural_language_understanding = NaturalLanguageUnderstandingV1(
    version='2020-08-01',
    authenticator=authenticator)

natural_language_understanding.set_service_url(nlu_url)

response = natural_language_understanding.analyze(
    text='Where is the firetruck with the flaming paint the tigers on top?',
    features=Features(
        entities=EntitiesOptions(emotion=True, sentiment=True, limit=5),
        keywords=KeywordsOptions(emotion=True, sentiment=True,limit=5),
        categories=CategoriesOptions(limit=3),
        sentiment=SentimentOptions(targets=['investments']) #sentiment=SentimentOptions(targets=['stocks'])
        )).get_result()

print(json.dumps(response, indent=2))
RESP_ID 答え
Q6_109.000000 チームビルディング
Q6_110.000000 テクノロジーとサービス間の有効化と調整
Q6_111.000000 スキル構築
Q6_113.000000 適切なリソースへのスピード
Q6_114.000000 現時点での変更の実用性に関する情報
4

1 に答える 1