Giter VIP home page Giter VIP logo

personality-insights-nodejs's Introduction

๐Ÿš€ 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

    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:

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

Setting Up the Twitter Application

  1. Create a Twitter application.

  2. 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
  1. Update the .env file and add your twitter application credentials:
TWITTER_CONSUMER_KEY=<consumer-key>
TWITTER_CONSUMER_SECRET=<consumer-secret>

Running locally

  1. Install the dependencies

    npm install
    
  2. Run the application

    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

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

    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

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

Directory structure

.
โ”œโ”€โ”€ app.js                       // express entry point
โ”œโ”€โ”€ config                       // express configuration
โ”‚ย ย  โ”œโ”€โ”€ error-handler.js
โ”‚ย ย  โ”œโ”€โ”€ express.js
โ”‚ย ย  โ”œโ”€โ”€ i18n.js
โ”‚ย ย  โ”œโ”€โ”€ passport.js
โ”‚ย ย  โ””โ”€โ”€ security.js
โ”œโ”€โ”€ helpers                      // utility modules
โ”‚ย ย  โ”œโ”€โ”€ personality-insights.js
โ”‚ย ย  โ””โ”€โ”€ twitter-helper.js
โ”œโ”€โ”€ i18n                         // internationalization
โ”‚ย ย  โ”œโ”€โ”€ en.json
โ”‚ย ย  โ”œโ”€โ”€ es.json
โ”‚ย ย  โ””โ”€โ”€ ja.json
โ”œโ”€โ”€ manifest.yml
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ public
โ”‚ย ย  โ”œโ”€โ”€ css
โ”‚ย ย  โ”œโ”€โ”€ data                     // sample text and tweets
โ”‚ย ย  โ”œโ”€โ”€ fonts
โ”‚ย ย  โ”œโ”€โ”€ images
โ”‚ย ย  โ””โ”€โ”€ js
โ”œโ”€โ”€ router.js                   // express routes
โ”œโ”€โ”€ server.js                   // application entry point
โ”œโ”€โ”€ test
โ””โ”€โ”€ 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.

personality-insights-nodejs's People

Contributors

agustincasamayor avatar andresfvilla avatar aprilwebster avatar arypbatista avatar berniecoyne avatar bvonhag avatar cclauss avatar dependabot[bot] avatar ehdsouza avatar germanattanasio avatar greenkeeperio-bot avatar jschoudt avatar jzhang300 avatar kognate avatar lhuihui avatar mamoonraja avatar mateobengualid avatar neil-boyette-ibm avatar nfriedly avatar noah-eigenfeld avatar opesanyaadebayo avatar richieverma avatar rmoe avatar sirspidey avatar someoneweird avatar soumak77 avatar vibhasinghal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

personality-insights-nodejs's Issues

speak up demo

doesn't seem to be a repo for that so posting here:

demo seems broken:

image

Creating service - cannot find plan name.

โžœ  ~  cf create-service personality_insights "IBM Watson Personality Insights Monthly Plan" personality-insights-service
Creating service instance personality-insights-service in org $email / space $space $email...
FAILED
Could not find plan with name IBM Watson Personality Insights Monthly Plan

I've tried looking and googling, but can't seem to figure out the correct plan name. Any ideas?

I can not log in on my twitter account

When I tried to check my personality on my twitter account, the page responde me with this message.

{"code":500,"error":"Failed to find request token in session"}

Where is the i18n directory

Hello , I 'd like to test the translation proposed in the readme but I cannot find the i18n directory.
Can you point it to me ?
Thank you

Captcha on the first request

We need to debug the rate-limitation module. @jschoudt reported that sometimes he gets the captcha on the first request. I've been playing with the production demo and I couldn't reproduce the issue.

There were some problems in Bluemix during the last week but I don't think those were related to this. I will keep this open to investigate the issue.

Failed to install

I forked and tried to get the code running but I get an error when running npm install

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\user\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v4.4.7
npm ERR! npm v3.10.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: (node-gyp rebuild 2> builderror.log) || (exit 0)
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script '(node-gyp rebuild 2> builderror.log) || (exit 0)'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! (node-gyp rebuild 2> builderror.log) || (exit 0)
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs websocket
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.

Here's the log file:npm-debug.zip

npm ERR with npm 5.4.0

I've got an error without any change on package.json today when 'cf push' against bluemix.

Dangerous semver range (>) in engines.node

So I replaced "npm": ">=3.0" with "npm": "5.3.0" and solved.

please review and resolve this version conflict with new npm .

Does personality insight API support simplified Chinese?

Hi there, I'm trying use personality insight API to get personality and value scores from social media posts in simplified Chinese. I find there do support Chinese in the API document, but I get the error when I doing so. Error info is {"code":400,"sub_code":"C00001","error":"The language you requested, zh-cn, is not supported. Languages supported: en,es,ja,ar,ko."}. Can anyone figure this out? If so, what is the code? THX!

How does the API generates summaries of personality insights?

Hey all,

I understand the way to invoke Watson's API, and I can get a large JSON including all the numerical results.

But how could I get a textual summary of a person from that numerical results? just as the demo page did.

something like this:

Summary
You are helpful and analytical.

You are emotionally aware: you are aware of your feelings and how to express them. You are empathetic: you feel what others feel and are compassionate towards them. And you are altruistic: you feel fulfilled when helping others, and will go out of your way to do so.

Your choices are driven by a desire for well-being.

You consider both tradition and independence to guide a large part of what you do. You highly respect the groups you belong to and follow their guidance. And you like to set your own goals to decide how to best achieve them.

I could not find anything like this from my API returns.

Application breaking when trying to analyze Twitter personality

