我正在尝试使用Alchemy API为URL列表提取关键字/实体-但是作为Python的相对新手-我不知道如何做到这一点,我读过的大量堆栈溢出文章也没有给我带来任何结果。你知道吗
因此,有人知道我如何对列表或单独的txt/csv文件中的url列表进行API调用吗?你知道吗
import json
from watson_developer_cloud import NaturalLanguageUnderstandingV1
from watson_developer_cloud.natural_language_understanding_v1 \
import Features, EntitiesOptions, KeywordsOptions
natural_language_understanding = NaturalLanguageUnderstandingV1(
username='Username',
password='Password',
version='2017-02-27')
response = natural_language_understanding.analyze(
url=('https://www.example.com/'),
features=Features(
entities=EntitiesOptions(
emotion=True,
sentiment=True,
limit=2),
keywords=KeywordsOptions(
emotion=True,
sentiment=True,
limit=2)))
print(json.dumps(response, indent=2))
你可以从一个文本文件中逐行读取它们
只需从文本文件中循环读取它们。你知道吗
相关问题 更多 >
编程相关推荐