如何在AlchemyAPI目标情绪分析中使用多个目标?

时间:2015-10-27 21:01:55

标签: alchemyapi

使用AlchemyAPI语言进行有针对性的情绪分析时,docs表示您可以指定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"

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

1 个答案:

答案 0 :(得分:1)

文档已更新,答案如下:http://www.alchemyapi.com/api/sentiment/textc.html#targetedsentiment

解决方案是使用管道字符:狗|猫。

完整示例:

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"
相关问题