Live demo: http://your-celebrity-match.ng.bluemix.net/
The application uses The Personality Insights API
- You input your Twitter handle.
- Calls the Twitter API to get the latest 2300 tweets from your public feed.
- Calls the Personality Insights API to analyze the language in your tweets and apply it to a spectrum of characteristics.
- Compares your Personality Insights profile to 232 celebrity profiles analyzed with the service.
- Sorts your matches and shows you the highest and lowest. These are calculated by the euclidean distance between the two.
- Sign up for an IBM Cloud account.
- Download the IBM Cloud CLI.
- Create an instance of the Language Translator 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, or copy theusername
andpassword
values if your service instance doesn't provide anapikey
. - Copy the
url
value.
This instructions will help you install the celebrities app in your local environment.
- Clone the repository with:
$ git clone [email protected]:watson-developer-cloud/your-celebrity-match.git
- Install node
- Install mongodb
- Install the npm modules:
Note: Make sure you are in the project directory, the
$ npm install
package.json
file should be visible. - Start mongodb
(Run this in a separate terminal window)
$ mongod
- You need some credentials to use Twitter API, Personality Insights and MongoDB:
- Get credentials to use Personality Insights.
- Create a FREE Mongodb database using MongoLab.
- Create a Twitter app and get the API credentials here.
-
Update the Twitter, MongoDB and Personality Insights credentials in
config/config.js
mongodb: process.env.MONGODB || 'mongodb://localhost/celebs', { personality_insights: { version: '2017-10-13', url: '<url>', iam_apikey: '<username>'s }, twitter: [{ consumer_key: '<consumer_key>', consumer_secret: '<consumer_secret>', access_token_key: '<access_token_key>', access_token_secret:'<access_token_secret>' }] }
-
Start the app
$ npm start
-
Update the database with the celebrities by making a POST request to:
http://localhost:3000/celebrities/syncdb
The celebrities are not added by default. Hence the above step is recommended. Refer #Celebrities section below for more information. When running in bluemix make sure the environment variable
DEMO
is set to0
. -
You can add additional celebrities to the database as long as they are verified, have at least 10,000 followers, and have over 1,000 tweets. To add another celebrity, make a POST request to:
http://localhost:3000/celebrities/add/@username
where
username
is the Twitter handle of the celebrity you would like to add.
The application comes with 1 'celebrity' profile: @germanatt. If you want to add more profiles, you have two options:
-
Choose a person on Twitter to include as a 'celebrity'. Ensure this person is verified, has at least 10,000 followers, and has over 1,000 tweets.
-
Make a POST request to:
http://localhost:3000/celebrities/add/@username
where
username
is the Twitter handle of the celebrity you would like to add.
- Choose a person to include as a 'celebrity'. You need at least 100 different words written by that person. Blog posts, tweets, text messages, emails will work.
- Get the profile by using the Personality Insights service with the text you have and save the json profile in the
profiles
folder. Make sure the file has the.json
extension as in the examples provided. - Start the app and make a POST request to:
http://localhost:3000/celebrities/syncdb
. It will repopulate the application database and add the new profile. Be aware that this command will erase all celebrities previously added to the database.
Note: In order to add celebrities, you must not be running the app in demo mode. Either run the app locally or set the DEMO
environment variable to 0
when running the app on Bluemix.
This sample code is licensed under Apache 2.0. Full license text is available in LICENSE.
See CONTRIBUTING.
Find more open source projects on the IBM Github Page