项目作者: watson-developer-cloud

项目描述 :
:bar_chart: Sample Nodejs Application for the IBM Watson Personality Insights Service
高级语言: JavaScript
项目地址: git://github.com/watson-developer-cloud/personality-insights-nodejs.git
创建时间: 2015-02-19T00:10:59Z
项目社区:https://github.com/watson-developer-cloud/personality-insights-nodejs

开源协议:Apache License 2.0

下载


🚀 Personality Insights Sample Application

This Node.js app demonstrates how to analyze text and tweets using Personality Insights.



Travis


semantic-release


The IBM Watson Personality Insights service uses linguistic analysis to extract cognitive and social characteristics from input text such as email, text messages, tweets, forum posts, and more. By deriving cognitive and social preferences, the service helps users to understand, connect to, and communicate with other people on a more personalized level.

Prerequisites

  1. Sign up for an IBM Cloud account.
  2. Download the IBM Cloud CLI.
  3. Create an instance of the Personality Insights service and get your credentials:
    • Go to the Personality Insights page in the IBM Cloud Catalog.
    • Log in to your IBM Cloud account.
    • Click Create.
    • Click Show to view the service credentials.
    • Copy the apikey value.
    • Copy the url value.

Configuring the application

  1. In the application folder, copy the .env.example file and create a file called .env

    1. cp .env.example .env
  2. Open the .env file and add the service credentials that you obtained in the previous step.

    Example .env file that configures the apikey and url for a Personality Insights service instance hosted in the US East region:

    1. PERSONALITY_INSIGHTS_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
    2. PERSONALITY_INSIGHTS_URL=https://gateway-wdc.watsonplatform.net/personality-insights/api

    Setting Up the Twitter Application

  3. Create a Twitter application.

  4. Add your application’s callback URL:

    • For Bluemix environment: <application-name>.mybluemix.net/auth/twitter/callback
    • For Local environment: http://localhost:3000/auth/twitter/callback
  5. Update the .env file and add your twitter application credentials:

    1. TWITTER_CONSUMER_KEY=<consumer-key>
    2. TWITTER_CONSUMER_SECRET=<consumer-secret>

Running locally

  1. Install the dependencies

    1. npm install
  2. Run the application

    1. npm start
  3. View the application in a browser at localhost:3000

Deploying to IBM Cloud as a Cloud Foundry Application

  1. Login to IBM Cloud with the IBM Cloud CLI

    1. ibmcloud login
  2. Target a Cloud Foundry organization and space.

    1. ibmcloud target --cf
  3. Edit the manifest.yml file. Change the name field to something unique.
    For example, - name: my-app-name.

  4. Deploy the application

    1. ibmcloud app push
  5. View the application online at the app URL.
    For example: https://my-app-name.mybluemix.net

Directory structure

  1. .
  2. ├── app.js // express entry point
  3. ├── config // express configuration
  4. ├── error-handler.js
  5. ├── express.js
  6. ├── i18n.js
  7. ├── passport.js
  8. └── security.js
  9. ├── helpers // utility modules
  10. ├── personality-insights.js
  11. └── twitter-helper.js
  12. ├── i18n // internationalization
  13. ├── en.json
  14. ├── es.json
  15. └── ja.json
  16. ├── manifest.yml
  17. ├── package.json
  18. ├── public
  19. ├── css
  20. ├── data // sample text and tweets
  21. ├── fonts
  22. ├── images
  23. └── js
  24. ├── router.js // express routes
  25. ├── server.js // application entry point
  26. ├── test
  27. └── views // ejs views

License

This sample code is licensed under Apache 2.0.
Full license text is available in LICENSE.

Contributing

See CONTRIBUTING.

Open Source @ IBM

Find more open source projects on the
IBM Github Page.