Giter VIP home page Giter VIP logo

Comments (7)

loretoparisi avatar loretoparisi commented on July 18, 2024

[UPDATE]
I have created a brand new tone-analyzer service just to be sure that it was not due to any wrong configuration, now Bluemix gives me back these credentials

{
  "credentials": {
    "url": "https://gateway.watsonplatform.net/tone-analyzer/api",
    "password": "<password>",
    "username": "<username>"
  }
}

So I have the production url, not the beta. By the way, using the same credentials of the demo app I have deployed, for some weird reason gives me back no sentences_tone like before...

The only difference I can see is the plan that are beta and standard. Is there anything else I have to do to get the right api (whole) response?

from tone-analyzer-nodejs.

herchu avatar herchu commented on July 18, 2024

The credentials panel shows the URL and user/password for the service you have instantiated (and bound to the app). The demo app needs to make sure it requests the same service you have bound the app to.

The first snippet above shows your app requests version: "v3" which searches for the production version. The second snippet suggests your app is still bound to a Beta service. Your update, or third snippet, shows that once you deleted the old service instance (beta) created a new one from production. This is all ok -- does the app work in the current form?

The confusion may come from having started this app earlier than 2016-05-19 when the new production version was published. Since May 19th, you are unable to create more Beta instances. Tone Analyer is now GA (not Beta), and note that you can still do 1000 API calls for free, for evaluation purposes.

Closing the issue now. Please reopen if you are still having trouble.

from tone-analyzer-nodejs.

loretoparisi avatar loretoparisi commented on July 18, 2024

@herchu it makes sense, that's why I have a created a standard version of the tone-analyzer so paid account. The problem is that I get the same response with this configuration as well:

{
  "credentials": {
    "url": "https://gateway.watsonplatform.net/tone-analyzer/api",
    "password": "<password>",
    "username": "<username>"
  }
}

I'm in the us-south region, just to know.

from tone-analyzer-nodejs.

herchu avatar herchu commented on July 18, 2024

I am sorry I am confused now: What is "the same response" ? No sentences_tone element?

In that case, can you share the input (text) you are analyzing?

from tone-analyzer-nodejs.

loretoparisi avatar loretoparisi commented on July 18, 2024

@herchu yes the missing response is the sentences_tone.
This is the simple module I did:

/**
* @author Loreto Parisi (loretoparisi at gmail dot com)
*/
(function() {

  var watson  = require('watson-developer-cloud');

  var ToneAnalyzer;
  ToneAnalyzer = (function() {

    function ToneAnalyzer(options) {

      // default options
      this._options = {

      };
      //override
      for (var attrname in options) { this._options[attrname] = options[attrname]; }

      // Create the service wrapper
      this.analyzer = watson.tone_analyzer({
        url : 'https://gateway.watsonplatform.net/tone-analyzer/api',
        username: '#####',
        password: '#######',
        version_date: '2016-05-19',
        version: 'v3'
      });

    }

    /**
     * Get Text tone
     * @param options Object Api parameters: { text := string }
     * @param callback Function Result callback
     */
    ToneAnalyzer.prototype.GetTone = function(options, callback) {
      var self=this;

      var extras={};
      for (var attrname in options) { extras[attrname] = options[attrname]; }

      this.analyzer.tone(extras, function(err, data) {
        if (err)
          return callback(null,err);
        else
          return callback( data );
      });
    }

    return ToneAnalyzer;

  })();

  module.exports = ToneAnalyzer;

}).call(this);

and the example is

toneAnalyzer = new ToneAnalyzer({});

  var lyricsBody = "Baby I like your style\nGrips on your waist\nFront way, back way\nYou know that I don't play\nStreets not safe\nBut I never run away\nEven when I'm away";

  var parameters = { text : lyricsBody };

  console.log( JSON.stringify(parameters,null,2) );

  toneAnalyzer.GetTone( parameters
  , function(results, error) {
      if(results) {
        console.log( JSON.stringify(results,null,2) );
      }
      else {
        console.error( error );
      }
  });

This is the response json, in the comment the input text related to this json.

from tone-analyzer-nodejs.

herchu avatar herchu commented on July 18, 2024

Ok, the problem is that your text is seen as a single sentence, so the sentences_tone output is just skipped. This is because there are (single) end-of-line chars, with no period, so text is taken as single sentence as a whole.

Lyrics and poetry trick the sentence parser in Tone Analyzer. You will need to add a period to forcefully end each sentence and the end-of-line, or alternatively leave a blank line between sentences. These two versions work when replacing the second line of your example:

  // Use periods
  var parameters = { text : lyricsBody.replace(/\n/g, ".\n") };
  // Or use double EOLs
  var parameters = { text : lyricsBody.replace(/\n/g, "\n\n") };

Looking forward to seeing the outcome of your analysis... or any new feature in musixmatch ;)

from tone-analyzer-nodejs.

loretoparisi avatar loretoparisi commented on July 18, 2024

@herchu great it makes sense thank you!
I have updated resulting json here.
Absolutely we will, Watson makes a lot of sense for us ;)

from tone-analyzer-nodejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.