Is there a way to pass an array through the ToneAnalyzer?

#1

I have an array of different texts that I need to pass separately through the ToneAnalyzer. I have to be able to access all of the analysis values afterwards.

Is there a way to do this without setting up a separate instance of the ToneAnalyzer for each text?

Thank you!

0 Likes

#2

What ToneAnalyzer?

0 Likes

#3

The Watson service through ibmcloud, via node-RED - it's this one I believe.

0 Likes

#4

Hi @nhar

as you've discovered, you shouldn't assume users in this forum automatically know you're referring to any particular technology, or that you're running in any particular environment.

As far as I know, the ToneAnalyzer can only do one text at a time (@chughts may be able to correct me....)

If you have msg.payload set as an array of multiple texts, you can pass that to a Split node that will then turn that into one message per text. You can then pass each of those to a single ToneAnalyzer node, use a Change node to move the result to msg.payload and then a Join node to recombine all of those messages back into one. That approach assumes the ToneAnalyzer node doesn't modify message properties it isn't using - for the Join node to be able to automatically join messages from the Split node, it requires the msg.parts property to survive through the flow.

0 Likes

#5

The Tone Analyzer can handle multiple sentences, but the input must be a single piece of text with normal punctuation, and not an array.

If you set the Sentences property in the node configuration to true. Then the tone response will be per sentence.

0 Likes