If I want to do an analysis of a single Twitter us

2019-07-23 17:51发布

I want to use the Watson Personality Insights API to analyze the personality traits of a particular Twitter user. This user has 1000 tweets. Do I have to call the Personality Insights API 1000 times in order to do this?

2条回答
萌系小妹纸
2楼-- · 2019-07-23 17:57

Personality Insights can process multiple text elements in a single API call. To obtain a single result (the a meaningful output according to the service documentation) this needs to be written by an individual author.

Now assuming you obtained 1000s of tweets from an author, you can format them in one (big) JSON string and POST-it with Content-Type: application/json header in your request. See the specs (right under "JSON output for text with timestamps" title) for an example of this type of input, with multiple elements included.

How many elements can fit in a single request? Currently the APIs limit the input payload to 20Mb. If you count the characters used by each of the contentItems in the JSON above, and assuming a 140-character limit per tweet, this gives about 350 characters used per tweet. So you can fit about 57,000 tweets in a single API call! At least, if this is English text (or rather: ASCII encoded text); the object size might perhaps double with utf-8 encoding special characters, but that will still leave plenty of room for many thousands of tweets.

查看更多
老娘就宠你
3楼-- · 2019-07-23 18:09

No you don't. You DO need to "bundle" the 1000 tweets in JSON and submit them with your SINGLE call to the profile method of the Personality Insights API. These tweets are each contained as individual content items in the JSON.

For details on the format of the JSON payload, and the response format, see the online documentation at http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/personality-insights/api/v2/?node#methods

查看更多
登录 后发表回答