Guest User

Untitled

a guest
Apr 2nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. require("dotenv").config();
  2. const readline = require('readline');
  3. const ToneAnalyzerV3 = require('watson-developer-cloud/tone-analyzer/v3');
  4. const getTweets = require('./getTweets');
  5.  
  6. const tone_analyzer = new ToneAnalyzerV3({
  7. username: process.env.TONE_ANALYZER_USERNAME,
  8. password: process.env.TONE_ANALYZER_PASSWORD,
  9. version_date: process.env.TONE_ANALYZER_VERSION_DATE
  10. });
  11.  
  12. const rl = readline.createInterface({
  13. input: process.stdin,
  14. output: process.stdout
  15. });
  16.  
  17. rl.question('Please enter a twitter Handle for Watson to analyze...', (handle) => {
  18.  
  19. console.log("Your results should show up soon. Thank you.");
  20.  
  21. getTweets(handle).then((tweets) => {
  22. let params = {
  23. tone_input: tweets,
  24. content_type: 'text/plain',
  25. sentences: false
  26. };
  27. tone_analyzer.tone(params, function (error, response) {
  28. if (error) {
  29. console.error(error);
  30. } else {
  31. console.log(JSON.stringify(response, null, 2));
  32. }
  33. });
  34.  
  35. rl.close();
  36. }).catch(err => console.error(err));
  37.  
  38. });
Add Comment
Please, Sign In to add comment