Guest User

Untitled

a guest
Apr 4th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. require("dotenv").config();
  2. const readline = require('readline');
  3. const PersonalityInsightsV3 = require('watson-developer-cloud/personality-insights/v3');
  4. const personality_insights = new PersonalityInsightsV3({
  5. username: process.env.PERSONALITY_INSIGHTS_USERNAME,
  6. password: process.env.PERSONALITY_INSIGHTS_PASSWORD,
  7. version_date: '2017-10-13'
  8. });
  9. const PersonalityTextSummaries = require('personality-text-summary');
  10. const v3EnglishTextSummaries = new PersonalityTextSummaries({
  11. locale: 'en',
  12. version: 'v3'
  13. });
  14.  
  15. const fetchTweets = require('./fetchTweets');
  16.  
  17.  
  18. const rl = readline.createInterface({
  19. input: process.stdin,
  20. output: process.stdout
  21. });
  22.  
  23. rl.question('Please enter a twitter Handle for Watson to analyze...', (handle) => {
  24.  
  25. console.log("Your results should show up soon. Thank you.");
  26.  
  27. fetchTweets(handle).then((tweets) => {
  28. let params = {
  29. // Content items are tweets.
  30. content_items: tweets,
  31. consumption_preferences: true,
  32. raw_scores: true,
  33. headers: {
  34. 'accept-language': 'en',
  35. 'accept': 'application/json'
  36. }
  37. };
  38. personality_insights.profile(params, function (error, personalityProfile) {
  39. if (error && error.code == 400) {
  40. reject(Error("Ouch! You either do not have sufficient tweets, or your language is not supported. Sorry."));
  41. } else
  42. console.log(JSON.stringify(personalityProfile, null, 2));
  43.  
  44. });
  45.  
  46. rl.close();
  47.  
  48. }).catch(err => console.error(err));
  49.  
  50. });
Add Comment
Please, Sign In to add comment