Guest User

Untitled

a guest
Apr 1st, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. require('dotenv').config();
  2. const readline = require('readline');
  3. const ToneAnalyzerV3 = require('watson-developer-cloud/tone-analyzer/v3');
  4.  
  5. const tone_analyzer = new ToneAnalyzerV3({
  6. username: process.env.TONE_ANALYZER_USERNAME,
  7. password: process.env.TONE_ANALYZER_PASSWORD,
  8. version_date: process.env.TONE_ANALYZER_VERSION_DATE
  9. });
  10.  
  11. const rl = readline.createInterface({
  12. input: process.stdin,
  13. output: process.stdout
  14. });
  15.  
  16. rl.question('Please enter a short paragraph for Watson to analyze...', (text) => {
  17.  
  18. let params = {
  19. tone_input: text,
  20. content_type: 'text/plain',
  21. sentences: true
  22. };
  23. tone_analyzer.tone(params, function (error, response) {
  24. if (error) {
  25. console.log(error);
  26. } else {
  27. console.log(JSON.stringify(response, null, 2));
  28. }
  29. });
  30.  
  31. rl.close();
  32. });
Add Comment
Please, Sign In to add comment