Skip to content

Commit fcae3b7

Browse files
committed
Merge branch 'jmeis-master'
2 parents 5ef3b1d + 2d2ceef commit fcae3b7

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import json
2-
from watson_developer_cloud import ToneAnalyzerV3Beta
2+
from watson_developer_cloud import ToneAnalyzerV3
33

44

5-
tone_analyzer = ToneAnalyzerV3Beta(
5+
tone_analyzer = ToneAnalyzerV3(
66
username='YOUR SERVICE USERNAME',
77
password='YOUR SERVICE PASSWORD',
88
version='2016-02-11')

watson_developer_cloud/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from .retrieve_and_rank_v1 import RetrieveAndRankV1
3232
from .speech_to_text_v1 import SpeechToTextV1
3333
from .text_to_speech_v1 import TextToSpeechV1
34-
from .tone_analyzer_v2_experimental import ToneAnalyzerV2Experimental
3534
from .tone_analyzer_v3_beta import ToneAnalyzerV3Beta
35+
from .tone_analyzer_v3 import ToneAnalyzerV3
3636
from .tradeoff_analytics_v1 import TradeoffAnalyticsV1
3737
from .visual_insights_v1_experimental import VisualInsightsV1Experimental
3838
from .visual_recognition_v1_beta import VisualRecognitionV1Beta
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2015 IBM All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
The v3 Tone Analyzer service
17+
(https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/tone-analyzer.html)
18+
"""
19+
20+
21+
from watson_developer_cloud.watson_developer_cloud_service import WatsonDeveloperCloudService
22+
23+
24+
class ToneAnalyzerV3(WatsonDeveloperCloudService):
25+
default_url = 'https://gateway.watsonplatform.net/tone-analyzer/api'
26+
latest_version = '2016-02-11'
27+
28+
def __init__(self, version, url=default_url, username=None, password=None, use_vcap_services=True):
29+
WatsonDeveloperCloudService.__init__(
30+
self, 'tone_analyzer', url, username, password, use_vcap_services)
31+
self.version = version
32+
33+
def tone(self, text):
34+
"""
35+
The tone API is the main API call: it analyzes the "tone" of a piece of text. The message is analyzed from
36+
several tones (social tone, emotional tone, writing tone), and for each of them various traits are derived
37+
(such as conscientiousness, agreeableness, openness).
38+
:param text: Text to analyze
39+
"""
40+
params = {'version': self.version}
41+
data = {'text': text}
42+
return self.request(method='POST', url='/v3/tone', params=params, json=data, accept_json=True)

0 commit comments

Comments
 (0)