コード例 #1
0
function analyze(token) {
  var toneAnalyzer = new ToneAnalyzerV3({
    token: token,
    version: '2016-05-19',
  });
  toneAnalyzer.tone(
    {
      text: input.value,
    },
    function(err, result) {
      if (err) {
        output.innerHTML = err;
        return console.log(err);
      }
      output.innerHTML = JSON.stringify(result, null, 2);
    }
  );
}
コード例 #2
0
var ToneAnalyzerV3 = require('ibm-watson/tone-analyzer/v3');

var toneAnalyzer = new ToneAnalyzerV3({
  username: '******',
  password: '******',
  version: '2017-09-21',
  url: 'https://gateway.watsonplatform.net/tone-analyzer/api/'
});

toneAnalyzer.tone(
  {
    tone_input: 'Greetings from the Watson Developer Cloud Node SDK, we are pleased to say hello!',
    content_type: 'text/plain'
  },
  function(err, tone) {
    if (err) {
      console.log(err);
    } else {
      console.log('tone endpoint:');
      console.log(JSON.stringify(tone, null, 2));
    }
  }
);

var params = {
  utterances: [
    { text: 'My charger isn’t working.', user: '******' },
    {
      text:
        'Thanks for reaching out. Can you give me some more detail about the issue?',
      user: '******'
    },