0

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.

4

1 回答 1

3

看起来你需要导入ToneAnalyzerV3. 从文档中检查这个例子。

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))

链接在这里 -音调分析器

编辑

也许由于这个原因它没有运行。

测试(轻微):Python 从 2.7 到 3.5-dev(开发分支)。Python 2.6 得到部分支持,但会生成 InsecurePlatformWarnings(和其他警告),可以忽略。

也许问题出在他们这边。尝试使用python2.6.

于 2016-05-29T13:54:59.597 回答