I tried to analyze my Twitter personality but kept getting an error.
{ "code": 500, "error": "Callback URL not approved for this client application. Approved callback URLs can be adjusted in your application settings" }

I guess there's a problem with the connection to the Twitter API.

Spurious text in Try the Service

Under try the service, there is some text that is repeated.

You can still play with the demo if you have at least 100 words, but ou can still play with the demo if you have at least 100 words, but you should take those results with a grain of salt.

Should be changed to

You can still play with the demo if you have at least 100 words, but you should take those results with a grain of salt.

Watson Personality Insights API is providing summary for a input text consisting of just numbers.

I was testing Watson Personality Insights API as a part of my application and found that when user provides an input text that consists of just numbers, Instead of error message, Watson is giving a proper summary back to the user.

It questions the credibility of watson on its understanding of the input text.

Please find the attached input text used for testing.

Watson_Personality Insights_Input Text_Numbers.txt

500 error after signing into twitter

Hi could I report something? I'm not too sure if this is a client side issue but tested on both Chrome and IE 11;

steps:

  1. click 'analyze twitter personality'
  2. redirected to twitter and sign in, redirected back to PI application
    3.on Chrome, gets a blank page with this error: {"code":500,"error":"Failed to find request token in session"}
  3. on IE, it simply goes back to the home page like nothing has happened.

do you get the same issue? pls let me know if you further info

App failed to deploy (unless I specified env in UI)

I followed the instructions and deployed the app to Bluemix. However, even with defining the creds in the .env file, I couldn't run the app UNTIL I defined the Twitter app creds in the Bluemix UI (Runtime -> Environment Variables -> User Defined). Suggest adding this to the README.

Remove links to `.shtml` pages

In the code there are references to our old pages in the ibm.com. We should update those links and save the user from a redirect ๐Ÿค“

ReactJS friendly version?

Is there any way you can provide a ReactJS (16.x) friendly version, or provide guidance on how to convert/use the graph with ReactJS?

What is the purpose of the Twitter app ?

Hello , Thank you for keeping the app available and updated.
I 've seen that you npw offer the ability to create a link to a twitter app "to enable live Twitter crawling".
How is this capability made visible when using the app ? Which account(s) are crawled ? the one of the Twitter app creator ? the ones of the sampled persons (ie@ Oprah, etc..)
Many thanks

Text sent to service is not well-escaped.

The demo is "over-escaping" the special characters. So instead of sending "\n" it sends "\n". The first parses as a new line, the second one as a literal string "\n". When tokenized, the "" is ignored and the final result is "n".

Example:

Given:
"Hello, it's me\nI was wondering if after all these years you'd like to meet\nTo go over everything\nThey say that time's supposed to heal ya\nBut I ain't done"

Parsed words are:
hello, it's, me, ni, was, wondering, if, after, all, these, years, you'd, like, to, meet, nto, go, over, everything, nthey, say, that, time's, supposed, to, heal, ya, nbut, i, ain't, done

API call

This is not an issue but can you guide what API call can I use to get the payload once I click on Analyze button. I want to get the json object as a data layer.

Thanks.

Localize for Korean

A new release of the Watson Personality Insights service with Korean support has been approved. The PI web application must also be localized for Korean.

OAuthStrategy requires a consumerKey option

I set the TWITTER_CONSUMER_KEY and the TWITTER_CONSUMER_SECRET in the .env
I try to deploy in CPANEL and the Passenger application server show me the error:

i18n module initialized. Default locale: en
/home/municiondigital/ibmwatson/node_modules/passport-oauth1/lib/strategy.js:83
  if (!options.consumerKey) { throw new TypeError('OAuthStrategy requires a consumerKey option'); }
                              ^

TypeError: OAuthStrategy requires a consumerKey option
    at Strategy.OAuthStrategy (/home/municiondigital/ibmwatson/node_modules/passport-oauth1/lib/strategy.js:83:37)
    at new Strategy (/home/municiondigital/ibmwatson/node_modules/passport-twitter/lib/strategy.js:53:17)
    at Object.<anonymous> (/home/municiondigital/ibmwatson/config/passport.js:32:18)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at Module.require (/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/node-loader.js:80:25)

Add GDPR Language to Stand Alone Demo Pages

Context:
GDPR will go into effect on May 25th; we need the demos to display the following language in order to make them compliant with the law:

This system is for demonstration purposes only and is not intended to process Personal Data. No Personal Data is to be entered into this system as it may not have the necessary controls in place to meet the requirements of the General Data Protection Regulation (EU) 2016/679.

For more information see: https://github.ibm.com/Watson/developer-experience/issues/4342

Stability

  • make sure it scales, it could be in the front page of reddit
    • Mainly looking at page weight: Shoot for 2-3mb max and rendering in 5 sec or less.
    • Test with dev tools throttling to 3G speeds and make sure things are still reasonable.
  • Add google analytics
  • blue-green deployment + travis (see this)
  • testing + travis (see this)
  • security.js (helmet + express-rate-limitation) + CSRF (see personality-insights and speech demos)
  • package.json should not specify node-engine so that Bluemix will always use the latest one.
  • Google RE-Captcha support (make sure design take this into account when designing a demo)
    • Talk to design to add it for existing demos.
  • Bluemix deployment tracker and privacy notice

Sample text smaller than the supposed "minimum input size"

The demo claims to require 3500 words and then provides a sample input with 1341 unique words. I understand the reasons for displaying deliberately incorrect input size requirements, but if we're going to do that we should at least provide a sample input that meets the stated fake size requirements.

404s in the console

The internationalization client-side code is generating 404s in the console. The design should not be that the client-side probes for what files exists and generates 404s every time it misses.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.