When using AlchemyAPI Language for targeted sentiment analysis, the docs indicate that you can specify either target
or targets
. Specifying targets
causes the response to contain an array, however I cannot figure out how to specify multiple targets in a single call.
Specifying a single target (but using the targets
parameter):
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"
Does the service support multiple targets? And if so, how do I pass them?
The documentation has been updated with the answer to this: http://www.alchemyapi.com/api/sentiment/textc.html#targetedsentiment
The solution is to use pipe characters: dogs|cats.
Full example:
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"