1

当使用 AlchemyAPI 语言进行有针对性的情绪分析时,文档表明您可以指定targettargets。指定targets会导致响应包含一个数组,但是我无法弄清楚如何在一次调用中指定多个目标。

指定单个目标(但使用targets参数):

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "text=I love cats. Dogs are the worst." -d "targets=cats" -d "outputMode=json" "https://gateway-a.watsonplatform.net/calls/text/TextGetTargetedSentiment?apikey=MY_API_KEY"

该服务是否支持多个目标?如果是这样,我该如何通过它们?

4

1 回答 1

1

文档已更新为对此的答案:http ://www.alchemyapi.com/api/sentiment/textc.html#targetedsentiment

解决方案是使用管道字符:dogs|cats。

完整示例:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "text=I love cats. Dogs are the worst." -d "targets=cats|dogs"  -d "outputMode=json"    "https://gateway-a.watsonplatform.net/calls/text/TextGetTargetedSentiment?apikey=MY_API_KEY"
于 2015-11-11T18:25:55.233 回答