0
votes

I am new to python and trying to get Json output from IBM Watson tone analyzer. Here is what I used from Tone analyzer API reference:

import json
from watson_developer_cloud import ToneAnalyzerV3
tone_analyzer = ToneAnalyzerV3(
   username='YOUR SERVICE USERNAME',
   password='YOUR SERVICE PASSWORD',
   version='2016-05-19')

The problem here is when I run the code in python it doesn't seem to find 'watson developer cloud' module (even after I did a pip install).

All I am trying to do is pass on a few text files through IBM Watson tone analyzer and get the outputs in CSV format.

I would really appreciate any inputs with this.

1

1 Answers

3
votes

Looks like you need to import ToneAnalyzerV3. Check this example from the docs.

import json
from watson_developer_cloud import ToneAnalyzerV3


tone_analyzer = ToneAnalyzerV3(
    username='YOUR SERVICE USERNAME',
    password='YOUR SERVICE PASSWORD',
    version='2016-05-19')

print(json.dumps(tone_analyzer.tone(text='I am very happy'), indent=2))

Link here - Tone analyzer

EDIT

Maybe it is not running due to this.

Tested 👌 (lightly) on: Python from 2.7 to 3.5-dev (development branch). Python 2.6 is partially supported but generates InsecurePlatformWarnings (and other warnings), which can be ignored.

Maybe the problem is from their side. Try using python2.6.