【发布时间】:2021-06-08 22:08:35
【问题描述】:
我正在尝试了解 IBM Watson Personality Insights API 在今年年底关闭之前的基本工作原理。我有一个要分析的基本文本文件,但无法让代码正常运行。 I have been trying to follow along on the official sits instructions,但我被困住了。我究竟做错了什么? (我已经在下面的代码中涂抹了我的密钥)。
from ibm_watson import PersonalityInsightsV3
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
authenticator = IAMAuthenticator('BlottedOutKey')
personality_insights = PersonalityInsightsV3(
version='2017-10-13',
authenticator=authenticator
)
personality_insights.set_service_url('https://api.us-west.personality-insights.watson.cloud.ibm.com')
with open(join(C:\Users\AWaywardShepherd\Documents\Data Science Projects\TwitterScraper-master\TwitterScraper-master\snscrape\python-wrapper\Folder\File.txt), './profile.json')) as profile_json:
profile = personality_insights.profile(
profile_json.read(),
content_type='text/plain',
consumption_preferences=True,
raw_scores=True)
.get_result()
print(json.dumps(profile, indent=2))
我不断收到以下无法描述的语法错误:
File "<ipython-input-1-1c7761f3f3ea>", line 11
with open(join(C:\Users\AWaywardShepherd\Documents\Data Science Projects\TwitterScraper-master\TwitterScraper-master\snscrape\python-wrapper\Folder\File.txt), './profile.json')) as profile_json:
^ SyntaxError: invalid syntax
【问题讨论】:
标签: python syntax-error ibm-watson personality-insights