Generate valid IBM Watson Personality Insights service input from different sources.
Supported sources (will add more as requested):
- Twitter tweets
- List of texts
Just require the package and call the API with your data:
var
tweets = require('./my_tweets'),
texts = require('./my_texts'),
PIInput = require('personality-insights-input'),
inputFromTweets = PIInput.fromTweets(tweets),
inputFromTexts = PIInput.fromTexts(texts);
You can use the result as payload for your IBM Watson Personality Insights service request.
See the complete example code for texts or the example code for tweets.
Public methods:
fromTweets :: ([Tweet]) -> ContentItems
- Transforms tweets into content items.fromTexts :: ([String], Metadata) -> ContentItems
- Transforms texts into content items.Metadata
parameter is optional.
Where:
Tweet
is a tweet as described in Twitter's Documentation.ContentItems
is anObject
of the form{ "ContentItems" : [ ContentItem ] }
.ContentItem
is anObject
as described in IBM Watson Personality Insights documentation.Metadata
is a subset ofContentItem
, with attributes: Metadata { userid (string, optional): Unique identifier for the author of this content., sourceid (string, optional): Identifier for the source of this content, for example, blog123 or twitter., created (integer, optional): Timestamp that identifies when this content was created, in milliseconds since midnight 1/1/1970 UTC. Required only for results about temporal behavior data., language (string, optional): Language identifier (two-letter ISO 639-1 identifier). Both English ("en") and Spanish ("es") input content are supported. The default is English. In all cases, regional variants are treated as their parent language; for example, "en-US" is interpreted as "en". }
You can run gulp
command to build the component. Binaries will be deployed to bin
folder.